Search in sources :

Example 1 with CancelJobResponse

use of org.apache.beam.model.jobmanagement.v1.JobApi.CancelJobResponse in project beam by apache.

the class JobServicePipelineResult method cancel.

@Override
public State cancel() {
    JobServiceBlockingStub stub = jobService.get();
    CancelJobResponse response = stub.cancel(CancelJobRequest.newBuilder().setJobIdBytes(jobId).build());
    return getJavaState(response.getState());
}
Also used : JobServiceBlockingStub(org.apache.beam.model.jobmanagement.v1.JobServiceGrpc.JobServiceBlockingStub) CancelJobResponse(org.apache.beam.model.jobmanagement.v1.JobApi.CancelJobResponse)

Example 2 with CancelJobResponse

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

CancelJobResponse (org.apache.beam.model.jobmanagement.v1.JobApi.CancelJobResponse)2 CancelJobRequest (org.apache.beam.model.jobmanagement.v1.JobApi.CancelJobRequest)1 JobState (org.apache.beam.model.jobmanagement.v1.JobApi.JobState)1 JobServiceBlockingStub (org.apache.beam.model.jobmanagement.v1.JobServiceGrpc.JobServiceBlockingStub)1 StatusException (org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException)1 StatusRuntimeException (org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException)1