in.count()
.values()
.parallelDo(new SleepForeverFn(), longs())
.write(To.textFile(tmpDir.getPath("out_" + i)));
}
MRPipelineExecution exec = pipeline.runAsync();
// Wait until both of the two jobs are submitted.
List<MRJob> jobs = exec.getJobs();
assertEquals(2, jobs.size());
StopWatch watch = new StopWatch();
watch.start();
int numOfJobsSubmitted = 0;
while (numOfJobsSubmitted < 2 && watch.getTime() < 10000) {
numOfJobsSubmitted = 0;
for (MRJob job : jobs) {
if (job.getJobState() == MRJob.State.RUNNING) {
numOfJobsSubmitted++;
}
}
Thread.sleep(100);
}
assertEquals(2, numOfJobsSubmitted);
// Kill one of them.
Job job0 = jobs.get(0).getJob();
job0.killJob();
// Expect the pipeline exits and the other job is killed.
StopWatch watch2 = new StopWatch();
watch2.start();
Job job1 = jobs.get(1).getJob();
while (!job1.isComplete() && watch2.getTime() < 10000) {
Thread.sleep(100);
}
assertTrue(job1.isComplete());
assertEquals(PipelineExecution.Status.FAILED, exec.getStatus());
}