Java Code Examples for io.grpc.Deadline#timeRemaining()
The following examples show how to use
io.grpc.Deadline#timeRemaining() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClientCallImpl.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
private static void logIfContextNarrowedTimeout( Deadline effectiveDeadline, @Nullable Deadline outerCallDeadline, @Nullable Deadline callDeadline) { if (!log.isLoggable(Level.FINE) || effectiveDeadline == null || outerCallDeadline != effectiveDeadline) { return; } long effectiveTimeout = max(0, effectiveDeadline.timeRemaining(TimeUnit.NANOSECONDS)); StringBuilder builder = new StringBuilder(String.format( "Call timeout set to '%d' ns, due to context deadline.", effectiveTimeout)); if (callDeadline == null) { builder.append(" Explicit call timeout was not set."); } else { long callTimeout = callDeadline.timeRemaining(TimeUnit.NANOSECONDS); builder.append(String.format(" Explicit call timeout was '%d' ns.", callTimeout)); } log.fine(builder.toString()); }
Example 2
Source File: ClientCallImpl.java From grpc-java with Apache License 2.0 | 6 votes |
private static void logIfContextNarrowedTimeout( Deadline effectiveDeadline, @Nullable Deadline outerCallDeadline, @Nullable Deadline callDeadline) { if (!log.isLoggable(Level.FINE) || effectiveDeadline == null || !effectiveDeadline.equals(outerCallDeadline)) { return; } long effectiveTimeout = max(0, effectiveDeadline.timeRemaining(TimeUnit.NANOSECONDS)); StringBuilder builder = new StringBuilder(String.format( "Call timeout set to '%d' ns, due to context deadline.", effectiveTimeout)); if (callDeadline == null) { builder.append(" Explicit call timeout was not set."); } else { long callTimeout = callDeadline.timeRemaining(TimeUnit.NANOSECONDS); builder.append(String.format(" Explicit call timeout was '%d' ns.", callTimeout)); } log.fine(builder.toString()); }
Example 3
Source File: ClientCallImpl.java From grpc-java with Apache License 2.0 | 6 votes |
private ScheduledFuture<?> startDeadlineNotifyApplicationTimer(Deadline deadline, final Listener<RespT> observer) { final long remainingNanos = deadline.timeRemaining(TimeUnit.NANOSECONDS); class DeadlineExceededNotifyApplicationTimer implements Runnable { @Override public void run() { Status status = buildDeadlineExceededStatusWithRemainingNanos(remainingNanos); delayedCancelOnDeadlineExceeded(status, observer); } } return deadlineCancellationExecutor.schedule( new LogExceptionRunnable(new DeadlineExceededNotifyApplicationTimer()), remainingNanos, TimeUnit.NANOSECONDS); }
Example 4
Source File: Poller.java From bazel-buildfarm with Apache License 2.0 | 5 votes |
private Duration getWaitTime() { checkNotNull(periodDeadline); Deadline waitDeadline = expirationDeadline.minimum(periodDeadline); long waitMicros = waitDeadline.timeRemaining(MICROSECONDS); if (waitMicros <= 0) { return Duration.getDefaultInstance(); } return Durations.fromMicros(waitMicros); }
Example 5
Source File: ClientCallImpl.java From grpc-nebula-java with Apache License 2.0 | 4 votes |
private ScheduledFuture<?> startDeadlineTimer(Deadline deadline) { long remainingNanos = deadline.timeRemaining(TimeUnit.NANOSECONDS); return deadlineCancellationExecutor.schedule( new LogExceptionRunnable( new DeadlineTimer(remainingNanos)), remainingNanos, TimeUnit.NANOSECONDS); }