Search in sources :

Example 16 with RecoveredSchedulerState

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

the class SchedulerStateRecoverHelperTest method testRecoverWithFinishedJobsOnly.

@Test
public void testRecoverWithFinishedJobsOnly() throws Exception {
    List<InternalJob> jobs = new ArrayList<>(DEFAULT_NUMBER_OF_JOBS);
    for (int i = 0; i < DEFAULT_NUMBER_OF_JOBS; i++) {
        InternalJob job = createJob(JobStatus.FINISHED);
        changeTasksState(job, TaskStatus.FINISHED);
        jobs.add(job);
    }
    RecoveredSchedulerState recoveredState = new Scenario(jobs).execute();
    assertTasksStatus(recoveredState.getFinishedJobs(), TaskStatus.FINISHED);
}
Also used : RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) Test(org.junit.Test)

Example 17 with RecoveredSchedulerState

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

the class SchedulerStateRecoverHelperTest method testRecoverWithFailedJobOnly.

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

Example 18 with RecoveredSchedulerState

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

the class SchedulerStateRecoverHelperTest method testRecoverWithPausedJobOnly.

@Test
public void testRecoverWithPausedJobOnly() throws Exception {
    InternalJob job = createJob(JobStatus.PAUSED);
    changeTasksState(job, TaskStatus.PAUSED);
    ImmutableMap<String, TaskStatus> tasksStatus = ImmutableMap.of("Ta", TaskStatus.FINISHED, "Tb", TaskStatus.PAUSED, "Tc", TaskStatus.PENDING);
    changeTasksState(job, tasksStatus);
    RecoveredSchedulerState recoveredState = new Scenario(job).execute();
    job = recoveredState.getRunningJobs().get(0);
    assertThat(job.getStatus()).isEqualTo(JobStatus.PAUSED);
    assertTasksStatus(job, ImmutableMap.of("Ta", TaskStatus.FINISHED, "Tb", TaskStatus.PAUSED, "Tc", TaskStatus.PAUSED));
}
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 19 with RecoveredSchedulerState

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

the class SchedulerStateRecoverHelperTest method testRecoverWithFinishedJobsOnlyFilteredByPeriod.

@Test
public void testRecoverWithFinishedJobsOnlyFilteredByPeriod() throws Exception {
    List<InternalJob> jobs = new ArrayList<>(DEFAULT_NUMBER_OF_JOBS);
    for (int i = 0; i < DEFAULT_NUMBER_OF_JOBS; i++) {
        InternalJob job = createJob(JobStatus.FINISHED);
        changeTasksState(job, TaskStatus.FINISHED);
        job.setSubmittedTime(i);
        jobs.add(job);
    }
    RecoveredSchedulerState recoveredState = new Scenario(jobs, 3).execute();
    assertThat(recoveredState.getFinishedJobs()).hasSize(DEFAULT_NUMBER_OF_JOBS - 3);
    assertTasksStatus(recoveredState.getFinishedJobs(), TaskStatus.FINISHED);
}
Also used : RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) Test(org.junit.Test)

Example 20 with RecoveredSchedulerState

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

the class TestLoadSchedulerClientState method testStateAfterTaskFinished.

@Test
public void testStateAfterTaskFinished() throws Exception {
    TaskFlowJob jobDef = new TaskFlowJob();
    JavaTask taskDef1 = createDefaultTask("task1");
    JavaTask taskDef2 = createDefaultTask("task2");
    taskDef2.addDependence(taskDef1);
    jobDef.addTask(taskDef1);
    jobDef.addTask(taskDef2);
    InternalJob job = defaultSubmitJobAndLoadInternal(true, jobDef);
    InternalTask task1 = job.getTask("task1");
    job.start();
    startTask(job, task1);
    dbManager.jobTaskStarted(job, task1, true);
    TaskResultImpl result = new TaskResultImpl(null, new TestResult(1, "res1"), null, 1000);
    terminateTask(job, task1, result);
    dbManager.updateAfterTaskFinished(job, task1, result);
    SchedulerStateRecoverHelper stateRecoverHelper = new SchedulerStateRecoverHelper(dbManager);
    RecoveredSchedulerState recovered;
    recovered = stateRecoverHelper.recover(-1);
    JobStateMatcher expectedJob;
    expectedJob = job(job.getId(), JobStatus.STALLED).withFinished(task("task1", TaskStatus.FINISHED).checkFinished()).withPending(task("task2", TaskStatus.PENDING), true).withEligible("task2");
    checkRecoveredState(recovered, state().withRunning(expectedJob));
    job = recovered.getRunningJobs().get(0);
    InternalTask task2 = job.getTask("task2");
    startTask(job, task2);
    dbManager.jobTaskStarted(job, task2, false);
    expectedJob = job(job.getId(), JobStatus.STALLED).withFinished(task("task1", TaskStatus.FINISHED).checkFinished()).withPending(task("task2", TaskStatus.PENDING), true).withEligible("task2");
    recovered = stateRecoverHelper.recover(-1);
    checkRecoveredState(recovered, state().withRunning(expectedJob));
    job = recovered.getRunningJobs().get(0);
    task2 = job.getTask("task2");
    startTask(job, task2);
    dbManager.jobTaskStarted(job, task2, false);
    terminateTask(job, task2, result);
    dbManager.updateAfterTaskFinished(job, task2, result);
    expectedJob = job(job.getId(), JobStatus.FINISHED).withFinished(task("task1", TaskStatus.FINISHED).checkFinished()).withFinished(task("task2", TaskStatus.FINISHED).checkFinished());
    recovered = stateRecoverHelper.recover(-1);
    checkRecoveredState(recovered, state().withFinished(expectedJob));
}
Also used : RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) 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