use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Metadata in project sonarlint-core by SonarSource.
the class ConnectedDaemonTest method getLogs.
private ClientCall<Void, LogEvent> getLogs(LogCollector collector, Channel channel) {
ClientCall<Void, LogEvent> call = channel.newCall(StandaloneSonarLintGrpc.METHOD_STREAM_LOGS, CallOptions.DEFAULT);
call.start(collector, new Metadata());
call.sendMessage(Void.newBuilder().build());
call.halfClose();
call.request(Integer.MAX_VALUE);
return call;
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Metadata in project google-cloud-java by GoogleCloudPlatform.
the class WatchdogInterceptorTest method callerCancelsBeforeTimeout.
@Test
public void callerCancelsBeforeTimeout() {
ClientCall<Void, Void> call = startCall();
// Cancel the call before the watchdog does.
call.cancel("Cancelled by user", null);
ticker.advance(TIMEOUT_NANOS + 1);
// Finish RPC with CANCELLED.
Metadata trailers = new Metadata();
innerListener.getValue().onClose(Status.CANCELLED, trailers);
watchdog.tick();
// The call should be cancelled exactly once.
verify(innerCall, times(1)).cancel(anyString(), Mockito.<Throwable>any());
// No translation, since the user beat the watchdog.
verify(listener).onClose(argThat(isStatusWithCode(Status.Code.CANCELLED)), same(trailers));
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Metadata in project google-cloud-java by GoogleCloudPlatform.
the class WatchdogInterceptorTest method failureAfterTimeout.
@Test
public void failureAfterTimeout() {
startCall();
ticker.advance(TIMEOUT_NANOS + 1);
watchdog.tick();
// The call should be cancelled exactly once.
verify(innerCall, times(1)).cancel(anyString(), Mockito.<Throwable>any());
// Finish RPC with error.
Metadata trailers = new Metadata();
innerListener.getValue().onClose(Status.DATA_LOSS, trailers);
// No translation expected.
verify(listener).onClose(argThat(isStatusWithCode(Status.Code.DATA_LOSS)), same(trailers));
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Metadata in project google-cloud-java by GoogleCloudPlatform.
the class WatchdogInterceptorTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
ticker = new FakeTicker();
watchdog = new WatchdogInterceptor(TIMEOUT_NANOS, TimeUnit.NANOSECONDS, ticker);
// Nothing special about the deadline: we just want a particular CallOptions instance to expect.
options = CallOptions.DEFAULT.withDeadlineAfter(10, TimeUnit.SECONDS);
metadata = new Metadata();
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Metadata in project google-cloud-java by GoogleCloudPlatform.
the class WatchdogInterceptorTest method timeout.
@Test
public void timeout() {
startCall();
ticker.advance(TIMEOUT_NANOS + 1);
watchdog.tick();
verify(innerCall, times(1)).cancel(anyString(), Mockito.<Throwable>any());
// Finish RPC with CANCELLED.
Metadata trailers = new Metadata();
innerListener.getValue().onClose(Status.CANCELLED, trailers);
// Should translate to UNAVAILABLE.
verify(listener).onClose(argThat(isStatusWithCode(Status.Code.UNAVAILABLE)), same(trailers));
}
Aggregations