Search in sources :

Example 31 with StatusException

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException in project google-cloud-java by GoogleCloudPlatform.

the class SubscriberTest method testFailedChannel_recoverableError_channelReopened.

@Test
public void testFailedChannel_recoverableError_channelReopened() throws Exception {
    if (!isStreamingTest) {
        // This test is not applicable to polling.
        return;
    }
    final int expectedChannelCount = Runtime.getRuntime().availableProcessors() * Subscriber.CHANNELS_PER_CORE;
    Subscriber subscriber = startSubscriber(getTestSubscriberBuilder(testReceiver).setExecutorProvider(InstantiatingExecutorProvider.newBuilder().setExecutorThreadCount(1).build()));
    // Recoverable error
    fakeSubscriberServiceImpl.sendError(new StatusException(Status.INTERNAL));
    assertEquals(1, fakeSubscriberServiceImpl.waitForClosedStreams(1));
    assertEquals(expectedChannelCount, fakeSubscriberServiceImpl.waitForOpenedStreams(expectedChannelCount));
    subscriber.stopAsync().awaitTerminated();
}
Also used : StatusException(io.grpc.StatusException) Test(org.junit.Test)

Example 32 with StatusException

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException in project core-java by SpineEventEngine.

the class ErrorsShould method return_absent_if_passed_Throwable_is_not_status_exception.

@Test
public void return_absent_if_passed_Throwable_is_not_status_exception() {
    final String msg = "Neither a StatusException nor a StatusRuntimeException.";
    final Exception exception = new Exception(msg);
    assertFalse(Errors.fromStreamError(exception).isPresent());
}
Also used : StatusRuntimeException(io.grpc.StatusRuntimeException) StatusException(io.grpc.StatusException) Test(org.junit.Test)

Example 33 with StatusException

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException in project core-java by SpineEventEngine.

the class ErrorsShould method return_Error_extracted_form_StatusException_metadata.

@Test
public void return_Error_extracted_form_StatusException_metadata() {
    final Error expectedError = Error.getDefaultInstance();
    final Metadata metadata = MetadataConverter.toMetadata(expectedError);
    final StatusException statusException = INVALID_ARGUMENT.asException(metadata);
    assertEquals(expectedError, Errors.fromStreamError(statusException).get());
}
Also used : StatusException(io.grpc.StatusException) Metadata(io.grpc.Metadata) Test(org.junit.Test)

Example 34 with StatusException

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException in project core-java by SpineEventEngine.

the class StreamObserversShould method return_absent_if_passed_Throwable_is_not_status_exception.

@Test
public void return_absent_if_passed_Throwable_is_not_status_exception() {
    final String msg = "Neither a StatusException nor a StatusRuntimeException.";
    final Exception exception = new Exception(msg);
    assertFalse(StreamObservers.fromStreamError(exception).isPresent());
}
Also used : StatusException(io.grpc.StatusException) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 35 with StatusException

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException in project curiostack by curioswitch.

the class ListenableFutureAssert method getFailureGrpcStatus.

private Status getFailureGrpcStatus() {
    Throwable t = catchThrowable(() -> getUnchecked(actual));
    Throwable cause = t.getCause();
    if (cause instanceof StatusRuntimeException) {
        return ((StatusRuntimeException) cause).getStatus();
    } else if (cause instanceof StatusException) {
        return ((StatusException) cause).getStatus();
    } else {
        // Could throw AssertionError, but use assertj for consistent error messages. The following
        // is guaranteed to throw.
        assertThat(cause).isInstanceOfAny(StatusException.class, StatusRuntimeException.class);
        throw new IllegalStateException("Can't reach here.");
    }
}
Also used : StatusException(io.grpc.StatusException) StatusRuntimeException(io.grpc.StatusRuntimeException) Assertions.catchThrowable(org.assertj.core.api.Assertions.catchThrowable)

Aggregations

StatusException (io.grpc.StatusException)45 Test (org.junit.Test)20 Status (io.grpc.Status)9 IOException (java.io.IOException)9 StatusException (org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException)9 ExecutionException (java.util.concurrent.ExecutionException)8 PinpointGrpcServer (com.navercorp.pinpoint.collector.receiver.grpc.PinpointGrpcServer)6 Metadata (io.grpc.Metadata)6 StatusRuntimeException (org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException)5 HealthCheckResponse (io.grpc.health.v1.HealthCheckResponse)4 TrackingObjectPoolForTest (io.grpc.netty.NettyTestUtil.TrackingObjectPoolForTest)4 TimeoutException (java.util.concurrent.TimeoutException)4 StatusRuntimeException (io.grpc.StatusRuntimeException)3 InetSocketAddress (java.net.InetSocketAddress)3 SSLHandshakeException (javax.net.ssl.SSLHandshakeException)3 RunnerApi (org.apache.beam.model.pipeline.v1.RunnerApi)3 AgentInfo (com.navercorp.pinpoint.collector.cluster.AgentInfo)2 PCmdMessage (com.navercorp.pinpoint.grpc.trace.PCmdMessage)2 PCmdRequest (com.navercorp.pinpoint.grpc.trace.PCmdRequest)2 PCmdResponse (com.navercorp.pinpoint.grpc.trace.PCmdResponse)2