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 2019/09/20 17:51:36 UTC
[hbase] 01/02: HBASE-22944 Check for hbase:quota table existence in
SpaceQuotaRefresherChore
This is an automated email from the ASF dual-hosted git repository.
elserj pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
commit ffbf8503eaf171e4614f32f9d9a3c575e5edb85f
Author: shardul-cr7 <sh...@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 <st...@apache.org>
Signed-off-by: Josh Elser <el...@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());