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();
}
}
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();
}
}
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());
}
}
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());
}
}
Aggregations