use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.
the class InProcessTaskExecutorTest method taskWithFlowScript.
@Test
public void taskWithFlowScript() throws Exception {
TestTaskOutput taskOutput = new TestTaskOutput();
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
initializer.setControlFlowScript(FlowScript.createReplicateFlowScript("print('flow'); runs=5", "groovy"));
initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
TaskResultImpl result = new InProcessTaskExecutor().execute(new TaskContext(new ScriptExecutableContainer(new TaskScript(new SimpleScript("print('hello'); result='hello'", "groovy"))), initializer, null, new NodeDataSpacesURIs("", "", "", "", "", ""), "", ""), taskOutput.outputStream, taskOutput.error);
assertEquals(FlowActionType.REPLICATE, result.getAction().getType());
assertEquals("helloflow", taskOutput.output());
}
use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.
the class TaskData method createTaskInfo.
TaskInfoImpl createTaskInfo(JobIdImpl jobId) {
TaskId taskId = TaskIdImpl.createTaskId(jobId, getTaskName(), getId().getTaskId(), getTag());
TaskInfoImpl taskInfo = new TaskInfoImpl();
taskInfo.setTaskId(taskId);
taskInfo.setStatus(getTaskStatus());
taskInfo.setStartTime(getStartTime());
taskInfo.setProgress(0);
taskInfo.setInErrorTime(getInErrorTime());
taskInfo.setNumberOfExecutionOnFailureLeft(getNumberOfExecutionOnFailureLeft());
taskInfo.setNumberOfExecutionLeft(getNumberOfExecutionLeft());
taskInfo.setJobInfo(getJobData().toJobInfo());
taskInfo.setJobId(jobId);
taskInfo.setFinishedTime(getFinishedTime());
taskInfo.setScheduledTime(getScheduledTime());
taskInfo.setExecutionHostName(getExecutionHostName());
taskInfo.setExecutionDuration(getExecutionDuration());
return taskInfo;
}
use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.
the class TerminateNotificationTest method testTerminate.
@Test
public void testTerminate() throws TerminateTaskException {
TaskId taskId = TaskIdImpl.createTaskId(new JobIdImpl(666, "readableName"), "task-name", 777L);
TaskResult taskResult = new TaskResultImpl(taskId, new Throwable());
terminateNotification.terminate(taskId, taskResult);
Mockito.verify(schedulingService, Mockito.times(1)).taskTerminatedWithResult(taskId, taskResult);
}
use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId 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.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.
the class JobDescriptorImplTest method testThatDoLoopPausesNewlyCreatedTasksIfJobIsPaused.
@Test
public void testThatDoLoopPausesNewlyCreatedTasksIfJobIsPaused() {
JobDescriptorImpl pausedJob = createEmptyJobDescriptor();
pausedJob.getInternal().setStatus(JobStatus.PAUSED);
// Create mocks for the loop root task
TaskId runningRootTaskId = TaskIdImpl.createTaskId(new JobIdImpl(1L, "Root"), "FirstLoopTask", 1L);
EligibleTaskDescriptorImpl mockLoopStartCurrentlyRunningTask = mock(EligibleTaskDescriptorImpl.class);
InternalTask mockInternalLoopRootTask = mock(InternalTask.class);
when(mockInternalLoopRootTask.getId()).thenReturn(runningRootTaskId);
when(mockLoopStartCurrentlyRunningTask.getTaskId()).thenReturn(runningRootTaskId);
when(mockLoopStartCurrentlyRunningTask.getInternal()).thenReturn(mockInternalLoopRootTask);
when(mockLoopStartCurrentlyRunningTask.getChildren()).thenReturn(new Vector<TaskDescriptor>());
// Create mocks for the new loop task
TaskId newLoopTaskId = TaskIdImpl.createTaskId(new JobIdImpl(1L, "Root"), "SecondLoopTask", 2L);
EligibleTaskDescriptorImpl mockLoopNewCreatedTaskForLoop = mock(EligibleTaskDescriptorImpl.class);
InternalTask mockInternalNewLoopTask = mock(InternalTask.class);
TaskInfo mockNewTaskTaskInfo = mock(TaskInfo.class);
when(mockNewTaskTaskInfo.getTaskId()).thenReturn(newLoopTaskId);
when(mockInternalNewLoopTask.getId()).thenReturn(newLoopTaskId);
when(mockInternalNewLoopTask.getStatus()).thenReturn(TaskStatus.SUBMITTED);
when(mockInternalNewLoopTask.getTaskInfo()).thenReturn(mockNewTaskTaskInfo);
when(mockLoopNewCreatedTaskForLoop.getTaskId()).thenReturn(newLoopTaskId);
when(mockLoopNewCreatedTaskForLoop.getInternal()).thenReturn(mockInternalNewLoopTask);
// Put the root loop task into running tasks, because it just terminated
pausedJob.getRunningTasks().put(mockLoopStartCurrentlyRunningTask.getTaskId(), mockLoopStartCurrentlyRunningTask);
// Put the new loop task into the Map, this is clue so that the test works
HashMap<TaskId, InternalTask> workflowTree = new HashMap<>();
workflowTree.put(newLoopTaskId, mockInternalNewLoopTask);
pausedJob.doLoop(mockLoopStartCurrentlyRunningTask.getTaskId(), workflowTree, mockLoopNewCreatedTaskForLoop.getInternal(), mockLoopNewCreatedTaskForLoop.getInternal());
verify(mockInternalNewLoopTask).setStatus(TaskStatus.PAUSED);
}
Aggregations