Index: hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java (revision 1354859) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java (working copy) @@ -342,9 +342,27 @@ * @throws IOException * @deprecated Use #getRootServerConnection(long) */ - public AdminProtocol waitForRootServerConnection(long timeout) + public AdminProtocol waitForRootServerConnection(long timeout) { + return waitForRootServerConnection(timeout, null); + } + + /** + * Gets a connection to the server hosting root, as reported by ZooKeeper, + * waiting up to the specified timeout for availability. + * @param timeout How long to wait on root location + * @param exclude The server to exclude for the ROOT location, used only by + * ServerShutdownHandler to ensure the ROOT region has not been assigned + * elsewhere. + * @see #waitForRoot(long) for additional information + * @return connection to server hosting root + * @throws InterruptedException + * @throws NotAllMetaRegionsOnlineException if timed out waiting + * @throws IOException + * @deprecated Use #getRootServerConnection(long) + */ + public AdminProtocol waitForRootServerConnection(long timeout, ServerName exclude) throws InterruptedException, NotAllMetaRegionsOnlineException, IOException { - return getRootServerConnection(timeout); + return getRootServerConnection(timeout, exclude); } /** @@ -358,9 +376,31 @@ * @throws NotAllMetaRegionsOnlineException if timed out waiting * @throws IOException */ - AdminProtocol getRootServerConnection(long timeout) + AdminProtocol getRootServerConnection(long timeout) { + return getRootServerConnection(timeout, null); + } + + /** + * Gets a connection to the server hosting root, as reported by ZooKeeper, + * waiting up to the specified timeout for availability. + *

WARNING: Does not retry. Use an {@link HTable} instead. + * @param timeout How long to wait on root location + * @param exclude The server to exclude for the ROOT location, used only by + * ServerShutdownHandler to ensure the ROOT region has not been assigned + * elsewhere. + * @see #waitForRoot(long) for additional information + * @return connection to server hosting root + * @throws InterruptedException + * @throws NotAllMetaRegionsOnlineException if timed out waiting + * @throws IOException + */ + AdminProtocol getRootServerConnection(long timeout, ServerName exclude) throws InterruptedException, NotAllMetaRegionsOnlineException, IOException { - return getCachedConnection(waitForRoot(timeout)); + ServerName server = waitForRoot(timeout); + if (exclude != null && exclude.equals(server)) + return null; + + return getCachedConnection(server); } /** @@ -649,11 +689,26 @@ * @throws IOException * @throws InterruptedException */ - public boolean verifyRootRegionLocation(final long timeout) + public boolean verifyRootRegionLocation(final long timeout) { + return verifyRootRegionLocation(timeout, null); + } + + /** + * Verify -ROOT- is deployed and accessible. + * @param timeout How long to wait on zk for root address (passed through to + * the internal call to {@link #waitForRootServerConnection(long)}. + * @param exclude The server to exclude for the ROOT location, used only by + * ServerShutdownHandler to ensure the ROOT region has not been assigned + * elsewhere. + * @return True if the -ROOT- location is healthy. + * @throws IOException + * @throws InterruptedException + */ + public boolean verifyRootRegionLocation(final long timeout, ServerName exclude) throws InterruptedException, IOException { AdminProtocol connection = null; try { - connection = waitForRootServerConnection(timeout); + connection = waitForRootServerConnection(timeout, exclude); } catch (NotAllMetaRegionsOnlineException e) { // Pass } catch (ServerNotRunningYetException e) { Index: hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java (revision 1354859) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java (working copy) @@ -104,7 +104,7 @@ throws InterruptedException, IOException, KeeperException { long timeout = this.server.getConfiguration(). getLong("hbase.catalog.verification.timeout", 1000); - if (!this.server.getCatalogTracker().verifyRootRegionLocation(timeout)) { + if (!this.server.getCatalogTracker().verifyRootRegionLocation(timeout, this.serverName)) { this.services.getAssignmentManager().assignRoot(); } }