Index: src/main/java/org/apache/hadoop/hbase/master/HMaster.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/master/HMaster.java (revision 1326472) +++ src/main/java/org/apache/hadoop/hbase/master/HMaster.java (working copy) @@ -28,7 +28,6 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -52,6 +51,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; @@ -1099,6 +1099,7 @@ @Override public void deleteTable(final byte [] tableName) throws IOException { + checkInitialized(); if (cpHost != null) { cpHost.preDeleteTable(tableName); } @@ -1120,6 +1121,7 @@ public void addColumn(byte [] tableName, HColumnDescriptor column) throws IOException { + checkInitialized(); if (cpHost != null) { if (cpHost.preAddColumn(tableName, column)) { return; @@ -1133,6 +1135,7 @@ public void modifyColumn(byte [] tableName, HColumnDescriptor descriptor) throws IOException { + checkInitialized(); if (cpHost != null) { if (cpHost.preModifyColumn(tableName, descriptor)) { return; @@ -1146,6 +1149,7 @@ public void deleteColumn(final byte [] tableName, final byte [] c) throws IOException { + checkInitialized(); if (cpHost != null) { if (cpHost.preDeleteColumn(tableName, c)) { return; @@ -1158,6 +1162,7 @@ } public void enableTable(final byte [] tableName) throws IOException { + checkInitialized(); if (cpHost != null) { cpHost.preEnableTable(tableName); } @@ -1170,6 +1175,7 @@ } public void disableTable(final byte [] tableName) throws IOException { + checkInitialized(); if (cpHost != null) { cpHost.preDisableTable(tableName); } @@ -1219,6 +1225,7 @@ @Override public void modifyTable(final byte[] tableName, HTableDescriptor htd) throws IOException { + checkInitialized(); if (cpHost != null) { cpHost.preModifyTable(tableName, htd); } @@ -1521,6 +1528,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 +1577,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 +1601,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 1326472) +++ 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 {