@Test public void testNoRpcTimeout() { parentFuture.timedAttemptSettings = parentFuture.timedAttemptSettings.toBuilder().setRpcTimeout(Duration.ZERO).build(); MutateRowsRequest request = MutateRowsRequest.newBuilder().addEntries(Entry.getDefaultInstance()).build(); innerCallable.response.add( MutateRowsResponse.newBuilder() .addEntries( MutateRowsResponse.Entry.newBuilder().setIndex(0).setStatus(OK_STATUS_PROTO)) .build()); MutateRowsAttemptCallable attemptCallable = new MutateRowsAttemptCallable(innerCallable, request, callContext, retryCodes); attemptCallable.setExternalFuture(parentFuture); attemptCallable.call(); assertThat(innerCallable.lastContext.getTimeout()).isNull(); }
/** * {@inheritDoc} * * <p>The attempt settings will be reset if the stream attempt produced any messages. */ @Override public TimedAttemptSettings createNextAttempt( Throwable prevThrowable, ResponseT prevResponse, TimedAttemptSettings prevSettings) { if (prevThrowable instanceof ServerStreamingAttemptException) { ServerStreamingAttemptException attemptException = (ServerStreamingAttemptException) prevThrowable; prevThrowable = prevThrowable.getCause(); // If we have made progress in the last attempt, then reset the delays if (attemptException.hasSeenResponses()) { prevSettings = createFirstAttempt() .toBuilder() .setFirstAttemptStartTimeNanos(prevSettings.getFirstAttemptStartTimeNanos()) .setOverallAttemptCount(prevSettings.getOverallAttemptCount()) .build(); } } return super.createNextAttempt(prevThrowable, prevResponse, prevSettings); }
/** * {@inheritDoc} * * <p>The attempt settings will be reset if the stream attempt produced any messages. */ @Override public TimedAttemptSettings createNextAttempt( Throwable prevThrowable, ResponseT prevResponse, TimedAttemptSettings prevSettings) { if (prevThrowable instanceof ServerStreamingAttemptException) { ServerStreamingAttemptException attemptException = (ServerStreamingAttemptException) prevThrowable; prevThrowable = prevThrowable.getCause(); // If we have made progress in the last attempt, then reset the delays if (attemptException.hasSeenResponses()) { prevSettings = createFirstAttempt() .toBuilder() .setFirstAttemptStartTimeNanos(prevSettings.getFirstAttemptStartTimeNanos()) .setOverallAttemptCount(prevSettings.getOverallAttemptCount()) .build(); } } return super.createNextAttempt(prevThrowable, prevResponse, prevSettings); }
@Test public void testRpcTimeout() { AttemptCallable<String, String> callable = new AttemptCallable<>(mockInnerCallable, "fake-request", FakeCallContext.createDefault()); callable.setExternalFuture(mockExternalFuture); // Make sure that the rpc timeout is set Duration timeout = Duration.ofSeconds(10); currentAttemptSettings = currentAttemptSettings.toBuilder().setRpcTimeout(timeout).build(); callable.call(); assertThat(capturedCallContext.getValue().getTimeout()).isEqualTo(timeout); // Make sure that subsequent attempts can extend the time out Duration longerTimeout = Duration.ofSeconds(20); currentAttemptSettings = currentAttemptSettings.toBuilder().setRpcTimeout(longerTimeout).build(); callable.call(); assertThat(capturedCallContext.getValue().getTimeout()).isEqualTo(longerTimeout); }
@Test public void testRpcTimeout() { CheckingAttemptCallable<String, String> callable = new CheckingAttemptCallable<>(mockInnerCallable, FakeCallContext.createDefault()); callable.setExternalFuture(mockExternalFuture); // Make sure that the rpc timeout is set Duration timeout = Duration.ofSeconds(10); currentAttemptSettings = currentAttemptSettings.toBuilder().setRpcTimeout(timeout).build(); callable.call(); assertThat(capturedCallContext.getValue().getTimeout()).isEqualTo(timeout); // Make sure that subsequent attempts can extend the time out Duration longerTimeout = Duration.ofSeconds(20); currentAttemptSettings = currentAttemptSettings.toBuilder().setRpcTimeout(longerTimeout).build(); callable.call(); assertThat(capturedCallContext.getValue().getTimeout()).isEqualTo(longerTimeout); } }