hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [hbase] 01/02: HBASE-22944 Check for hbase:quota table existence in SpaceQuotaRefresherChore
Date Fri, 20 Sep 2019 17:51:45 GMT
This is an automated email from the ASF dual-hosted git repository.

elserj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git

commit 2b3c9b18dde65ab5e1b305e3e04ed02fef9c8ef5
Author: shardul-cr7 <shardulsingh22@gmail.com>
AuthorDate: Thu Aug 29 11:41:04 2019 +0530

    HBASE-22944 Check for hbase:quota table existence in SpaceQuotaRefresherChore
    
    During startup, it's possible that quotas are enabled but the Master has
    not yet created the hbase:quotas table.
    
    Closes #559
    
    Signed-off-by: stack <stack@apache.org>
    Signed-off-by: Josh Elser <elserj@apache.org>
---
 .../hadoop/hbase/quotas/SpaceQuotaRefresherChore.java | 19 +++++++++++++++++++
 .../TestSpaceQuotaViolationPolicyRefresherChore.java  |  1 +
 2 files changed, 20 insertions(+)

diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceQuotaRefresherChore.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceQuotaRefresherChore.java
index 7ae7240..94f1bda 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceQuotaRefresherChore.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SpaceQuotaRefresherChore.java
@@ -23,6 +23,7 @@ import java.util.Map.Entry;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.ScheduledChore;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.yetus.audience.InterfaceAudience;
@@ -60,6 +61,7 @@ public class SpaceQuotaRefresherChore extends ScheduledChore {
 
   private final RegionServerSpaceQuotaManager manager;
   private final Connection conn;
+  private boolean quotaTablePresent = false;
 
   public SpaceQuotaRefresherChore(RegionServerSpaceQuotaManager manager, Connection conn)
{
     super(SpaceQuotaRefresherChore.class.getSimpleName(),
@@ -74,6 +76,13 @@ public class SpaceQuotaRefresherChore extends ScheduledChore {
   @Override
   protected void chore() {
     try {
+      // check whether quotaTable is present or not.
+      if (!quotaTablePresent && !checkQuotaTableExists()) {
+        LOG.info("Quota table not found, skipping quota manager cache refresh.");
+        return;
+      }
+      // since quotaTable is present so setting the flag as true.
+      quotaTablePresent = true;
       if (LOG.isTraceEnabled()) {
         LOG.trace("Reading current quota snapshots from hbase:quota.");
       }
@@ -145,6 +154,16 @@ public class SpaceQuotaRefresherChore extends ScheduledChore {
   }
 
   /**
+   * Checks if hbase:quota exists in hbase:meta
+   *
+   * @return true if hbase:quota table is in meta, else returns false.
+   * @throws IOException throws IOException
+   */
+  boolean checkQuotaTableExists() throws IOException {
+    return MetaTableAccessor.tableExists(getConnection(), QuotaUtil.QUOTA_TABLE_NAME);
+  }
+
+  /**
    * Checks if the given <code>snapshot</code> is in violation, allowing the
snapshot to be null.
    * If the snapshot is null, this is interpreted as no snapshot which implies not in violation.
    *
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaViolationPolicyRefresherChore.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaViolationPolicyRefresherChore.java
index 58270c3..aa871f1 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaViolationPolicyRefresherChore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaViolationPolicyRefresherChore.java
@@ -82,6 +82,7 @@ public class TestSpaceQuotaViolationPolicyRefresherChore {
     chore = mock(SpaceQuotaRefresherChore.class);
     when(chore.getConnection()).thenReturn(conn);
     when(chore.getManager()).thenReturn(manager);
+    when(chore.checkQuotaTableExists()).thenReturn(true);
     doCallRealMethod().when(chore).chore();
     when(chore.isInViolation(any())).thenCallRealMethod();
     doCallRealMethod().when(chore).extractQuotaSnapshot(any(), any());


Mime
View raw message