You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2015/03/28 22:01:15 UTC

hbase git commit: HBASE-13357 If maxTables/maxRegions exceeds quota in a namespace, throw QuotaExceededException (Ashish Singhi)

Repository: hbase
Updated Branches:
  refs/heads/master 0967c6af2 -> a6ff17b95


HBASE-13357 If maxTables/maxRegions exceeds quota in a namespace, throw QuotaExceededException (Ashish Singhi)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/a6ff17b9
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a6ff17b9
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a6ff17b9

Branch: refs/heads/master
Commit: a6ff17b958985f806233c345f0c1a2e6f85ec323
Parents: 0967c6a
Author: tedyu <yu...@gmail.com>
Authored: Sat Mar 28 14:01:06 2015 -0700
Committer: tedyu <yu...@gmail.com>
Committed: Sat Mar 28 14:01:06 2015 -0700

----------------------------------------------------------------------
 .../hbase/namespace/NamespaceStateManager.java    |  9 +++++----
 .../hbase/namespace/TestNamespaceAuditor.java     | 18 ++++++++++++++++++
 2 files changed, 23 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/a6ff17b9/hbase-server/src/main/java/org/apache/hadoop/hbase/namespace/NamespaceStateManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/namespace/NamespaceStateManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/namespace/NamespaceStateManager.java
index 981748b..ea1e21a 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/namespace/NamespaceStateManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/namespace/NamespaceStateManager.java
@@ -24,7 +24,6 @@ import java.util.concurrent.ConcurrentMap;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.hbase.DoNotRetryIOException;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.NamespaceDescriptor;
@@ -32,6 +31,7 @@ import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.master.MasterServices;
 import org.apache.hadoop.hbase.master.TableNamespaceManager;
+import org.apache.hadoop.hbase.quotas.QuotaExceededException;
 import org.apache.hadoop.hbase.util.Bytes;
 
 /**
@@ -123,13 +123,14 @@ class NamespaceStateManager {
       NamespaceTableAndRegionInfo currentStatus;
       currentStatus = getState(nspdesc.getName());
       if ((currentStatus.getTables().size()) >= TableNamespaceManager.getMaxTables(nspdesc)) {
-        throw new DoNotRetryIOException("The table " + table.getNameAsString()
+        throw new QuotaExceededException("The table " + table.getNameAsString()
             + "cannot be created as it would exceed maximum number of tables allowed "
-            + " in the namespace.");
+            + " in the namespace.  The total number of tables permitted is "
+            + TableNamespaceManager.getMaxTables(nspdesc));
       }
       if ((currentStatus.getRegionCount() + numRegions) > TableNamespaceManager
           .getMaxRegions(nspdesc)) {
-        throw new DoNotRetryIOException("The table " + table.getNameAsString()
+        throw new QuotaExceededException("The table " + table.getNameAsString()
             + " is not allowed to have " + numRegions
             + " regions. The total number of regions permitted is only "
             + TableNamespaceManager.getMaxRegions(nspdesc)

http://git-wip-us.apache.org/repos/asf/hbase/blob/a6ff17b9/hbase-server/src/test/java/org/apache/hadoop/hbase/namespace/TestNamespaceAuditor.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/namespace/TestNamespaceAuditor.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/namespace/TestNamespaceAuditor.java
index 6204f0d..1c0ae11 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/namespace/TestNamespaceAuditor.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/namespace/TestNamespaceAuditor.java
@@ -68,6 +68,7 @@ import org.apache.hadoop.hbase.master.RegionState;
 import org.apache.hadoop.hbase.master.RegionStates;
 import org.apache.hadoop.hbase.master.TableNamespaceManager;
 import org.apache.hadoop.hbase.quotas.MasterQuotaManager;
+import org.apache.hadoop.hbase.quotas.QuotaExceededException;
 import org.apache.hadoop.hbase.quotas.QuotaUtil;
 import org.apache.hadoop.hbase.regionserver.HRegion;
 import org.apache.hadoop.hbase.regionserver.HRegionServer;
@@ -589,4 +590,21 @@ public class TestNamespaceAuditor {
     ADMIN.deleteTable(tableName);
     observer.tableDeletionLatch.await();
   }
+
+  @Test(expected = QuotaExceededException.class, timeout = 30000)
+  public void testExceedTableQuotaInNamespace() throws Exception {
+    String nsp = prefix + "_testExceedTableQuotaInNamespace";
+    NamespaceDescriptor nspDesc =
+        NamespaceDescriptor.create(nsp).addConfiguration(TableNamespaceManager.KEY_MAX_TABLES, "1")
+            .build();
+    ADMIN.createNamespace(nspDesc);
+    assertNotNull("Namespace descriptor found null.", ADMIN.getNamespaceDescriptor(nsp));
+    assertEquals(ADMIN.listNamespaceDescriptors().length, 3);
+    HTableDescriptor tableDescOne =
+        new HTableDescriptor(TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table1"));
+    HTableDescriptor tableDescTwo =
+        new HTableDescriptor(TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table2"));
+    ADMIN.createTable(tableDescOne);
+    ADMIN.createTable(tableDescTwo, Bytes.toBytes("AAA"), Bytes.toBytes("ZZZ"), 4);
+  }
 }