Index: src/main/java/org/apache/hadoop/hbase/master/HMaster.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/master/HMaster.java (revision 1291545) +++ src/main/java/org/apache/hadoop/hbase/master/HMaster.java (working copy) @@ -26,16 +26,15 @@ import java.net.InetSocketAddress; import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -47,6 +46,7 @@ import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HServerLoad; import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.MasterNotInitializedException; import org.apache.hadoop.hbase.MasterNotRunningException; import org.apache.hadoop.hbase.Server; import org.apache.hadoop.hbase.ServerName; @@ -70,7 +70,6 @@ import org.apache.hadoop.hbase.ipc.HMasterRegionInterface; import org.apache.hadoop.hbase.ipc.ProtocolSignature; import org.apache.hadoop.hbase.ipc.RpcServer; -import org.apache.hadoop.hbase.master.CatalogJanitor.SplitParentFirstComparator; import org.apache.hadoop.hbase.master.handler.CreateTableHandler; import org.apache.hadoop.hbase.master.handler.DeleteTableHandler; import org.apache.hadoop.hbase.master.handler.DisableTableHandler; @@ -1122,6 +1121,9 @@ public void createTable(HTableDescriptor hTableDescriptor, byte [][] splitKeys) throws IOException { + if (!isInitialized()) { + throw new MasterNotInitializedException("Master is not initialized"); + } if (!isMasterRunning()) { throw new MasterNotRunningException(); } @@ -1168,6 +1170,9 @@ @Override public void deleteTable(final byte [] tableName) throws IOException { + if (!isInitialized()) { + throw new MasterNotInitializedException("Master is not initialized"); + } if (cpHost != null) { cpHost.preDeleteTable(tableName); } @@ -1230,6 +1235,9 @@ public void addColumn(byte [] tableName, HColumnDescriptor column) throws IOException { + if (!isInitialized()) { + throw new MasterNotInitializedException("Master is not initialized"); + } if (cpHost != null) { if (cpHost.preAddColumn(tableName, column)) { return; @@ -1244,6 +1252,9 @@ public void modifyColumn(byte [] tableName, HColumnDescriptor descriptor) throws IOException { + if (!isInitialized()) { + throw new MasterNotInitializedException("Master is not initialized"); + } if (cpHost != null) { if (cpHost.preModifyColumn(tableName, descriptor)) { return; @@ -1258,6 +1269,9 @@ public void deleteColumn(final byte [] tableName, final byte [] c) throws IOException { + if (!isInitialized()) { + throw new MasterNotInitializedException("Master is not initialized"); + } if (cpHost != null) { if (cpHost.preDeleteColumn(tableName, c)) { return; @@ -1271,6 +1285,9 @@ } public void enableTable(final byte [] tableName) throws IOException { + if (!isInitialized()) { + throw new MasterNotInitializedException("Master is not initialized"); + } if (cpHost != null) { cpHost.preEnableTable(tableName); } @@ -1283,6 +1300,9 @@ } public void disableTable(final byte [] tableName) throws IOException { + if (!isInitialized()) { + throw new MasterNotInitializedException("Master is not initialized"); + } if (cpHost != null) { cpHost.preDisableTable(tableName); } @@ -1332,6 +1352,9 @@ @Override public void modifyTable(final byte[] tableName, HTableDescriptor htd) throws IOException { + if (!isInitialized()) { + throw new MasterNotInitializedException("Master is not initialized"); + } if (cpHost != null) { cpHost.preModifyTable(tableName, htd); } @@ -1667,6 +1690,9 @@ @Override public void assign(final byte [] regionName)throws IOException { + if (!isInitialized()) { + throw new MasterNotInitializedException("Master is not initialized"); + } Pair pair = MetaReader.getRegion(this.catalogTracker, regionName); if (pair == null) throw new UnknownRegionException(Bytes.toString(regionName)); @@ -1690,6 +1716,9 @@ @Override public void unassign(final byte [] regionName, final boolean force) throws IOException { + if (!isInitialized()) { + throw new MasterNotInitializedException("Master is not initialized"); + } Pair pair = MetaReader.getRegion(this.catalogTracker, regionName); if (pair == null) throw new UnknownRegionException(Bytes.toString(regionName)); Index: src/main/java/org/apache/hadoop/hbase/MasterNotInitializedException.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/MasterNotInitializedException.java (revision 0) +++ src/main/java/org/apache/hadoop/hbase/MasterNotInitializedException.java (revision 0) @@ -0,0 +1,53 @@ +/** + * Copyright 2007 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase; + +import java.io.IOException; + +/** + * Thrown if the master is not initialized when call admin operations. + */ +public class MasterNotInitializedException extends IOException { + private static final long serialVersionUID = -5828790543381661660L; + + /** default constructor */ + public MasterNotInitializedException() { + super(); + } + + /** + * Constructor + * + * @param s message + */ + public MasterNotInitializedException(String s) { + super(s); + } + + /** + * Constructor taking another exception. + * + * @param e Exception to grab data from. + */ + public MasterNotInitializedException(Exception e) { + super(e); + } + +}