Search in sources :

Example 1 with JobStateInternal

use of org.apache.hadoop.mapreduce.v2.app.job.JobStateInternal in project hadoop by apache.

the class JobImpl method handle.

@Override
public /**
   * The only entry point to change the Job.
   */
void handle(JobEvent event) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Processing " + event.getJobId() + " of type " + event.getType());
    }
    try {
        writeLock.lock();
        JobStateInternal oldState = getInternalState();
        try {
            getStateMachine().doTransition(event.getType(), event);
        } catch (InvalidStateTransitionException e) {
            LOG.error("Can't handle this event at current state", e);
            addDiagnostic("Invalid event " + event.getType() + " on Job " + this.jobId);
            eventHandler.handle(new JobEvent(this.jobId, JobEventType.INTERNAL_ERROR));
        }
        //notify the eventhandler of state change
        if (oldState != getInternalState()) {
            LOG.info(jobId + "Job Transitioned from " + oldState + " to " + getInternalState());
            rememberLastNonFinalState(oldState);
        }
    } finally {
        writeLock.unlock();
    }
}
Also used : InvalidStateTransitionException(org.apache.hadoop.yarn.state.InvalidStateTransitionException) JobEvent(org.apache.hadoop.mapreduce.v2.app.job.event.JobEvent) JobStateInternal(org.apache.hadoop.mapreduce.v2.app.job.JobStateInternal)

Example 2 with JobStateInternal

use of org.apache.hadoop.mapreduce.v2.app.job.JobStateInternal in project hadoop by apache.

the class TestJobImpl method testMetaInfoSizeOverMax.

@Test
public void testMetaInfoSizeOverMax() throws Exception {
    Configuration conf = new Configuration();
    JobID jobID = JobID.forName("job_1234567890000_0001");
    JobId jobId = TypeConverter.toYarn(jobID);
    MRAppMetrics mrAppMetrics = MRAppMetrics.create();
    JobImpl job = new JobImpl(jobId, ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 0), 0), conf, mock(EventHandler.class), null, new JobTokenSecretManager(), new Credentials(), null, null, mrAppMetrics, null, true, null, 0, null, null, null, null);
    InitTransition initTransition = new InitTransition() {

        @Override
        protected TaskSplitMetaInfo[] createSplits(JobImpl job, JobId jobId) {
            throw new YarnRuntimeException(EXCEPTIONMSG);
        }
    };
    JobEvent mockJobEvent = mock(JobEvent.class);
    JobStateInternal jobSI = initTransition.transition(job, mockJobEvent);
    Assert.assertTrue("When init fails, return value from InitTransition.transition should equal NEW.", jobSI.equals(JobStateInternal.NEW));
    Assert.assertTrue("Job diagnostics should contain YarnRuntimeException", job.getDiagnostics().toString().contains("YarnRuntimeException"));
    Assert.assertTrue("Job diagnostics should contain " + EXCEPTIONMSG, job.getDiagnostics().toString().contains(EXCEPTIONMSG));
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) JobStateInternal(org.apache.hadoop.mapreduce.v2.app.job.JobStateInternal) CommitterEventHandler(org.apache.hadoop.mapreduce.v2.app.commit.CommitterEventHandler) EventHandler(org.apache.hadoop.yarn.event.EventHandler) YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) InitTransition(org.apache.hadoop.mapreduce.v2.app.job.impl.JobImpl.InitTransition) JobEvent(org.apache.hadoop.mapreduce.v2.app.job.event.JobEvent) JobTokenSecretManager(org.apache.hadoop.mapreduce.security.token.JobTokenSecretManager) TaskSplitMetaInfo(org.apache.hadoop.mapreduce.split.JobSplit.TaskSplitMetaInfo) MRAppMetrics(org.apache.hadoop.mapreduce.v2.app.metrics.MRAppMetrics) JobID(org.apache.hadoop.mapreduce.JobID) JobId(org.apache.hadoop.mapreduce.v2.api.records.JobId) Credentials(org.apache.hadoop.security.Credentials) Test(org.junit.Test)

Example 3 with JobStateInternal

use of org.apache.hadoop.mapreduce.v2.app.job.JobStateInternal in project hadoop by apache.

the class MRAppMaster method createJob.

/** Create and initialize (but don't start) a single job. 
   * @param forcedState a state to force the job into or null for normal operation. 
   * @param diagnostic a diagnostic message to include with the job.
   */
