use of org.apache.beam.model.jobmanagement.v1.JobApi.CancelJobRequest 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