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 1355618) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java (working copy) @@ -344,12 +344,31 @@ */ public AdminProtocol waitForRootServerConnection(long timeout) throws InterruptedException, NotAllMetaRegionsOnlineException, IOException { - return getRootServerConnection(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, exclude); + } + + /** + * 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 * @see #waitForRoot(long) for additional information @@ -360,11 +379,34 @@ */ AdminProtocol getRootServerConnection(long timeout) throws InterruptedException, NotAllMetaRegionsOnlineException, IOException { - return getCachedConnection(waitForRoot(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 {
+ ServerName server = waitForRoot(timeout);
+ if (exclude != null && exclude.equals(server)) {
+ return null;
+ }
+ return getCachedConnection(server);
+ }
+
+ /**
+ * Gets a connection to the server hosting root, as reported by ZooKeeper,
* waiting for the default timeout specified on instantiation.
* @see #waitForRoot(long) for additional information
* @return connection to server hosting root
@@ -651,9 +693,25 @@
*/
public boolean verifyRootRegionLocation(final long timeout)
throws InterruptedException, IOException {
+ 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 1355618)
+++ 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();
}
}