AckHandler(String ackId, int outstandingBytes, Instant totalExpiration) { this.ackId = ackId; this.outstandingBytes = outstandingBytes; this.receivedTimeMillis = clock.millisTime(); this.totalExpiration = totalExpiration; }
private Instant now() { return Instant.ofEpochMilli(clock.millisTime()); } }
@Override public void onSuccess(AckReply reply) { LinkedBlockingQueue<String> destination; switch (reply) { case ACK: destination = pendingAcks; // Record the latency rounded to the next closest integer. ackLatencyDistribution.record( Ints.saturatedCast( (long) Math.ceil((clock.millisTime() - receivedTimeMillis) / 1000D))); break; case NACK: destination = pendingNacks; break; default: throw new IllegalArgumentException(String.format("AckReply: %s not supported", reply)); } destination.add(ackId); forget(); } }
getOptions().getClock().millisTime() + unit.toMillis(duration), TimeUnit.MILLISECONDS);
@Override public void onResponseImpl(ResponseT response) { synchronized (lock) { state = State.DELIVERING; } outerResponseObserver.onResponse(response); synchronized (lock) { pendingCount--; lastActivityAt = clock.millisTime(); if (autoAutoFlowControl || pendingCount > 0) { state = State.WAITING; } else { state = State.IDLE; } } }
@Override public void onResponseImpl(ResponseT response) { synchronized (lock) { state = State.DELIVERING; } outerResponseObserver.onResponse(response); synchronized (lock) { pendingCount--; lastActivityAt = clock.millisTime(); if (autoAutoFlowControl || pendingCount > 0) { state = State.WAITING; } else { state = State.IDLE; } } }
private void onRequest(int count) { Preconditions.checkArgument(count > 0, "count must be > 0"); Preconditions.checkState(!autoAutoFlowControl, "Auto flow control is enabled"); // Only reset the request water mark if there are no outstanding requests. synchronized (lock) { if (state == State.IDLE) { state = State.WAITING; lastActivityAt = clock.millisTime(); } // Increment the request count without overflow int maxIncrement = Integer.MAX_VALUE - pendingCount; count = Math.min(maxIncrement, count); pendingCount += count; } innerController.request(count); }
private void onRequest(int count) { Preconditions.checkArgument(count > 0, "count must be > 0"); Preconditions.checkState(!autoAutoFlowControl, "Auto flow control is enabled"); // Only reset the request water mark if there are no outstanding requests. synchronized (lock) { if (state == State.IDLE) { state = State.WAITING; lastActivityAt = clock.millisTime(); } // Increment the request count without overflow int maxIncrement = Integer.MAX_VALUE - pendingCount; count = Math.min(maxIncrement, count); pendingCount += count; } innerController.request(count); }
getOptions().getClock().millisTime() + unit.toMillis(duration), TimeUnit.MILLISECONDS);
private void checkForTimeout(long initialMillis) throws TimeoutException { if (photosLibrarySettings.uploadMediaItemSettings().getRetrySettings().getTotalTimeout() != UNLIMITED_TIMEOUT) { long duration = clientContext.getClock().millisTime() - initialMillis; if (duration > photosLibrarySettings .uploadMediaItemSettings() .getRetrySettings() .getTotalTimeout() .get(MILLIS)) { throw new TimeoutException(ExceptionStrings.UPLOAD_TIMED_OUT); } } }
long initialMillis = clientContext.getClock().millisTime();
long waitTime = clock.millisTime() - lastActivityAt;
long waitTime = clock.millisTime() - lastActivityAt;