Search in sources :

Example 26 with InternalJob

use of org.ow2.proactive.scheduler.job.InternalJob 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 27 with InternalJob

use of org.ow2.proactive.scheduler.job.InternalJob 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 28 with InternalJob

use of org.ow2.proactive.scheduler.job.InternalJob 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 29 with InternalJob

use of org.ow2.proactive.scheduler.job.InternalJob 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 30 with InternalJob

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

the class SchedulerStateRecoverHelperTest method changeTasksState.

private void changeTasksState(InternalJob job, Map<String, TaskStatus> newStatuses) {
    int nbPending = 0;
    int nbRunning = 0;
    int nbFinished = 0;
    for (InternalTask internalTask : job.getITasks()) {
        TaskStatus newStatus = newStatuses.get(internalTask.getName());
        if (newStatus != null) {
            internalTask.setStatus(newStatus);
        }
        switch(internalTask.getStatus()) {
            case PENDING:
                nbPending++;
                break;
            case RUNNING:
                nbRunning++;
                break;
            case FINISHED:
                nbFinished++;
                break;
        }
    }
    updateJobCounters(job, nbPending, nbRunning, nbFinished);
}
Also used : InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus)

Aggregations

InternalJob (org.ow2.proactive.scheduler.job.InternalJob)166 Test (org.junit.Test)115 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)90 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)53 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)36 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)34 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)33 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)32 JobId (org.ow2.proactive.scheduler.common.job.JobId)28 ArrayList (java.util.ArrayList)27 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)26 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)19 RecoveredSchedulerState (org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState)19 Matchers.containsString (org.hamcrest.Matchers.containsString)16 Matchers.anyString (org.mockito.Matchers.anyString)16 ExecuterInformation (org.ow2.proactive.scheduler.task.internal.ExecuterInformation)15 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)13 SchedulerStateRecoverHelper (org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper)12 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)12 HashMap (java.util.HashMap)10