Search in sources :

Example 11 with TaskDescriptor

use of org.ow2.proactive.scheduler.common.TaskDescriptor in project scheduling by ow2-proactive.

the class SchedulingServiceTest3 method testTaskKill.

@Test
public void testTaskKill() throws Exception {
    service.submitJob(createJob(createTestJob(false)));
    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());
    try {
        service.killTask(jobDesc.getJobId(), "invalid task name");
        Assert.fail();
    } catch (UnknownTaskException e) {
    }
    try {
        service.killTask(JobIdImpl.makeJobId("1234567"), "javaTask");
        Assert.fail();
    } catch (UnknownJobException e) {
    }
    Assert.assertTrue(service.killTask(jobDesc.getJobId(), "javaTask"));
    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);
    infrastructure.assertRequests(1);
    Assert.assertFalse(service.killTask(jobDesc.getJobId(), "javaTask"));
    TaskId nativeTaskId = ((JobDescriptorImpl) jobDesc).getInternal().getTask("nativeTask").getId();
    service.taskTerminatedWithResult(nativeTaskId, new TaskResultImpl(nativeTaskId, new Integer(0), null, 0));
    listener.assertEvents(SchedulerEvent.TASK_RUNNING_TO_FINISHED, SchedulerEvent.JOB_RUNNING_TO_FINISHED, SchedulerEvent.JOB_UPDATED);
    infrastructure.assertRequests(1);
    try {
        service.killTask(jobDesc.getJobId(), "javaTask");
    } catch (UnknownJobException e) {
        Assert.fail("The job should still exist in the memory context as the auto Job removal feature isn't enabled");
    }
}
Also used : UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) TaskDescriptor(org.ow2.proactive.scheduler.common.TaskDescriptor) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) JobDescriptor(org.ow2.proactive.scheduler.common.JobDescriptor) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) JobDescriptorImpl(org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 12 with TaskDescriptor

use of org.ow2.proactive.scheduler.common.TaskDescriptor in project scheduling by ow2-proactive.

the class SchedulingServiceTest3 method testTaskKillAndJobCancel.

@Test
public void testTaskKillAndJobCancel() throws Exception {
    service.submitJob(createJob(createTestJob(true)));
    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());
    Assert.assertTrue(service.killTask(jobDesc.getJobId(), "javaTask"));
    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);
}
Also used : TaskDescriptor(org.ow2.proactive.scheduler.common.TaskDescriptor) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor) JobDescriptor(org.ow2.proactive.scheduler.common.JobDescriptor) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 13 with TaskDescriptor

use of org.ow2.proactive.scheduler.common.TaskDescriptor in project scheduling by ow2-proactive.

the class TaskResultCreatorTest method mockedPausedOrRunningTaskMapWithoutParentTasks.

private Map<TaskId, EligibleTaskDescriptor> mockedPausedOrRunningTaskMapWithoutParentTasks() {
    EligibleTaskDescriptor eligibleTaskDescriptor = this.createEligibleTaskDescriptor(new Vector<TaskDescriptor>());
    Map<TaskId, EligibleTaskDescriptor> mockedMap = mock(HashMap.class);
    when(mockedMap.get(any())).thenReturn(eligibleTaskDescriptor);
    return mockedMap;
}
Also used : TaskDescriptor(org.ow2.proactive.scheduler.common.TaskDescriptor) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor)

Example 14 with TaskDescriptor

use of org.ow2.proactive.scheduler.common.TaskDescriptor 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 15 with TaskDescriptor

use of org.ow2.proactive.scheduler.common.TaskDescriptor in project scheduling by ow2-proactive.

the class SchedulingServiceTest4 method startTask.

private JobDescriptor startTask() throws Exception {
    Map<JobId, JobDescriptor> jobsMap;
    JobDescriptor jobDesc;
    jobsMap = service.lockJobsToSchedule();
    assertEquals(1, jobsMap.size());
    jobDesc = jobsMap.values().iterator().next();
    Assert.assertEquals(1, jobDesc.getEligibleTasks().size());
    for (TaskDescriptor taskDesc : jobDesc.getEligibleTasks()) {
        taskStarted(jobDesc, (EligibleTaskDescriptor) taskDesc);
    }
    service.unlockJobsToSchedule(jobsMap.values());
    return jobDesc;
}
Also used : TaskDescriptor(org.ow2.proactive.scheduler.common.TaskDescriptor) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor) JobDescriptor(org.ow2.proactive.scheduler.common.JobDescriptor) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Aggregations

TaskDescriptor (org.ow2.proactive.scheduler.common.TaskDescriptor)21 EligibleTaskDescriptor (org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor)15 JobDescriptor (org.ow2.proactive.scheduler.common.JobDescriptor)12 JobId (org.ow2.proactive.scheduler.common.job.JobId)10 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)10 Test (org.junit.Test)8 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)7 ArrayList (java.util.ArrayList)4 LinkedList (java.util.LinkedList)4 HashMap (java.util.HashMap)3 EligibleTaskDescriptorImpl (org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptorImpl)3 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)3 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)3 IOException (java.io.IOException)2 Collection (java.util.Collection)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)2 TopologyDisabledException (org.ow2.proactive.resourcemanager.frontend.topology.TopologyDisabledException)2 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)2 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)2