Search in sources :

Example 1 with QuotaSettings

use of org.apache.hadoop.hbase.quotas.QuotaSettings in project hbase by apache.

the class TestAsyncQuotaAdminApi method testThrottleType.

@Test
public void testThrottleType() throws Exception {
    String userName = User.getCurrent().getShortName();
    admin.setQuota(QuotaSettingsFactory.throttleUser(userName, ThrottleType.READ_NUMBER, 6, TimeUnit.MINUTES)).get();
    admin.setQuota(QuotaSettingsFactory.throttleUser(userName, ThrottleType.WRITE_NUMBER, 12, TimeUnit.MINUTES)).get();
    admin.setQuota(QuotaSettingsFactory.bypassGlobals(userName, true)).get();
    int countThrottle = 0;
    int countGlobalBypass = 0;
    for (QuotaSettings settings : admin.getQuota(null).get()) {
        switch(settings.getQuotaType()) {
            case THROTTLE:
                countThrottle++;
                break;
            case GLOBAL_BYPASS:
                countGlobalBypass++;
                break;
            default:
                fail("unexpected settings type: " + settings.getQuotaType());
        }
    }
    assertEquals(2, countThrottle);
    assertEquals(1, countGlobalBypass);
    admin.setQuota(QuotaSettingsFactory.unthrottleUser(userName)).get();
    assertNumResults(1, null);
    admin.setQuota(QuotaSettingsFactory.bypassGlobals(userName, false)).get();
    assertNumResults(0, null);
}
Also used : QuotaSettings(org.apache.hadoop.hbase.quotas.QuotaSettings) Test(org.junit.Test)

Example 2 with QuotaSettings

use of org.apache.hadoop.hbase.quotas.QuotaSettings in project hbase by apache.

the class TestAsyncQuotaAdminApi method countResults.

private int countResults(final QuotaFilter filter) throws Exception {
    int count = 0;
    for (QuotaSettings settings : admin.getQuota(filter).get()) {
        LOG.debug(Objects.toString(settings));
        count++;
    }
    return count;
}
Also used : QuotaSettings(org.apache.hadoop.hbase.quotas.QuotaSettings)

Aggregations

QuotaSettings (org.apache.hadoop.hbase.quotas.QuotaSettings)2 Test (org.junit.Test)1