@Override protected ThrottleSettings merge(QuotaSettings other) throws IOException { if (other instanceof ThrottleSettings) { ThrottleSettings otherThrottle = (ThrottleSettings) other; // Make sure this and the other target the same "subject" validateQuotaTarget(other); QuotaProtos.ThrottleRequest.Builder builder = proto.toBuilder(); if (!otherThrottle.proto.hasType()) { return null; } QuotaProtos.ThrottleRequest otherProto = otherThrottle.proto; if (otherProto.hasTimedQuota()) { if (otherProto.hasTimedQuota()) { validateTimedQuota(otherProto.getTimedQuota()); } if (!proto.getType().equals(otherProto.getType())) { throw new IllegalArgumentException( "Cannot merge a ThrottleRequest for " + proto.getType() + " with " + otherProto.getType()); } QuotaProtos.TimedQuota.Builder timedQuotaBuilder = proto.getTimedQuota().toBuilder(); timedQuotaBuilder.mergeFrom(otherProto.getTimedQuota()); QuotaProtos.ThrottleRequest mergedReq = builder.setTimedQuota( timedQuotaBuilder.build()).build(); return new ThrottleSettings(getUserName(), getTableName(), getNamespace(), getRegionServer(), mergedReq); } } return this; }
assertEquals(null, throttle.getTableName()); assertEquals(null, throttle.getNamespace()); assertEquals(null, throttle.getRegionServer()); assertEquals(6, throttle.getSoftLimit()); assertEquals(TimeUnit.MINUTES, throttle.getTimeUnit());
assertNull("Username should be null", throttleSettings.getUserName()); assertNull("Namespace should be null", throttleSettings.getNamespace()); assertNull("RegionServer should be null", throttleSettings.getRegionServer()); seenRead = true; break; assertNull("Username should be null", throttleSettings.getUserName()); assertNull("Namespace should be null", throttleSettings.getNamespace()); assertNull("RegionServer should be null", throttleSettings.getRegionServer()); seenWrite = true; break;
assertTrue(settings.getQuotaType() == QuotaType.THROTTLE); ThrottleSettings throttleSettings = (ThrottleSettings) settings; assertEquals(regionServer, throttleSettings.getRegionServer()); count++; if (throttleSettings.getThrottleType() == ThrottleType.REQUEST_NUMBER) {