use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.
the class SchedulingServiceTest2 method testFailedTask.
private void testFailedTask(boolean failNativeTask) 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(2, jobDesc.getEligibleTasks().size());
for (TaskDescriptor taskDesc : jobDesc.getEligibleTasks()) {
taskStarted(jobDesc, (EligibleTaskDescriptor) taskDesc);
}
service.unlockJobsToSchedule(jobsMap.values());
if (failNativeTask) {
InternalTask nativeTask = ((JobDescriptorImpl) jobDesc).getInternal().getTask("nativeTask");
// native task terminates with code 1, flag 'cancelJobOnError' was
// set so job should be cancelled
service.taskTerminatedWithResult(nativeTask.getId(), new TaskResultImpl(nativeTask.getId(), new RuntimeException(), null, 0));
} else {
InternalTask javaTask = ((JobDescriptorImpl) jobDesc).getInternal().getTask("javaTask");
// java task terminates with exception, flag 'cancelJobOnError' was
// set so job should be cancelled
service.taskTerminatedWithResult(javaTask.getId(), new TaskResultImpl(javaTask.getId(), new RuntimeException(), null, 0));
}
jobsMap = service.lockJobsToSchedule();
assertEquals(0, jobsMap.size());
listener.assertEvents(SchedulerEvent.JOB_PENDING_TO_RUNNING, SchedulerEvent.JOB_UPDATED, SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_RUNNING_TO_FINISHED, SchedulerEvent.TASK_RUNNING_TO_FINISHED, SchedulerEvent.JOB_RUNNING_TO_FINISHED, SchedulerEvent.JOB_UPDATED);
infrastructure.assertRequests(2);
}
use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.
the class OnErrorPolicyInterpreterTest method createTask.
private InternalTask createTask() {
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
InternalTask task = new InternalTask(job) {
@Override
public boolean handleResultsArguments() {
// TODO Auto-generated method stub
return false;
}
@Override
public TaskLauncher createLauncher(Node node) throws ActiveObjectCreationException, NodeException {
// TODO Auto-generated method stub
return null;
}
};
return task;
}
use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.
the class SchedulingServiceTest method testRestartTaskOnNodeFailure.
@Test
public void testRestartTaskOnNodeFailure() {
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
InternalTask task = new InternalScriptTask(job);
ExecutorService executorService = Mockito.mock(ExecutorService.class);
Mockito.when(infrastructure.getInternalOperationsThreadPool()).thenReturn(executorService);
schedulingService.restartTaskOnNodeFailure(task);
Mockito.verify(executorService, Mockito.times(1)).submit(any(Runnable.class));
}
use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.
the class TerminationDataTest method testHandleTerminationForTaskNodeFailureTermination.
@Test
public void testHandleTerminationForTaskNodeFailureTermination() throws IOException, ClassNotFoundException {
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
JobId jobId = new JobIdImpl(666, "readableName");
InternalTask internalTask = new InternalScriptTask(job);
TaskId taskId = TaskIdImpl.createTaskId(jobId, "task-name", 777L);
internalTask.setId(taskId);
internalTask.setName("task-name");
internalTask.setStatus(TaskStatus.RUNNING);
internalTask.setExecuterInformation(Mockito.mock(ExecuterInformation.class));
RunningTaskData taskData = new RunningTaskData(internalTask, "user", null, launcher);
terminationData.addTaskData(null, taskData, TerminationData.TerminationStatus.NODEFAILED, null);
terminationData.handleTermination(service);
Mockito.verify(launcher, Mockito.times(0)).kill();
}
use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.
the class TaskResultCreatorTest method getMockedInternalTask.
private InternalTask getMockedInternalTask() {
InternalTask mockedInternalTask = mock(InternalScriptTask.class);
TaskInfo mockedTaskInfo = this.getMockedTaskInfo();
when(mockedInternalTask.getTaskInfo()).thenReturn(mockedTaskInfo);
when(mockedInternalTask.getId()).thenReturn(this.createTaskID());
when(mockedInternalTask.handleResultsArguments()).thenReturn(true);
return mockedInternalTask;
}
Aggregations