Search in sources :

Example 36 with TaskResultImpl

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

the class TestRestoreWorkflowJobs method test.

@Test
public void test() throws Exception {
    TaskFlowJob jobDef = createJob();
    InternalJob job = defaultSubmitJobAndLoadInternal(true, jobDef);
    job.start();
    InternalTask mainTask = job.getTask("T");
    startTask(job, mainTask);
    dbManager.jobTaskStarted(job, mainTask, true);
    TaskResultImpl result = new TaskResultImpl(mainTask.getId(), "ok", null, 0);
    FlowAction action = new FlowAction(FlowActionType.REPLICATE);
    action.setDupNumber(2);
    ChangedTasksInfo changesInfo = job.terminateTask(false, mainTask.getId(), null, action, result);
    dbManager.updateAfterWorkflowTaskFinished(job, changesInfo, result);
    SchedulerStateRecoverHelper recoverHelper = new SchedulerStateRecoverHelper(dbManager);
    JobStateMatcher expectedJob;
    expectedJob = job(job.getId(), JobStatus.STALLED).withFinished(task("T", TaskStatus.FINISHED).checkFinished(), true).withPending(task("T1", TaskStatus.PENDING), true).withPending(task("T1*1", TaskStatus.SUBMITTED), true).withPending(task("T2", TaskStatus.PENDING), true).withPending(task("T3", TaskStatus.PENDING), true).withPending(task("T2*1", TaskStatus.SUBMITTED), true).withPending(task("T3*1", TaskStatus.SUBMITTED), true).withPending(task("T4", TaskStatus.PENDING), true).withEligible("T1", "T1*1");
    checkRecoveredState(recoverHelper.recover(-1), state().withRunning(expectedJob));
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) ChangedTasksInfo(org.ow2.proactive.scheduler.job.ChangedTasksInfo) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) FlowAction(org.ow2.proactive.scheduler.common.task.flow.FlowAction) 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)

Example 37 with TaskResultImpl

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

the class TestRestoreWorkflowJobs2 method test.

@Test
public void test() throws Exception {
    TaskFlowJob jobDef = createJob();
    InternalJob job = defaultSubmitJobAndLoadInternal(true, jobDef);
    job.start();
    InternalTask mainTask = job.getTask("A");
    startTask(job, mainTask);
    dbManager.jobTaskStarted(job, mainTask, true);
    TaskResultImpl result = new TaskResultImpl(mainTask.getId(), "ok", null, 0);
    FlowAction action = new FlowAction(FlowActionType.IF);
    action.setDupNumber(1);
    action.setTarget("B");
    action.setTargetElse("C");
    ChangedTasksInfo changesInfo = job.terminateTask(false, mainTask.getId(), null, action, result);
    dbManager.updateAfterWorkflowTaskFinished(job, changesInfo, result);
    SchedulerStateRecoverHelper recoverHelper = new SchedulerStateRecoverHelper(dbManager);
    RecoveredSchedulerState state = recoverHelper.recover(-1);
    job = state.getRunningJobs().get(0);
    System.out.println("OK");
}
Also used : RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) ChangedTasksInfo(org.ow2.proactive.scheduler.job.ChangedTasksInfo) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) FlowAction(org.ow2.proactive.scheduler.common.task.flow.FlowAction) 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)

Example 38 with TaskResultImpl

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

the class TestTaskResultData method testFlowAction.

@Test
public void testFlowAction() throws Exception {
    InternalJob job = saveSingleTask(createDefaultTask("task"));
    InternalTask task = (InternalTask) job.getTasks().get(0);
    TaskResultImpl result = new TaskResultImpl(null, new TestResult(10, "12345"), null, 0);
    FlowAction action = new FlowAction(FlowActionType.LOOP);
    action.setDupNumber(33);
    action.setTarget("t");
    action.setTargetContinuation("tc");
    action.setTargetElse("te");
    result.setAction(action);
    dbManager.updateAfterTaskFinished(job, task, result);
    TaskResultImpl restoredResult = (TaskResultImpl) dbManager.loadLastTaskResult(task.getId());
    FlowAction restoredAction = restoredResult.getAction();
    Assert.assertNotNull(restoredAction);
    Assert.assertEquals(FlowActionType.LOOP, restoredAction.getType());
    Assert.assertEquals(33, restoredAction.getDupNumber());
    Assert.assertEquals("t", restoredAction.getTarget());
    Assert.assertEquals("tc", restoredAction.getTargetContinuation());
    Assert.assertEquals("te", restoredAction.getTargetElse());
    restoredResult = (TaskResultImpl) dbManager.loadTaskResult(job.getId(), "task", 0);
    restoredAction = restoredResult.getAction();
    Assert.assertEquals(FlowActionType.LOOP, restoredAction.getType());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) FlowAction(org.ow2.proactive.scheduler.common.task.flow.FlowAction) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) Test(org.junit.Test)

Example 39 with TaskResultImpl

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

the class TestTaskResultData method testExceptionResult.