protected Job createJob(Configuration conf, JobStateInternal forcedState, String diagnostic) {
    // create single job
    Job newJob = new JobImpl(jobId, appAttemptID, conf, dispatcher.getEventHandler(), taskAttemptListener, jobTokenSecretManager, jobCredentials, clock, completedTasksFromPreviousRun, metrics, committer, newApiCommitter, currentUser.getUserName(), appSubmitTime, amInfos, context, forcedState, diagnostic);
    ((RunningAppContext) context).jobs.put(newJob.getID(), newJob);
    dispatcher.register(JobFinishEvent.Type.class, createJobFinishEventHandler());
    return newJob;
}
Also used : JobImpl(org.apache.hadoop.mapreduce.v2.app.job.impl.JobImpl) JobFinishEvent(org.apache.hadoop.mapreduce.v2.app.job.event.JobFinishEvent) Job(org.apache.hadoop.mapreduce.v2.app.job.Job)

Example 4 with JobStateInternal

use of org.apache.hadoop.mapreduce.v2.app.job.JobStateInternal in project hadoop by apache.

the class JobImpl method getAllCounters.

@Override
public Counters getAllCounters() {
    readLock.lock();
    try {
        JobStateInternal state = getInternalState();
        if (state == JobStateInternal.ERROR || state == JobStateInternal.FAILED || state == JobStateInternal.KILLED || state == JobStateInternal.SUCCEEDED) {
            this.mayBeConstructFinalFullCounters();
            return fullCounters;
        }
        Counters counters = new Counters();
        counters.incrAllCounters(jobCounters);
        return incrTaskCounters(counters, tasks.values());
    } finally {
        readLock.unlock();
    }
}
Also used : JobStateInternal(org.apache.hadoop.mapreduce.v2.app.job.JobStateInternal) Counters(org.apache.hadoop.mapreduce.Counters)

Example 5 with JobStateInternal

use of org.apache.hadoop.mapreduce.v2.app.job.JobStateInternal in project hadoop by apache.

the class MRApp method waitForInternalState.

public void waitForInternalState(JobImpl job, JobStateInternal finalState) throws Exception {
    int timeoutSecs = 0;
    JobStateInternal iState = job.getInternalState();
    while (!finalState.equals(iState) && timeoutSecs++ < 20) {
        System.out.println("Job Internal State is : " + iState + " Waiting for Internal state : " + finalState);
        Thread.sleep(500);
        iState = job.getInternalState();
    }
    System.out.println("Task Internal State is : " + iState);
    Assert.assertEquals("Task Internal state is not correct (timedout)", finalState, iState);
}
Also used : JobStateInternal(org.apache.hadoop.mapreduce.v2.app.job.JobStateInternal)

Aggregations

JobStateInternal (org.apache.hadoop.mapreduce.v2.app.job.JobStateInternal)4 Job (org.apache.hadoop.mapreduce.v2.app.job.Job)2 JobEvent (org.apache.hadoop.mapreduce.v2.app.job.event.JobEvent)2 JobFinishEvent (org.apache.hadoop.mapreduce.v2.app.job.event.JobFinishEvent)2 YarnRuntimeException (org.apache.hadoop.yarn.exceptions.YarnRuntimeException)2 IOException (java.io.IOException)1 Configuration (org.apache.hadoop.conf.Configuration)1 Counters (org.apache.hadoop.mapreduce.Counters)1 JobID (org.apache.hadoop.mapreduce.JobID)1 JobTokenSecretManager (org.apache.hadoop.mapreduce.security.token.JobTokenSecretManager)1 TaskSplitMetaInfo (org.apache.hadoop.mapreduce.split.JobSplit.TaskSplitMetaInfo)1 JobId (org.apache.hadoop.mapreduce.v2.api.records.JobId)1 CommitterEventHandler (org.apache.hadoop.mapreduce.v2.app.commit.CommitterEventHandler)1 JobImpl (org.apache.hadoop.mapreduce.v2.app.job.impl.JobImpl)1 InitTransition (org.apache.hadoop.mapreduce.v2.app.job.impl.JobImpl.InitTransition)1 MRAppMetrics (org.apache.hadoop.mapreduce.v2.app.metrics.MRAppMetrics)1 Credentials (org.apache.hadoop.security.Credentials)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 EventHandler (org.apache.hadoop.yarn.event.EventHandler)1 InvalidStateTransitionException (org.apache.hadoop.yarn.state.InvalidStateTransitionException)1