From 9abe2da9e80b83ca41f9789bbb0a269631492b6b Mon Sep 17 00:00:00 2001 From: Jimmy Xiang Date: Fri, 8 Aug 2014 10:10:28 -0700 Subject: [PATCH] HBASE-11709 TestMasterShutdown can fail sometime --- .../hadoop/hbase/master/AssignmentManager.java | 13 +------------ .../org/apache/hadoop/hbase/master/HMaster.java | 16 +++++++--------- .../hadoop/hbase/master/MasterRpcServices.java | 2 +- .../hadoop/hbase/regionserver/HRegionServer.java | 2 +- 4 files changed, 10 insertions(+), 23 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 1b7aea06ea8..0503c5c35a0 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 @@ -644,11 +644,6 @@ public class AssignmentManager { if (isDisabledorDisablingRegionInRIT(region)) { return; } - if (this.serverManager.isClusterShutdown()) { - LOG.info("Cluster shutdown is set; skipping assign of " + - region.getRegionNameAsString()); - return; - } String encodedName = region.getEncodedName(); Lock lock = locker.acquireLock(encodedName); try { @@ -2089,13 +2084,7 @@ public class AssignmentManager { } public void stop() { - shutdown(); // Stop executor service, etc - } - - /** - * Shutdown the threadpool executor service - */ - public void shutdown() { + // Shutdown the threadpool executor service threadPoolExecutorService.shutdownNow(); regionStateStore.stop(); } 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 0c87e637331..eca599992e6 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 @@ -1632,18 +1632,16 @@ public class HMaster extends HRegionServer implements MasterServices, Server { LOG.error("Error call master coprocessor preShutdown()", ioe); } } - if (this.assignmentManager != null) { - this.assignmentManager.shutdown(); + + if (this.serverManager != null) { + this.serverManager.shutdownCluster(); } - try { - if (this.clusterStatusTracker != null){ + if (this.clusterStatusTracker != null){ + try { this.clusterStatusTracker.setClusterDown(); - if (this.serverManager != null) { - this.serverManager.shutdownCluster(); - } + } catch (KeeperException e) { + LOG.error("ZooKeeper exception trying to set cluster as down in ZK", e); } - } catch (KeeperException e) { - LOG.error("ZooKeeper exception trying to set cluster as down in ZK", e); } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java index d6f825b352f..f0309a2b474 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java @@ -874,7 +874,7 @@ public class MasterRpcServices extends RSRpcServices public IsMasterRunningResponse isMasterRunning(RpcController c, IsMasterRunningRequest req) throws ServiceException { try { - master.checkInitialized(); + master.checkServiceStarted(); return IsMasterRunningResponse.newBuilder().setIsMasterRunning( !master.isStopped()).build(); } catch (IOException e) { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index 24bb09af4b3..8e626208859 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -670,7 +670,7 @@ public class HRegionServer extends HasThread implements * @return False if cluster shutdown in progress */ private boolean isClusterUp() { - return this.clusterStatusTracker.isClusterUp(); + return clusterStatusTracker != null && clusterStatusTracker.isClusterUp(); } private void initializeThreads() throws IOException {