use of org.apache.hadoop.mapreduce.JobStatus in project hadoop by apache.
the class TestResourceMgrDelegate method tesAllJobs.
@Test
public void tesAllJobs() throws Exception {
final ApplicationClientProtocol applicationsManager = Mockito.mock(ApplicationClientProtocol.class);
GetApplicationsResponse allApplicationsResponse = Records.newRecord(GetApplicationsResponse.class);
List<ApplicationReport> applications = new ArrayList<ApplicationReport>();
applications.add(getApplicationReport(YarnApplicationState.FINISHED, FinalApplicationStatus.FAILED));
applications.add(getApplicationReport(YarnApplicationState.FINISHED, FinalApplicationStatus.SUCCEEDED));
applications.add(getApplicationReport(YarnApplicationState.FINISHED, FinalApplicationStatus.KILLED));
applications.add(getApplicationReport(YarnApplicationState.FAILED, FinalApplicationStatus.FAILED));
allApplicationsResponse.setApplicationList(applications);
Mockito.when(applicationsManager.getApplications(Mockito.any(GetApplicationsRequest.class))).thenReturn(allApplicationsResponse);
ResourceMgrDelegate resourceMgrDelegate = new ResourceMgrDelegate(new YarnConfiguration()) {
@Override
protected void serviceStart() throws Exception {
Assert.assertTrue(this.client instanceof YarnClientImpl);
((YarnClientImpl) this.client).setRMClient(applicationsManager);
}
};
JobStatus[] allJobs = resourceMgrDelegate.getAllJobs();
Assert.assertEquals(State.FAILED, allJobs[0].getState());
Assert.assertEquals(State.SUCCEEDED, allJobs[1].getState());
Assert.assertEquals(State.KILLED, allJobs[2].getState());
Assert.assertEquals(State.FAILED, allJobs[3].getState());
}
use of org.apache.hadoop.mapreduce.JobStatus in project ignite by apache.
the class HadoopUtils method status.
/**
* Convert Ignite job status to Hadoop job status.
*
* @param status Ignite job status.
* @return Hadoop job status.
*/
public static JobStatus status(HadoopJobStatus status, Configuration conf) {
JobID jobId = new JobID(status.jobId().globalId().toString(), status.jobId().localId());
float setupProgress = 0;
float mapProgress = 0;
float reduceProgress = 0;
float cleanupProgress = 0;
JobStatus.State state = JobStatus.State.RUNNING;
switch(status.jobPhase()) {
case PHASE_SETUP:
setupProgress = 0.42f;
break;
case PHASE_MAP:
setupProgress = 1;
mapProgress = 1f - status.pendingMapperCnt() / (float) status.totalMapperCnt();
break;
case PHASE_REDUCE:
setupProgress = 1;
mapProgress = 1;
if (status.totalReducerCnt() > 0)
reduceProgress = 1f - status.pendingReducerCnt() / (float) status.totalReducerCnt();
else
reduceProgress = 1f;
break;
case PHASE_CANCELLING:
case PHASE_COMPLETE:
if (!status.isFailed()) {
setupProgress = 1;
mapProgress = 1;
reduceProgress = 1;
cleanupProgress = 1;
state = JobStatus.State.SUCCEEDED;
} else
state = JobStatus.State.FAILED;
break;
default:
assert false;
}
return new JobStatus(jobId, setupProgress, mapProgress, reduceProgress, cleanupProgress, state, JobPriority.NORMAL, status.user(), status.jobName(), jobFile(conf, status.user(), jobId).toString(), "N/A");
}
Aggregations