Author: stack
Date: Thu Mar 1 17:36:23 2012
New Revision: 1295693
URL: http://svn.apache.org/viewvc?rev=1295693&view=rev
Log:
HBASE-5454 Refuse operations from Admin before master is initialized
Modified:
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/PleaseHoldException.java
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
Modified:
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/PleaseHoldException.java
URL:
http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/PleaseHoldException.java?rev=1295693&r1=1295692&r2=1295693&view=diff
==============================================================================
---
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/PleaseHoldException.java
(original)
+++
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/PleaseHoldException.java
Thu Mar 1 17:36:23 2012
@@ -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 {
Modified:
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL:
http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1295693&r1=1295692&r2=1295693&view=diff
==============================================================================
---
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
(original)
+++
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
Thu Mar 1 17:36:23 2012
@@ -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.HRegionIn
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));