Pipeline pipeline = new MRPipeline(FailIT.class, tempDir.getDefaultConfiguration());
PCollection<String> p = pipeline.readTextFile(tempDir.copyResourceFileName("shakes.txt"));
PCollection<Integer> result = p.parallelDo(new InverseFn(), Writables.ints());
result.cache();
PipelineExecution execution = pipeline.runAsync();
while (!execution.isDone() && !execution.isCancelled()
&& execution.getStatus() != PipelineExecution.Status.FAILED
&& execution.getResult() == null) {
try {
Thread.sleep(1000);
System.out.println("Job Status: " + execution.getStatus().toString());
} catch (InterruptedException e) {
System.err.println("ABORTING");
e.printStackTrace();
try {
execution.kill();
execution.waitUntilDone();
} catch (InterruptedException e1) {
throw new RuntimeException(e1);
}
throw new RuntimeException(e);
}
}
System.out.println("Finished running job.");
assertEquals(PipelineExecution.Status.FAILED, execution.getStatus());
}