Search in sources :

Example 31 with EligibleTaskDescriptor

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

the class BaseServiceTest method taskStarted.

void taskStarted(JobDescriptor jobDesc, EligibleTaskDescriptor taskDesc) throws Exception {
    InternalTask task = ((EligibleTaskDescriptorImpl) taskDesc).getInternal();
    TaskLauncher launcher = Mockito.mock(TaskLauncher.class);
    task.setExecuterInformation(new ExecuterInformation(launcher, NodeFactory.getDefaultNode()));
    service.taskStarted(((JobDescriptorImpl) jobDesc).getInternal(), task, launcher);
}
Also used : ExecuterInformation(org.ow2.proactive.scheduler.task.internal.ExecuterInformation) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskLauncher(org.ow2.proactive.scheduler.task.TaskLauncher) EligibleTaskDescriptorImpl(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptorImpl)

Example 32 with EligibleTaskDescriptor

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

the class SchedulingServiceTest1 method testSimpleJob.

@Test
public void testSimpleJob() 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());
    taskStarted(jobDesc, (EligibleTaskDescriptor) jobDesc.getEligibleTasks().iterator().next());
    service.unlockJobsToSchedule(jobsMap.values());
    jobsMap = service.lockJobsToSchedule();
    assertEquals(1, jobsMap.size());
    jobDesc = jobsMap.values().iterator().next();
    Assert.assertEquals(0, jobDesc.getEligibleTasks().size());
    service.unlockJobsToSchedule(jobsMap.values());
    TaskId taskId = ((JobDescriptorImpl) jobDesc).getInternal().getTask("task1").getId();
    service.taskTerminatedWithResult(taskId, new TaskResultImpl(taskId, "Result", null, 0));
    jobsMap = service.lockJobsToSchedule();
    // when a job finishes, it isn't removed from the hibernate context unless
    // the housekeeping mechanism is enabled
    assertEquals(1, jobsMap.size());
    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);
    infrastructure.assertRequests(1);
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) JobDescriptor(org.ow2.proactive.scheduler.common.JobDescriptor) JobDescriptorImpl(org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 33 with EligibleTaskDescriptor

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

the class SchedulerFrontend method getTasksToSchedule.

@Override
public List<TaskDescriptor> getTasksToSchedule() throws NotConnectedException, PermissionException {
    Policy policy = null;
    List<TaskDescriptor> eligibleTasks = new ArrayList<>();
    Map<JobId, JobDescriptor> jobMap = null;
    try {
        jobMap = schedulingService.lockJobsToSchedule();
        policy = (Policy) Class.forName(getCurrentPolicy()).newInstance();
        // we wait for next scheduling loop
        if (jobMap.isEmpty()) {
            return eligibleTasks;
        }
        List<JobDescriptor> descriptors = new ArrayList<>(jobMap.values());
        LinkedList<EligibleTaskDescriptor> taskRetrievedFromPolicy = policy.getOrderedTasks(descriptors);
        // if there is no task to scheduled, return
        if (taskRetrievedFromPolicy.isEmpty()) {
            return eligibleTasks;
        }
        eligibleTasks = (List) taskRetrievedFromPolicy;
    } catch (Exception e) {
        logger.error("Error Loading Current Policy:", e);
    } finally {
        schedulingService.unlockJobsToSchedule(jobMap.values());
    }
    return eligibleTasks;
}
Also used : Policy(org.ow2.proactive.scheduler.policy.Policy) ClientsPolicy(org.ow2.proactive.policy.ClientsPolicy) TaskDescriptor(org.ow2.proactive.scheduler.common.TaskDescriptor) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor) JobDescriptor(org.ow2.proactive.scheduler.common.JobDescriptor) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor) ArrayList(java.util.ArrayList) JobId(org.ow2.proactive.scheduler.common.job.JobId) KeyException(java.security.KeyException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) TaskCouldNotRestartException(org.ow2.proactive.scheduler.common.exception.TaskCouldNotRestartException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) AlreadyConnectedException(org.ow2.proactive.scheduler.common.exception.AlreadyConnectedException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) TaskCouldNotStartException(org.ow2.proactive.scheduler.common.exception.TaskCouldNotStartException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException) DatabaseManagerException(org.ow2.proactive.db.DatabaseManagerException) TaskSkippedException(org.ow2.proactive.scheduler.common.exception.TaskSkippedException)

Example 34 with EligibleTaskDescriptor

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

the class LiveJobs method simulateJobStart.

TerminationData simulateJobStart(List<EligibleTaskDescriptor> tasksToSchedule, String errorMsg) {
    TerminationData terminationData = TerminationData.newTerminationData();
    for (EligibleTaskDescriptor eltd : tasksToSchedule) {
        JobId jobId = eltd.getJobId();
        if (!terminationData.jobTerminated(jobId)) {
            JobData jobData = lockJob(jobId);
            if (jobData != null) {
                try {
                    if (jobData.job.getStartTime() < 0) {
                        jobData.job.start();
                        updateJobInSchedulerState(jobData.job, SchedulerEvent.JOB_PENDING_TO_RUNNING);
                        jlogger.info(jobId, "started");
                    }
                    endJob(jobData, terminationData, ((EligibleTaskDescriptorImpl) eltd).getInternal(), null, errorMsg, JobStatus.CANCELED);
                } finally {
                    jobData.unlock();
                }
            }
        }
    }
    return terminationData;
}
Also used : EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor) JobId(org.ow2.proactive.scheduler.common.job.JobId)

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