From f05b600cf4966c6d31bac589907790465b3ef22b Mon Sep 17 00:00:00 2001 From: ramkrishna Date: Thu, 31 May 2012 17:05:59 +0000 Subject: [PATCH] HBASE-6089 SSH and AM.joinCluster causes Concurrent Modification exception. (Rajesh) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1344816 13f79535-47bb-0310-9956-ffa450edef68 --- .../hbase/master/AssignmentManager.java | 34 +++++++++---------- .../apache/hadoop/hbase/master/HMaster.java | 1 - .../hadoop/hbase/master/MasterFileSystem.java | 2 -- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java index 6013463e03b..dfae608ed8d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java @@ -358,7 +358,6 @@ public class AssignmentManager extends ZooKeeperListener { /** * Called on startup. * Figures whether a fresh cluster start of we are joining extant running cluster. - * @param onlineServers onlined servers when master started * @throws IOException * @throws KeeperException * @throws InterruptedException @@ -426,17 +425,19 @@ public class AssignmentManager extends ZooKeeperListener { // Run through all regions. If they are not assigned and not in RIT, then // its a clean cluster startup, else its a failover. - for (Map.Entry e: this.regions.entrySet()) { - if (!e.getKey().isMetaTable() && e.getValue() != null) { - LOG.debug("Found " + e + " out on cluster"); - this.failover = true; - break; - } - if (nodes.contains(e.getKey().getEncodedName())) { - LOG.debug("Found " + e.getKey().getRegionNameAsString() + " in RITs"); - // Could be a meta region. - this.failover = true; - break; + synchronized (this.regions) { + for (Map.Entry e: this.regions.entrySet()) { + if (!e.getKey().isMetaTable() && e.getValue() != null) { + LOG.debug("Found " + e + " out on cluster"); + this.failover = true; + break; + } + if (nodes.contains(e.getKey().getEncodedName())) { + LOG.debug("Found " + e.getKey().getRegionNameAsString() + " in RITs"); + // Could be a meta region. + this.failover = true; + break; + } } } @@ -2547,8 +2548,6 @@ public class AssignmentManager extends ZooKeeperListener { *

* Returns a map of servers that are not found to be online and the regions * they were hosting. - * @param onlineServers if one region's location belongs to onlineServers, it - * doesn't need to be assigned. * @return map of servers not online to their assigned regions, as stored * in META * @throws IOException @@ -2624,8 +2623,10 @@ public class AssignmentManager extends ZooKeeperListener { // add only if region not in disabled and enabling table if (false == checkIfRegionBelongsToDisabled(regionInfo) && false == checkIfRegionsBelongsToEnabling(regionInfo)) { - regions.put(regionInfo, regionLocation); - addToServers(regionLocation, regionInfo); + synchronized (this.regions) { + regions.put(regionInfo, regionLocation); + addToServers(regionLocation, regionInfo); + } } disablingOrEnabling = addTheTablesInPartialState(this.disablingTables, this.enablingTables, regionInfo, tableName); @@ -3366,7 +3367,6 @@ public class AssignmentManager extends ZooKeeperListener { * Run through remaining regionservers and unassign all catalog regions. */ void unassignCatalogRegions() { - this.servers.entrySet(); synchronized (this.regions) { for (Map.Entry> e: this.servers.entrySet()) { Set regions = e.getValue(); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index 09fcd46be9c..0c6b0422487 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -663,7 +663,6 @@ Server { /** * Override to change master's splitLogAfterStartup. Used testing * @param mfs - * @param onlineServers */ protected void splitLogAfterStartup(final MasterFileSystem mfs) { mfs.splitLogAfterStartup(); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java index 368a46fb524..9d177c8a773 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java @@ -187,8 +187,6 @@ public class MasterFileSystem { /** * Inspect the log directory to recover any log file without * an active region server. - * @param onlineServers Set of online servers keyed by - * {@link ServerName} */ void splitLogAfterStartup() { boolean retrySplitting = !conf.getBoolean("hbase.hlog.split.skip.errors",