Search in sources :

Example 31 with JobDescriptor

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

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

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

the class SchedulingServiceTest4 method testTaskRestart1.

@Test
public void testTaskRestart1() throws Exception {
    service.submitJob(createJob(createTestJob()));
    listener.assertEvents(SchedulerEvent.JOB_SUBMITTED);
    JobDescriptor jobDesc = startTask();
    try {
        service.restartTask(jobDesc.getJobId(), "invalid task name", 100);
        Assert.fail();
    } catch (UnknownTaskException e) {
    }
    try {
        service.restartTask(JobIdImpl.makeJobId("1234567"), "javaTask", 100);
        Assert.fail();
    } catch (UnknownJobException e) {
    }
    service.restartTask(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();
    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);
}
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 34 with JobDescriptor

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

Aggregations

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