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));
}
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");
}
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());
}
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());
}
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());
}
Aggregations