Search in sources :

Example 16 with JobDescriptorImpl

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

the class TaskResultCreatorTest method getMockedJobDescriptorWithRunningTask.

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

Example 17 with JobDescriptorImpl

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

the class TaskResultCreatorTest method getMockedInternalJob.

private InternalJob getMockedInternalJob(JobDescriptorImpl mockedJobDescriptor) {
    InternalJob mockedInternalJob = mock(InternalJob.class);
    when(mockedInternalJob.getJobDescriptor()).thenReturn(mockedJobDescriptor);
    return mockedInternalJob;
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob)

Example 18 with JobDescriptorImpl

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

the class DefaultPolicyTest method createSingleTaskJob.

private JobDescriptorImpl createSingleTaskJob(JobPriority jobPriority) {
    InternalTaskFlowJob taskFlowJob = new InternalTaskFlowJob("test", jobPriority, OnTaskError.CANCEL_JOB, "");
    taskFlowJob.setId(JobIdImpl.makeJobId(Integer.toString(jobId++)));
    ArrayList<InternalTask> tasks = new ArrayList<>();
    tasks.add(new InternalScriptTask(taskFlowJob));
    taskFlowJob.addTasks(tasks);
    return new JobDescriptorImpl(taskFlowJob);
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) ArrayList(java.util.ArrayList) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobDescriptorImpl(org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl)

Example 19 with JobDescriptorImpl

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

the class DefaultPolicyTest method job_with_same_priorities.

@Test
public void job_with_same_priorities() throws Exception {
    JobDescriptorImpl job1 = createSingleTaskJob();
    JobDescriptorImpl job2 = createSingleTaskJob();
    JobDescriptorImpl job3 = createSingleTaskJob();
    List<JobDescriptor> jobs = submitJobs(job1, job3, job2);
    LinkedList<EligibleTaskDescriptor> orderedTasks = new DefaultPolicy().getOrderedTasks(jobs);
    assertEquals(job1.getJobId(), orderedTasks.get(0).getJobId());
    assertEquals(job2.getJobId(), orderedTasks.get(1).getJobId());
    assertEquals(job3.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)

Example 20 with JobDescriptorImpl

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

the class SchedulingServiceTest7 method testTaskReplication.

@Test
public void testTaskReplication() 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(1, jobDesc.getEligibleTasks().size());
    for (TaskDescriptor taskDesc : jobDesc.getEligibleTasks()) {
        taskStarted(jobDesc, (EligibleTaskDescriptor) taskDesc);
    }
    service.unlockJobsToSchedule(jobsMap.values());
    listener.assertEvents(SchedulerEvent.JOB_PENDING_TO_RUNNING, SchedulerEvent.JOB_UPDATED, SchedulerEvent.TASK_PENDING_TO_RUNNING);
    TaskId taskId;
    taskId = ((JobDescriptorImpl) jobDesc).getInternal().getTask("Main task").getId();
    TaskResultImpl result = new TaskResultImpl(taskId, "OK", null, 0);
    FlowAction action = new FlowAction(FlowActionType.REPLICATE);
    action.setDupNumber(3);
    result.setAction(action);
    service.taskTerminatedWithResult(taskId, result);
    listener.assertEvents(SchedulerEvent.TASK_REPLICATED, SchedulerEvent.TASK_SKIPPED, SchedulerEvent.JOB_UPDATED, SchedulerEvent.TASK_RUNNING_TO_FINISHED);
    jobsMap = service.lockJobsToSchedule();
    assertEquals(1, jobsMap.size());
    jobDesc = jobsMap.values().iterator().next();
    Assert.assertEquals(3, jobDesc.getEligibleTasks().size());
    for (TaskDescriptor taskDesc : jobDesc.getEligibleTasks()) {
        taskStarted(jobDesc, (EligibleTaskDescriptor) taskDesc);
    }
    service.unlockJobsToSchedule(jobsMap.values());
    listener.assertEvents(SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_PENDING_TO_RUNNING);
}
Also used : 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) FlowAction(org.ow2.proactive.scheduler.common.task.flow.FlowAction) JobDescriptor(org.ow2.proactive.scheduler.common.JobDescriptor) JobId(org.ow2.proactive.scheduler.common.job.JobId) 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