@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; }
case THROTTLE: ThrottleSettings throttle = (ThrottleSettings)settings; assertEquals(userName, throttle.getUserName()); assertEquals(null, throttle.getTableName()); assertEquals(null, throttle.getNamespace());
assertEquals(TimeUnit.MINUTES, throttleSettings.getTimeUnit()); assertEquals(tn, throttleSettings.getTableName()); assertNull("Username should be null", throttleSettings.getUserName()); assertNull("Namespace should be null", throttleSettings.getNamespace()); assertNull("RegionServer should be null", throttleSettings.getRegionServer()); assertEquals(TimeUnit.MINUTES, throttleSettings.getTimeUnit()); assertEquals(tn, throttleSettings.getTableName()); assertNull("Username should be null", throttleSettings.getUserName()); assertNull("Namespace should be null", throttleSettings.getNamespace()); assertNull("RegionServer should be null", throttleSettings.getRegionServer());
fail("should not come here, because don't set quota with this limit"); assertEquals(userName, throttle.getUserName()); assertEquals(null, throttle.getTableName()); assertEquals(null, throttle.getNamespace());
@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(), mergedReq); } } return this; }
assertEquals(TimeUnit.MINUTES, throttleSettings.getTimeUnit()); assertEquals(tn, throttleSettings.getTableName()); assertNull("Username should be null", throttleSettings.getUserName()); assertNull("Namespace should be null", throttleSettings.getNamespace()); seenRead = true; assertEquals(TimeUnit.MINUTES, throttleSettings.getTimeUnit()); assertEquals(tn, throttleSettings.getTableName()); assertNull("Username should be null", throttleSettings.getUserName()); assertNull("Namespace should be null", throttleSettings.getNamespace()); seenWrite = true;
@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(), mergedReq); } } return this; }
case THROTTLE: ThrottleSettings throttle = (ThrottleSettings)settings; assertEquals(userName, throttle.getUserName()); assertEquals(null, throttle.getTableName()); assertEquals(null, throttle.getNamespace());
fail("should not come here, because don't set quota with this limit"); assertEquals(userName, throttle.getUserName()); assertEquals(null, throttle.getTableName()); assertEquals(null, throttle.getNamespace());