Search in sources :

Example 6 with TaskStatus

use of org.ow2.proactive.scheduler.common.task.TaskStatus in project scheduling by ow2-proactive.

the class SchedulerStateRecoverHelperTest method testRecoverWithCanceledJobOnly.

@Test
public void testRecoverWithCanceledJobOnly() throws Exception {
    InternalJob job = createJob(JobStatus.CANCELED);
    changeTasksState(job, TaskStatus.PENDING);
    ImmutableMap<String, TaskStatus> tasksStatus = ImmutableMap.of("Ta", TaskStatus.FINISHED, "Tb", TaskStatus.FAILED, "Tc", TaskStatus.NOT_STARTED);
    changeTasksState(job, tasksStatus);
    RecoveredSchedulerState recoveredState = new Scenario(job).execute();
    job = recoveredState.getFinishedJobs().get(0);
    assertThat(job.getStatus()).isEqualTo(JobStatus.CANCELED);
    assertTasksStatus(job, tasksStatus);
}
Also used : RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus) Test(org.junit.Test)

Example 7 with TaskStatus

use of org.ow2.proactive.scheduler.common.task.TaskStatus in project scheduling by ow2-proactive.

the class AbstractSmartProxy method updateTask.

/**
 * Check if the task concerned by this notification is awaited. Retrieve
 * corresponding data if needed
 *
 * @param notification
 */
