You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by dl...@apache.org on 2021/04/13 15:55:57 UTC

[accumulo] branch 1451-external-compactions-feature updated: Filter out ports with value of 0 to prevent duplicate key error when creating the map

This is an automated email from the ASF dual-hosted git repository.

dlmarion pushed a commit to branch 1451-external-compactions-feature
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/1451-external-compactions-feature by this push:
     new dd12644  Filter out ports with value of 0 to prevent duplicate key error when creating the map
dd12644 is described below

commit dd1264436853a2fddb59f1f262743ae9eba6ded2
Author: Dave Marion <dl...@apache.org>
AuthorDate: Tue Apr 13 15:55:05 2021 +0000

    Filter out ports with value of 0 to prevent duplicate key error when creating the map
---
 .../main/java/org/apache/accumulo/server/rpc/TServerUtils.java   | 9 +++++----
 .../java/org/apache/accumulo/server/util/TServerUtilsTest.java   | 3 ++-
 .../java/org/apache/accumulo/tserver/tablet/CompactableImpl.java | 3 ++-
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/server/base/src/main/java/org/apache/accumulo/server/rpc/TServerUtils.java b/server/base/src/main/java/org/apache/accumulo/server/rpc/TServerUtils.java
index 9cc2899..213d950 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/rpc/TServerUtils.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/rpc/TServerUtils.java
@@ -103,11 +103,12 @@ public class TServerUtils {
    * @return A Map object with reserved port numbers as keys and Property objects as values
    */
 
-  public static Map<Integer,Property> getReservedPorts(AccumuloConfiguration config) {
+  public static Map<Integer,Property> getReservedPorts(AccumuloConfiguration config,
+      Property portProperty) {
     return EnumSet.allOf(Property.class).stream()
-        .filter(p -> p.getType() == PropertyType.PORT && p != Property.TSERV_CLIENTPORT)
+        .filter(p -> p.getType() == PropertyType.PORT && p != portProperty)
         .flatMap(rp -> config.getPortStream(rp).mapToObj(portNum -> new Pair<>(portNum, rp)))
-        .collect(Collectors.toMap(Pair::getFirst, Pair::getSecond));
+        .filter(p -> p.getFirst() != 0).collect(Collectors.toMap(Pair::getFirst, Pair::getSecond));
   }
 
   /**
@@ -190,7 +191,7 @@ public class TServerUtils {
     } catch (TTransportException e) {
       if (portSearch) {
         // Build a list of reserved ports - as identified by properties of type PropertyType.PORT
-        Map<Integer,Property> reservedPorts = getReservedPorts(config);
+        Map<Integer,Property> reservedPorts = getReservedPorts(config, portHintProperty);
 
         HostAndPort last = addresses[addresses.length - 1];
         // Attempt to allocate a port outside of the specified port property
diff --git a/server/base/src/test/java/org/apache/accumulo/server/util/TServerUtilsTest.java b/server/base/src/test/java/org/apache/accumulo/server/util/TServerUtilsTest.java
index 287b906..dcb10c1 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/util/TServerUtilsTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/util/TServerUtilsTest.java
@@ -243,7 +243,8 @@ public class TServerUtilsTest {
     conf.set(Property.TSERV_PORTSEARCH, "true");
 
     // Ensure that the TServer client port we set above is NOT in the reserved ports
-    Map<Integer,Property> reservedPorts = TServerUtils.getReservedPorts(conf);
+    Map<Integer,Property> reservedPorts =
+        TServerUtils.getReservedPorts(conf, Property.TSERV_CLIENTPORT);
     assertFalse(reservedPorts.containsKey(tserverDefaultPort));
 
     // Ensure that all the ports we assigned (GC, Manager, Monitor) are included in the reserved
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/CompactableImpl.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/CompactableImpl.java
index 0bcb561..09480f7 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/CompactableImpl.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/CompactableImpl.java
@@ -523,7 +523,8 @@ public class CompactableImpl implements Compactable {
                 Map<String,String> hints = Map.of();
                 if (kind == CompactionKind.USER)
                   hints = compactionConfig.getExecutionHints();
-                return Optional.of(new Compactable.Files(files, candidates, runningJobsCopy, hints));
+                return Optional
+                    .of(new Compactable.Files(files, candidates, runningJobsCopy, hints));
               } else {
                 return Optional.of(new Compactable.Files(files, Set.of(), runningJobsCopy));
               }