Search in sources :

Example 41 with StatusException

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

the class XdsServerWrapper method internalStart.

private void internalStart() {
    try {
        xdsClientPool = xdsClientPoolFactory.getOrCreate();
    } catch (Exception e) {
        StatusException statusException = Status.UNAVAILABLE.withDescription("Failed to initialize xDS").withCause(e).asException();
        listener.onNotServing(statusException);
        initialStartFuture.set(statusException);
        return;
    }
    xdsClient = xdsClientPool.getObject();
    boolean useProtocolV3 = xdsClient.getBootstrapInfo().servers().get(0).useProtocolV3();
    String listenerTemplate = xdsClient.getBootstrapInfo().serverListenerResourceNameTemplate();
    if (!useProtocolV3 || listenerTemplate == null) {
        StatusException statusException = Status.UNAVAILABLE.withDescription("Can only support xDS v3 with listener resource name template").asException();
        listener.onNotServing(statusException);
        initialStartFuture.set(statusException);
        xdsClient = xdsClientPool.returnObject(xdsClient);
        return;
    }
    String replacement = listenerAddress;
    if (listenerTemplate.startsWith(XDSTP_SCHEME)) {
        replacement = XdsClient.percentEncodePath(replacement);
    }
    discoveryState = new DiscoveryState(listenerTemplate.replaceAll("%s", replacement));
}
Also used : StatusException(io.grpc.StatusException) StatusException(io.grpc.StatusException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Example 42 with StatusException

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

the class CsdsService method handleRequest.

private boolean handleRequest(ClientStatusRequest request, StreamObserver<ClientStatusResponse> responseObserver) {
    StatusException error;
    try {
        responseObserver.onNext(getConfigDumpForRequest(request));
        return true;
    } catch (StatusException e) {
        error = e;
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        logger.log(Level.FINE, "Server interrupted while building CSDS config dump", e);
        error = Status.ABORTED.withDescription("Thread interrupted").withCause(e).asException();
    } catch (Exception e) {
        logger.log(Level.WARNING, "Unexpected error while building CSDS config dump", e);
        error = Status.INTERNAL.withDescription("Unexpected internal error").withCause(e).asException();
    }
    responseObserver.onError(error);
    return false;
}
Also used : StatusException(io.grpc.StatusException) StatusException(io.grpc.StatusException) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException)

Example 43 with StatusException

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

the class StatusProtoTest method toStatusException.

@Test
public void toStatusException() throws Exception {
    StatusException se = StatusProto.toStatusException(STATUS_PROTO);
    com.google.rpc.Status extractedStatusProto = StatusProto.fromThrowable(se);
    assertEquals(STATUS_PROTO.getCode(), se.getStatus().getCode().value());
    assertEquals(STATUS_PROTO.getMessage(), se.getStatus().getDescription());
    assertEquals(STATUS_PROTO, extractedStatusProto);
}
Also used : StatusException(io.grpc.StatusException) Test(org.junit.Test)

Example 44 with StatusException

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

the class BinderTransport method sendOutOfBandClose.

final void sendOutOfBandClose(int callId, Status status) {
    Parcel parcel = Parcel.obtain();
    try {
        // Placeholder for flags. Will be filled in below.
        parcel.writeInt(0);
        int flags = TransactionUtils.writeStatus(parcel, status);
        TransactionUtils.fillInFlags(parcel, flags | TransactionUtils.FLAG_OUT_OF_BAND_CLOSE);
        sendTransaction(callId, parcel);
    } catch (StatusException e) {
        logger.log(Level.WARNING, "Failed sending oob close transaction", e);
    } finally {
        parcel.recycle();
    }
}
Also used : StatusException(io.grpc.StatusException) Parcel(android.os.Parcel)

Example 45 with StatusException

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

the class ProtocolNegotiatorsTest method from_tls_clientAuthRequire_noClientCert.

@Test
public void from_tls_clientAuthRequire_noClientCert() throws Exception {
    ServerCredentials serverCreds = TlsServerCredentials.newBuilder().keyManager(server1Cert, server1Key).trustManager(caCert).clientAuth(TlsServerCredentials.ClientAuth.REQUIRE).build();
    ChannelCredentials channelCreds = TlsChannelCredentials.newBuilder().trustManager(caCert).build();
    Status status = expectFailedHandshake(channelCreds, serverCreds);
    assertEquals(Status.Code.UNAVAILABLE, status.getCode());
    StatusException sre = status.asException();
    // because of netty/netty#11604 we need to check for both TLSv1.2 and v1.3 behaviors
    if (sre.getCause() instanceof SSLHandshakeException) {
        assertThat(sre).hasCauseThat().isInstanceOf(SSLHandshakeException.class);
        assertThat(sre).hasCauseThat().hasMessageThat().contains("SSLV3_ALERT_HANDSHAKE_FAILURE");
    } else {
        // Client cert verification is after handshake in TLSv1.3
        assertThat(sre).hasCauseThat().hasCauseThat().isInstanceOf(SSLException.class);
        assertThat(sre).hasCauseThat().hasMessageThat().contains("CERTIFICATE_REQUIRED");
    }
}
Also used : Status(io.grpc.Status) StatusException(io.grpc.StatusException) InsecureServerCredentials(io.grpc.InsecureServerCredentials) TlsServerCredentials(io.grpc.TlsServerCredentials) ChoiceServerCredentials(io.grpc.ChoiceServerCredentials) ServerCredentials(io.grpc.ServerCredentials) ChoiceChannelCredentials(io.grpc.ChoiceChannelCredentials) TlsChannelCredentials(io.grpc.TlsChannelCredentials) InsecureChannelCredentials(io.grpc.InsecureChannelCredentials) ChannelCredentials(io.grpc.ChannelCredentials) CompositeChannelCredentials(io.grpc.CompositeChannelCredentials) SSLHandshakeException(javax.net.ssl.SSLHandshakeException) Test(org.junit.Test)

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