JobClient client = cluster.getJTClient().getClient();
RunningJob rJob = client.submitJob(new JobConf(conf));
JobID id = rJob.getID();
JobInfo jInfo = wovenClient.getJobInfo(id);
while (jInfo.getStatus().getRunState() != JobStatus.RUNNING) {
Thread.sleep(1000);
jInfo = wovenClient.getJobInfo(id);
}
LOG.info("Waiting till job starts running one map");
jInfo = wovenClient.getJobInfo(id);
Assert.assertEquals(jInfo.runningMaps(), 1);
LOG.info("waiting for another cycle to " +
"check if the maps dont finish off");
Thread.sleep(1000);
jInfo = wovenClient.getJobInfo(id);
Assert.assertEquals(jInfo.runningMaps(), 1);
TaskInfo[] taskInfos = wovenClient.getTaskInfo(id);
for(TaskInfo info : taskInfos) {
LOG.info("constructing control action to signal task to finish");
FinishTaskControlAction action = new FinishTaskControlAction(
TaskID.downgrade(info.getTaskID()));
for(TTClient cli : cluster.getTTClients()) {
cli.getProxy().sendAction(action);
}
}
jInfo = wovenClient.getJobInfo(id);
int i = 1;
if (jInfo != null) {
while (!jInfo.getStatus().isJobComplete()) {
Thread.sleep(1000);
jInfo = wovenClient.getJobInfo(id);
if (jInfo == null) {
break;
}
if(i > 40) {
Assert.fail("Controlled Job with ID : "
+ jInfo.getID()
+ " has not completed in 40 seconds after signalling.");
}
i++;
}
}