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