private void validateTimedQuota(final TimedQuota timedQuota) throws IOException { if (timedQuota.getSoftLimit() < 1) { throw new DoNotRetryIOException(new UnsupportedOperationException( "The throttle limit must be greater then 0, got " + timedQuota.getSoftLimit())); } }
private void validateTimedQuota(final TimedQuota timedQuota) throws IOException { if (timedQuota.getSoftLimit() < 1) { throw new DoNotRetryIOException(new UnsupportedOperationException( "The throttle limit must be greater then 0, got " + timedQuota.getSoftLimit())); } }
case WRITE_NUMBER: case READ_NUMBER: builder.append(String.format("%dreq", timedQuota.getSoftLimit())); break; case REQUEST_SIZE: case WRITE_SIZE: case READ_SIZE: builder.append(sizeToString(timedQuota.getSoftLimit())); break; case REQUEST_CAPACITY_UNIT: case READ_CAPACITY_UNIT: case WRITE_CAPACITY_UNIT: builder.append(String.format("%dCU", timedQuota.getSoftLimit())); default:
public Builder mergeFrom(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.TimedQuota other) { if (other == org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.TimedQuota.getDefaultInstance()) return this; if (other.hasTimeUnit()) { setTimeUnit(other.getTimeUnit()); } if (other.hasSoftLimit()) { setSoftLimit(other.getSoftLimit()); } if (other.hasShare()) { setShare(other.getShare()); } if (other.hasScope()) { setScope(other.getScope()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
public long getSoftLimit() { return proto.hasTimedQuota() ? proto.getTimedQuota().getSoftLimit() : -1; }
private void validateTimedQuota(final TimedQuota timedQuota) throws IOException { if (timedQuota.getSoftLimit() < 1) { throw new DoNotRetryIOException(new UnsupportedOperationException( "The throttle limit must be greater then 0, got " + timedQuota.getSoftLimit())); } }
private void assertRPCQuota(ThrottleType type, long limit, TimeUnit tu, QuotaSettings actualSettings) throws Exception { assertTrue( "The actual QuotaSettings was not an instance of " + ThrottleSettings.class + " but of " + actualSettings.getClass(), actualSettings instanceof ThrottleSettings); QuotaProtos.ThrottleRequest throttleRequest = ((ThrottleSettings) actualSettings).getProto(); assertEquals(limit, throttleRequest.getTimedQuota().getSoftLimit()); assertEquals(ProtobufUtil.toProtoTimeUnit(tu), throttleRequest.getTimedQuota().getTimeUnit()); assertEquals(ProtobufUtil.toProtoThrottleType(type), throttleRequest.getType()); }
case WRITE_NUMBER: case READ_NUMBER: builder.append(String.format("%dreq", timedQuota.getSoftLimit())); break; case REQUEST_SIZE: case WRITE_SIZE: case READ_SIZE: builder.append(sizeToString(timedQuota.getSoftLimit())); break;
public long getSoftLimit() { return proto.hasTimedQuota() ? proto.getTimedQuota().getSoftLimit() : -1; }
private void validateTimedQuota(final TimedQuota timedQuota) throws IOException { if (timedQuota.getSoftLimit() < 1) { throw new DoNotRetryIOException(new UnsupportedOperationException( "The throttle limit must be greater then 0, got " + timedQuota.getSoftLimit())); } }
case WRITE_NUMBER: case READ_NUMBER: builder.append(String.format("%dreq", timedQuota.getSoftLimit())); break; case REQUEST_SIZE: case WRITE_SIZE: case READ_SIZE: builder.append(sizeToString(timedQuota.getSoftLimit())); break; case REQUEST_CAPACITY_UNIT: case READ_CAPACITY_UNIT: case WRITE_CAPACITY_UNIT: builder.append(String.format("%dCU", timedQuota.getSoftLimit())); break; default:
assertEquals(t.getSoftLimit(), limit); assertEquals(t.getTimeUnit(), ProtobufUtil.toProtoTimeUnit(tu));
assertTrue(throttle.hasReqNum()); QuotaProtos.TimedQuota reqNumQuota = throttle.getReqNum(); assertEquals(REQUEST_THROTTLE.getSoftLimit(), reqNumQuota.getSoftLimit()); assertEquals(writeQuota.getSoftLimit(), writeNumQuota.getSoftLimit());
result = result && (getSoftLimit() == other.getSoftLimit());
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (hasTimeUnit()) { hash = (37 * hash) + TIME_UNIT_FIELD_NUMBER; hash = (53 * hash) + timeUnit_; } if (hasSoftLimit()) { hash = (37 * hash) + SOFT_LIMIT_FIELD_NUMBER; hash = (53 * hash) + org.apache.hbase.thirdparty.com.google.protobuf.Internal.hashLong( getSoftLimit()); } if (hasShare()) { hash = (37 * hash) + SHARE_FIELD_NUMBER; hash = (53 * hash) + java.lang.Float.floatToIntBits( getShare()); } if (hasScope()) { hash = (37 * hash) + SCOPE_FIELD_NUMBER; hash = (53 * hash) + scope_; } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@Test public void testMergeThrottle() throws IOException { QuotaProtos.Quotas quota = QuotaProtos.Quotas.newBuilder() .setThrottle(THROTTLE).build(); QuotaProtos.TimedQuota writeQuota = REQUEST_THROTTLE.toBuilder() .setSoftLimit(500).build(); // Unset the req throttle, set a write throttle QuotaProtos.ThrottleRequest writeThrottle = QuotaProtos.ThrottleRequest.newBuilder() .setTimedQuota(writeQuota).setType(QuotaProtos.ThrottleType.WRITE_NUMBER).build(); GlobalQuotaSettingsImpl settings = new GlobalQuotaSettingsImpl("joe", null, null, null, quota); GlobalQuotaSettingsImpl merged = settings.merge( new ThrottleSettings("joe", null, null, null, writeThrottle)); QuotaProtos.Throttle mergedThrottle = merged.getThrottleProto(); // Verify the request throttle is in place assertTrue(mergedThrottle.hasReqNum()); QuotaProtos.TimedQuota actualReqNum = mergedThrottle.getReqNum(); assertEquals(REQUEST_THROTTLE.getSoftLimit(), actualReqNum.getSoftLimit()); // Verify the write throttle is in place assertTrue(mergedThrottle.hasWriteNum()); QuotaProtos.TimedQuota actualWriteNum = mergedThrottle.getWriteNum(); assertEquals(writeQuota.getSoftLimit(), actualWriteNum.getSoftLimit()); }
public Builder mergeFrom(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.TimedQuota other) { if (other == org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.TimedQuota.getDefaultInstance()) return this; if (other.hasTimeUnit()) { setTimeUnit(other.getTimeUnit()); } if (other.hasSoftLimit()) { setSoftLimit(other.getSoftLimit()); } if (other.hasShare()) { setShare(other.getShare()); } if (other.hasScope()) { setScope(other.getScope()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
public long getSoftLimit() { return proto.hasTimedQuota() ? proto.getTimedQuota().getSoftLimit() : -1; }
private static void setFromTimedQuota(final RateLimiter limiter, final TimedQuota timedQuota) { limiter.set(timedQuota.getSoftLimit(), ProtobufUtil.toTimeUnit(timedQuota.getTimeUnit())); }
private void assertRPCQuota(ThrottleType type, long limit, TimeUnit tu, QuotaSettings actualSettings) throws Exception { assertTrue( "The actual QuotaSettings was not an instance of " + ThrottleSettings.class + " but of " + actualSettings.getClass(), actualSettings instanceof ThrottleSettings); QuotaProtos.ThrottleRequest throttleRequest = ((ThrottleSettings) actualSettings).getProto(); assertEquals(limit, throttleRequest.getTimedQuota().getSoftLimit()); assertEquals(ProtobufUtil.toProtoTimeUnit(tu), throttleRequest.getTimedQuota().getTimeUnit()); assertEquals(ProtobufUtil.toProtoThrottleType(type), throttleRequest.getType()); }