Search in sources :

Example 86 with TaskResultImpl

use of org.ow2.proactive.scheduler.rest.data.TaskResultImpl in project scheduling by ow2-proactive.

the class SchedulingServiceTest1 method testSimpleJob.

@Test
public void testSimpleJob() throws Exception {
    service.submitJob(createJob(createTestJob()));
    listener.assertEvents(SchedulerEvent.JOB_SUBMITTED);
    Map<JobId, JobDescriptor> jobsMap;
    JobDescriptor jobDesc;
    jobsMap = service.lockJobsToSchedule();
    assertEquals(1, jobsMap.size());
    jobDesc = jobsMap.values().iterator().next();
    Assert.assertEquals(1, jobDesc.getEligibleTasks().size());
    taskStarted(jobDesc, (EligibleTaskDescriptor) jobDesc.getEligibleTasks().iterator().next());
    service.unlockJobsToSchedule(jobsMap.values());
    jobsMap = service.lockJobsToSchedule();
    assertEquals(1, jobsMap.size());
    jobDesc = jobsMap.values().iterator().next();
    Assert.assertEquals(0, jobDesc.getEligibleTasks().size());
    service.unlockJobsToSchedule(jobsMap.values());
    TaskId taskId = ((JobDescriptorImpl) jobDesc).getInternal().getTask("task1").getId();
    service.taskTerminatedWithResult(taskId, new TaskResultImpl(taskId, "Result", null, 0));
    jobsMap = service.lockJobsToSchedule();
    // when a job finishes, it isn't removed from the hibernate context unless
    // the housekeeping mechanism is enabled
    assertEquals(1, jobsMap.size());
    listener.assertEvents(SchedulerEvent.JOB_PENDING_TO_RUNNING, SchedulerEvent.JOB_UPDATED, SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_RUNNING_TO_FINISHED, SchedulerEvent.JOB_RUNNING_TO_FINISHED, SchedulerEvent.JOB_UPDATED);
    infrastructure.assertRequests(1);
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) JobDescriptor(org.ow2.proactive.scheduler.common.JobDescriptor) JobDescriptorImpl(org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 87 with TaskResultImpl

use of org.ow2.proactive.scheduler.rest.data.TaskResultImpl in project scheduling by ow2-proactive.

the class SchedulingServiceTest4 method testTaskRestart1.

@Test
public void testTaskRestart1() throws Exception {
    service.submitJob(createJob(createTestJob()));
    listener.assertEvents(SchedulerEvent.JOB_SUBMITTED);
    JobDescriptor jobDesc = startTask();
    try {
        service.restartTask(jobDesc.getJobId(), "invalid task name", 100);
        Assert.fail();
    } catch (UnknownTaskException e) {
    }
    try {
        service.restartTask(JobIdImpl.makeJobId("1234567"), "javaTask", 100);
        Assert.fail();
    } catch (UnknownJobException e) {
    }
    service.restartTask(jobDesc.getJobId(), "javaTask", 100);
    listener.assertEvents(SchedulerEvent.JOB_PENDING_TO_RUNNING, SchedulerEvent.JOB_UPDATED, SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_WAITING_FOR_RESTART);
    infrastructure.assertRequests(1);
    startTask();
    TaskId taskId = ((JobDescriptorImpl) jobDesc).getInternal().getTask("javaTask").getId();
    service.taskTerminatedWithResult(taskId, new TaskResultImpl(taskId, "OK", null, 0));
    listener.assertEvents(SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_RUNNING_TO_FINISHED, SchedulerEvent.JOB_RUNNING_TO_FINISHED, SchedulerEvent.JOB_UPDATED);
    infrastructure.assertRequests(1);
}
Also used : UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) JobDescriptor(org.ow2.proactive.scheduler.common.JobDescriptor) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) JobDescriptorImpl(org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl) Test(org.junit.Test)

Example 88 with TaskResultImpl

use of org.ow2.proactive.scheduler.rest.data.TaskResultImpl in project scheduling by ow2-proactive.

the class TestLoadJobResult method testLoadJobResult.

