hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1295433 - in /hbase/trunk/src/main/java/org/apache/hadoop/hbase: PleaseHoldException.java master/HMaster.java
Date Thu, 01 Mar 2012 06:59:51 GMT
Author: stack
Date: Thu Mar  1 06:59:51 2012
New Revision: 1295433

URL: http://svn.apache.org/viewvc?rev=1295433&view=rev
Log:
HBASE-5454 Refuse operations from Admin before master is initialized

Modified:
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/PleaseHoldException.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/PleaseHoldException.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/PleaseHoldException.java?rev=1295433&r1=1295432&r2=1295433&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/PleaseHoldException.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/PleaseHoldException.java Thu Mar  1
06:59:51 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/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1295433&r1=1295432&r2=1295433&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Thu Mar  1 06:59:51
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));



Mime
View raw message