if (!externalFuture.getAttemptSettings().getRpcTimeout().isZero()) { currentCallContext = currentCallContext.withTimeout(externalFuture.getAttemptSettings().getRpcTimeout());
/** Wraps the target observer with timing constraints. */ public <ResponseT> ResponseObserver<ResponseT> watch( ResponseObserver<ResponseT> innerObserver, @Nonnull Duration waitTimeout, @Nonnull Duration idleTimeout) { Preconditions.checkNotNull(innerObserver, "innerObserver can't be null"); Preconditions.checkNotNull(waitTimeout, "waitTimeout can't be null"); Preconditions.checkNotNull(idleTimeout, "idleTimeout can't be null"); if (waitTimeout.isZero() && idleTimeout.isZero()) { return innerObserver; } WatchdogStream<ResponseT> stream = new WatchdogStream<>(innerObserver, waitTimeout, idleTimeout); openStreams.put(stream, PRESENT); return stream; }
/** Wraps the target observer with timing constraints. */ public <ResponseT> ResponseObserver<ResponseT> watch( ResponseObserver<ResponseT> innerObserver, @Nonnull Duration waitTimeout, @Nonnull Duration idleTimeout) { Preconditions.checkNotNull(innerObserver, "innerObserver can't be null"); Preconditions.checkNotNull(waitTimeout, "waitTimeout can't be null"); Preconditions.checkNotNull(idleTimeout, "idleTimeout can't be null"); if (waitTimeout.isZero() && idleTimeout.isZero()) { return innerObserver; } WatchdogStream<ResponseT> stream = new WatchdogStream<>(innerObserver, waitTimeout, idleTimeout); openStreams.put(stream, PRESENT); return stream; }
@SuppressWarnings("ConstantConditions") @Nullable @Override public Watchdog getWatchdog() { Preconditions.checkState(!needsClock(), "A clock is needed"); Preconditions.checkState(!needsCheckInterval(), "A check interval is needed"); Preconditions.checkState(!needsExecutor(), "An executor is needed"); // Watchdog is disabled if (checkInterval.isZero()) { return null; } Watchdog watchdog = new Watchdog(clock); executor.scheduleAtFixedRate( watchdog, checkInterval.toMillis(), checkInterval.toMillis(), TimeUnit.MILLISECONDS); return watchdog; } }
@Override public GrpcCallContext withTimeout(@Nullable Duration timeout) { // Default RetrySettings use 0 for RPC timeout. Treat that as disabled timeouts. if (timeout != null && (timeout.isZero() || timeout.isNegative())) { timeout = null; } // Prevent expanding timeouts if (timeout != null && this.timeout != null && this.timeout.compareTo(timeout) <= 0) { return this; } return new GrpcCallContext( this.channel, this.callOptions, timeout, this.streamWaitTimeout, this.streamIdleTimeout, this.channelAffinity, this.extraHeaders); }
@SuppressWarnings("ConstantConditions") @Nullable @Override public Watchdog getWatchdog() { Preconditions.checkState(!needsClock(), "A clock is needed"); Preconditions.checkState(!needsCheckInterval(), "A check interval is needed"); Preconditions.checkState(!needsExecutor(), "An executor is needed"); // Watchdog is disabled if (checkInterval.isZero()) { return null; } Watchdog watchdog = new Watchdog(clock); executor.scheduleAtFixedRate( watchdog, checkInterval.toMillis(), checkInterval.toMillis(), TimeUnit.MILLISECONDS); return watchdog; } }
@Override public HttpJsonCallContext withTimeout(Duration timeout) { // Default RetrySettings use 0 for RPC timeout. Treat that as disabled timeouts. if (timeout != null && (timeout.isZero() || timeout.isNegative())) { timeout = null; } // Prevent expanding deadlines if (timeout != null && this.timeout != null && this.timeout.compareTo(timeout) <= 0) { return this; } return new HttpJsonCallContext( this.channel, timeout, this.deadline, this.credentials, this.extraHeaders, this.tracer); }
@Override public GrpcCallContext withTimeout(@Nullable Duration timeout) { // Default RetrySettings use 0 for RPC timeout. Treat that as disabled timeouts. if (timeout != null && (timeout.isZero() || timeout.isNegative())) { timeout = null; } // Prevent expanding timeouts if (timeout != null && this.timeout != null && this.timeout.compareTo(timeout) <= 0) { return this; } return new GrpcCallContext( this.channel, this.callOptions, timeout, this.streamWaitTimeout, this.streamIdleTimeout, this.channelAffinity, this.extraHeaders); }
@Override public HttpJsonCallContext withTimeout(Duration timeout) { // Default RetrySettings use 0 for RPC timeout. Treat that as disabled timeouts. if (timeout != null && (timeout.isZero() || timeout.isNegative())) { timeout = null; } // Prevent expanding deadlines if (timeout != null && this.timeout != null && this.timeout.compareTo(timeout) <= 0) { return this; } return new HttpJsonCallContext( this.channel, timeout, this.deadline, this.credentials, this.extraHeaders, this.tracer); }
@Override public FakeCallContext withTimeout(Duration timeout) { // Default RetrySettings use 0 for RPC timeout. Treat that as disabled timeouts. if (timeout != null && (timeout.isZero() || timeout.isNegative())) { timeout = null; } // Prevent expanding timeouts if (timeout != null && this.timeout != null && this.timeout.compareTo(timeout) <= 0) { return this; } return new FakeCallContext( this.credentials, this.channel, timeout, this.streamWaitTimeout, this.streamIdleTimeout, this.extraHeaders, this.tracer); }
if (!externalFuture.getAttemptSettings().getRpcTimeout().isZero()) { currentCallContext = currentCallContext.withTimeout(externalFuture.getAttemptSettings().getRpcTimeout());
@Override public ApiFuture<OperationSnapshot> futureCall(RequestT request, ApiCallContext context) { FakeCallContext fakeCallContext = (FakeCallContext) context; if (fakeCallContext != null && fakeCallContext.getTimeout() != null && fakeCallContext.getTimeout().isZero()) { throw new DeadlineExceededException( "Invalid timeout of 0 s", null, FakeStatusCode.of(StatusCode.Code.DEADLINE_EXCEEDED), true); } OperationSnapshot response = results[index]; if (index < results.length - 1) { index += 1; } return newFuture(returnStatusCode, response); } };
if (!outerRetryingFuture.getAttemptSettings().getRpcTimeout().isZero()) { attemptContext = attemptContext.withStreamWaitTimeout(
if (!outerRetryingFuture.getAttemptSettings().getRpcTimeout().isZero()) { attemptContext = attemptContext.withStreamWaitTimeout(
@Override public ResponseT call() { ApiCallContext callContext = originalCallContext; try { Duration rpcTimeout = externalFuture.getAttemptSettings().getRpcTimeout(); if (!rpcTimeout.isZero()) { callContext = callContext.withTimeout(rpcTimeout); } externalFuture.setAttemptFuture(new NonCancellableFuture<ResponseT>()); if (externalFuture.isDone()) { return null; } callContext .getTracer() .attemptStarted(externalFuture.getAttemptSettings().getOverallAttemptCount()); ApiFuture<ResponseT> internalFuture = callable.futureCall(request, callContext); externalFuture.setAttemptFuture(internalFuture); } catch (Throwable e) { externalFuture.setAttemptFuture(ApiFutures.<ResponseT>immediateFailedFuture(e)); } return null; } }
@Override public ResponseT call() { ApiCallContext callContext = originalCallContext; try { Duration rpcTimeout = externalFuture.getAttemptSettings().getRpcTimeout(); if (!rpcTimeout.isZero()) { callContext = callContext.withTimeout(rpcTimeout); } externalFuture.setAttemptFuture(new NonCancellableFuture<ResponseT>()); if (externalFuture.isDone()) { return null; } callContext .getTracer() .attemptStarted(externalFuture.getAttemptSettings().getOverallAttemptCount()); ApiFuture<ResponseT> internalFuture = callable.futureCall(request, callContext); externalFuture.setAttemptFuture(internalFuture); } catch (Throwable e) { externalFuture.setAttemptFuture(ApiFutures.<ResponseT>immediateFailedFuture(e)); } return null; } }
if (!rpcTimeout.isZero()) { callContext = callContext.withTimeout(rpcTimeout);
if (!rpcTimeout.isZero()) { callContext = callContext.withTimeout(rpcTimeout);