boolean continueLoop = true;
//counter for job Loop
int countLoop = 0;
TaskInfo taskInfo = null;
String jobTrackerUserName = remoteJTClient.getDaemonUser();
LOG.info("jobTrackerUserName is :" + jobTrackerUserName);
//This counter will check for count of a loop,
//which might become infinite.
int count = 0;
SleepJob job = new SleepJob();
job.setConf(conf);
int totalMapTasks = 5;
int totalReduceTasks = 1;
conf = job.setupJobConf(totalMapTasks, totalReduceTasks,
100, 100, 100, 100);
JobConf jconf = new JobConf(conf);
count = 0;
//The last hour and last day are given 60 seconds and 120 seconds
//recreate values rate, replacing one hour and 1 day. Waiting for
//them to be ona just created stage when testacse starts.
while (remoteJTClient.getInfoFromAllClients("last_day","total_tasks")
!= 0) {
count++;
UtilsForTests.waitFor(1000);
//If the count goes beyond a point, then break; This is to avoid
//infinite loop under unforeseen circumstances. Testcase will
//anyway fail later.
if (count > 140) {
Assert.fail("Since this value has not reached 0" +
"in more than 140 seconds. Failing at this point");
}
}
statisticsCollectionHandler = null;
statisticsCollectionHandler = remoteJTClient.
getInfoFromAllClientsForAllTaskType();
int totalTasksSinceStartBeforeJob = statisticsCollectionHandler.
getSinceStartTotalTasks();
int succeededTasksSinceStartBeforeJob = statisticsCollectionHandler.
getSinceStartSucceededTasks();
int totalTasksLastHourBeforeJob = statisticsCollectionHandler.
getLastHourTotalTasks();
int succeededTasksLastHourBeforeJob = statisticsCollectionHandler.
getLastHourSucceededTasks();
int totalTasksLastDayBeforeJob = statisticsCollectionHandler.
getLastDayTotalTasks();
int succeededTasksLastDayBeforeJob = statisticsCollectionHandler.
getLastDaySucceededTasks();
//Submitting the job
RunningJob rJob = cluster.getJTClient().getClient().
submitJob(jconf);
JobInfo jInfo = remoteJTClient.getJobInfo(rJob.getID());
LOG.info("jInfo is :" + jInfo);
count = 0;
while (count < 60) {
if (jInfo.getStatus().getRunState() == JobStatus.RUNNING) {
break;
} else {
UtilsForTests.waitFor(1000);
jInfo = remoteJTClient.getJobInfo(rJob.getID());
}
count++;
}
Assert.assertTrue("Job has not been started for 1 min.",
count != 60);
//Assert if jobInfo is null
Assert.assertNotNull("jobInfo is null", jInfo);
TaskInfo[] taskInfos = remoteJTClient.getTaskInfo(rJob.getID());
for (TaskInfo taskinfo : taskInfos) {
if (!taskinfo.isSetupOrCleanup()) {
taskInfo = taskinfo;
}
}
count = 0;
taskInfo = remoteJTClient.getTaskInfo(taskInfo.getTaskID());
while (count < 60) {
if (taskInfo.getTaskStatus().length > 0) {
if (taskInfo.getTaskStatus()[0].getRunState()
== TaskStatus.State.RUNNING) {
break;
}
}
UtilsForTests.waitFor(1000);
taskInfo = remoteJTClient.getTaskInfo(taskInfo.getTaskID());
count++;
}
Assert.assertTrue("Task has not been started for 1 min.",
count != 60);
TaskID tID = TaskID.downgrade(taskInfo.getTaskID());
TaskAttemptID taskAttID = new TaskAttemptID(tID , 0);
rJob.killTask(taskAttID, false);
count = 0;
LOG.info("Waiting till the job is completed...");