Search in sources :

Example 51 with StatusException

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException in project pinpoint by naver.

the class GrpcCommandService method commandStreamActiveThreadCount.

@Override
public StreamObserver<PCmdActiveThreadCountRes> commandStreamActiveThreadCount(StreamObserver<Empty> streamConnectionManagerObserver) {
    final Long transportId = getTransportId();
    PinpointGrpcServer pinpointGrpcServer = grpcServerRepository.get(transportId);
    if (pinpointGrpcServer == null) {
        logger.info("{} => local. Can't find PinpointGrpcServer(transportId={})", getAgentInfo().getAgentKey(), transportId);
        streamConnectionManagerObserver.onError(new StatusException(Status.NOT_FOUND));
        return DisabledStreamObserver.instance();
    }
    try {
        return activeThreadCountService.handle(pinpointGrpcServer, streamConnectionManagerObserver);
    } catch (IllegalArgumentException e) {
        logger.warn("Failed to handle activeThreadCountService. agentKey={}, transportId={}", getAgentInfo().getAgentKey(), transportId, e);
        streamConnectionManagerObserver.onError(Status.INTERNAL.withDescription("Internal Server Error").asException());
        return DisabledStreamObserver.instance();
    }
}
Also used : StatusException(io.grpc.StatusException) PinpointGrpcServer(com.navercorp.pinpoint.collector.receiver.grpc.PinpointGrpcServer)

Example 52 with StatusException

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

the class FnApiControlClientPoolService method getProcessBundleDescriptor.

@Override
public void getProcessBundleDescriptor(BeamFnApi.GetProcessBundleDescriptorRequest request, StreamObserver<BeamFnApi.ProcessBundleDescriptor> responseObserver) {
    String bundleDescriptorId = request.getProcessBundleDescriptorId();
    LOG.info("getProcessBundleDescriptor request with id {}", bundleDescriptorId);
    BeamFnApi.ProcessBundleDescriptor descriptor = processBundleDescriptors.get(bundleDescriptorId);
    if (descriptor == null) {
        String msg = String.format("ProcessBundleDescriptor with id %s not found", bundleDescriptorId);
        responseObserver.onError(new StatusException(Status.NOT_FOUND.withDescription(msg)));
        LOG.error(msg);
    } else {
        responseObserver.onNext(descriptor);
        responseObserver.onCompleted();
    }
}
Also used : StatusException(org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException) BeamFnApi(org.apache.beam.model.fnexecution.v1.BeamFnApi)

Example 53 with StatusException

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

the class InMemoryJobService method run.

@Override
public void run(RunJobRequest request, StreamObserver<RunJobResponse> responseObserver) {
    LOG.trace("{} {}", RunJobRequest.class.getSimpleName(), request);
    String preparationId = request.getPreparationId();
    try {
        // retrieve job preparation
        JobPreparation preparation = preparations.get(preparationId);
        if (preparation == null) {
            String errMessage = String.format("Unknown Preparation Id \"%s\".", preparationId);
            StatusException exception = Status.NOT_FOUND.withDescription(errMessage).asException();
            responseObserver.onError(exception);
            return;
        }
        try {
            PipelineValidator.validate(preparation.pipeline());
        } catch (Exception e) {
            LOG.warn("Encountered Unexpected Exception during validation", e);
            responseObserver.onError(new StatusRuntimeException(Status.INVALID_ARGUMENT.withCause(e)));
            return;
        }
        // create new invocation
        JobInvocation invocation = invoker.invoke(resolveDependencies(preparation.pipeline(), stagingSessionTokens.get(preparationId)), preparation.options(), request.getRetrievalToken());
        String invocationId = invocation.getId();
        invocation.addStateListener(event -> {
            if (!JobInvocation.isTerminated(event.getState())) {
                return;
            }
            String stagingSessionToken = stagingSessionTokens.get(preparationId);
            stagingSessionTokens.remove(preparationId);
            try {
                if (cleanupJobFn != null) {
                    cleanupJobFn.accept(stagingSessionToken);
                }
            } catch (Exception e) {
                LOG.warn("Failed to remove job staging directory for token {}.", stagingSessionToken, e);
            } finally {
                onFinishedInvocationCleanup(invocationId);
            }
        });
        invocation.start();
        invocations.put(invocationId, invocation);
        // Cleanup this preparation because we are running it now.
        // If we fail, we need to prepare again.
        preparations.remove(preparationId);
        RunJobResponse response = RunJobResponse.newBuilder().setJobId(invocationId).build();
        responseObserver.onNext(response);
        responseObserver.onCompleted();
    } catch (StatusRuntimeException e) {
        LOG.warn("Encountered Status Exception", e);
        responseObserver.onError(e);
    } catch (Exception e) {
        String errMessage = String.format("Encountered Unexpected Exception for Preparation %s", preparationId);
        LOG.error(errMessage, e);
        responseObserver.onError(Status.INTERNAL.withCause(e).asException());
    }
}
Also used : StatusException(org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException) RunJobRequest(org.apache.beam.model.jobmanagement.v1.JobApi.RunJobRequest) StatusRuntimeException(org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException) RunJobResponse(org.apache.beam.model.jobmanagement.v1.JobApi.RunJobResponse) StatusRuntimeException(org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException) StatusException(org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException)

Example 54 with StatusException

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

the class InMemoryJobService method cancel.

@Override
public void cancel(CancelJobRequest request, StreamObserver<CancelJobResponse> responseObserver) {
    LOG.trace("{} {}", CancelJobRequest.class.getSimpleName(), request);
    String invocationId = request.getJobId();
    try {
        JobInvocation invocation = getInvocation(invocationId);
        invocation.cancel();
        JobState.Enum state = invocation.getState();
        CancelJobResponse response = CancelJobResponse.newBuilder().setState(state).build();
        responseObserver.onNext(response);
        responseObserver.onCompleted();
    } catch (StatusRuntimeException | StatusException e) {
        responseObserver.onError(e);
    } catch (Exception e) {
        String errMessage = String.format("Encountered Unexpected Exception for Invocation %s", invocationId);
        LOG.error(errMessage, e);
        responseObserver.onError(Status.INTERNAL.withCause(e).asException());
    }
}
Also used : StatusException(org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException) CancelJobResponse(org.apache.beam.model.jobmanagement.v1.JobApi.CancelJobResponse) CancelJobRequest(org.apache.beam.model.jobmanagement.v1.JobApi.CancelJobRequest) StatusRuntimeException(org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException) JobState(org.apache.beam.model.jobmanagement.v1.JobApi.JobState) StatusRuntimeException(org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException) StatusException(org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException)

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