From commits-return-89576-archive-asf-public=cust-asf.ponee.io@hbase.apache.org Fri Sep 20 17:51:40 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 09D7E180608 for ; Fri, 20 Sep 2019 19:51:39 +0200 (CEST) Received: (qmail 99164 invoked by uid 500); 20 Sep 2019 17:51:36 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 98965 invoked by uid 99); 20 Sep 2019 17:51:36 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Sep 2019 17:51:36 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id E132081E21; Fri, 20 Sep 2019 17:51:35 +0000 (UTC) Date: Fri, 20 Sep 2019 17:51:42 +0000 To: "commits@hbase.apache.org" Subject: [hbase] 01/02: HBASE-22944 Check for hbase:quota table existence in SpaceQuotaRefresherChore MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: elserj@apache.org In-Reply-To: <156900189523.20140.14930541290761903008@gitbox.apache.org> References: <156900189523.20140.14930541290761903008@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: hbase X-Git-Refname: refs/heads/branch-2.2 X-Git-Reftype: branch X-Git-Rev: f1682a12e5c2a9f2029786ce9700b6c43cf282bb X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20190920175135.E132081E21@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. elserj pushed a commit to branch branch-2.2 in repository https://gitbox.apache.org/repos/asf/hbase.git commit f1682a12e5c2a9f2029786ce9700b6c43cf282bb Author: shardul-cr7 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 Signed-off-by: Josh Elser --- .../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 snapshot 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());