use of org.ow2.proactive.scheduler.task.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.task.TaskResultImpl in project scheduling by ow2-proactive.
the class TestLoadJobResult method testEmptyResult.
@Test
public void testEmptyResult() throws Throwable {
TaskFlowJob jobDef = new TaskFlowJob();
jobDef.addTask(createDefaultTask("task1"));
InternalJob job = defaultSubmitJobAndLoadInternal(true, jobDef);
InternalTask task1 = job.getTask("task1");
JobResult result;
result = dbManager.loadJobResult(job.getId());
Assert.assertNotNull(result.getJobInfo());
Assert.assertEquals(0, result.getAllResults().size());
Assert.assertEquals(1, result.getJobInfo().getTotalNumberOfTasks());
dbManager.updateAfterTaskFinished(job, task1, new TaskResultImpl(null, new TestResult(0, "1_1"), null, 0));
result = dbManager.loadJobResult(job.getId());
Assert.assertNotNull(result.getJobInfo());
Assert.assertEquals(1, result.getAllResults().size());
Assert.assertEquals(1, result.getJobInfo().getTotalNumberOfTasks());
}
use of org.ow2.proactive.scheduler.task.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.SUBMITTED), true).withPending(task("T1*1", TaskStatus.SUBMITTED), true).withPending(task("T2", TaskStatus.SUBMITTED), true).withPending(task("T3", TaskStatus.SUBMITTED), true).withPending(task("T2*1", TaskStatus.SUBMITTED), true).withPending(task("T3*1", TaskStatus.SUBMITTED), true).withPending(task("T4", TaskStatus.SUBMITTED), true).withEligible("T1", "T1*1");
checkRecoveredState(recoverHelper.recover(-1), state().withRunning(expectedJob));
}
use of org.ow2.proactive.scheduler.task.TaskResultImpl in project scheduling by ow2-proactive.
the class TerminationData method getStringSerializableMap.
public VariablesMap getStringSerializableMap(SchedulingService service, TaskTerminationData taskToTerminate) throws Exception {
VariablesMap variablesMap = new VariablesMap();
RunningTaskData taskData = taskToTerminate.taskData;
TaskResultImpl taskResult = taskToTerminate.taskResult;
InternalJob internalJob = taskToTerminate.internalJob;
if (taskToTerminate.terminationStatus == ABORTED || taskResult == null) {
List<InternalTask> iDependences = taskData.getTask().getIDependences();
if (iDependences != null) {
taskData.getTask().updateParentTasksResults(service);
getResultsFromListOfTaskResults(variablesMap.getInheritedMap(), taskData.getTask().getParentTasksResults());
} else {
if (internalJob != null) {
for (Map.Entry<String, JobVariable> jobVariableEntry : internalJob.getVariables().entrySet()) {
variablesMap.getInheritedMap().put(jobVariableEntry.getKey(), jobVariableEntry.getValue().getValue());
}
}
}
variablesMap.getInheritedMap().put(SchedulerVars.PA_TASK_SUCCESS.toString(), Boolean.toString(false));
} else if (taskResult.hadException()) {
variablesMap.setInheritedMap(fillMapWithTaskResult(taskResult, false));
} else {
variablesMap.setInheritedMap(fillMapWithTaskResult(taskResult, true));
}
variablesMap.setScopeMap(getNonInheritedScopeVariables(variablesMap.getInheritedMap(), taskData.getTask().getScopeVariables(), taskData.getTask().getVariables()));
return variablesMap;
}
use of org.ow2.proactive.scheduler.task.TaskResultImpl in project scheduling by ow2-proactive.
the class SchedulerFrontend method getTaskResultFromIncarnation.
/**
* {@inheritDoc}
*/
@Override
@ImmediateService
public TaskResult getTaskResultFromIncarnation(JobId jobId, String taskName, int inc) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException {
// checking permissions
frontendState.checkPermissions("getTaskResultFromIncarnation", frontendState.getIdentifiedJob(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_RESULT_OF_THIS_JOB);
if (inc < 0) {
throw new IllegalArgumentException("Incarnation must be 0 or greater.");
}
logger.debug("Job " + jobId + ", trying to get the task result, incarnation " + inc);
try {
TaskResult result = dbManager.loadTaskResult(jobId, taskName, inc);
// handling special statuses
TaskState ts = frontendState.getTaskState(jobId, taskName);
switch(ts.getStatus()) {
case NOT_STARTED:
if (result == null) {
return new TaskResultImpl(frontendState.getTaskId(jobId, taskName), new TaskCouldNotStartException(), new SimpleTaskLogs("", "The task could not start due to dependency failure"), 0);
} else {
Throwable newException = new TaskCouldNotStartException("The task could not start due to dependency failure", result.getException());
((TaskResultImpl) result).setException(newException);
}
break;
case NOT_RESTARTED:
if (result == null) {
return new TaskResultImpl(frontendState.getTaskId(jobId, taskName), new TaskCouldNotRestartException(), new SimpleTaskLogs("", "The task could not be restarted after an error during the previous execution"), 0);
} else {
Throwable newException = new TaskCouldNotRestartException("The task could not be restarted after an error during the previous execution", result.getException());
((TaskResultImpl) result).setException(newException);
}
break;
case SKIPPED:
// result should always be null
return new TaskResultImpl(frontendState.getTaskId(jobId, taskName), new TaskSkippedException(), new SimpleTaskLogs("", "The task was skipped in the workflow"), 0);
default:
if (result == null) {
// otherwise the task is not finished
logger.info("Task " + taskName + " of job " + jobId + " is not finished");
}
break;
}
return result;
} catch (DatabaseManagerException e) {
throw new UnknownTaskException("Unknown task " + taskName + ", job: " + jobId);
}
}
Aggregations