You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by la...@apache.org on 2012/04/24 07:18:39 UTC

svn commit: r1329558 - in /hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase: PleaseHoldException.java master/HMaster.java

Author: larsh
Date: Tue Apr 24 05:18:39 2012
New Revision: 1329558

URL: http://svn.apache.org/viewvc?rev=1329558&view=rev
Log:
Refuse operations from Admin before master is initialized - fix for all branches

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

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/PleaseHoldException.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/PleaseHoldException.java?rev=1329558&r1=1329557&r2=1329558&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/PleaseHoldException.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/PleaseHoldException.java Tue Apr 24 05:18:39 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.90/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1329558&r1=1329557&r2=1329558&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Tue Apr 24 05:18:39 2012
@@ -43,6 +43,7 @@ import org.apache.hadoop.hbase.HServerAd
 import org.apache.hadoop.hbase.HServerInfo;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.MasterNotRunningException;
+import org.apache.hadoop.hbase.PleaseHoldException;
 import org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException;
 import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.TableExistsException;
@@ -802,6 +803,7 @@ implements HMasterInterface, HMasterRegi
 
   public void createTable(HTableDescriptor desc, byte [][] splitKeys)
   throws IOException {
+    checkInitialized();
     createTable(desc, splitKeys, false);
   }
 
@@ -888,30 +890,36 @@ implements HMasterInterface, HMasterRegi
   }
 
   public void deleteTable(final byte [] tableName) throws IOException {
+    checkInitialized();
     this.executorService.submit(new DeleteTableHandler(tableName, this, this));
   }
 
   public void addColumn(byte [] tableName, HColumnDescriptor column)
   throws IOException {
+    checkInitialized();
     new TableAddFamilyHandler(tableName, column, this, this).process();
   }
 
   public void modifyColumn(byte [] tableName, HColumnDescriptor descriptor)
   throws IOException {
+    checkInitialized();
     new TableModifyFamilyHandler(tableName, descriptor, this, this).process();
   }
 
   public void deleteColumn(final byte [] tableName, final byte [] c)
   throws IOException {
+    checkInitialized();
     new TableDeleteFamilyHandler(tableName, c, this, this).process();
   }
 
   public void enableTable(final byte [] tableName) throws IOException {
+    checkInitialized();
     this.executorService.submit(new EnableTableHandler(this, tableName,
       catalogTracker, assignmentManager));
   }
 
   public void disableTable(final byte [] tableName) throws IOException {
+    checkInitialized();
     this.executorService.submit(new DisableTableHandler(this, tableName,
       catalogTracker, assignmentManager));
   }
@@ -956,6 +964,7 @@ implements HMasterInterface, HMasterRegi
   @Override
   public void modifyTable(final byte[] tableName, HTableDescriptor htd)
   throws IOException {
+    checkInitialized();
     this.executorService.submit(new ModifyTableHandler(tableName, htd, this, this));
   }
 
@@ -1049,6 +1058,12 @@ implements HMasterInterface, HMasterRegi
   public boolean isStopped() {
     return this.stopped;
   }
+  
+  void checkInitialized() throws PleaseHoldException {
+    if (!this.initialized) {
+      throw new PleaseHoldException("Master is initializing");
+    }
+  }
 
   /**
    * Report whether this master is currently the active master or not.
@@ -1078,6 +1093,7 @@ implements HMasterInterface, HMasterRegi
   @Override
   public void assign(final byte [] regionName, final boolean force)
   throws IOException {
+    checkInitialized();
     Pair<HRegionInfo, HServerAddress> pair =
       MetaReader.getRegion(this.catalogTracker, regionName);
     if (pair == null) throw new UnknownRegionException(Bytes.toString(regionName));
@@ -1091,6 +1107,7 @@ implements HMasterInterface, HMasterRegi
   @Override
   public void unassign(final byte [] regionName, final boolean force)
   throws IOException {
+    checkInitialized();
     Pair<HRegionInfo, HServerAddress> pair =
       MetaReader.getRegion(this.catalogTracker, regionName);
     if (pair == null) throw new UnknownRegionException(Bytes.toStringBinary(regionName));