* by using -fail-task option.
*/
@Test
public void testProcessTreeCleanupOfFailedTask2() throws
Exception {
TaskInfo taskInfo = null;
TaskID tID = null;
TTTaskInfo [] ttTaskinfo = null;
String pid = null;
TTProtocol ttIns = null;
TTClient ttClientIns = null;
int counter = 0;
JobConf jobConf = new JobConf(conf);
jobConf.setJobName("Message Display");
jobConf.setJarByClass(GenerateTaskChildProcess.class);
jobConf.setMapperClass(GenerateTaskChildProcess.StrDisplayMapper.class);
jobConf.setNumMapTasks(1);
jobConf.setNumReduceTasks(0);
cleanup(outputDir, conf);
FileInputFormat.setInputPaths(jobConf, inputDir);
FileOutputFormat.setOutputPath(jobConf, outputDir);
JTClient jtClient = cluster.getJTClient();
JobClient client = jtClient.getClient();
JTProtocol wovenClient = cluster.getJTClient().getProxy();
RunningJob runJob = client.submitJob(jobConf);
JobID id = runJob.getID();
JobInfo jInfo = wovenClient.getJobInfo(id);
Assert.assertNotNull("Job information is null", jInfo);
Assert.assertTrue("Job has not been started for 1 min.",
jtClient.isJobStarted(id));
TaskInfo[] taskInfos = wovenClient.getTaskInfo(id);
for (TaskInfo taskinfo : taskInfos) {
if (!taskinfo.isSetupOrCleanup()) {
taskInfo = taskinfo;
break;
}
}
Assert.assertTrue("Task has not been started for 1 min.",
jtClient.isTaskStarted(taskInfo));
tID = TaskID.downgrade(taskInfo.getTaskID());
TaskAttemptID tAttID = new TaskAttemptID(tID,0);
FinishTaskControlAction action = new FinishTaskControlAction(tID);
Collection<TTClient> ttClients = cluster.getTTClients();
for (TTClient ttClient : ttClients) {
TTProtocol tt = ttClient.getProxy();
tt.sendAction(action);
ttTaskinfo = tt.getTasks();
for (TTTaskInfo tttInfo : ttTaskinfo) {
if (!tttInfo.isTaskCleanupTask()) {
pid = tttInfo.getPid();
ttClientIns = ttClient;
ttIns = tt;
break;
}
}
if (ttClientIns != null) {
break;
}
}
Assert.assertTrue("Map process is not alive before task fails.",
ttIns.isProcessTreeAlive(pid));
String args[] = new String[] { "-fail-task", tAttID.toString() };
int exitCode = runTool(jobConf, client, args);
Assert.assertEquals("Exit Code:", 0, exitCode);
LOG.info("Waiting till the task is failed...");
taskInfo = wovenClient.getTaskInfo(taskInfo.getTaskID());
counter = 0;
while (counter < 60) {
if (taskInfo.getTaskStatus().length > 0) {
if (taskInfo.getTaskStatus()[0].getRunState() ==
TaskStatus.State.FAILED) {
break;
}
}
UtilsForTests.waitFor(1000);
taskInfo = wovenClient.getTaskInfo(taskInfo.getTaskID());
counter ++;
}
counter = 0;
LOG.info("Waiting till the job is completed...");
while (counter < 60) {