HBASE-20633 Dropping a table containing a disable violation policy fails to remove the quota upon table delete
Signed-off-by: Josh Elser <elserj@apache.org> Signed-off-by: Michael Stack <stack@apache.org>
This commit is contained in:
parent
aa00391140
commit
d36cce1574
@ -20,6 +20,7 @@ import java.io.IOException;
|
|||||||
|
|
||||||
import org.apache.hadoop.hbase.TableNotDisabledException;
|
import org.apache.hadoop.hbase.TableNotDisabledException;
|
||||||
import org.apache.hadoop.hbase.TableNotEnabledException;
|
import org.apache.hadoop.hbase.TableNotEnabledException;
|
||||||
|
import org.apache.hadoop.hbase.TableNotFoundException;
|
||||||
import org.apache.yetus.audience.InterfaceAudience;
|
import org.apache.yetus.audience.InterfaceAudience;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -62,8 +63,9 @@ public class DisableTableViolationPolicyEnforcement extends DefaultViolationPoli
|
|||||||
if (LOG.isTraceEnabled()) {
|
if (LOG.isTraceEnabled()) {
|
||||||
LOG.trace("Enable is complete for " + getTableName());
|
LOG.trace("Enable is complete for " + getTableName());
|
||||||
}
|
}
|
||||||
} catch (TableNotDisabledException tnde) {
|
} catch (TableNotDisabledException | TableNotFoundException e) {
|
||||||
// The state we wanted it to be in
|
// The state we wanted it to be in
|
||||||
|
// Or, in case table is not found, nothing to do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +95,7 @@ public class TestSpaceQuotas {
|
|||||||
@Rule
|
@Rule
|
||||||
public TestName testName = new TestName();
|
public TestName testName = new TestName();
|
||||||
private SpaceQuotaHelperForTests helper;
|
private SpaceQuotaHelperForTests helper;
|
||||||
|
private final TableName NON_EXISTENT_TABLE = TableName.valueOf("NON_EXISTENT_TABLE");
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
@ -391,6 +392,11 @@ public class TestSpaceQuotas {
|
|||||||
setQuotaAndThenDropTable(SpaceViolationPolicy.NO_WRITES_COMPACTIONS);
|
setQuotaAndThenDropTable(SpaceViolationPolicy.NO_WRITES_COMPACTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetQuotaAndThenDropTableWithDisable() throws Exception {
|
||||||
|
setQuotaAndThenDropTable(SpaceViolationPolicy.DISABLE);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetQuotaAndThenIncreaseQuotaWithNoInserts() throws Exception {
|
public void testSetQuotaAndThenIncreaseQuotaWithNoInserts() throws Exception {
|
||||||
setQuotaAndThenIncreaseQuota(SpaceViolationPolicy.NO_INSERTS);
|
setQuotaAndThenIncreaseQuota(SpaceViolationPolicy.NO_INSERTS);
|
||||||
@ -426,6 +432,26 @@ public class TestSpaceQuotas {
|
|||||||
setQuotaAndThenRemoveInOneAmongTwoTables(SpaceViolationPolicy.DISABLE);
|
setQuotaAndThenRemoveInOneAmongTwoTables(SpaceViolationPolicy.DISABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetQuotaOnNonExistingTableWithNoInserts() throws Exception {
|
||||||
|
setQuotaLimit(NON_EXISTENT_TABLE, SpaceViolationPolicy.NO_INSERTS, 2L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetQuotaOnNonExistingTableWithNoWrites() throws Exception {
|
||||||
|
setQuotaLimit(NON_EXISTENT_TABLE, SpaceViolationPolicy.NO_WRITES, 2L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetQuotaOnNonExistingTableWithNoWritesCompaction() throws Exception {
|
||||||
|
setQuotaLimit(NON_EXISTENT_TABLE, SpaceViolationPolicy.NO_WRITES_COMPACTIONS, 2L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetQuotaOnNonExistingTableWithDisable() throws Exception {
|
||||||
|
setQuotaLimit(NON_EXISTENT_TABLE, SpaceViolationPolicy.DISABLE, 2L);
|
||||||
|
}
|
||||||
|
|
||||||
private void setQuotaAndThenRemove(SpaceViolationPolicy policy) throws Exception {
|
private void setQuotaAndThenRemove(SpaceViolationPolicy policy) throws Exception {
|
||||||
Put put = new Put(Bytes.toBytes("to_reject"));
|
Put put = new Put(Bytes.toBytes("to_reject"));
|
||||||
put.addColumn(Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"),
|
put.addColumn(Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"),
|
||||||
@ -470,7 +496,7 @@ public class TestSpaceQuotas {
|
|||||||
final TableName tn = writeUntilViolationAndVerifyViolation(policy, put);
|
final TableName tn = writeUntilViolationAndVerifyViolation(policy, put);
|
||||||
|
|
||||||
// Now, increase limit and perform put
|
// Now, increase limit and perform put
|
||||||
increaseQuotaLimit(tn, policy);
|
setQuotaLimit(tn, policy, 4L);
|
||||||
|
|
||||||
// Put some row now: should not violate as quota limit increased
|
// Put some row now: should not violate as quota limit increased
|
||||||
verifyNoViolation(policy, tn, put);
|
verifyNoViolation(policy, tn, put);
|
||||||
@ -503,12 +529,12 @@ public class TestSpaceQuotas {
|
|||||||
LOG.debug("Space quota settings removed from the table ", tn);
|
LOG.debug("Space quota settings removed from the table ", tn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void increaseQuotaLimit(final TableName tn, SpaceViolationPolicy policy)
|
private void setQuotaLimit(final TableName tn, SpaceViolationPolicy policy, long sizeInMBs)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
final long sizeLimit = 4L * SpaceQuotaHelperForTests.ONE_MEGABYTE;
|
final long sizeLimit = sizeInMBs * SpaceQuotaHelperForTests.ONE_MEGABYTE;
|
||||||
QuotaSettings settings = QuotaSettingsFactory.limitTableSpace(tn, sizeLimit, policy);
|
QuotaSettings settings = QuotaSettingsFactory.limitTableSpace(tn, sizeLimit, policy);
|
||||||
TEST_UTIL.getAdmin().setQuota(settings);
|
TEST_UTIL.getAdmin().setQuota(settings);
|
||||||
LOG.debug("Quota limit increased for table ", tn);
|
LOG.debug("Quota limit set for table = {}, limit = {}", tn, sizeLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<RegionInfo,Long> getReportedSizesForTable(TableName tn) {
|
private Map<RegionInfo,Long> getReportedSizesForTable(TableName tn) {
|
||||||
@ -525,11 +551,7 @@ public class TestSpaceQuotas {
|
|||||||
|
|
||||||
private TableName writeUntilViolation(SpaceViolationPolicy policyToViolate) throws Exception {
|
private TableName writeUntilViolation(SpaceViolationPolicy policyToViolate) throws Exception {
|
||||||
TableName tn = helper.createTableWithRegions(10);
|
TableName tn = helper.createTableWithRegions(10);
|
||||||
|
setQuotaLimit(tn, policyToViolate, 2L);
|
||||||
final long sizeLimit = 2L * SpaceQuotaHelperForTests.ONE_MEGABYTE;
|
|
||||||
QuotaSettings settings = QuotaSettingsFactory.limitTableSpace(tn, sizeLimit, policyToViolate);
|
|
||||||
TEST_UTIL.getAdmin().setQuota(settings);
|
|
||||||
|
|
||||||
// Write more data than should be allowed and flush it to disk
|
// Write more data than should be allowed and flush it to disk
|
||||||
helper.writeData(tn, 3L * SpaceQuotaHelperForTests.ONE_MEGABYTE);
|
helper.writeData(tn, 3L * SpaceQuotaHelperForTests.ONE_MEGABYTE);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user