accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adamjsh...@apache.org
Subject [accumulo] branch 1.9 updated: Fix ConcurrentModificationException in HostRegexTableLoadBalancer (#1107)
Date Thu, 18 Apr 2019 18:22:49 GMT
This is an automated email from the ASF dual-hosted git repository.

adamjshook pushed a commit to branch 1.9
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/1.9 by this push:
     new 570dabd  Fix ConcurrentModificationException in HostRegexTableLoadBalancer (#1107)
570dabd is described below

commit 570dabd22a47fdd1332e81e7f53154f3e1da2029
Author: Adam J. Shook <adamjshook@gmail.com>
AuthorDate: Thu Apr 18 14:22:44 2019 -0400

    Fix ConcurrentModificationException in HostRegexTableLoadBalancer (#1107)
---
 .../master/balancer/HostRegexTableLoadBalancer.java     | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancer.java
b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancer.java
index fb5a600..9f20a13 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancer.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancer.java
@@ -51,6 +51,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.HashMultimap;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Multimap;
 
@@ -111,8 +112,8 @@ public class HostRegexTableLoadBalancer extends TableLoadBalancer implements
Con
   private static final long ONE_HOUR = 60 * 60 * 1000;
   private static final Set<KeyExtent> EMPTY_MIGRATIONS = Collections.emptySet();
 
-  private Map<String,String> tableIdToTableName = null;
-  private Map<String,Pattern> poolNameToRegexPattern = null;
+  private volatile Map<String,String> tableIdToTableName = null;
+  private volatile Map<String,Pattern> poolNameToRegexPattern = null;
   private volatile long lastOOBCheck = System.currentTimeMillis();
   private volatile boolean isIpBasedRegex = false;
   private Map<String,SortedMap<TServerInstance,TabletServerStatus>> pools = new
HashMap<>();
@@ -226,10 +227,10 @@ public class HostRegexTableLoadBalancer extends TableLoadBalancer implements
Con
     if (null == t) {
       throw new RuntimeException("Table Operations cannot be null");
     }
-    tableIdToTableName = new HashMap<>();
-    poolNameToRegexPattern = new HashMap<>();
+    Map<String,String> tableIdToTableNameBuilder = new HashMap<>();
+    Map<String,Pattern> poolNameToRegexPatternBuilder = new HashMap<>();
     for (Entry<String,String> table : t.tableIdMap().entrySet()) {
-      tableIdToTableName.put(table.getValue(), table.getKey());
+      tableIdToTableNameBuilder.put(table.getValue(), table.getKey());
       conf.getTableConfiguration(table.getValue()).addObserver(this);
       Map<String,String> customProps = conf.getTableConfiguration(table.getValue())
           .getAllPropertiesWithPrefix(Property.TABLE_ARBITRARY_PROP_PREFIX);
@@ -244,11 +245,15 @@ public class HostRegexTableLoadBalancer extends TableLoadBalancer implements
Con
             }
             String tableName = customProp.getKey().substring(HOST_BALANCER_PREFIX.length());
             String regex = customProp.getValue();
-            poolNameToRegexPattern.put(tableName, Pattern.compile(regex));
+            poolNameToRegexPatternBuilder.put(tableName, Pattern.compile(regex));
           }
         }
       }
     }
+
+    tableIdToTableName = ImmutableMap.copyOf(tableIdToTableNameBuilder);
+    poolNameToRegexPattern = ImmutableMap.copyOf(poolNameToRegexPatternBuilder);
+
     String oobProperty = conf.getConfiguration().get(HOST_BALANCER_OOB_CHECK_KEY);
     if (null != oobProperty) {
       oobCheckMillis = AccumuloConfiguration.getTimeInMillis(oobProperty);


Mime
View raw message