Search in sources :

Example 1 with RecoveredSchedulerState

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

the class RecoveredSchedulerStateTest method testConstructor.

@Test
public void testConstructor() throws Exception {
    int nbJobs = 2;
    Vector<InternalJob> pendingJobs = createJobs(JobStatus.PENDING, nbJobs);
    Vector<InternalJob> runningJobs = createJobs(JobStatus.RUNNING, nbJobs);
    Vector<InternalJob> finishedJobs = createJobs(JobStatus.FINISHED, nbJobs);
    RecoveredSchedulerState recoveredState = new RecoveredSchedulerState(pendingJobs, runningJobs, finishedJobs);
    assertThat(recoveredState.getPendingJobs()).containsExactlyElementsIn(pendingJobs);
    assertThat(recoveredState.getRunningJobs()).containsExactlyElementsIn(runningJobs);
    assertThat(recoveredState.getFinishedJobs()).containsExactlyElementsIn(finishedJobs);
    SchedulerStateImpl schedulerState = recoveredState.getSchedulerState();
    assertThat(schedulerState).isNotNull();
    assertThat(schedulerState.getPendingJobs()).hasSize(nbJobs);
    assertThat(schedulerState.getRunningJobs()).hasSize(nbJobs);
    assertThat(schedulerState.getFinishedJobs()).hasSize(nbJobs);
    assertThat(schedulerState.getPendingJobs().get(0)).isInstanceOf(ClientJobState.class);
    assertThat(schedulerState.getRunningJobs().get(0)).isInstanceOf(ClientJobState.class);
    assertThat(schedulerState.getFinishedJobs().get(0)).isInstanceOf(ClientJobState.class);
}
Also used : RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) SchedulerStateImpl(org.ow2.proactive.scheduler.core.SchedulerStateImpl) Test(org.junit.Test)

Example 2 with RecoveredSchedulerState

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

the class SchedulerStateRecoverHelperTest method testRecoverWithMixedJobs.

@Test
public void testRecoverWithMixedJobs() throws Exception {
    ImmutableList<JobStatus> jobStatuses = ImmutableList.of(JobStatus.CANCELED, JobStatus.FAILED, JobStatus.FINISHED, JobStatus.KILLED, JobStatus.PAUSED, JobStatus.PENDING, JobStatus.RUNNING, JobStatus.STALLED);
    ImmutableList<TaskStatus> taskStatuses = ImmutableList.of(TaskStatus.ABORTED, TaskStatus.FAILED, TaskStatus.FINISHED, TaskStatus.ABORTED, TaskStatus.PAUSED, TaskStatus.PENDING, TaskStatus.RUNNING, TaskStatus.SUBMITTED);
    List<InternalJob> jobs = new ArrayList<>(jobStatuses.size());
    for (int i = 0; i < jobStatuses.size(); i++) {
        InternalJob job = createJob(jobStatuses.get(i));
        jobs.add(job);
        changeTasksState(job, taskStatuses.get(i));
    }
    RecoveredSchedulerState recoveredState = new Scenario(jobs).execute();
    assertThat(recoveredState.getFinishedJobs()).hasSize(4);
    assertThat(recoveredState.getPendingJobs()).hasSize(2);
    assertThat(recoveredState.getRunningJobs()).hasSize(2);
}
Also used : JobStatus(org.ow2.proactive.scheduler.common.job.JobStatus) 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 3 with RecoveredSchedulerState

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

the class SchedulerStateRecoverHelperTest method testRecoverWithStalledJobOnly.

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

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

the class SchedulerStateRecoverHelperTest method testRecoverWithRunningJobOnlyAllTasksSameStatus.

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

Example 5 with RecoveredSchedulerState

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

the class SchedulerStateRecoverHelperTest method testRecoverWithRunningJobOnly.

@Test
public void testRecoverWithRunningJobOnly() throws Exception {
    InternalJob job = createJob(JobStatus.RUNNING);
    changeTasksState(job, TaskStatus.RUNNING);
    ImmutableMap<String, TaskStatus> tasksStatus = ImmutableMap.of("Ta", TaskStatus.ABORTED, "Tb", TaskStatus.FAULTY, "Tc", TaskStatus.PENDING);
    changeTasksState(job, tasksStatus);
    RecoveredSchedulerState recoveredState = new Scenario(job).execute();
    job = recoveredState.getRunningJobs().get(0);
    assertThat(job.getStatus()).isEqualTo(JobStatus.STALLED);
    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)

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