use of org.ow2.proactive.scheduler.common.exception.TaskSkippedException in project scheduling by ow2-proactive.
the class TestTaskNotExecuted method testTaskNotExecuted.
private void testTaskNotExecuted(String jobDescriptorPath1, String jobDescriptorPath2, String jobDescriptorPath3) throws Exception {
log("Submitting job 1");
JobId id1 = schedulerHelper.submitJob(jobDescriptorPath1);
log("Wait for event job 1 submitted");
schedulerHelper.waitForEventJobSubmitted(id1);
log("Wait for event t1 running");
schedulerHelper.waitForEventTaskRunning(id1, "t0");
schedulerHelper.waitForEventTaskFinished(id1, "t0");
schedulerHelper.waitForEventJobFinished(id1);
TaskResult tr1 = schedulerHelper.getSchedulerInterface().getTaskResult(id1, "t1");
assertTrue(tr1.getException() instanceof TaskCouldNotStartException);
log("Submitting job 2");
JobId id2 = schedulerHelper.submitJob(jobDescriptorPath2);
log("Wait for event job 2 submitted");
schedulerHelper.waitForEventJobSubmitted(id2);
log("Wait for event t2 running");
schedulerHelper.waitForEventTaskRunning(id2, "t2");
log("Restarting task");
schedulerHelper.getSchedulerInterface().restartTask(id2, "t2", Integer.MAX_VALUE);
TaskInfo ti2 = schedulerHelper.waitForEventTaskWaitingForRestart(id2, "t2");
schedulerHelper.getSchedulerInterface().killJob(id2);
schedulerHelper.waitForEventJobFinished(id2);
JobState jobState = schedulerHelper.getSchedulerInterface().getJobState(id2);
Assert.assertEquals(TaskStatus.NOT_RESTARTED, jobState.getTasks().get(0).getStatus());
TaskResult tr2 = schedulerHelper.getSchedulerInterface().getTaskResult(id2, "t2");
assertTrue(tr2.getException() instanceof TaskCouldNotRestartException);
log("Submitting job 3");
JobId id3 = schedulerHelper.submitJob(jobDescriptorPath3);
log("Wait for event job 3 submitted");
schedulerHelper.waitForEventJobSubmitted(id3);
log("Wait for event T T1 T2 finished");
schedulerHelper.waitForEventTaskFinished(id3, "T");
schedulerHelper.waitForEventTaskFinished(id3, "T1");
TaskResult tr3_1 = schedulerHelper.getSchedulerInterface().getTaskResult(id3, "T1");
TaskResult tr3_2 = schedulerHelper.getSchedulerInterface().getTaskResult(id3, "T2");
assertNull(tr3_1.getException());
assertTrue(tr3_2.getException() instanceof TaskSkippedException);
}
use of org.ow2.proactive.scheduler.common.exception.TaskSkippedException 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.");
}
jlogger.debug(jobId, "trying to get the task result, incarnation " + inc);
if (inc < 0) {
throw new IllegalArgumentException("Incarnation must be 0 or greater.");
}
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);
}
if (result == null) {
// otherwise the task is not finished
jlogger.info(jobId, taskName + " is not finished");
return null;
} else {
return result;
}
} catch (DatabaseManagerException e) {
throw new UnknownTaskException("Unknown task " + taskName + ", job: " + jobId);
}
}
Aggregations