Search in sources :

Example 1 with JobStateEvent

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

the class JobServicePipelineResult method waitForTerminalState.

private void waitForTerminalState() {
    JobServiceBlockingStub stub = jobService.get().withDeadlineAfter(jobServerTimeout, TimeUnit.SECONDS);
    GetJobStateRequest request = GetJobStateRequest.newBuilder().setJobIdBytes(jobId).build();
    JobStateEvent response = stub.getState(request);
    State lastState = getJavaState(response.getState());
    while (!lastState.isTerminal()) {
        try {
            Thread.sleep(POLL_INTERVAL_MS);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new RuntimeException(e);
        }
        response = stub.withDeadlineAfter(jobServerTimeout, TimeUnit.SECONDS).getState(request);
        lastState = getJavaState(response.getState());
    }
    terminalState = lastState;
}
Also used : JobServiceBlockingStub(org.apache.beam.model.jobmanagement.v1.JobServiceGrpc.JobServiceBlockingStub) JobStateEvent(org.apache.beam.model.jobmanagement.v1.JobApi.JobStateEvent) GetJobStateRequest(org.apache.beam.model.jobmanagement.v1.JobApi.GetJobStateRequest)

Example 2 with JobStateEvent

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

the class JobServicePipelineResult method getState.

@Override
public State getState() {
    if (terminalState != null) {
        return terminalState;
    }
    JobServiceBlockingStub stub = jobService.get().withDeadlineAfter(jobServerTimeout, TimeUnit.SECONDS);
    JobStateEvent response = stub.getState(GetJobStateRequest.newBuilder().setJobIdBytes(jobId).build());
    return getJavaState(response.getState());
}
Also used : JobServiceBlockingStub(org.apache.beam.model.jobmanagement.v1.JobServiceGrpc.JobServiceBlockingStub) JobStateEvent(org.apache.beam.model.jobmanagement.v1.JobApi.JobStateEvent)

Example 3 with JobStateEvent

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

the class InMemoryJobService method getState.

@Override
public void getState(GetJobStateRequest request, StreamObserver<JobStateEvent> responseObserver) {
    LOG.trace("{} {}", GetJobStateRequest.class.getSimpleName(), request);
    String invocationId = request.getJobId();
    try {
        JobInvocation invocation = getInvocation(invocationId);
        JobStateEvent response = invocation.getStateEvent();
        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 : JobStateEvent(org.apache.beam.model.jobmanagement.v1.JobApi.JobStateEvent) StatusException(org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException) GetJobStateRequest(org.apache.beam.model.jobmanagement.v1.JobApi.GetJobStateRequest) StatusRuntimeException(org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException) StatusRuntimeException(org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException) StatusException(org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException)

Example 4 with JobStateEvent

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

the class JobInvocation method setState.

private synchronized void setState(JobState.Enum state) {
    JobStateEvent event = JobStateEvent.newBuilder().setState(state).setTimestamp(Timestamps.fromMillis(System.currentTimeMillis())).build();
    this.stateHistory.add(event);
    for (Consumer<JobStateEvent> observer : stateObservers) {
        observer.accept(event);
    }
}
Also used : JobStateEvent(org.apache.beam.model.jobmanagement.v1.JobApi.JobStateEvent)

Aggregations

JobStateEvent (org.apache.beam.model.jobmanagement.v1.JobApi.JobStateEvent)4 GetJobStateRequest (org.apache.beam.model.jobmanagement.v1.JobApi.GetJobStateRequest)2 JobServiceBlockingStub (org.apache.beam.model.jobmanagement.v1.JobServiceGrpc.JobServiceBlockingStub)2 StatusException (org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException)1 StatusRuntimeException (org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException)1