Search in sources :

Example 6 with RecoveredSchedulerState

use of org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState in project scheduling by ow2-proactive.

the class SchedulerStateRecoverHelperTest method testRecoverWithCanceledJobOnly.

@Test
public void testRecoverWithCanceledJobOnly() throws Exception {
    InternalJob job = createJob(JobStatus.CANCELED);
    changeTasksState(job, TaskStatus.PENDING);
    ImmutableMap<String, TaskStatus> tasksStatus = ImmutableMap.of("Ta", TaskStatus.FINISHED, "Tb", TaskStatus.FAILED, "Tc", TaskStatus.NOT_STARTED);
    changeTasksState(job, tasksStatus);
    RecoveredSchedulerState recoveredState = new Scenario(job).execute();
    job = recoveredState.getFinishedJobs().get(0);
    assertThat(job.getStatus()).isEqualTo(JobStatus.CANCELED);
    assertTasksStatus(job, tasksStatus);
}
Also used : RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus) Test(org.junit.Test)

Example 7 with RecoveredSchedulerState

use of org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState in project scheduling by ow2-proactive.

the class SchedulerStateRecoverHelperTest method testRecoverWithPausedJobOnlyAllTasksSameStatus.

@Test
public void testRecoverWithPausedJobOnlyAllTasksSameStatus() throws Exception {
    InternalJob job = createJob(JobStatus.PAUSED);
    changeTasksState(job, TaskStatus.PAUSED);
    RecoveredSchedulerState recoveredState = new Scenario(job).execute(false);
    job = recoveredState.getPendingJobs().get(0);
    assertThat(job.getStatus()).isEqualTo(JobStatus.PAUSED);
    assertTasksStatus(job, TaskStatus.PAUSED);
}
Also used : RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) Test(org.junit.Test)

Example 8 with RecoveredSchedulerState

use of org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState in project scheduling by ow2-proactive.

the class SchedulerStateRecoverHelperTest method testRecoverWithPendingJobOnly.

@Test
public void testRecoverWithPendingJobOnly() throws Exception {
    InternalJob job = createJob(JobStatus.PENDING);
    changeTasksState(job, TaskStatus.PENDING);
    RecoveredSchedulerState recoveredState = new Scenario(job).execute();
    assertTasksStatus(recoveredState.getPendingJobs(), TaskStatus.PENDING);
}
Also used : RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) Test(org.junit.Test)

Example 9 with RecoveredSchedulerState

use of org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState in project scheduling by ow2-proactive.

the class SchedulerStateRecoverHelperTest method testRecoverWithCopyAndSortThrowingRuntimeException.

@Test
public void testRecoverWithCopyAndSortThrowingRuntimeException() throws KeyException, JobCreationException {
    RecoveredSchedulerState recoveredState = new Scenario(createJob(JobStatus.RUNNING)).execute(new SchedulerStateRecoverHelperSupplier() {

        @Override
        public SchedulerStateRecoverHelper get(SchedulerDBManager dbManager) {
            return new SchedulerStateRecoverHelper(dbManager) {

                @Override
                protected List<InternalTask> copyAndSort(List<InternalTask> tasks) {
                    throw new RuntimeException("bouh!");
                }
            };
        }
    }, false);
    assertThat(recoveredState.getFinishedJobs()).hasSize(1);
    assertThat(recoveredState.getPendingJobs()).hasSize(0);
    assertThat(recoveredState.getRunningJobs()).hasSize(0);
    assertThat(recoveredState.getFinishedJobs().get(0).getStatus()).isEqualTo(JobStatus.CANCELED);
}
Also used : RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) SchedulerStateRecoverHelper(org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper) ImmutableList(com.google.common.collect.ImmutableList) Test(org.junit.Test)

Example 10 with RecoveredSchedulerState

use of org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState in project scheduling by ow2-proactive.

the class SchedulerTasksStateRecoverIntegrationTest method testRecover.

@Test
public void testRecover() throws Exception {
    SchedulerStateRecoverHelper recoverHelper = new SchedulerStateRecoverHelper(dbManager);
    RecoveredSchedulerState state = recoverHelper.recover(-1);
    Assert.assertEquals(0, state.getFinishedJobs().size());
    Assert.assertEquals(0, state.getRunningJobs().size());
    Assert.assertEquals(0, state.getPendingJobs().size());
    TaskFlowJob job1 = new TaskFlowJob();
    JavaTask task1 = createDefaultTask("task1");
    JavaTask task2 = createDefaultTask("task2");
    JavaTask task3 = createDefaultTask("task3");
    task1.addDependence(task2);
    task1.addDependence(task3);
    task2.addDependence(task3);
    job1.addTask(task1);
    job1.addTask(task2);
    job1.addTask(task3);
    InternalJob job = defaultSubmitJob(job1);
    JobStateMatcher expectedJob;
    expectedJob = job(job.getId(), JobStatus.PENDING).withPending(task("task1", TaskStatus.SUBMITTED), false).withPending(task("task2", TaskStatus.SUBMITTED), false).withPending(task("task3", TaskStatus.SUBMITTED), false).withEligible("task3");
    state = checkRecoveredState(recoverHelper.recover(-1), state().withPending(expectedJob));
    job = state.getPendingJobs().get(0);
    TaskDescriptor task = job.getJobDescriptor().getEligibleTasks().iterator().next();
    Assert.assertEquals(2, task.getChildren().size());
    Assert.assertEquals(0, task.getParents().size());
    job.terminate();
    dbManager.updateAfterTaskFinished(job, null, null);
    expectedJob = job(job.getId(), JobStatus.FINISHED).withPending(task("task1", TaskStatus.SUBMITTED), false).withPending(task("task2", TaskStatus.SUBMITTED), false).withPending(task("task3", TaskStatus.SUBMITTED), false).withEligible("task3");
    state = checkRecoveredState(recoverHelper.recover(-1), state().withFinished(expectedJob));
    job = state.getFinishedJobs().get(0);
    task = job.getJobDescriptor().getEligibleTasks().iterator().next();
    Assert.assertEquals(2, task.getChildren().size());
    Assert.assertEquals(0, task.getParents().size());
}
Also used : RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) TaskDescriptor(org.ow2.proactive.scheduler.common.TaskDescriptor) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SchedulerStateRecoverHelper(org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) Test(org.junit.Test)

Aggregations

RecoveredSchedulerState (org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState)20 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)20 Test (org.junit.Test)19 SchedulerStateRecoverHelper (org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper)7 TaskStatus (org.ow2.proactive.scheduler.common.task.TaskStatus)6 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)6 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)5 ExecutorService (java.util.concurrent.ExecutorService)2 TaskDescriptor (org.ow2.proactive.scheduler.common.TaskDescriptor)2 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)2 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)2 ImmutableList (com.google.common.collect.ImmutableList)1 KeyException (java.security.KeyException)1 Vector (java.util.Vector)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 PAActiveObject (org.objectweb.proactive.api.PAActiveObject)1 ActiveObject (org.objectweb.proactive.extensions.annotation.ActiveObject)1 NamedThreadFactory (org.objectweb.proactive.utils.NamedThreadFactory)1 DatabaseManagerException (org.ow2.proactive.db.DatabaseManagerException)1