Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2728,16 +2728,20 @@ protected void run() throws IOException {
MasterQuotaManager quotaManager = getMasterQuotaManager();
if (quotaManager != null) {
if (quotaManager.isQuotaInitialized()) {
SpaceQuotaSnapshot currSnapshotOfTable =
QuotaTableUtil.getCurrentSnapshotFromQuotaTable(getConnection(), tableName);
if (currSnapshotOfTable != null) {
SpaceQuotaStatus quotaStatus = currSnapshotOfTable.getQuotaStatus();
if (
quotaStatus.isInViolation()
&& SpaceViolationPolicy.DISABLE == quotaStatus.getPolicy().orElse(null)
) {
throw new AccessDeniedException("Enabling the table '" + tableName
+ "' is disallowed due to a violated space quota.");
// skip checking quotas for system tables, see:
// https://issues.apache.org/jira/browse/HBASE-28183
if (!tableName.isSystemTable()) {
SpaceQuotaSnapshot currSnapshotOfTable =
QuotaTableUtil.getCurrentSnapshotFromQuotaTable(getConnection(), tableName);
if (currSnapshotOfTable != null) {
SpaceQuotaStatus quotaStatus = currSnapshotOfTable.getQuotaStatus();
if (
quotaStatus.isInViolation()
&& SpaceViolationPolicy.DISABLE == quotaStatus.getPolicy().orElse(null)
) {
throw new AccessDeniedException("Enabling the table '" + tableName
+ "' is disallowed due to a violated space quota.");
}
}
}
} else if (LOG.isTraceEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -994,4 +994,15 @@ public int getQuotaSettingCount(Admin admin) throws IOException {
}
return quotaSettingCount;
}

@Test
public void testQuotaTableDisableAndEnable() throws Exception {
final Admin admin = TEST_UTIL.getAdmin();
admin.disableTable(QuotaUtil.QUOTA_TABLE_NAME);
try {
admin.enableTable(QuotaUtil.QUOTA_TABLE_NAME);
} catch (Exception ex) {
fail("Got an exception while enabling table: " + QuotaUtil.QUOTA_TABLE_NAME);
}
}
}