protected void updateTask(NotificationData<TaskInfo> notification) {
    // am I interested in this task?
    TaskInfo taskInfoData = notification.getData();
    JobId id = taskInfoData.getJobId();
    TaskId tid = taskInfoData.getTaskId();
    String tname = tid.getReadableName();
    TaskStatus status = taskInfoData.getStatus();
    AwaitedJob aj = jobTracker.getAwaitedJob(id.toString());
    if (aj == null)
        return;
    AwaitedTask at = aj.getAwaitedTask(tname);
    if (at == null)
        return;
    at.setTaskId(tid.toString());
    jobTracker.putAwaitedJob(id.toString(), aj);
    switch(status) {
        case ABORTED:
        case NOT_RESTARTED:
        case NOT_STARTED:
        case SKIPPED:
            {
                log.debug("The task " + tname + " from job " + id + " couldn't start. No data will be transfered");
                jobTracker.removeAwaitedTask(id.toString(), tname);
                break;
            }
        case FINISHED:
            {
                log.debug("The task " + tname + " from job " + id + " is finished.");
                if (aj.isAutomaticTransfer()) {
                    log.debug("Transferring data for finished task " + tname + " from job " + id);
                    try {
                        downloadTaskOutputFiles(aj, id.toString(), tname, aj.getLocalOutputFolder());
                    } catch (Throwable t) {
                        log.error("Error while handling data for finished task " + tname + " for job " + id + ", task will be removed");
                        jobTracker.removeAwaitedTask(id.toString(), tname);
                    }
                }
                break;
            }
        case FAILED:
        case FAULTY:
            {
                log.debug("The task " + tname + " from job " + id + " is faulty.");
                jobTracker.removeAwaitedTask(id.toString(), tname);
                break;
            }
    }
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 8 with TaskStatus

use of org.ow2.proactive.scheduler.common.task.TaskStatus in project scheduling by ow2-proactive.

the class TestPreemptRestartKillTask method TestPreemtRestartKillTask.

private void TestPreemtRestartKillTask(String jobDescriptorPath) throws Exception {
    log("Submitting job");
    log(schedulerHelper.getSchedulerInterface().getClass().toString());
    schedulerHelper.addExtraNodes(3);
    JobId id = schedulerHelper.submitJob(jobDescriptorPath);
    log("Wait for event job submitted");
    schedulerHelper.waitForEventJobSubmitted(id);
    log("Wait for event t1 running");
    schedulerHelper.waitForEventTaskRunning(id, "t1");
    log("Wait for event t2 running");
    schedulerHelper.waitForEventTaskRunning(id, "t2");
    log("Wait for event t3 running");
    schedulerHelper.waitForEventTaskRunning(id, "t3");
    log("Wait for event t4 running");
    schedulerHelper.waitForEventTaskRunning(id, "t4");
    log("Preempt t1");
    schedulerHelper.getSchedulerInterface().preemptTask(id, "t1", 1);
    log("Wait for event t1 waiting for restart");
    // running jobs list must have only one job, task t1 must have number of execution to 0
    TaskInfo ti1 = schedulerHelper.waitForEventTaskWaitingForRestart(id, "t1");
    // task result for t1 must be available with TaskPreemptedException
    TaskResult tr1 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t1");
    log("Restart t2");
    schedulerHelper.getSchedulerInterface().restartTask(id, "t2", 1);
    log("Wait for event t2 waiting for restart");
    // running jobs list must have only one job, task t2 must have number of execution to 1
    TaskInfo ti2 = schedulerHelper.waitForEventTaskWaitingForRestart(id, "t2");
    // task result for t2 must be available with TaskRestartedException
    TaskResult tr2 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t2");
    log("Wait for event t2 running");
    schedulerHelper.waitForEventTaskRunning(id, "t2");
    log("Restart t2 again");
    schedulerHelper.getSchedulerInterface().restartTask(id, "t2", 1);
    log("Wait for event t2 waiting for restart again");
    // running jobs list must have only one job, task t2 must have number of execution to 2
    TaskInfo ti3 = schedulerHelper.waitForEventTaskWaitingForRestart(id, "t2");
    // task result for t2 must be available with TaskRestartedException
    TaskResult tr3 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t2");
    // ensure every tasks are running at this point
    schedulerHelper.waitForEventTaskRunning(id, "t1");
    schedulerHelper.waitForEventTaskRunning(id, "t2");
    log("Kill t3");
    schedulerHelper.getSchedulerInterface().killTask(id, "t3");
    log("Wait for event t3 finished");
    schedulerHelper.waitForEventTaskFinished(id, "t3");
    // task result for t3 must be available with TaskRestartedException
    TaskResult tr4 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t3");
    log("Kill t4");
    schedulerHelper.getSchedulerInterface().killTask(id, "t4");
    log("Wait for event job finished");
    // finished jobs list must have only one job
    JobInfo ji4 = schedulerHelper.waitForEventJobFinished(id);
    // task result for t4 must be TaskRestartedException
    JobState j4 = schedulerHelper.getSchedulerInterface().getJobState(id);
    TaskResult tr5 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t4");
    // check result j1
    assertEquals(2, ti1.getNumberOfExecutionLeft());
    assertTrue(tr1.getException() instanceof TaskPreemptedException);
    // check result j2
    assertEquals(3, ti2.getNumberOfExecutionLeft());
    assertTrue(tr2.getException() instanceof TaskRestartedException);
    // check result j3
    assertEquals(2, ti3.getNumberOfExecutionLeft());
    assertTrue(tr3.getException() instanceof TaskRestartedException);
    // check result tr4
    assertTrue(tr4.getException() instanceof TaskAbortedException);
    // check result j4
    assertEquals(JobStatus.CANCELED, ji4.getStatus());
    TaskStatus t1Status = getTask(j4, "t1").getStatus();
    assertTrue(t1Status.equals(TaskStatus.ABORTED) || t1Status.equals(TaskStatus.NOT_RESTARTED));
    TaskStatus t2Status = getTask(j4, "t2").getStatus();
    assertTrue(t2Status.equals(TaskStatus.ABORTED) || t2Status.equals(TaskStatus.NOT_RESTARTED));
    assertEquals(TaskStatus.FAULTY, getTask(j4, "t3").getStatus());
    assertEquals(TaskStatus.FAULTY, getTask(j4, "t4").getStatus());
    // check result tr5
    // 
    assertTrue(tr5.getException() instanceof Exception);
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskPreemptedException(org.ow2.proactive.scheduler.common.exception.TaskPreemptedException) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) TaskRestartedException(org.ow2.proactive.scheduler.common.exception.TaskRestartedException) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus) TaskAbortedException(org.ow2.proactive.scheduler.common.exception.TaskAbortedException) JobId(org.ow2.proactive.scheduler.common.job.JobId) TaskAbortedException(org.ow2.proactive.scheduler.common.exception.TaskAbortedException) TaskPreemptedException(org.ow2.proactive.scheduler.common.exception.TaskPreemptedException) TaskRestartedException(org.ow2.proactive.scheduler.common.exception.TaskRestartedException)

Example 9 with TaskStatus

use of org.ow2.proactive.scheduler.common.task.TaskStatus in project scheduling by ow2-proactive.

the class TestPreemptRestartKillTaskSchema33 method TestPreemtRestartKillTask.

