Search in sources :

Example 11 with JobDescriptorImpl

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

the class DefaultPolicyTest method single_job.

@Test
public void single_job() throws Exception {
    JobDescriptorImpl job = createSingleTaskJob();
    List<JobDescriptor> jobs = submitJobs(job);
    LinkedList<EligibleTaskDescriptor> orderedTasks = new DefaultPolicy().getOrderedTasks(jobs);
    assertEquals(1, orderedTasks.size());
}
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 12 with JobDescriptorImpl

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

the class ExtendedSchedulerPolicyTest method createJobDescWithTwoTasks.

private JobDescriptor createJobDescWithTwoTasks(String jobStartAt, String oneTaskStartAt, String otherTaskStartAt) {
    InternalTaskFlowJob taskFlowJob = new InternalTaskFlowJob("test", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "");
    taskFlowJob.setId(JobIdImpl.makeJobId(Integer.toString(jobId++)));
    ArrayList<InternalTask> tasks = new ArrayList<>();
    tasks.add(createTask(oneTaskStartAt));
    tasks.add(createTask(otherTaskStartAt));
    taskFlowJob.addTasks(tasks);
    if (jobStartAt != null) {
        taskFlowJob.addGenericInformation("START_AT", jobStartAt);
    }
    return new JobDescriptorImpl(taskFlowJob);
}
Also used : 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 13 with JobDescriptorImpl

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

the class SchedulingServiceTest8 method testTaskPreempt.

@Test
public void testTaskPreempt() throws Exception {
    service.submitJob(createJob(createTestJob()));
    listener.assertEvents(SchedulerEvent.JOB_SUBMITTED);
    JobDescriptor jobDesc = startTask();
    try {
        service.preemptTask(jobDesc.getJobId(), "invalid task name", 100);
        Assert.fail();
    } catch (UnknownTaskException e) {
    }
    try {
        service.preemptTask(JobIdImpl.makeJobId("1234567"), "javaTask", 100);
        Assert.fail();
    } catch (UnknownJobException e) {
    }
    service.preemptTask(jobDesc.getJobId(), "javaTask", 100);
    listener.assertEvents(SchedulerEvent.JOB_PENDING_TO_RUNNING, SchedulerEvent.JOB_UPDATED, SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_WAITING_FOR_RESTART);
    infrastructure.assertRequests(1);
    startTask();
    service.preemptTask(jobDesc.getJobId(), "javaTask", 100);
    listener.assertEvents(SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_WAITING_FOR_RESTART);
    infrastructure.assertRequests(1);
    startTask();
    TaskId taskId = ((JobDescriptorImpl) jobDesc).getInternal().getTask("javaTask").getId();
    service.taskTerminatedWithResult(taskId, new TaskResultImpl(taskId, "OK", null, 0));
    listener.assertEvents(SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_RUNNING_TO_FINISHED, SchedulerEvent.JOB_RUNNING_TO_FINISHED, SchedulerEvent.JOB_UPDATED);
    infrastructure.assertRequests(1);
    service.removeJob(jobDesc.getJobId());
    try {
        service.preemptTask(jobDesc.getJobId(), "javaTask", 100);
        Assert.fail();
    } catch (UnknownJobException e) {
    }
}
Also used : UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) 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) Test(org.junit.Test)

Example 14 with JobDescriptorImpl

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

the class TaskResultCreatorTest method getMockedJobDescriptorWithPausedTask.

private JobDescriptorImpl getMockedJobDescriptorWithPausedTask() {
    JobDescriptorImpl mockedJobDescriptor = this.getMockedJobDescriptor();
    Map fakeMap = this.mockedPausedOrRunningTaskMap();
    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 15 with JobDescriptorImpl

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

the class TaskResultCreatorTest method testRunningTasksAreCheckedForATaskId.

@Test
public void testRunningTasksAreCheckedForATaskId() throws UnknownTaskException {
    TaskResultCreator taskResultCreator = new TaskResultCreator();
    TaskResultImpl mockedTaskResultImpl = mock(TaskResultImpl.class);
    Map<TaskId, TaskResult> loadTaskResultsValue = new HashMap<>();
    loadTaskResultsValue.put(this.createTaskID(), mockedTaskResultImpl);
    SchedulerDBManager mockedschedulerDbManager = mock(SchedulerDBManager.class);
    when(mockedschedulerDbManager.loadTasksResults(any(JobId.class), any(List.class))).thenReturn(loadTaskResultsValue);
    JobDescriptorImpl mockedJobDescriptorHasRunningTask = this.getMockedJobDescriptorWithRunningTask();
    taskResultCreator.getTaskResult(mockedschedulerDbManager, this.getMockedInternalJob(mockedJobDescriptorHasRunningTask), this.getMockedInternalTask());
    verify(mockedJobDescriptorHasRunningTask, atLeastOnce()).getRunningTasks();
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) HashMap(java.util.HashMap) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) List(java.util.List) JobDescriptorImpl(org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl) 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