Java Code Examples for io.grpc.Status#fromCode()
The following examples show how to use
io.grpc.Status#fromCode() .
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: RetriableStreamTest.java From grpc-java with Apache License 2.0 | 6 votes |
@Test public void droppedShouldNeverRetry() { ClientStream mockStream1 = mock(ClientStream.class); ClientStream mockStream2 = mock(ClientStream.class); doReturn(mockStream1).when(retriableStreamRecorder).newSubstream(0); doReturn(mockStream2).when(retriableStreamRecorder).newSubstream(1); // start retriableStream.start(masterListener); verify(retriableStreamRecorder).newSubstream(0); ArgumentCaptor<ClientStreamListener> sublistenerCaptor1 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream1).start(sublistenerCaptor1.capture()); // drop and verify no retry Status status = Status.fromCode(RETRIABLE_STATUS_CODE_1); sublistenerCaptor1.getValue().closed(status, DROPPED, new Metadata()); verifyNoMoreInteractions(mockStream1, mockStream2); verify(retriableStreamRecorder).postCommit(); verify(masterListener).closed(same(status), any(Metadata.class)); }
Example 2
Source File: RetriableStreamTest.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
@Test public void unretriableClosed_cancel() { ClientStream mockStream1 = mock(ClientStream.class); doReturn(mockStream1).when(retriableStreamRecorder).newSubstream(0); InOrder inOrder = inOrder(retriableStreamRecorder); retriableStream.start(masterListener); ArgumentCaptor<ClientStreamListener> sublistenerCaptor1 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream1).start(sublistenerCaptor1.capture()); // closed Status status = Status.fromCode(NON_RETRIABLE_STATUS_CODE); Metadata metadata = new Metadata(); sublistenerCaptor1.getValue().closed(status, metadata); inOrder.verify(retriableStreamRecorder).postCommit(); verify(masterListener).closed(status, metadata); // cancel retriableStream.cancel(Status.CANCELLED); inOrder.verify(retriableStreamRecorder, never()).postCommit(); }
Example 3
Source File: RetriableStreamTest.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
@Test public void droppedShouldNeverRetry() { ClientStream mockStream1 = mock(ClientStream.class); ClientStream mockStream2 = mock(ClientStream.class); doReturn(mockStream1).when(retriableStreamRecorder).newSubstream(0); doReturn(mockStream2).when(retriableStreamRecorder).newSubstream(1); // start retriableStream.start(masterListener); verify(retriableStreamRecorder).newSubstream(0); ArgumentCaptor<ClientStreamListener> sublistenerCaptor1 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream1).start(sublistenerCaptor1.capture()); // drop and verify no retry Status status = Status.fromCode(RETRIABLE_STATUS_CODE_1); sublistenerCaptor1.getValue().closed(status, DROPPED, new Metadata()); verifyNoMoreInteractions(mockStream1, mockStream2); verify(retriableStreamRecorder).postCommit(); verify(masterListener).closed(same(status), any(Metadata.class)); }
Example 4
Source File: RetriableStreamTest.java From grpc-java with Apache License 2.0 | 6 votes |
@Test public void unretriableClosed_cancel() { ClientStream mockStream1 = mock(ClientStream.class); doReturn(mockStream1).when(retriableStreamRecorder).newSubstream(0); InOrder inOrder = inOrder(retriableStreamRecorder); retriableStream.start(masterListener); ArgumentCaptor<ClientStreamListener> sublistenerCaptor1 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream1).start(sublistenerCaptor1.capture()); // closed Status status = Status.fromCode(NON_RETRIABLE_STATUS_CODE); Metadata metadata = new Metadata(); sublistenerCaptor1.getValue().closed(status, metadata); inOrder.verify(retriableStreamRecorder).postCommit(); verify(masterListener).closed(status, metadata); // cancel retriableStream.cancel(Status.CANCELLED); inOrder.verify(retriableStreamRecorder, never()).postCommit(); }
Example 5
Source File: RetriableStreamTest.java From grpc-java with Apache License 2.0 | 6 votes |
@Test public void headersRead_closed() { ClientStream mockStream1 = mock(ClientStream.class); doReturn(mockStream1).when(retriableStreamRecorder).newSubstream(0); InOrder inOrder = inOrder(retriableStreamRecorder); retriableStream.start(masterListener); ArgumentCaptor<ClientStreamListener> sublistenerCaptor1 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream1).start(sublistenerCaptor1.capture()); sublistenerCaptor1.getValue().headersRead(new Metadata()); inOrder.verify(retriableStreamRecorder).postCommit(); Status status = Status.fromCode(RETRIABLE_STATUS_CODE_1); Metadata metadata = new Metadata(); sublistenerCaptor1.getValue().closed(status, metadata); verify(masterListener).closed(status, metadata); inOrder.verify(retriableStreamRecorder, never()).postCommit(); }
Example 6
Source File: RetriableStreamTest.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
@Test public void headersRead_closed() { ClientStream mockStream1 = mock(ClientStream.class); doReturn(mockStream1).when(retriableStreamRecorder).newSubstream(0); InOrder inOrder = inOrder(retriableStreamRecorder); retriableStream.start(masterListener); ArgumentCaptor<ClientStreamListener> sublistenerCaptor1 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream1).start(sublistenerCaptor1.capture()); sublistenerCaptor1.getValue().headersRead(new Metadata()); inOrder.verify(retriableStreamRecorder).postCommit(); Status status = Status.fromCode(RETRIABLE_STATUS_CODE_1); Metadata metadata = new Metadata(); sublistenerCaptor1.getValue().closed(status, metadata); verify(masterListener).closed(status, metadata); inOrder.verify(retriableStreamRecorder, never()).postCommit(); }
Example 7
Source File: RetriableStreamTest.java From grpc-java with Apache License 2.0 | 5 votes |
@Test public void retry_headersRead_closed() { ClientStream mockStream1 = mock(ClientStream.class); doReturn(mockStream1).when(retriableStreamRecorder).newSubstream(0); InOrder inOrder = inOrder(retriableStreamRecorder); retriableStream.start(masterListener); ArgumentCaptor<ClientStreamListener> sublistenerCaptor1 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream1).start(sublistenerCaptor1.capture()); // retry ClientStream mockStream2 = mock(ClientStream.class); doReturn(mockStream2).when(retriableStreamRecorder).newSubstream(1); sublistenerCaptor1.getValue().closed(Status.fromCode(RETRIABLE_STATUS_CODE_1), new Metadata()); fakeClock.forwardTime((long) (INITIAL_BACKOFF_IN_SECONDS * FAKE_RANDOM), TimeUnit.SECONDS); ArgumentCaptor<ClientStreamListener> sublistenerCaptor2 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream2).start(sublistenerCaptor2.capture()); inOrder.verify(retriableStreamRecorder, never()).postCommit(); // headersRead sublistenerCaptor2.getValue().headersRead(new Metadata()); inOrder.verify(retriableStreamRecorder).postCommit(); // closed even with retriable status Status status = Status.fromCode(RETRIABLE_STATUS_CODE_1); Metadata metadata = new Metadata(); sublistenerCaptor2.getValue().closed(status, metadata); verify(masterListener).closed(status, metadata); inOrder.verify(retriableStreamRecorder, never()).postCommit(); }
Example 8
Source File: LocalFallbackStrategy.java From buck with Apache License 2.0 | 5 votes |
public FallbackStrategyBuildResult( String buildTarget, StrategyBuildResult remoteStrategyBuildResult, BuildStrategyContext strategyContext, BuckEventBus eventBus, boolean localFallbackEnabled, boolean localFallbackDisabledOnCorruptedArtifacts, boolean localFallbackEnabledForCompletedAction) { this.lock = new Object(); this.localStrategyBuildResult = Optional.empty(); this.buildTarget = buildTarget; this.remoteStrategyBuildResult = remoteStrategyBuildResult; this.strategyContext = strategyContext; this.combinedFinalResult = SettableFuture.create(); this.hasCancellationBeenRequested = false; this.eventBus = eventBus; this.startedEvent = LocalFallbackEvent.createStarted(buildTarget); this.remoteBuildResult = Optional.empty(); this.remoteExecutionTimer = Stopwatch.createStarted(); this.remoteBuildErrorMessage = Optional.empty(); this.localFallbackEnabled = localFallbackEnabled; this.localFallbackDisabledOnCorruptedArtifacts = localFallbackDisabledOnCorruptedArtifacts; this.localFallbackEnabledForCompletedAction = localFallbackEnabledForCompletedAction; this.remoteGrpcStatus = Status.fromCode(Status.Code.OK); this.lastNonTerminalState = State.WAITING; this.exitCode = OptionalInt.empty(); this.remoteExecutionMetadata = Optional.empty(); this.eventBus.post(this.startedEvent); this.remoteStrategyBuildResult .getBuildResult() .addListener( () -> onMainBuildFinished(remoteStrategyBuildResult.getBuildResult()), MoreExecutors.directExecutor()); }
Example 9
Source File: RetriableStreamTest.java From grpc-java with Apache License 2.0 | 5 votes |
@Test public void hedging_transparentRetryNotAllowed() { ClientStream mockStream1 = mock(ClientStream.class); ClientStream mockStream2 = mock(ClientStream.class); ClientStream mockStream3 = mock(ClientStream.class); when(retriableStreamRecorder.newSubstream(anyInt())) .thenReturn(mockStream1, mockStream2, mockStream3); hedgingStream.start(masterListener); ArgumentCaptor<ClientStreamListener> sublistenerCaptor1 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream1).start(sublistenerCaptor1.capture()); fakeClock.forwardTime(HEDGING_DELAY_IN_SECONDS, TimeUnit.SECONDS); ArgumentCaptor<ClientStreamListener> sublistenerCaptor2 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream2).start(sublistenerCaptor2.capture()); fakeClock.forwardTime(HEDGING_DELAY_IN_SECONDS, TimeUnit.SECONDS); ArgumentCaptor<ClientStreamListener> sublistenerCaptor3 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream3).start(sublistenerCaptor3.capture()); sublistenerCaptor2.getValue() .closed(Status.fromCode(NON_FATAL_STATUS_CODE_1), new Metadata()); // no more transparent retry Status status = Status.fromCode(FATAL_STATUS_CODE); Metadata metadata = new Metadata(); sublistenerCaptor3.getValue() .closed(status, REFUSED, metadata); ArgumentCaptor<Status> statusCaptor = ArgumentCaptor.forClass(Status.class); verify(mockStream1).cancel(statusCaptor.capture()); assertEquals(Status.CANCELLED.getCode(), statusCaptor.getValue().getCode()); assertEquals(CANCELLED_BECAUSE_COMMITTED, statusCaptor.getValue().getDescription()); verify(retriableStreamRecorder).postCommit(); verify(masterListener).closed(status, metadata); }
Example 10
Source File: RetriableStreamTest.java From grpc-java with Apache License 2.0 | 5 votes |
@Test public void retry_unretriableClosed_cancel() { ClientStream mockStream1 = mock(ClientStream.class); doReturn(mockStream1).when(retriableStreamRecorder).newSubstream(0); InOrder inOrder = inOrder(retriableStreamRecorder); retriableStream.start(masterListener); ArgumentCaptor<ClientStreamListener> sublistenerCaptor1 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream1).start(sublistenerCaptor1.capture()); // retry ClientStream mockStream2 = mock(ClientStream.class); doReturn(mockStream2).when(retriableStreamRecorder).newSubstream(1); sublistenerCaptor1.getValue().closed(Status.fromCode(RETRIABLE_STATUS_CODE_1), new Metadata()); fakeClock.forwardTime((long) (INITIAL_BACKOFF_IN_SECONDS * FAKE_RANDOM), TimeUnit.SECONDS); ArgumentCaptor<ClientStreamListener> sublistenerCaptor2 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream2).start(sublistenerCaptor2.capture()); inOrder.verify(retriableStreamRecorder, never()).postCommit(); // closed Status status = Status.fromCode(NON_RETRIABLE_STATUS_CODE); Metadata metadata = new Metadata(); sublistenerCaptor2.getValue().closed(status, metadata); inOrder.verify(retriableStreamRecorder).postCommit(); verify(masterListener).closed(status, metadata); // cancel retriableStream.cancel(Status.CANCELLED); inOrder.verify(retriableStreamRecorder, never()).postCommit(); }
Example 11
Source File: RetriableStreamTest.java From grpc-java with Apache License 2.0 | 5 votes |
@Test public void retry_cancel_closed() { ClientStream mockStream1 = mock(ClientStream.class); doReturn(mockStream1).when(retriableStreamRecorder).newSubstream(0); InOrder inOrder = inOrder(retriableStreamRecorder); retriableStream.start(masterListener); ArgumentCaptor<ClientStreamListener> sublistenerCaptor1 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream1).start(sublistenerCaptor1.capture()); // retry ClientStream mockStream2 = mock(ClientStream.class); doReturn(mockStream2).when(retriableStreamRecorder).newSubstream(1); sublistenerCaptor1.getValue().closed(Status.fromCode(RETRIABLE_STATUS_CODE_1), new Metadata()); fakeClock.forwardTime((long) (INITIAL_BACKOFF_IN_SECONDS * FAKE_RANDOM), TimeUnit.SECONDS); ArgumentCaptor<ClientStreamListener> sublistenerCaptor2 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream2).start(sublistenerCaptor2.capture()); inOrder.verify(retriableStreamRecorder, never()).postCommit(); // cancel retriableStream.cancel(Status.CANCELLED); inOrder.verify(retriableStreamRecorder).postCommit(); ArgumentCaptor<Status> statusCaptor = ArgumentCaptor.forClass(Status.class); verify(mockStream2).cancel(statusCaptor.capture()); assertEquals(Status.CANCELLED.getCode(), statusCaptor.getValue().getCode()); assertEquals(CANCELLED_BECAUSE_COMMITTED, statusCaptor.getValue().getDescription()); // closed Status status = Status.fromCode(NON_RETRIABLE_STATUS_CODE); Metadata metadata = new Metadata(); sublistenerCaptor2.getValue().closed(status, metadata); inOrder.verify(retriableStreamRecorder, never()).postCommit(); }
Example 12
Source File: RetriableStreamTest.java From grpc-java with Apache License 2.0 | 5 votes |
@Test public void cancel_closed() { ClientStream mockStream1 = mock(ClientStream.class); doReturn(mockStream1).when(retriableStreamRecorder).newSubstream(0); InOrder inOrder = inOrder(retriableStreamRecorder); retriableStream.start(masterListener); ArgumentCaptor<ClientStreamListener> sublistenerCaptor1 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream1).start(sublistenerCaptor1.capture()); // cancel retriableStream.cancel(Status.CANCELLED); inOrder.verify(retriableStreamRecorder).postCommit(); ArgumentCaptor<Status> statusCaptor = ArgumentCaptor.forClass(Status.class); verify(mockStream1).cancel(statusCaptor.capture()); assertEquals(Status.CANCELLED.getCode(), statusCaptor.getValue().getCode()); assertEquals(CANCELLED_BECAUSE_COMMITTED, statusCaptor.getValue().getDescription()); // closed even with retriable status Status status = Status.fromCode(RETRIABLE_STATUS_CODE_1); Metadata metadata = new Metadata(); sublistenerCaptor1.getValue().closed(status, metadata); inOrder.verify(retriableStreamRecorder, never()).postCommit(); }
Example 13
Source File: ZeebeSinkFutureTest.java From kafka-connect-zeebe with Apache License 2.0 | 5 votes |
private Runnable retriable(final Code code) { return new Runnable() { boolean failed = false; @Override public void run() { if (!failed) { failed = true; throw new StatusRuntimeException(Status.fromCode(code)); } } }; }
Example 14
Source File: RetriableStreamTest.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
@Test public void retry_unretriableClosed_cancel() { ClientStream mockStream1 = mock(ClientStream.class); doReturn(mockStream1).when(retriableStreamRecorder).newSubstream(0); InOrder inOrder = inOrder(retriableStreamRecorder); retriableStream.start(masterListener); ArgumentCaptor<ClientStreamListener> sublistenerCaptor1 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream1).start(sublistenerCaptor1.capture()); // retry ClientStream mockStream2 = mock(ClientStream.class); doReturn(mockStream2).when(retriableStreamRecorder).newSubstream(1); sublistenerCaptor1.getValue().closed(Status.fromCode(RETRIABLE_STATUS_CODE_1), new Metadata()); fakeClock.forwardTime((long) (INITIAL_BACKOFF_IN_SECONDS * FAKE_RANDOM), TimeUnit.SECONDS); ArgumentCaptor<ClientStreamListener> sublistenerCaptor2 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream2).start(sublistenerCaptor2.capture()); inOrder.verify(retriableStreamRecorder, never()).postCommit(); // closed Status status = Status.fromCode(NON_RETRIABLE_STATUS_CODE); Metadata metadata = new Metadata(); sublistenerCaptor2.getValue().closed(status, metadata); inOrder.verify(retriableStreamRecorder).postCommit(); verify(masterListener).closed(status, metadata); // cancel retriableStream.cancel(Status.CANCELLED); inOrder.verify(retriableStreamRecorder, never()).postCommit(); }
Example 15
Source File: RetriableStreamTest.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
@Test public void retry_cancel_closed() { ClientStream mockStream1 = mock(ClientStream.class); doReturn(mockStream1).when(retriableStreamRecorder).newSubstream(0); InOrder inOrder = inOrder(retriableStreamRecorder); retriableStream.start(masterListener); ArgumentCaptor<ClientStreamListener> sublistenerCaptor1 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream1).start(sublistenerCaptor1.capture()); // retry ClientStream mockStream2 = mock(ClientStream.class); doReturn(mockStream2).when(retriableStreamRecorder).newSubstream(1); sublistenerCaptor1.getValue().closed(Status.fromCode(RETRIABLE_STATUS_CODE_1), new Metadata()); fakeClock.forwardTime((long) (INITIAL_BACKOFF_IN_SECONDS * FAKE_RANDOM), TimeUnit.SECONDS); ArgumentCaptor<ClientStreamListener> sublistenerCaptor2 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream2).start(sublistenerCaptor2.capture()); inOrder.verify(retriableStreamRecorder, never()).postCommit(); // cancel retriableStream.cancel(Status.CANCELLED); inOrder.verify(retriableStreamRecorder).postCommit(); ArgumentCaptor<Status> statusCaptor = ArgumentCaptor.forClass(Status.class); verify(mockStream2).cancel(statusCaptor.capture()); assertEquals(Status.CANCELLED.getCode(), statusCaptor.getValue().getCode()); assertEquals(CANCELLED_BECAUSE_COMMITTED, statusCaptor.getValue().getDescription()); // closed Status status = Status.fromCode(NON_RETRIABLE_STATUS_CODE); Metadata metadata = new Metadata(); sublistenerCaptor2.getValue().closed(status, metadata); inOrder.verify(retriableStreamRecorder, never()).postCommit(); }
Example 16
Source File: RetriableStreamTest.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
@Test public void cancel_closed() { ClientStream mockStream1 = mock(ClientStream.class); doReturn(mockStream1).when(retriableStreamRecorder).newSubstream(0); InOrder inOrder = inOrder(retriableStreamRecorder); retriableStream.start(masterListener); ArgumentCaptor<ClientStreamListener> sublistenerCaptor1 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream1).start(sublistenerCaptor1.capture()); // cancel retriableStream.cancel(Status.CANCELLED); inOrder.verify(retriableStreamRecorder).postCommit(); ArgumentCaptor<Status> statusCaptor = ArgumentCaptor.forClass(Status.class); verify(mockStream1).cancel(statusCaptor.capture()); assertEquals(Status.CANCELLED.getCode(), statusCaptor.getValue().getCode()); assertEquals(CANCELLED_BECAUSE_COMMITTED, statusCaptor.getValue().getDescription()); // closed even with retriable status Status status = Status.fromCode(RETRIABLE_STATUS_CODE_1); Metadata metadata = new Metadata(); sublistenerCaptor1.getValue().closed(status, metadata); inOrder.verify(retriableStreamRecorder, never()).postCommit(); }
Example 17
Source File: RetriableStreamTest.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
@Test public void retry_headersRead_closed() { ClientStream mockStream1 = mock(ClientStream.class); doReturn(mockStream1).when(retriableStreamRecorder).newSubstream(0); InOrder inOrder = inOrder(retriableStreamRecorder); retriableStream.start(masterListener); ArgumentCaptor<ClientStreamListener> sublistenerCaptor1 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream1).start(sublistenerCaptor1.capture()); // retry ClientStream mockStream2 = mock(ClientStream.class); doReturn(mockStream2).when(retriableStreamRecorder).newSubstream(1); sublistenerCaptor1.getValue().closed(Status.fromCode(RETRIABLE_STATUS_CODE_1), new Metadata()); fakeClock.forwardTime((long) (INITIAL_BACKOFF_IN_SECONDS * FAKE_RANDOM), TimeUnit.SECONDS); ArgumentCaptor<ClientStreamListener> sublistenerCaptor2 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream2).start(sublistenerCaptor2.capture()); inOrder.verify(retriableStreamRecorder, never()).postCommit(); // headersRead sublistenerCaptor2.getValue().headersRead(new Metadata()); inOrder.verify(retriableStreamRecorder).postCommit(); // closed even with retriable status Status status = Status.fromCode(RETRIABLE_STATUS_CODE_1); Metadata metadata = new Metadata(); sublistenerCaptor2.getValue().closed(status, metadata); verify(masterListener).closed(status, metadata); inOrder.verify(retriableStreamRecorder, never()).postCommit(); }
Example 18
Source File: RetriableStreamTest.java From grpc-java with Apache License 2.0 | 4 votes |
@Test public void hedging_transparentRetry() { ClientStream mockStream1 = mock(ClientStream.class); ClientStream mockStream2 = mock(ClientStream.class); ClientStream mockStream3 = mock(ClientStream.class); ClientStream mockStream4 = mock(ClientStream.class); when(retriableStreamRecorder.newSubstream(anyInt())) .thenReturn(mockStream1, mockStream2, mockStream3, mockStream4); hedgingStream.start(masterListener); ArgumentCaptor<ClientStreamListener> sublistenerCaptor1 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream1).start(sublistenerCaptor1.capture()); fakeClock.forwardTime(HEDGING_DELAY_IN_SECONDS, TimeUnit.SECONDS); ArgumentCaptor<ClientStreamListener> sublistenerCaptor2 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream2).start(sublistenerCaptor2.capture()); fakeClock.forwardTime(HEDGING_DELAY_IN_SECONDS, TimeUnit.SECONDS); ArgumentCaptor<ClientStreamListener> sublistenerCaptor3 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream3).start(sublistenerCaptor3.capture()); // transparent retry for hedge2 sublistenerCaptor2.getValue() .closed(Status.fromCode(FATAL_STATUS_CODE), REFUSED, new Metadata()); ArgumentCaptor<ClientStreamListener> sublistenerCaptor4 = ArgumentCaptor.forClass(ClientStreamListener.class); verify(mockStream4).start(sublistenerCaptor4.capture()); assertEquals(1, fakeClock.numPendingTasks()); // no more transparent retry Status status = Status.fromCode(FATAL_STATUS_CODE); Metadata metadata = new Metadata(); sublistenerCaptor3.getValue() .closed(status, REFUSED, metadata); ArgumentCaptor<Status> statusCaptor = ArgumentCaptor.forClass(Status.class); verify(mockStream1).cancel(statusCaptor.capture()); assertEquals(Status.CANCELLED.getCode(), statusCaptor.getValue().getCode()); assertEquals(CANCELLED_BECAUSE_COMMITTED, statusCaptor.getValue().getDescription()); verify(mockStream4).cancel(statusCaptor.capture()); assertEquals(Status.CANCELLED.getCode(), statusCaptor.getValue().getCode()); assertEquals(CANCELLED_BECAUSE_COMMITTED, statusCaptor.getValue().getDescription()); verify(retriableStreamRecorder).postCommit(); verify(masterListener).closed(status, metadata); }