private void TestPreemtRestartKillTask(String jobDescriptorPath) throws Exception {
    log("Submitting job");
    schedulerHelper.addExtraNodes(3);
    JobId id = schedulerHelper.submitJob(jobDescriptorPath);
    log("Wait for event job submitted");
    schedulerHelper.waitForEventJobSubmitted(id);
    log("Wait for event t1 running");
    schedulerHelper.waitForEventTaskRunning(id, "t1");
    log("Wait for event t2 running");
    schedulerHelper.waitForEventTaskRunning(id, "t2");
    log("Wait for event t3 running");
    schedulerHelper.waitForEventTaskRunning(id, "t3");
    log("Wait for event t4 running");
    schedulerHelper.waitForEventTaskRunning(id, "t4");
    log("Preempt t1");
    schedulerHelper.getSchedulerInterface().preemptTask(id, "t1", 1);
    log("Wait for event t1 waiting for restart");
    // running jobs list must have only one job, task t1 must have number of execution to 0
    TaskInfo ti1 = schedulerHelper.waitForEventTaskWaitingForRestart(id, "t1");
    // task result for t1 must be available with TaskPreemptedException
    TaskResult tr1 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t1");
    log("Restart t2");
    schedulerHelper.getSchedulerInterface().restartTask(id, "t2", 1);
    log("Wait for event t2 waiting for restart");
    // running jobs list must have only one job, task t2 must have number of execution to 1
    TaskInfo ti2 = schedulerHelper.waitForEventTaskWaitingForRestart(id, "t2");
    // task result for t2 must be available with TaskRestartedException
    TaskResult tr2 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t2");
    log("Wait for event t2 running");
    schedulerHelper.waitForEventTaskRunning(id, "t2");
    log("Restart t2 again");
    schedulerHelper.getSchedulerInterface().restartTask(id, "t2", 1);
    log("Wait for event t2 waiting for restart again");
    // running jobs list must have only one job, task t2 must have number of execution to 2
    TaskInfo ti3 = schedulerHelper.waitForEventTaskWaitingForRestart(id, "t2");
    // task result for t2 must be available with TaskRestartedException
    TaskResult tr3 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t2");
    // ensure every tasks are running at this point
    schedulerHelper.waitForEventTaskRunning(id, "t1");
    schedulerHelper.waitForEventTaskRunning(id, "t2");
    log("Kill t3");
    schedulerHelper.getSchedulerInterface().killTask(id, "t3");
    log("Wait for event t3 finished");
    schedulerHelper.waitForEventTaskFinished(id, "t3");
    // task result for t3 must be available with TaskRestartedException
    TaskResult tr4 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t3");
    log("Kill t4");
    schedulerHelper.getSchedulerInterface().killTask(id, "t4");
    log("Wait for event job finished");
    // finished jobs list must have only one job
    JobInfo ji4 = schedulerHelper.waitForEventJobFinished(id);
    // task result for t4 must be TaskRestartedException
    JobState j4 = schedulerHelper.getSchedulerInterface().getJobState(id);
    TaskResult tr5 = schedulerHelper.getSchedulerInterface().getTaskResult(id, "t4");
    // check result j1
    assertEquals(2, ti1.getNumberOfExecutionLeft());
    assertTrue(tr1.getException() instanceof TaskPreemptedException);
    // check result j2
    assertEquals(3, ti2.getNumberOfExecutionLeft());
    assertTrue(tr2.getException() instanceof TaskRestartedException);
    // check result j3
    assertEquals(2, ti3.getNumberOfExecutionLeft());
    assertTrue(tr3.getException() instanceof TaskRestartedException);
    // check result tr4
    assertTrue(tr4.getException() instanceof TaskAbortedException);
    // check result j4
    assertEquals(JobStatus.CANCELED, ji4.getStatus());
    TaskStatus t1Status = getTask(j4, "t1").getStatus();
    assertTrue(t1Status.equals(TaskStatus.ABORTED) || t1Status.equals(TaskStatus.NOT_RESTARTED));
    TaskStatus t2Status = getTask(j4, "t2").getStatus();
    assertTrue(t2Status.equals(TaskStatus.ABORTED) || t2Status.equals(TaskStatus.NOT_RESTARTED));
    assertEquals(TaskStatus.FAULTY, getTask(j4, "t3").getStatus());
    assertEquals(TaskStatus.FAULTY, getTask(j4, "t4").getStatus());
    // check result tr5
    // 
    assertTrue(tr5.getException() instanceof Exception);
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskPreemptedException(org.ow2.proactive.scheduler.common.exception.TaskPreemptedException) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) TaskRestartedException(org.ow2.proactive.scheduler.common.exception.TaskRestartedException) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus) TaskAbortedException(org.ow2.proactive.scheduler.common.exception.TaskAbortedException) JobId(org.ow2.proactive.scheduler.common.job.JobId) TaskAbortedException(org.ow2.proactive.scheduler.common.exception.TaskAbortedException) TaskPreemptedException(org.ow2.proactive.scheduler.common.exception.TaskPreemptedException) TaskRestartedException(org.ow2.proactive.scheduler.common.exception.TaskRestartedException)

Example 10 with TaskStatus

use of org.ow2.proactive.scheduler.common.task.TaskStatus in project scheduling by ow2-proactive.

the class RestSmartProxyTest method testInErrorEventsReception.

