You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by el...@apache.org on 2018/05/29 16:07:42 UTC

[2/3] hbase git commit: HBASE-20633 Dropping a table containing a disable violation policy fails to remove the quota upon table delete

HBASE-20633 Dropping a table containing a disable violation policy fails to remove the quota upon table delete

Signed-off-by: Josh Elser <el...@apache.org>
Signed-off-by: Michael Stack <st...@apache.org>


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

Branch: refs/heads/branch-2
Commit: d36cce1574dfe6576cdcc6ca087b32045ed29ac2
Parents: aa00391
Author: Nihal Jain <ni...@gmail.com>
Authored: Mon May 28 14:36:14 2018 +0530
Committer: Josh Elser <el...@apache.org>
Committed: Tue May 29 11:50:40 2018 -0400

----------------------------------------------------------------------
 .../DisableTableViolationPolicyEnforcement.java |  4 +-
 .../hadoop/hbase/quotas/TestSpaceQuotas.java    | 40 +++++++++++++++-----
 2 files changed, 34 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/d36cce15/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/policies/DisableTableViolationPolicyEnforcement.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/policies/DisableTableViolationPolicyEnforcement.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/policies/DisableTableViolationPolicyEnforcement.java
index c85ba21..9d24c92 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/policies/DisableTableViolationPolicyEnforcement.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/policies/DisableTableViolationPolicyEnforcement.java
@@ -20,6 +20,7 @@ import java.io.IOException;
 
 import org.apache.hadoop.hbase.TableNotDisabledException;
 import org.apache.hadoop.hbase.TableNotEnabledException;
+import org.apache.hadoop.hbase.TableNotFoundException;
 import org.apache.yetus.audience.InterfaceAudience;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -62,8 +63,9 @@ public class DisableTableViolationPolicyEnforcement extends DefaultViolationPoli
       if (LOG.isTraceEnabled()) {
         LOG.trace("Enable is complete for " + getTableName());
       }
-    } catch (TableNotDisabledException tnde) {
+    } catch (TableNotDisabledException | TableNotFoundException e) {
       // The state we wanted it to be in
+      // Or, in case table is not found, nothing to do
     }
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/d36cce15/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotas.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotas.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotas.java
index 7365f7b..6cd2cae 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotas.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotas.java
@@ -95,6 +95,7 @@ public class TestSpaceQuotas {
   @Rule
   public TestName testName = new TestName();
   private SpaceQuotaHelperForTests helper;
+  private final TableName NON_EXISTENT_TABLE = TableName.valueOf("NON_EXISTENT_TABLE");
 
   @BeforeClass
   public static void setUp() throws Exception {
@@ -392,6 +393,11 @@ public class TestSpaceQuotas {
   }
 
   @Test
+  public void testSetQuotaAndThenDropTableWithDisable() throws Exception {
+    setQuotaAndThenDropTable(SpaceViolationPolicy.DISABLE);
+  }
+
+  @Test
   public void testSetQuotaAndThenIncreaseQuotaWithNoInserts() throws Exception {
     setQuotaAndThenIncreaseQuota(SpaceViolationPolicy.NO_INSERTS);
   }
@@ -426,6 +432,26 @@ public class TestSpaceQuotas {
     setQuotaAndThenRemoveInOneAmongTwoTables(SpaceViolationPolicy.DISABLE);
   }
 
+  @Test
+  public void testSetQuotaOnNonExistingTableWithNoInserts() throws Exception {
+    setQuotaLimit(NON_EXISTENT_TABLE, SpaceViolationPolicy.NO_INSERTS, 2L);
+  }
+
+  @Test
+  public void testSetQuotaOnNonExistingTableWithNoWrites() throws Exception {
+    setQuotaLimit(NON_EXISTENT_TABLE, SpaceViolationPolicy.NO_WRITES, 2L);
+  }
+
+  @Test
+  public void testSetQuotaOnNonExistingTableWithNoWritesCompaction() throws Exception {
+    setQuotaLimit(NON_EXISTENT_TABLE, SpaceViolationPolicy.NO_WRITES_COMPACTIONS, 2L);
+  }
+
+  @Test
+  public void testSetQuotaOnNonExistingTableWithDisable() throws Exception {
+    setQuotaLimit(NON_EXISTENT_TABLE, SpaceViolationPolicy.DISABLE, 2L);
+  }
+
   private void setQuotaAndThenRemove(SpaceViolationPolicy policy) throws Exception {
     Put put = new Put(Bytes.toBytes("to_reject"));
     put.addColumn(Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"),
@@ -470,7 +496,7 @@ public class TestSpaceQuotas {
     final TableName tn = writeUntilViolationAndVerifyViolation(policy, put);
 
     // Now, increase limit and perform put
-    increaseQuotaLimit(tn, policy);
+    setQuotaLimit(tn, policy, 4L);
 
     // Put some row now: should not violate as quota limit increased
     verifyNoViolation(policy, tn, put);
@@ -503,12 +529,12 @@ public class TestSpaceQuotas {
     LOG.debug("Space quota settings removed from the table ", tn);
   }
 
-  private void increaseQuotaLimit(final TableName tn, SpaceViolationPolicy policy)
+  private void setQuotaLimit(final TableName tn, SpaceViolationPolicy policy, long sizeInMBs)
       throws Exception {
-    final long sizeLimit = 4L * SpaceQuotaHelperForTests.ONE_MEGABYTE;
+    final long sizeLimit = sizeInMBs * SpaceQuotaHelperForTests.ONE_MEGABYTE;
     QuotaSettings settings = QuotaSettingsFactory.limitTableSpace(tn, sizeLimit, policy);
     TEST_UTIL.getAdmin().setQuota(settings);
-    LOG.debug("Quota limit increased for table ", tn);
+    LOG.debug("Quota limit set for table = {}, limit = {}", tn, sizeLimit);
   }
 
   private Map<RegionInfo,Long> getReportedSizesForTable(TableName tn) {
@@ -525,11 +551,7 @@ public class TestSpaceQuotas {
 
   private TableName writeUntilViolation(SpaceViolationPolicy policyToViolate) throws Exception {
     TableName tn = helper.createTableWithRegions(10);
-
-    final long sizeLimit = 2L * SpaceQuotaHelperForTests.ONE_MEGABYTE;
-    QuotaSettings settings = QuotaSettingsFactory.limitTableSpace(tn, sizeLimit, policyToViolate);
-    TEST_UTIL.getAdmin().setQuota(settings);
-
+    setQuotaLimit(tn, policyToViolate, 2L);
     // Write more data than should be allowed and flush it to disk
     helper.writeData(tn, 3L * SpaceQuotaHelperForTests.ONE_MEGABYTE);