@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; }
ThrottleSettings throttle = (ThrottleSettings)settings; assertEquals(userName, throttle.getUserName()); assertEquals(null, throttle.getTableName()); assertEquals(null, throttle.getNamespace()); assertEquals(null, throttle.getRegionServer());
assertEquals(readLimit, throttleSettings.getSoftLimit()); assertEquals(TimeUnit.MINUTES, throttleSettings.getTimeUnit()); assertEquals(tn, throttleSettings.getTableName()); assertNull("Username should be null", throttleSettings.getUserName()); assertNull("Namespace should be null", throttleSettings.getNamespace()); assertEquals(writeLimit, throttleSettings.getSoftLimit()); assertEquals(TimeUnit.MINUTES, throttleSettings.getTimeUnit()); assertEquals(tn, throttleSettings.getTableName()); assertNull("Username should be null", throttleSettings.getUserName()); assertNull("Namespace should be null", throttleSettings.getNamespace());
assertEquals(null, throttle.getTableName()); assertEquals(null, throttle.getNamespace()); assertEquals(TimeUnit.MINUTES, throttle.getTimeUnit());
@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(readLimit, throttleSettings.getSoftLimit()); assertEquals(TimeUnit.MINUTES, throttleSettings.getTimeUnit()); assertEquals(tn, throttleSettings.getTableName()); assertNull("Username should be null", throttleSettings.getUserName()); assertNull("Namespace should be null", throttleSettings.getNamespace()); assertEquals(writeLimit, throttleSettings.getSoftLimit()); assertEquals(TimeUnit.MINUTES, throttleSettings.getTimeUnit()); assertEquals(tn, throttleSettings.getTableName()); assertNull("Username should be null", throttleSettings.getUserName()); assertNull("Namespace should be null", throttleSettings.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; }
ThrottleSettings throttle = (ThrottleSettings)settings; assertEquals(userName, throttle.getUserName()); assertEquals(null, throttle.getTableName()); assertEquals(null, throttle.getNamespace()); assertEquals(6, throttle.getSoftLimit());
assertEquals(null, throttle.getTableName()); assertEquals(null, throttle.getNamespace()); assertEquals(TimeUnit.MINUTES, throttle.getTimeUnit());