@Test(timeout = TEN_MINUTES)
public void testInErrorEventsReception() throws Exception {
    System.out.println("Begin testInErrorEventsReception ");
    TaskFlowJob job = createInErrorJob();
    final Semaphore semaphore = new Semaphore(0);
    printJobXmlRepresentation(job);
    final MutableBoolean taskHasBeenInError = new MutableBoolean(false);
    final MutableBoolean taskMarkedAsFinished = new MutableBoolean(false);
    SchedulerEventListenerExtended listener = new SchedulerEventListenerExtended() {

        @Override
        public void schedulerStateUpdatedEvent(SchedulerEvent eventType) {
            System.out.println("RestSmartProxyTest.schedulerStateUpdatedEvent " + eventType);
        }

        @Override
        public void jobSubmittedEvent(JobState job) {
            System.out.println("RestSmartProxyTest.jobSubmittedEvent");
        }

        @Override
        public void jobStateUpdatedEvent(NotificationData<JobInfo> notification) {
            JobStatus status = notification.getData().getStatus();
            System.out.println("RestSmartProxyTest.jobStateUpdatedEvent, eventType=" + notification.getEventType() + ", jobStatus=" + status);
            if (status == JobStatus.IN_ERROR) {
                semaphore.release();
            }
        }

        @Override
        public void taskStateUpdatedEvent(NotificationData<TaskInfo> notification) {
            TaskStatus status = notification.getData().getStatus();
            System.out.println("RestSmartProxyTest.taskStateUpdatedEvent, taskStatus=" + status);
            if (status == TaskStatus.WAITING_ON_ERROR || status == TaskStatus.IN_ERROR) {
                // IN_ERROR previously
                taskHasBeenInError.setTrue();
            }
            if (status == TaskStatus.FINISHED && taskHasBeenInError.isTrue()) {
                taskMarkedAsFinished.setTrue();
            }
        }

        @Override
        public void usersUpdatedEvent(NotificationData<UserIdentification> notification) {
            System.out.println("RestSmartProxyTest.usersUpdatedEvent " + notification.getData());
        }

        @Override
        public void pullDataFinished(String jobId, String taskName, String localFolderPath) {
            System.out.println("RestSmartProxyTest.pullDataFinished");
        }

        @Override
        public void pullDataFailed(String jobId, String taskName, String remoteFolder_URL, Throwable t) {
            System.out.println("RestSmartProxyTest.pullDataFailed");
        }

        @Override
        public void jobUpdatedFullDataEvent(JobState job) {
            System.out.println("RestSmartProxyTest.jobUpdatedFullDataEvent");
        }
    };
    restSmartProxy.addEventListener(listener);
    JobId jobId = restSmartProxy.submit(job, inputLocalFolder.getAbsolutePath(), pushUrl, outputLocalFolder.getAbsolutePath(), pullUrl, false, false);
    // the next line blocks until jobStateUpdatedEvent is called on the
    // listener
    // with job status set to IN_ERROR
    semaphore.acquire();
    String jobIdAsString = jobId.value();
    System.out.println("Finish in-error task");
    restSmartProxy.finishInErrorTask(jobIdAsString, inerrorTaskName);
    waitForJobFinishState(jobIdAsString);
    assertThat(taskHasBeenInError.booleanValue()).isTrue();
    assertThat(taskMarkedAsFinished.booleanValue()).isTrue();
    System.out.println("End testInErrorEventsReception");
}
Also used : JobStatus(org.ow2.proactive.scheduler.common.job.JobStatus) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) MutableBoolean(org.apache.commons.lang3.mutable.MutableBoolean) JobState(org.ow2.proactive.scheduler.common.job.JobState) SchedulerEventListenerExtended(org.ow2.proactive.scheduler.smartproxy.common.SchedulerEventListenerExtended) Semaphore(java.util.concurrent.Semaphore) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus) JobId(org.ow2.proactive.scheduler.common.job.JobId) SchedulerEvent(org.ow2.proactive.scheduler.common.SchedulerEvent) NotificationData(org.ow2.proactive.scheduler.common.NotificationData) Test(org.junit.Test)

Aggregations

TaskStatus (org.ow2.proactive.scheduler.common.task.TaskStatus)16 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)8 Test (org.junit.Test)7 RecoveredSchedulerState (org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState)6 TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)5 JobId (org.ow2.proactive.scheduler.common.job.JobId)4 Query (org.hibernate.Query)3 JobState (org.ow2.proactive.scheduler.common.job.JobState)3 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)3 TaskAbortedException (org.ow2.proactive.scheduler.common.exception.TaskAbortedException)2 TaskPreemptedException (org.ow2.proactive.scheduler.common.exception.TaskPreemptedException)2 TaskRestartedException (org.ow2.proactive.scheduler.common.exception.TaskRestartedException)2 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)2 JobStatus (org.ow2.proactive.scheduler.common.job.JobStatus)2 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)2 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)2 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Semaphore (java.util.concurrent.Semaphore)1 MutableBoolean (org.apache.commons.lang3.mutable.MutableBoolean)1