@Test
public void testLoadJobResult() throws Throwable {
    TaskFlowJob job = new TaskFlowJob();
    ForkEnvironment forkEnvironment = new ForkEnvironment();
    forkEnvironment.addAdditionalClasspath("/path1/path1");
    forkEnvironment.addAdditionalClasspath("/path2/path2");
    JavaTask javaTask1 = createDefaultTask("task1");
    javaTask1.setPreciousResult(true);
    javaTask1.setForkEnvironment(forkEnvironment);
    job.addTask(javaTask1);
    for (int i = 2; i <= 4; i++) {
        JavaTask task = createDefaultTask("task" + i);
        task.setForkEnvironment(forkEnvironment);
        job.addTask(task);
    }
    JavaTask javaTask5 = createDefaultTask("task5");
    javaTask5.setPreciousResult(true);
    javaTask5.setForkEnvironment(forkEnvironment);
    job.addTask(javaTask5);
    InternalJob internalJob = defaultSubmitJobAndLoadInternal(true, job);
    InternalTask task1 = internalJob.getTask("task1");
    InternalTask task2 = internalJob.getTask("task2");
    InternalTask task3 = internalJob.getTask("task3");
    InternalTask task4 = internalJob.getTask("task4");
    InternalTask task5 = internalJob.getTask("task5");
    dbManager.updateAfterTaskFinished(internalJob, task1, new TaskResultImpl(null, new TestResult(0, "1_1"), null, 0));
    dbManager.updateAfterTaskFinished(internalJob, task1, new TaskResultImpl(null, new TestResult(0, "1_2"), null, 0));
    dbManager.updateAfterTaskFinished(internalJob, task2, new TaskResultImpl(null, new TestResult(0, "2_1"), null, 0));
    dbManager.updateAfterTaskFinished(internalJob, task2, new TaskResultImpl(null, new TestResult(0, "2_2"), null, 0));
    dbManager.updateAfterTaskFinished(internalJob, task3, new TaskResultImpl(null, new TestResult(0, "3_1"), null, 0));
    dbManager.updateAfterTaskFinished(internalJob, task4, new TaskResultImpl(null, new TestException("message4_1", "data4_1"), null, 0));
    dbManager.updateAfterTaskFinished(internalJob, task4, new TaskResultImpl(null, new TestException("message4_2", "data4_2"), null, 0));
    dbManager.updateAfterTaskFinished(internalJob, task5, new TaskResultImpl(null, new TestException("message5_1", "data5_1"), null, 0));
    TaskFlowJob job2 = new TaskFlowJob();
    job2.addTask(createDefaultTask("job2 task1"));
    InternalJob internalJob2 = defaultSubmitJobAndLoadInternal(true, job2);
    InternalTask task2_1 = internalJob2.getTask("job2 task1");
    dbManager.updateAfterTaskFinished(internalJob2, task2_1, new TaskResultImpl(null, new TestResult(0, "job2_task1"), null, 0));
    System.out.println("Load job result1");
    JobResult result = dbManager.loadJobResult(internalJob.getId());
    Assert.assertEquals(5, result.getAllResults().size());
    Assert.assertEquals(2, result.getExceptionResults().size());
    Assert.assertEquals(2, result.getPreciousResults().size());
    Assert.assertNotNull(result.getJobInfo());
    Assert.assertEquals(internalJob.getId(), result.getJobId());
    Assert.assertEquals(5, result.getJobInfo().getTotalNumberOfTasks());
    TestResult taskResultValue;
    taskResultValue = (TestResult) result.getResult("task1").value();
    Assert.assertEquals("1_2", taskResultValue.getB());
    taskResultValue = (TestResult) result.getResult("task2").value();
    Assert.assertEquals("2_2", taskResultValue.getB());
    taskResultValue = (TestResult) result.getResult("task3").value();
    Assert.assertEquals("3_1", taskResultValue.getB());
    TestException taskException;
    taskException = (TestException) result.getResult("task4").getException();
    Assert.assertEquals("message4_2", taskException.getMessage());
    taskException = (TestException) result.getResult("task5").getException();
    Assert.assertEquals("message5_1", taskException.getMessage());
    System.out.println("Load job result2");
    result = dbManager.loadJobResult(internalJob2.getId());
    Assert.assertEquals(1, result.getAllResults().size());
    Assert.assertEquals(0, result.getExceptionResults().size());
    Assert.assertEquals(0, result.getPreciousResults().size());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) JobResult(org.ow2.proactive.scheduler.common.job.JobResult) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) Test(org.junit.Test)

Example 89 with TaskResultImpl

use of org.ow2.proactive.scheduler.rest.data.TaskResultImpl in project scheduling by ow2-proactive.

the class TestLoadSchedulerClientState method testStateAfterTaskFinished.

