private void removeQuotaFromtable(final TableName tn) throws Exception { QuotaSettings removeQuota = QuotaSettingsFactory.removeTableSpaceLimit(tn); TEST_UTIL.getAdmin().setQuota(removeQuota); LOG.debug("Space quota settings removed from the table ", tn); }
@Override public Void call() throws Exception { try (Connection conn = getConnection()) { final Admin admin = conn.getAdmin(); QuotaSettings qs = QuotaSettingsFactory.removeTableSpaceLimit(tn); try { admin.setQuota(qs); fail("Expected that an unprivileged user should not be allowed to remove a quota"); } catch (Exception e) { // pass } return null; } } });
@Override public Void call() throws Exception { try (Connection conn = getConnection()) { final Admin admin = conn.getAdmin(); QuotaSettings qs = QuotaSettingsFactory.removeTableSpaceLimit(tn); admin.setQuota(qs); assertNull(helper.getTableSpaceQuota(conn, tn)); return null; } } });
@Override public void postDeleteTable( ObserverContext<MasterCoprocessorEnvironment> ctx, TableName tableName) throws IOException { // Do nothing if quotas aren't enabled if (!quotasEnabled) { return; } final Connection conn = ctx.getEnvironment().getConnection(); Quotas quotas = QuotaUtil.getTableQuota(conn, tableName); if (quotas != null){ if (quotas.hasSpace()){ QuotaSettings settings = QuotaSettingsFactory.removeTableSpaceLimit(tableName); try (Admin admin = conn.getAdmin()) { admin.setQuota(settings); } } if (quotas.hasThrottle()){ QuotaSettings settings = QuotaSettingsFactory.unthrottleTable(tableName); try (Admin admin = conn.getAdmin()) { admin.setQuota(settings); } } } }
@Test public void testSpaceLimitSettingsForDeletes() { final String ns = "ns1"; final TableName tn = TableName.valueOf("tn1"); QuotaSettings nsSettings = QuotaSettingsFactory.removeNamespaceSpaceLimit(ns); assertNotNull("QuotaSettings should not be null", nsSettings); assertTrue("Should be an instance of SpaceLimitSettings", nsSettings instanceof SpaceLimitSettings); SpaceLimitRequest nsProto = ((SpaceLimitSettings) nsSettings).getProto(); assertTrue("Request should have a SpaceQuota", nsProto.hasQuota()); assertTrue("The remove attribute should be true", nsProto.getQuota().getRemove()); QuotaSettings tableSettings = QuotaSettingsFactory.removeTableSpaceLimit(tn); assertNotNull("QuotaSettings should not be null", tableSettings); assertTrue("Should be an instance of SpaceLimitSettings", tableSettings instanceof SpaceLimitSettings); SpaceLimitRequest tableProto = ((SpaceLimitSettings) tableSettings).getProto(); assertTrue("Request should have a SpaceQuota", tableProto.hasQuota()); assertTrue("The remove attribute should be true", tableProto.getQuota().getRemove()); } }
QuotaSettings removeQuota = QuotaSettingsFactory.removeTableSpaceLimit(tn); admin.setQuota(removeQuota);
QuotaSettings removeQuota = QuotaSettingsFactory.removeTableSpaceLimit(tn); admin.setQuota(removeQuota);
settings = QuotaSettingsFactory.removeTableSpaceLimit(tn); admin.setQuota(settings); assertEquals(0, getNumSpaceQuotas());
@Test public void testSpaceLimitSettingsForDeletes() { final String ns = "ns1"; final TableName tn = TableName.valueOf("tn1"); QuotaSettings nsSettings = QuotaSettingsFactory.removeNamespaceSpaceLimit(ns); assertNotNull("QuotaSettings should not be null", nsSettings); assertTrue("Should be an instance of SpaceLimitSettings", nsSettings instanceof SpaceLimitSettings); SpaceLimitRequest nsProto = ((SpaceLimitSettings) nsSettings).getProto(); assertTrue("Request should have a SpaceQuota", nsProto.hasQuota()); assertTrue("The remove attribute should be true", nsProto.getQuota().getRemove()); QuotaSettings tableSettings = QuotaSettingsFactory.removeTableSpaceLimit(tn); assertNotNull("QuotaSettings should not be null", tableSettings); assertTrue("Should be an instance of SpaceLimitSettings", tableSettings instanceof SpaceLimitSettings); SpaceLimitRequest tableProto = ((SpaceLimitSettings) tableSettings).getProto(); assertTrue("Request should have a SpaceQuota", tableProto.hasQuota()); assertTrue("The remove attribute should be true", tableProto.getQuota().getRemove()); } }
private void removeQuotaFromtable(final TableName tn) throws Exception { QuotaSettings removeQuota = QuotaSettingsFactory.removeTableSpaceLimit(tn); TEST_UTIL.getAdmin().setQuota(removeQuota); LOG.debug("Space quota settings removed from the table ", tn); }
@Override public Void call() throws Exception { try (Connection conn = getConnection()) { final Admin admin = conn.getAdmin(); QuotaSettings qs = QuotaSettingsFactory.removeTableSpaceLimit(tn); try { admin.setQuota(qs); fail("Expected that an unprivileged user should not be allowed to remove a quota"); } catch (Exception e) { // pass } return null; } } });
@Override public Void call() throws Exception { try (Connection conn = getConnection()) { final Admin admin = conn.getAdmin(); QuotaSettings qs = QuotaSettingsFactory.removeTableSpaceLimit(tn); admin.setQuota(qs); assertNull(helper.getTableSpaceQuota(conn, tn)); return null; } } });
QuotaSettings removeQuota = QuotaSettingsFactory.removeTableSpaceLimit(tn); admin.setQuota(removeQuota);
QuotaSettings removeQuota = QuotaSettingsFactory.removeTableSpaceLimit(tn); admin.setQuota(removeQuota);