@Test
public void testExceptionResult() throws Throwable {
    InternalJob job = saveSingleTask(createDefaultTask("task"));
    TaskResultImpl result = new TaskResultImpl(null, new TestException("message", "data"), null, 0);
    InternalTask task = (InternalTask) job.getTasks().get(0);
    dbManager.updateAfterTaskFinished(job, task, result);
    TaskResult restoredResult = dbManager.loadLastTaskResult(task.getId());
    TestException exception = (TestException) restoredResult.getException();
    Assert.assertNotNull(exception);
    Assert.assertEquals("message", exception.getMessage());
    Assert.assertEquals("data", exception.getData());
    try {
        restoredResult.value();
        Assert.fail("Exception is expected");
    } catch (TestException e) {
    }
    Assert.assertNull(restoredResult.getOutput());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) Test(org.junit.Test)

Example 40 with TaskResultImpl

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

the class TestTaskResultData method testMultipleResults.

@Test
public void testMultipleResults() throws Throwable {
    TaskFlowJob job = new TaskFlowJob();
    job.addTask(createDefaultTask("task1"));
    job.addTask(createDefaultTask("task2"));
    job.addTask(createDefaultTask("task3"));
    InternalJob internalJob = defaultSubmitJobAndLoadInternal(true, job);
    InternalTask task1 = internalJob.getTask("task1");
    InternalTask task2 = internalJob.getTask("task2");
    InternalTask task3 = internalJob.getTask("task3");
    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, task1, new TaskResultImpl(null, new TestResult(0, "1_3"), 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, task2, new TaskResultImpl(null, new TestResult(0, "2_3"), null, 0));
    dbManager.updateAfterTaskFinished(internalJob, task3, new TaskResultImpl(null, new TestResult(0, "3_1"), null, 0));
    dbManager.updateAfterTaskFinished(internalJob, task3, new TaskResultImpl(null, new TestResult(0, "3_2"), null, 0));
    dbManager.updateAfterTaskFinished(internalJob, task3, new TaskResultImpl(null, new TestResult(0, "3_3"), null, 0));
    TestResult result;
    result = (TestResult) dbManager.loadLastTaskResult(task1.getId()).value();
    Assert.assertEquals("1_3", result.getB());
    result = (TestResult) dbManager.loadTaskResult(internalJob.getId(), task1.getName(), 0).value();
    Assert.assertEquals("1_3", result.getB());
    result = (TestResult) dbManager.loadLastTaskResult(task2.getId()).value();
    Assert.assertEquals("2_3", result.getB());
    result = (TestResult) dbManager.loadTaskResult(internalJob.getId(), task2.getName(), 0).value();
    Assert.assertEquals("2_3", result.getB());
    result = (TestResult) dbManager.loadLastTaskResult(task3.getId()).value();
    Assert.assertEquals("3_3", result.getB());
    result = (TestResult) dbManager.loadTaskResult(internalJob.getId(), task3.getName(), 0).value();
    Assert.assertEquals("3_3", result.getB());
    result = (TestResult) dbManager.loadTaskResult(task2.getId(), 0).value();
    Assert.assertEquals("2_3", result.getB());
    result = (TestResult) dbManager.loadTaskResult(internalJob.getId(), task2.getName(), 0).value();
    Assert.assertEquals("2_3", result.getB());
    result = (TestResult) dbManager.loadTaskResult(task2.getId(), 1).value();
    Assert.assertEquals("2_2", result.getB());
    result = (TestResult) dbManager.loadTaskResult(internalJob.getId(), task2.getName(), 1).value();
    Assert.assertEquals("2_2", result.getB());
    result = (TestResult) dbManager.loadTaskResult(task2.getId(), 2).value();
    Assert.assertEquals("2_1", result.getB());
    result = (TestResult) dbManager.loadTaskResult(internalJob.getId(), task2.getName(), 2).value();
    Assert.assertEquals("2_1", result.getB());
    Assert.assertNull(dbManager.loadTaskResult(task2.getId(), 3));
    Assert.assertNull(dbManager.loadTaskResult(internalJob.getId(), task2.getName(), 3));
    List<TaskId> taskIds = Arrays.asList(task1.getId(), task2.getId(), task3.getId());
    System.out.println("Load results for 3 tasks");
    Map<TaskId, TaskResult> results = dbManager.loadTasksResults(internalJob.getId(), taskIds);
    Assert.assertEquals(3, results.size());
    result = (TestResult) results.get(task1.getId()).value();
    Assert.assertEquals("1_3", result.getB());
    result = (TestResult) results.get(task2.getId()).value();
    Assert.assertEquals("2_3", result.getB());
    result = (TestResult) results.get(task3.getId()).value();
    Assert.assertEquals("3_3", result.getB());
    taskIds = Arrays.asList(task2.getId(), task3.getId());
    System.out.println("Load results for 2 tasks");
    results = dbManager.loadTasksResults(internalJob.getId(), taskIds);
    Assert.assertEquals(2, results.size());
    result = (TestResult) results.get(task2.getId()).value();
    Assert.assertEquals("2_3", result.getB());
    result = (TestResult) results.get(task3.getId()).value();
    Assert.assertEquals("3_3", result.getB());
}
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) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) 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