@Test
public void testStateAfterTaskFinished() throws Exception {
    TaskFlowJob jobDef = new TaskFlowJob();
    JavaTask taskDef1 = createDefaultTask("task1");
    JavaTask taskDef2 = createDefaultTask("task2");
    taskDef2.addDependence(taskDef1);
    jobDef.addTask(taskDef1);
    jobDef.addTask(taskDef2);
    InternalJob job = defaultSubmitJobAndLoadInternal(true, jobDef);
    InternalTask task1 = job.getTask("task1");
    job.start();
    startTask(job, task1);
    dbManager.jobTaskStarted(job, task1, true);
    TaskResultImpl result = new TaskResultImpl(null, new TestResult(1, "res1"), null, 1000);
    terminateTask(job, task1, result);
    dbManager.updateAfterTaskFinished(job, task1, result);
    SchedulerStateRecoverHelper stateRecoverHelper = new SchedulerStateRecoverHelper(dbManager);
    RecoveredSchedulerState recovered;
    recovered = stateRecoverHelper.recover(-1);
    JobStateMatcher expectedJob;
    expectedJob = job(job.getId(), JobStatus.STALLED).withFinished(task("task1", TaskStatus.FINISHED).checkFinished()).withPending(task("task2", TaskStatus.PENDING), true).withEligible("task2");
    checkRecoveredState(recovered, state().withRunning(expectedJob));
    job = recovered.getRunningJobs().get(0);
    InternalTask task2 = job.getTask("task2");
    startTask(job, task2);
    dbManager.jobTaskStarted(job, task2, false);
    expectedJob = job(job.getId(), JobStatus.STALLED).withFinished(task("task1", TaskStatus.FINISHED).checkFinished()).withPending(task("task2", TaskStatus.PENDING), true).withEligible("task2");
    recovered = stateRecoverHelper.recover(-1);
    checkRecoveredState(recovered, state().withRunning(expectedJob));
    job = recovered.getRunningJobs().get(0);
    task2 = job.getTask("task2");
    startTask(job, task2);
    dbManager.jobTaskStarted(job, task2, false);
    terminateTask(job, task2, result);
    dbManager.updateAfterTaskFinished(job, task2, result);
    expectedJob = job(job.getId(), JobStatus.FINISHED).withFinished(task("task1", TaskStatus.FINISHED).checkFinished()).withFinished(task("task2", TaskStatus.FINISHED).checkFinished());
    recovered = stateRecoverHelper.recover(-1);
    checkRecoveredState(recovered, state().withFinished(expectedJob));
}
Also used : RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SchedulerStateRecoverHelper(org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) Test(org.junit.Test)

Example 90 with TaskResultImpl

use of org.ow2.proactive.scheduler.rest.data.TaskResultImpl in project scheduling by ow2-proactive.

the class TestLoadSchedulerClientState method testStateAfterJobEnd.

@Test
public void testStateAfterJobEnd() throws Exception {
    TaskFlowJob jobDef = new TaskFlowJob();
    jobDef.addTask(createDefaultTask("task1"));
    InternalJob job = defaultSubmitJobAndLoadInternal(false, jobDef);
    dbManager.removeJob(job.getId(), System.currentTimeMillis(), false);
    jobDef = new TaskFlowJob();
    jobDef.addTask(createDefaultTask("task1"));
    jobDef.addTask(createDefaultTask("task2"));
    job = defaultSubmitJobAndLoadInternal(true, jobDef);
    InternalTask task1 = job.getTask("task1");
    InternalTask task2 = job.getTask("task2");
    job.start();
    startTask(job, task1);
    dbManager.jobTaskStarted(job, task1, true);
    startTask(job, task2);
    dbManager.jobTaskStarted(job, task2, false);
    // task 2 finished with error, stop job
    Set<TaskId> ids = job.failed(task2.getId(), JobStatus.CANCELED);
    TaskResultImpl res = new TaskResultImpl(null, new TestException("message", "data"), null, 0);
    dbManager.updateAfterJobFailed(job, task2, res, ids);
    SchedulerStateRecoverHelper stateRecoverHelper = new SchedulerStateRecoverHelper(dbManager);
    JobStateMatcher expectedJob = job(job.getId(), JobStatus.CANCELED).withFinished(task("task1", TaskStatus.ABORTED).checkFinished(), false).withFinished(task("task2", TaskStatus.FAULTY).checkFinished()).checkFinished();
    checkRecoveredState(stateRecoverHelper.recover(-1), state().withFinished(expectedJob));
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SchedulerStateRecoverHelper(org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper) Test(org.junit.Test)

Aggregations

TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)73 Test (org.junit.Test)70 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)32 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)30 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)26 SimpleScript (org.ow2.proactive.scripting.SimpleScript)26 TaskScript (org.ow2.proactive.scripting.TaskScript)26 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)25 TaskContext (org.ow2.proactive.scheduler.task.context.TaskContext)25 NodeDataSpacesURIs (org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs)22 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)21 JobId (org.ow2.proactive.scheduler.common.job.JobId)16 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)16 InProcessTaskExecutor (org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor)15 HashMap (java.util.HashMap)13 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)13 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)13 SimpleTaskLogs (org.ow2.proactive.scheduler.common.task.SimpleTaskLogs)12 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)11 TaskLauncherInitializer (org.ow2.proactive.scheduler.task.TaskLauncherInitializer)10