You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zg...@apache.org on 2019/01/30 09:55:45 UTC
[hbase] branch master updated: HBASE-21733
SnapshotQuotaObserverChore should only fetch space quotas
This is an automated email from the ASF dual-hosted git repository.
zghao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/master by this push:
new 5ddda1a HBASE-21733 SnapshotQuotaObserverChore should only fetch space quotas
5ddda1a is described below
commit 5ddda1a1f694f3f6fe70f3182c719629b2840602
Author: meiyi <my...@gamil.com>
AuthorDate: Fri Jan 18 09:51:51 2019 +0800
HBASE-21733 SnapshotQuotaObserverChore should only fetch space quotas
Signed-off-by: Guanghao Zhang <zg...@apache.org>
---
.../hbase/quotas/SnapshotQuotaObserverChore.java | 24 ++++++++++++----------
.../hbase/quotas/SpaceQuotaHelperForTests.java | 9 +++++---
.../quotas/TestSnapshotQuotaObserverChore.java | 8 ++++++++
3 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SnapshotQuotaObserverChore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SnapshotQuotaObserverChore.java
index 9dd2ac0..f74bae0 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SnapshotQuotaObserverChore.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/SnapshotQuotaObserverChore.java
@@ -131,17 +131,19 @@ public class SnapshotQuotaObserverChore extends ScheduledChore {
try (Admin admin = conn.getAdmin()) {
// Pull all of the tables that have quotas (direct, or from namespace)
for (QuotaSettings qs : QuotaRetriever.open(conf, filter)) {
- String ns = qs.getNamespace();
- TableName tn = qs.getTableName();
- if ((null == ns && null == tn) || (null != ns && null != tn)) {
- throw new IllegalStateException(
- "Expected only one of namespace and tablename to be null");
- }
- // Collect either the table name itself, or all of the tables in the namespace
- if (null != ns) {
- tablesToFetchSnapshotsFrom.addAll(Arrays.asList(admin.listTableNamesByNamespace(ns)));
- } else {
- tablesToFetchSnapshotsFrom.add(tn);
+ if (qs.getQuotaType() == QuotaType.SPACE) {
+ String ns = qs.getNamespace();
+ TableName tn = qs.getTableName();
+ if ((null == ns && null == tn) || (null != ns && null != tn)) {
+ throw new IllegalStateException(
+ "Expected either one of namespace and tablename to be null but not both");
+ }
+ // Collect either the table name itself, or all of the tables in the namespace
+ if (null != ns) {
+ tablesToFetchSnapshotsFrom.addAll(Arrays.asList(admin.listTableNamesByNamespace(ns)));
+ } else {
+ tablesToFetchSnapshotsFrom.add(tn);
+ }
}
}
// Fetch all snapshots that were created from these tables
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/SpaceQuotaHelperForTests.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/SpaceQuotaHelperForTests.java
index 17f86a8..40cd540 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/SpaceQuotaHelperForTests.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/SpaceQuotaHelperForTests.java
@@ -135,13 +135,16 @@ public class SpaceQuotaHelperForTests {
for (QuotaSettings quotaSettings : scanner) {
final String namespace = quotaSettings.getNamespace();
final TableName tableName = quotaSettings.getTableName();
+ final String userName = quotaSettings.getUserName();
if (namespace != null) {
LOG.debug("Deleting quota for namespace: " + namespace);
QuotaUtil.deleteNamespaceQuota(conn, namespace);
- } else {
- assert tableName != null;
- LOG.debug("Deleting quota for table: "+ tableName);
+ } else if (tableName != null) {
+ LOG.debug("Deleting quota for table: " + tableName);
QuotaUtil.deleteTableQuota(conn, tableName);
+ } else if (userName != null) {
+ LOG.debug("Deleting quota for user: " + userName);
+ QuotaUtil.deleteUserQuota(conn, userName);
}
}
} finally {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSnapshotQuotaObserverChore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSnapshotQuotaObserverChore.java
index 097e646..2f00aa1 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSnapshotQuotaObserverChore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSnapshotQuotaObserverChore.java
@@ -28,6 +28,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
@@ -160,6 +161,13 @@ public class TestSnapshotQuotaObserverChore {
TableName tn2 = helper.createTableWithRegions(ns.getName(), 1);
TableName tn3 = helper.createTableWithRegions(1);
+ // Set a throttle quota on 'default' namespace
+ admin.setQuota(QuotaSettingsFactory.throttleNamespace(tn3.getNamespaceAsString(),
+ ThrottleType.WRITE_NUMBER, 100, TimeUnit.SECONDS));
+ // Set a user throttle quota
+ admin.setQuota(
+ QuotaSettingsFactory.throttleUser("user", ThrottleType.WRITE_NUMBER, 100, TimeUnit.MINUTES));
+
// Set a space quota on the namespace
admin.setQuota(QuotaSettingsFactory.limitNamespaceSpace(
ns.getName(), SpaceQuotaHelperForTests.ONE_GIGABYTE, SpaceViolationPolicy.NO_INSERTS));