Search in sources :

Example 21 with EligibleTaskDescriptor

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

the class SchedulingServiceTest6 method testJobRemove.

@Test
public void testJobRemove() 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());
    Assert.assertTrue(service.removeJob(jobDesc.getJobId()));
    listener.assertEvents(SchedulerEvent.JOB_PENDING_TO_RUNNING, SchedulerEvent.JOB_UPDATED, SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_RUNNING_TO_FINISHED, SchedulerEvent.JOB_RUNNING_TO_FINISHED, SchedulerEvent.JOB_UPDATED, SchedulerEvent.JOB_REMOVE_FINISHED);
    infrastructure.assertRequests(1);
    Assert.assertFalse(service.removeJob(jobDesc.getJobId()));
}
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 22 with EligibleTaskDescriptor

use of org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor 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)

Example 23 with EligibleTaskDescriptor

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

the class SchedulingServiceTest8 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)

Example 24 with EligibleTaskDescriptor

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

the class SchedulingServiceTest9 method startTask.

private JobDescriptor startTask(int expectedTasks) throws Exception {
    Map<JobId, JobDescriptor> jobsMap;
    JobDescriptor jobDesc;
    jobsMap = service.lockJobsToSchedule();
    assertEquals(1, jobsMap.size());
    jobDesc = jobsMap.values().iterator().next();
    Assert.assertEquals(expectedTasks, 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)

Example 25 with EligibleTaskDescriptor

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

the class ExtendedSchedulerPolicy method getOrderedTasks.

/*
     * Utilize 'startAt' generic info and filter any tasks that should not be scheduled for current
     * execution cycle.
     */
@Override
public LinkedList<EligibleTaskDescriptor> getOrderedTasks(List<JobDescriptor> jobDescList) {
    Date now = new Date();
    LinkedList<EligibleTaskDescriptor> executionCycleTasks = new LinkedList<>();
    Collections.sort(jobDescList, FIFO_BY_PRIORITY_COMPARATOR);
    for (JobDescriptor jobDesc : jobDescList) {
        Collection<TaskDescriptor> tasks = jobDesc.getEligibleTasks();
        Collection<EligibleTaskDescriptor> eligibleTasks = (Collection) tasks;
        for (EligibleTaskDescriptor candidate : eligibleTasks) {
            String startAt = getStartAtValue(jobDesc, candidate);
            if (startAt == null) {
                executionCycleTasks.add(candidate);
            } else {
                try {
                    if (now.after(ISO8601DateUtil.toDate(startAt))) {
                        executionCycleTasks.add(candidate);
                    } else {
                        if (logger.isTraceEnabled()) {
                            logger.trace(String.format("Task [jobId:\"%s\", taskId:\"%s\"] is scheduled to be executed at %s." + " It will not be scheduled for this execution cycle at %s.", jobDesc.getJobId(), candidate.getTaskId(), startAt, ISO8601DateUtil.parse(now)));
                        }
                    }
                } catch (IllegalArgumentException e) {
                    logger.error(String.format("An error occurred while processing 'startAt' generic info.%n" + "Task ([job-id:\"%s\", task-id:\"%s\"]) will be scheduled immediately for execution.", jobDesc.getJobId().toString(), candidate.getTaskId().toString()), e);
                    executionCycleTasks.add(candidate);
                }
            }
        }
    }
    return executionCycleTasks;
}
Also used : TaskDescriptor(org.ow2.proactive.scheduler.common.TaskDescriptor) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor) JobDescriptor(org.ow2.proactive.scheduler.common.JobDescriptor) Collection(java.util.Collection) Date(java.util.Date) LinkedList(java.util.LinkedList)

Aggregations

EligibleTaskDescriptor (org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor)25 JobDescriptor (org.ow2.proactive.scheduler.common.JobDescriptor)18 TaskDescriptor (org.ow2.proactive.scheduler.common.TaskDescriptor)16 JobId (org.ow2.proactive.scheduler.common.job.JobId)12 Test (org.junit.Test)10 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)9 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)8 JobDescriptorImpl (org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl)7 EligibleTaskDescriptorImpl (org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptorImpl)6 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)5 ArrayList (java.util.ArrayList)4 LinkedList (java.util.LinkedList)4 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)3 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)3 IOException (java.io.IOException)2 Collection (java.util.Collection)2 Entry (java.util.Map.Entry)2 TopologyDisabledException (org.ow2.proactive.resourcemanager.frontend.topology.TopologyDisabledException)2 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)2 RMProxyCreationException (org.ow2.proactive.scheduler.core.rmproxies.RMProxyCreationException)2