HBASE-5454 Refuse operations from Admin before master is initialized

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1295433 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2012-03-01 06:59:51 +00:00
parent 8eab15acf5
commit 324a2cfeb4
2 changed files with 20 additions and 5 deletions

View File

@ -22,9 +22,10 @@ package org.apache.hadoop.hbase;
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 {

View File

@ -26,16 +26,15 @@ import java.net.InetAddress;
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 javax.management.ObjectName;
@ -50,6 +49,7 @@ import org.apache.hadoop.hbase.HRegionInfo;
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;
@ -1178,6 +1178,7 @@ Server {
@Override
public void deleteTable(final byte [] tableName) throws IOException {
checkInitialized();
if (cpHost != null) {
cpHost.preDeleteTable(tableName);
}
@ -1240,6 +1241,7 @@ Server {
public void addColumn(byte [] tableName, HColumnDescriptor column)
throws IOException {
checkInitialized();
if (cpHost != null) {
if (cpHost.preAddColumn(tableName, column)) {
return;
@ -1254,6 +1256,7 @@ Server {
public void modifyColumn(byte [] tableName, HColumnDescriptor descriptor)
throws IOException {
checkInitialized();
if (cpHost != null) {
if (cpHost.preModifyColumn(tableName, descriptor)) {
return;
@ -1268,6 +1271,7 @@ Server {
public void deleteColumn(final byte [] tableName, final byte [] c)
throws IOException {
checkInitialized();
if (cpHost != null) {
if (cpHost.preDeleteColumn(tableName, c)) {
return;
@ -1281,6 +1285,7 @@ Server {
}
public void enableTable(final byte [] tableName) throws IOException {
checkInitialized();
if (cpHost != null) {
cpHost.preEnableTable(tableName);
}
@ -1293,6 +1298,7 @@ Server {
}
public void disableTable(final byte [] tableName) throws IOException {
checkInitialized();
if (cpHost != null) {
cpHost.preDisableTable(tableName);
}
@ -1342,6 +1348,7 @@ Server {
@Override
public void modifyTable(final byte[] tableName, HTableDescriptor htd)
throws IOException {
checkInitialized();
if (cpHost != null) {
cpHost.preModifyTable(tableName, htd);
}
@ -1648,6 +1655,11 @@ Server {
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.
@ -1683,6 +1695,7 @@ Server {
@Override
public void assign(final byte [] regionName)throws IOException {
checkInitialized();
Pair<HRegionInfo, ServerName> pair =
MetaReader.getRegion(this.catalogTracker, regionName);
if (pair == null) throw new UnknownRegionException(Bytes.toString(regionName));
@ -1706,6 +1719,7 @@ Server {
@Override
public void unassign(final byte [] regionName, final boolean force)
throws IOException {
checkInitialized();
Pair<HRegionInfo, ServerName> pair =
MetaReader.getRegion(this.catalogTracker, regionName);
if (pair == null) throw new UnknownRegionException(Bytes.toString(regionName));