builder.append(", LIMIT => "); if (timedQuota.hasSoftLimit()) { switch (getThrottleType()) { case REQUEST_NUMBER: case WRITE_NUMBER:
assertEquals(regionServer, throttleSettings.getRegionServer()); count++; if (throttleSettings.getThrottleType() == ThrottleType.REQUEST_NUMBER) { assertEquals(20, throttleSettings.getSoftLimit()); assertEquals(TimeUnit.MINUTES, throttleSettings.getTimeUnit()); } else if (throttleSettings.getThrottleType() == ThrottleType.READ_NUMBER) { assertEquals(30, throttleSettings.getSoftLimit()); assertEquals(TimeUnit.SECONDS, throttleSettings.getTimeUnit());
ThrottleSettings throttle = (ThrottleSettings)settings; if (throttle.getSoftLimit() == 6) { assertEquals(ThrottleType.READ_NUMBER, throttle.getThrottleType()); } else if (throttle.getSoftLimit() == 12) { assertEquals(ThrottleType.WRITE_NUMBER, throttle.getThrottleType()); } else { fail("should not come here, because don't set quota with this limit");
@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()); }
builder.append(", LIMIT => "); if (timedQuota.hasSoftLimit()) { switch (getThrottleType()) { case REQUEST_NUMBER: case WRITE_NUMBER:
if (setting instanceof ThrottleSettings) { ThrottleSettings throttleSettings = (ThrottleSettings) setting; switch (throttleSettings.getThrottleType()) { case READ_NUMBER: assertFalse("Should not have multiple read quotas", seenRead); break; default: fail("Unexpected throttle type: " + throttleSettings.getThrottleType());
builder.append(", LIMIT => "); if (timedQuota.hasSoftLimit()) { switch (getThrottleType()) { case REQUEST_NUMBER: case WRITE_NUMBER: break; default: throw new RuntimeException("Invalid throttle type: " + getThrottleType());
builder.append(", LIMIT => "); if (timedQuota.hasSoftLimit()) { switch (getThrottleType()) { case REQUEST_NUMBER: case WRITE_NUMBER:
@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, 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, tr2)); assertEquals(10, merged.getSoftLimit()); assertEquals(ThrottleType.REQUEST_NUMBER, merged.getThrottleType()); assertEquals(TimeUnit.SECONDS, merged.getTimeUnit()); }
if (setting instanceof ThrottleSettings) { ThrottleSettings throttleSettings = (ThrottleSettings) setting; switch (throttleSettings.getThrottleType()) { case READ_NUMBER: assertFalse("Should not have multiple read quotas", seenRead); break; default: fail("Unexpected throttle type: " + throttleSettings.getThrottleType());
ThrottleSettings throttle = (ThrottleSettings)settings; if (throttle.getSoftLimit() == 6) { assertEquals(ThrottleType.READ_NUMBER, throttle.getThrottleType()); } else if (throttle.getSoftLimit() == 12) { assertEquals(ThrottleType.WRITE_NUMBER, throttle.getThrottleType()); } else { fail("should not come here, because don't set quota with this limit");