From 50bac9f39741e0e339439b212cf3d1104b4acdf4 Mon Sep 17 00:00:00 2001 From: zjushch Date: Fri, 11 Jan 2013 05:47:18 +0000 Subject: [PATCH] HBASE-7506 Judgment of carrying ROOT/META will become wrong when expiring server (Chunhui) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1431901 13f79535-47bb-0310-9956-ffa450edef68 --- .../hbase/master/AssignmentManager.java | 4 +-- .../master/handler/ServerShutdownHandler.java | 33 +++++++++++++------ 2 files changed, 25 insertions(+), 12 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 f69afe9f692..5d8d836e4b1 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 @@ -2636,11 +2636,11 @@ public class AssignmentManager extends ZooKeeperListener { threadPoolExecutorService.submit(new UnAssignCallable(this, regionInfo)); } - boolean isCarryingRoot(ServerName serverName) { + public boolean isCarryingRoot(ServerName serverName) { return isCarryingRegion(serverName, HRegionInfo.ROOT_REGIONINFO); } - boolean isCarryingMeta(ServerName serverName) { + public boolean isCarryingMeta(ServerName serverName) { return isCarryingRegion(serverName, HRegionInfo.FIRST_META_REGIONINFO); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java index d6e5fca5623..f325708fb35 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java @@ -196,20 +196,33 @@ public class ServerShutdownHandler extends EventHandler { // Assign root and meta if we were carrying them. if (isCarryingRoot()) { // -ROOT- - LOG.info("Server " + serverName + - " was carrying ROOT. Trying to assign."); - this.services.getAssignmentManager(). - regionOffline(HRegionInfo.ROOT_REGIONINFO); - verifyAndAssignRootWithRetries(); + // Check again: region may be assigned to other where because of RIT + // timeout + if (this.services.getAssignmentManager().isCarryingRoot(serverName)) { + LOG.info("Server " + serverName + + " was carrying ROOT. Trying to assign."); + this.services.getAssignmentManager().regionOffline( + HRegionInfo.ROOT_REGIONINFO); + verifyAndAssignRootWithRetries(); + } else { + LOG.info("ROOT has been assigned to otherwhere, skip assigning."); + } } // Carrying meta? if (isCarryingMeta()) { - LOG.info("Server " + serverName + - " was carrying META. Trying to assign."); - this.services.getAssignmentManager(). - regionOffline(HRegionInfo.FIRST_META_REGIONINFO); - this.services.getAssignmentManager().assignMeta(); + // Check again: region may be assigned to other where because of RIT + // timeout + if (this.services.getAssignmentManager().isCarryingMeta(serverName)) { + LOG.info("Server " + serverName + + " was carrying META. Trying to assign."); + this.services.getAssignmentManager().regionOffline( + HRegionInfo.FIRST_META_REGIONINFO); + this.services.getAssignmentManager().assignMeta(); + } else { + LOG.info("META has been assigned to otherwhere, skip assigning."); + } + } // We don't want worker thread in the MetaServerShutdownHandler