use of org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.ThrottleRequest in project hbase by apache.
the class TestThrottleSettings method testIncompatibleThrottleTypes.
@Test
public void testIncompatibleThrottleTypes() throws IOException {
TimedQuota requestsQuota = TimedQuota.newBuilder().setSoftLimit(10).setScope(QuotaProtos.QuotaScope.MACHINE).setTimeUnit(HBaseProtos.TimeUnit.MINUTES).build();
ThrottleRequest requestsQuotaReq = ThrottleRequest.newBuilder().setTimedQuota(requestsQuota).setType(QuotaProtos.ThrottleType.REQUEST_NUMBER).build();
ThrottleSettings orig = new ThrottleSettings("joe", null, null, null, requestsQuotaReq);
TimedQuota readsQuota = TimedQuota.newBuilder().setSoftLimit(10).setScope(QuotaProtos.QuotaScope.MACHINE).setTimeUnit(HBaseProtos.TimeUnit.SECONDS).build();
ThrottleRequest readsQuotaReq = ThrottleRequest.newBuilder().setTimedQuota(readsQuota).setType(QuotaProtos.ThrottleType.READ_NUMBER).build();
try {
orig.merge(new ThrottleSettings("joe", null, null, null, readsQuotaReq));
fail("A read throttle should not be capable of being merged with a request quota");
} catch (IllegalArgumentException e) {
// Pass
}
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.ThrottleRequest in project hbase by apache.
the class TestThrottleSettings method testMerge.
@Test
public void testMerge() throws IOException {
TimedQuota tq1 = TimedQuota.newBuilder().setSoftLimit(10).setScope(QuotaProtos.QuotaScope.MACHINE).setTimeUnit(HBaseProtos.TimeUnit.MINUTES).build();
ThrottleRequest tr1 = ThrottleRequest.newBuilder().setTimedQuota(tq1).setType(QuotaProtos.ThrottleType.REQUEST_NUMBER).build();
ThrottleSettings orig = new ThrottleSettings("joe", null, null, null, tr1);
TimedQuota tq2 = TimedQuota.newBuilder().setSoftLimit(10).setScope(QuotaProtos.QuotaScope.MACHINE).setTimeUnit(HBaseProtos.TimeUnit.SECONDS).build();
ThrottleRequest tr2 = ThrottleRequest.newBuilder().setTimedQuota(tq2).setType(QuotaProtos.ThrottleType.REQUEST_NUMBER).build();
ThrottleSettings merged = orig.merge(new ThrottleSettings("joe", null, null, null, tr2));
assertEquals(10, merged.getSoftLimit());
assertEquals(ThrottleType.REQUEST_NUMBER, merged.getThrottleType());
assertEquals(TimeUnit.SECONDS, merged.getTimeUnit());
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.ThrottleRequest in project hbase by apache.
the class TestThrottleSettings method testNoThrottleReturnsOriginal.
@Test
public void testNoThrottleReturnsOriginal() throws IOException {
TimedQuota tq1 = TimedQuota.newBuilder().setSoftLimit(10).setScope(QuotaProtos.QuotaScope.MACHINE).setTimeUnit(HBaseProtos.TimeUnit.MINUTES).build();
ThrottleRequest tr1 = ThrottleRequest.newBuilder().setTimedQuota(tq1).setType(QuotaProtos.ThrottleType.REQUEST_NUMBER).build();
ThrottleSettings orig = new ThrottleSettings("joe", null, null, null, tr1);
ThrottleRequest tr2 = ThrottleRequest.newBuilder().setType(QuotaProtos.ThrottleType.REQUEST_NUMBER).build();
assertTrue("The same object should be returned by merge, but it wasn't", orig == orig.merge(new ThrottleSettings("joe", null, null, null, tr2)));
}
Aggregations