Search in sources :

Example 21 with JobStatus

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());
}
Also used : ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) JobStatus(org.apache.hadoop.mapreduce.JobStatus) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) GetApplicationsResponse(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse) ArrayList(java.util.ArrayList) YarnClientImpl(org.apache.hadoop.yarn.client.api.impl.YarnClientImpl) ApplicationClientProtocol(org.apache.hadoop.yarn.api.ApplicationClientProtocol) GetApplicationsRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest) Test(org.junit.Test)

Example 22 with JobStatus

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");
}
Also used : HadoopJobStatus(org.apache.ignite.internal.processors.hadoop.HadoopJobStatus) JobStatus(org.apache.hadoop.mapreduce.JobStatus) JobID(org.apache.hadoop.mapreduce.JobID)

Aggregations

JobStatus (org.apache.hadoop.mapreduce.JobStatus)22 Test (org.junit.Test)10 IOException (java.io.IOException)7 MRClientProtocol (org.apache.hadoop.mapreduce.v2.api.MRClientProtocol)7 Job (org.apache.hadoop.mapreduce.Job)5 GetJobReportRequest (org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetJobReportRequest)5 JobID (org.apache.hadoop.mapreduce.JobID)4 InetSocketAddress (java.net.InetSocketAddress)3 Configuration (org.apache.hadoop.conf.Configuration)3 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)3 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)3 OutputStreamWriter (java.io.OutputStreamWriter)2 PrintWriter (java.io.PrintWriter)2 ArrayList (java.util.ArrayList)2 Path (org.apache.hadoop.fs.Path)2 GetJobReportResponse (org.apache.hadoop.mapreduce.v2.api.protocolrecords.GetJobReportResponse)2 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)2 ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)2 AggregationPhaseJob (com.linkedin.thirdeye.hadoop.aggregation.AggregationPhaseJob)1 BackfillPhaseJob (com.linkedin.thirdeye.hadoop.backfill.BackfillPhaseJob)1