Search in sources :

Example 41 with JobId

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

the class SchedulingServiceTest3 method testTaskKill.

@Test
public void testTaskKill() throws Exception {
    service.submitJob(createJob(createTestJob(false)));
    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(2, jobDesc.getEligibleTasks().size());
    for (TaskDescriptor taskDesc : jobDesc.getEligibleTasks()) {
        taskStarted(jobDesc, (EligibleTaskDescriptor) taskDesc);
    }
    service.unlockJobsToSchedule(jobsMap.values());
    try {
        service.killTask(jobDesc.getJobId(), "invalid task name");
        Assert.fail();
    } catch (UnknownTaskException e) {
    }
    try {
        service.killTask(JobIdImpl.makeJobId("1234567"), "javaTask");
        Assert.fail();
    } catch (UnknownJobException e) {
    }
    Assert.assertTrue(service.killTask(jobDesc.getJobId(), "javaTask"));
    listener.assertEvents(SchedulerEvent.JOB_PENDING_TO_RUNNING, SchedulerEvent.JOB_UPDATED, SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_RUNNING_TO_FINISHED);
    infrastructure.assertRequests(1);
    Assert.assertFalse(service.killTask(jobDesc.getJobId(), "javaTask"));
    TaskId nativeTaskId = ((JobDescriptorImpl) jobDesc).getInternal().getTask("nativeTask").getId();
    service.taskTerminatedWithResult(nativeTaskId, new TaskResultImpl(nativeTaskId, new Integer(0), null, 0));
    listener.assertEvents(SchedulerEvent.TASK_RUNNING_TO_FINISHED, SchedulerEvent.JOB_RUNNING_TO_FINISHED, SchedulerEvent.JOB_UPDATED);
    infrastructure.assertRequests(1);
    try {
        service.killTask(jobDesc.getJobId(), "javaTask");
    } catch (UnknownJobException e) {
        Assert.fail("The job should still exist in the memory context as the auto Job removal feature isn't enabled");
    }
}
Also used : UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) 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) JobDescriptor(org.ow2.proactive.scheduler.common.JobDescriptor) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) JobDescriptorImpl(org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 42 with JobId

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

the class SchedulingServiceTest3 method testTaskKillAndJobCancel.

@Test
public void testTaskKillAndJobCancel() throws Exception {
    service.submitJob(createJob(createTestJob(true)));
    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(2, jobDesc.getEligibleTasks().size());
    for (TaskDescriptor taskDesc : jobDesc.getEligibleTasks()) {
        taskStarted(jobDesc, (EligibleTaskDescriptor) taskDesc);
    }
    service.unlockJobsToSchedule(jobsMap.values());
    Assert.assertTrue(service.killTask(jobDesc.getJobId(), "javaTask"));
    listener.assertEvents(SchedulerEvent.JOB_PENDING_TO_RUNNING, SchedulerEvent.JOB_UPDATED, SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_RUNNING_TO_FINISHED, SchedulerEvent.TASK_RUNNING_TO_FINISHED, SchedulerEvent.JOB_RUNNING_TO_FINISHED, SchedulerEvent.JOB_UPDATED);
    infrastructure.assertRequests(2);
}
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 43 with JobId

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

the class SchedulingServiceTest method testScheduleJobRemoveShouldUseHousekeepingButAlreadyRemoved.

@Test
public void testScheduleJobRemoveShouldUseHousekeepingButAlreadyRemoved() {
    Mockito.when(schedulerDBManager.loadJobWithTasksIfNotRemoved(any(JobId.class))).thenReturn(Collections.<InternalJob>emptyList());
    JobId jobId = JobIdImpl.makeJobId("42");
    schedulingService.scheduleJobRemove(jobId, 42);
    Mockito.verify(schedulerDBManager).loadJobWithTasksIfNotRemoved(jobId);
}
Also used : JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 44 with JobId

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

the class SchedulingServiceTest method testScheduleJobRemoveShouldUseHousekeeping.

@Test
public void testScheduleJobRemoveShouldUseHousekeeping() {
    JobId jobId = JobIdImpl.makeJobId("42");
    InternalJob mockedInternalJob = createMockedInternalJob(jobId);
    Mockito.when(schedulerDBManager.loadJobWithTasksIfNotRemoved(any(JobId.class))).thenReturn(Collections.singletonList(mockedInternalJob));
    schedulingService.scheduleJobRemove(jobId, 42);
    // second case: the job is not null
    Mockito.verify(schedulerDBManager).loadJobWithTasksIfNotRemoved(jobId);
    Mockito.verify(schedulerDBManager).scheduleJobForRemoval(eq(jobId), eq(42L), anyBoolean());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 45 with JobId

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

the class TerminationDataTest method testAddJobToTerminate.

@Test
public void testAddJobToTerminate() {
    assertThat(terminationData.isEmpty(), is(true));
    JobId jobId = new JobIdImpl(666, "readableName");
    terminationData.addJobToTerminate(jobId);
    assertThat(terminationData.isEmpty(), is(false));
    assertThat(terminationData.jobTerminated(jobId), is(true));
}
Also used : JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Aggregations

JobId (org.ow2.proactive.scheduler.common.job.JobId)179 Test (org.junit.Test)121 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)73 File (java.io.File)58 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)57 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)55 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)55 JobState (org.ow2.proactive.scheduler.common.job.JobState)51 ArrayList (java.util.ArrayList)45 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)43 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)42 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)40 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)38 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)37 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)36 Path (javax.ws.rs.Path)35 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)35 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)34 Produces (javax.ws.rs.Produces)33 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)33