Search in sources :

Example 6 with JobDescriptorImpl

use of org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl in project scheduling by ow2-proactive.

the class TaskResultCreatorTest method getMockedJobDescriptorWithPausedTaskWithoutParent.

private JobDescriptorImpl getMockedJobDescriptorWithPausedTaskWithoutParent() {
    JobDescriptorImpl mockedJobDescriptor = this.getMockedJobDescriptor();
    Map fakeMap = this.mockedPausedOrRunningTaskMapWithoutParentTasks();
    when(mockedJobDescriptor.getPausedTasks()).thenReturn(fakeMap);
    return mockedJobDescriptor;
}
Also used : JobDescriptorImpl(org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl) HashMap(java.util.HashMap) Map(java.util.Map)

Example 7 with JobDescriptorImpl

use of org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl in project scheduling by ow2-proactive.

the class TaskResultCreatorTest method getMockedInternalJobTaskFlowType.

private InternalJob getMockedInternalJobTaskFlowType(JobDescriptorImpl mockedJobDescriptor) {
    InternalJob mockedInternalJob = mock(InternalJob.class);
    when(mockedInternalJob.getJobDescriptor()).thenReturn(mockedJobDescriptor);
    when(mockedInternalJob.getType()).thenReturn(JobType.TASKSFLOW);
    when(mockedInternalJob.getVariables()).thenReturn(new HashMap<String, JobVariable>());
    return mockedInternalJob;
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable)

Example 8 with JobDescriptorImpl

use of org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl 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);
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskDescriptor(org.ow2.proactive.scheduler.common.TaskDescriptor) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) HashMap(java.util.HashMap) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) Test(org.junit.Test)

Example 9 with JobDescriptorImpl

use of org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl in project scheduling by ow2-proactive.

the class TerminateReplicateTaskHandlerTest method init.

@Before
public void init() {
    action = new FlowAction(FlowActionType.REPLICATE);
    action.setDupNumber(0);
    MockitoAnnotations.initMocks(this);
    when(internalJob.getJobInfo()).thenReturn(jobInfoImpl);
    when(internalJob.getJobDescriptor()).thenReturn(jobDescriptorImpl);
    terminateReplicateTaskHandler = new TerminateReplicateTaskHandler(internalJob);
}
Also used : FlowAction(org.ow2.proactive.scheduler.common.task.flow.FlowAction) Before(org.junit.Before)

Example 10 with JobDescriptorImpl

use of org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl in project scheduling by ow2-proactive.

the class DefaultPolicyTest method job_with_different_priorities.

@Test
public void job_with_different_priorities() throws Exception {
    JobDescriptorImpl jobHigh = createSingleTaskJob(JobPriority.HIGH);
    JobDescriptorImpl jobLow = createSingleTaskJob(JobPriority.LOW);
    JobDescriptorImpl jobNormal = createSingleTaskJob(JobPriority.NORMAL);
    List<JobDescriptor> jobs = submitJobs(jobHigh, jobLow, jobNormal);
    LinkedList<EligibleTaskDescriptor> orderedTasks = new DefaultPolicy().getOrderedTasks(jobs);
    assertEquals(jobHigh.getJobId(), orderedTasks.get(0).getJobId());
    assertEquals(jobNormal.getJobId(), orderedTasks.get(1).getJobId());
    assertEquals(jobLow.getJobId(), orderedTasks.get(2).getJobId());
}
Also used : JobDescriptor(org.ow2.proactive.scheduler.common.JobDescriptor) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor) JobDescriptorImpl(org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl) Test(org.junit.Test)

Aggregations

JobDescriptorImpl (org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl)16 Test (org.junit.Test)12 JobDescriptor (org.ow2.proactive.scheduler.common.JobDescriptor)10 EligibleTaskDescriptor (org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor)9 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)9 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)8 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)8 HashMap (java.util.HashMap)6 JobId (org.ow2.proactive.scheduler.common.job.JobId)6 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)5 TaskDescriptor (org.ow2.proactive.scheduler.common.TaskDescriptor)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)3 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)3 EligibleTaskDescriptorImpl (org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptorImpl)3 IOException (java.io.IOException)2 List (java.util.List)2 TopologyDisabledException (org.ow2.proactive.resourcemanager.frontend.topology.TopologyDisabledException)2 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)2