Index: src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (revision 1308049) +++ src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (working copy) @@ -176,6 +176,13 @@ throws MasterNotRunningException, ZooKeeperConnectionException { return this.connection.isMasterRunning(); } + /** @return - true if the master server is available + * @throws ZooKeeperConnectionException + * @throws MasterNotRunningException */ + public boolean isMasterAvailable() + throws MasterNotRunningException, ZooKeeperConnectionException { + return this.connection.isMasterAvailable(); + } /** * @param tableName Table to check. @@ -420,7 +427,7 @@ * @throws IOException if a remote or network exception occurs */ public void deleteTable(final byte [] tableName) throws IOException { - isMasterRunning(); + isMasterAvailable(); HTableDescriptor.isLegalTableName(tableName); HRegionLocation firstMetaServer = getFirstMetaServerForTable(tableName); try { @@ -535,7 +542,7 @@ */ public void enableTableAsync(final byte [] tableName) throws IOException { - isMasterRunning(); + isMasterAvailable(); try { getMaster().enableTable(tableName); } catch (RemoteException e) { @@ -562,7 +569,7 @@ * @since 0.90.0 */ public void disableTableAsync(final byte [] tableName) throws IOException { - isMasterRunning(); + isMasterAvailable(); try { getMaster().disableTable(tableName); } catch (RemoteException e) { Index: src/main/java/org/apache/hadoop/hbase/client/HConnection.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/client/HConnection.java (revision 1308049) +++ src/main/java/org/apache/hadoop/hbase/client/HConnection.java (working copy) @@ -79,6 +79,10 @@ /** @return - true if the master server is running */ public boolean isMasterRunning() throws MasterNotRunningException, ZooKeeperConnectionException; + + /** @return - true if the master server is available */ + public boolean isMasterAvailable() + throws MasterNotRunningException, ZooKeeperConnectionException; /** * A table that isTableEnabled == false and isTableDisabled == false Index: src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (revision 1308049) +++ src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (working copy) @@ -595,7 +595,7 @@ // Check if we already have a good master connection if (master != null) { - if (master.isMasterRunning()) { + if (master.isMasterAvailable()) { return master; } } @@ -619,7 +619,7 @@ HMasterInterface.class, HBaseRPCProtocolVersion.versionID, masterLocation.getInetSocketAddress(), this.conf, this.rpcTimeout); - if (tryMaster.isMasterRunning()) { + if (tryMaster.isMasterAvailable()) { this.master = tryMaster; this.masterLock.notifyAll(); break; @@ -669,6 +669,18 @@ } throw new MasterNotRunningException(); } + + public boolean isMasterAvailable() + throws MasterNotRunningException, ZooKeeperConnectionException { + if (this.master == null) { + getMaster(); + } + boolean isAvailable = master.isMasterAvailable(); + if(isAvailable) { + return true; + } + throw new MasterNotRunningException(); + } public HRegionLocation getRegionLocation(final byte [] name, final byte [] row, boolean reload) Index: src/main/java/org/apache/hadoop/hbase/ipc/HMasterInterface.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/ipc/HMasterInterface.java (revision 1308049) +++ src/main/java/org/apache/hadoop/hbase/ipc/HMasterInterface.java (working copy) @@ -37,8 +37,13 @@ */ public interface HMasterInterface extends HBaseRPCProtocolVersion { + /** @return true if master is running */ + public boolean isMasterRunning(); + /** @return true if master is available */ - public boolean isMasterRunning(); + public boolean isMasterAvailable(); + + // Admin tools would use these cmds Index: src/main/java/org/apache/hadoop/hbase/master/HMaster.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/master/HMaster.java (revision 1308049) +++ src/main/java/org/apache/hadoop/hbase/master/HMaster.java (working copy) @@ -709,7 +709,11 @@ public boolean isMasterRunning() { return !isStopped(); } - + + //the master is running and it can provide service + public boolean isMasterAvailable() { + return !isStopped() && isInitialized(); + } @Override public boolean balance() { // If balance not true, don't run balancer.