in dbeam-core/src/main/java/com/spotify/dbeam/beam/BeamHelper.java [48:75]
public static PipelineResult waitUntilDone(
final PipelineResult result, final Duration exportTimeout) {
// terminal state might be null, such as:
// {{ @link org.apache.beam.runners.dataflow.DataflowPipelineJob.waitUntilFinish }}
@Nullable
final PipelineResult.State terminalState =
result.waitUntilFinish(org.joda.time.Duration.millis(exportTimeout.toMillis()));
if (terminalState == null || !terminalState.isTerminal()) {
try {
result.cancel();
} catch (IOException e) {
throw new Pipeline.PipelineExecutionException(
new Exception(
String.format(
"Job exceeded timeout of %s, but was not possible to cancel, "
+ "finished with terminalState %s",
exportTimeout.toString(), terminalState),
e));
}
throw new Pipeline.PipelineExecutionException(
new Exception("Job cancelled after exceeding timeout " + exportTimeout.toString()));
}
if (!terminalState.equals(PipelineResult.State.DONE)) {
throw new Pipeline.PipelineExecutionException(
new Exception("Job finished with terminalState " + terminalState.toString()));
}
return result;
}