Index: src/main/java/org/apache/hadoop/hbase/master/HMaster.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/master/HMaster.java (revision 1328188) +++ src/main/java/org/apache/hadoop/hbase/master/HMaster.java (working copy) @@ -52,6 +52,7 @@ import org.apache.hadoop.hbase.HServerLoad; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.MasterNotRunningException; +import org.apache.hadoop.hbase.PleaseHoldException; import org.apache.hadoop.hbase.Server; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableDescriptors; @@ -1058,6 +1059,7 @@ } HRegionInfo [] newRegions = getHRegionInfos(hTableDescriptor, splitKeys); + checkInitialized(); if (cpHost != null) { cpHost.preCreateTable(hTableDescriptor, newRegions); } @@ -1099,6 +1101,7 @@ @Override public void deleteTable(final byte [] tableName) throws IOException { + checkInitialized(); if (cpHost != null) { cpHost.preDeleteTable(tableName); } @@ -1120,6 +1123,7 @@ public void addColumn(byte [] tableName, HColumnDescriptor column) throws IOException { + checkInitialized(); if (cpHost != null) { if (cpHost.preAddColumn(tableName, column)) { return; @@ -1133,6 +1137,7 @@ public void modifyColumn(byte [] tableName, HColumnDescriptor descriptor) throws IOException { + checkInitialized(); if (cpHost != null) { if (cpHost.preModifyColumn(tableName, descriptor)) { return; @@ -1146,6 +1151,7 @@ public void deleteColumn(final byte [] tableName, final byte [] c) throws IOException { + checkInitialized(); if (cpHost != null) { if (cpHost.preDeleteColumn(tableName, c)) { return; @@ -1158,6 +1164,7 @@ } public void enableTable(final byte [] tableName) throws IOException { + checkInitialized(); if (cpHost != null) { cpHost.preEnableTable(tableName); } @@ -1170,6 +1177,7 @@ } public void disableTable(final byte [] tableName) throws IOException { + checkInitialized(); if (cpHost != null) { cpHost.preDisableTable(tableName); } @@ -1219,6 +1227,7 @@ @Override public void modifyTable(final byte[] tableName, HTableDescriptor htd) throws IOException { + checkInitialized(); if (cpHost != null) { cpHost.preModifyTable(tableName, htd); } @@ -1521,6 +1530,11 @@ return this.abort; } + void checkInitialized() throws PleaseHoldException { + if (!this.initialized) { + throw new PleaseHoldException("Master is initializing"); + } + } /** * Report whether this master is currently the active master or not. @@ -1565,6 +1579,7 @@ @Override public void assign(final byte [] regionName)throws IOException { + checkInitialized(); Pair pair = MetaReader.getRegion(this.catalogTracker, regionName); if (pair == null) throw new UnknownRegionException(Bytes.toString(regionName)); @@ -1588,6 +1603,7 @@ @Override public void unassign(final byte [] regionName, final boolean force) throws IOException { + checkInitialized(); Pair pair = MetaReader.getRegion(this.catalogTracker, regionName); if (pair == null) throw new UnknownRegionException(Bytes.toString(regionName)); Index: src/main/java/org/apache/hadoop/hbase/PleaseHoldException.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/PleaseHoldException.java (revision 1328188) +++ src/main/java/org/apache/hadoop/hbase/PleaseHoldException.java (working copy) @@ -22,9 +22,10 @@ import java.io.IOException; /** - * This exception is thrown by the master when a region server was shut down - * and restarted so fast that the master still hasn't processed the server - * shutdown of the first instance. + * This exception is thrown by the master when a region server was shut down and + * restarted so fast that the master still hasn't processed the server shutdown + * of the first instance, or when master is initializing and client call admin + * operations */ @SuppressWarnings("serial") public class PleaseHoldException extends IOException {