Search in sources :

Example 1 with TaskStatus

use of org.ow2.proactive.scheduler.common.task.TaskStatus in project scheduling by ow2-proactive.

the class TaskDBUtils method fetchTaskData.

private static List<TaskData> fetchTaskData(Session session, DBTaskDataParameters params) {
    Set<TaskStatus> taskStatuses = params.getStatuses();
    boolean hasUser = params.hasUser();
    boolean hasTag = params.hasTag();
    boolean hasDateFrom = params.hasDateFrom();
    boolean hasDateTo = params.hasDateTo();
    String queryPrefix = "select T from TaskData T where ";
    Query query = getQuery(session, params, taskStatuses, hasUser, hasTag, hasDateFrom, hasDateTo, params.getSortParams(), queryPrefix);
    query.setMaxResults(params.getLimit());
    query.setFirstResult(params.getOffset());
    return query.list();
}
Also used : Query(org.hibernate.Query) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus)

Example 2 with TaskStatus

use of org.ow2.proactive.scheduler.common.task.TaskStatus 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 TaskStatus

use of org.ow2.proactive.scheduler.common.task.TaskStatus 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 TaskStatus

use of org.ow2.proactive.scheduler.common.task.TaskStatus 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)

Example 5 with TaskStatus

use of org.ow2.proactive.scheduler.common.task.TaskStatus 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

TaskStatus (org.ow2.proactive.scheduler.common.task.TaskStatus)16 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)8 Test (org.junit.Test)7 RecoveredSchedulerState (org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState)6 TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)5 JobId (org.ow2.proactive.scheduler.common.job.JobId)4 Query (org.hibernate.Query)3 JobState (org.ow2.proactive.scheduler.common.job.JobState)3 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)3 TaskAbortedException (org.ow2.proactive.scheduler.common.exception.TaskAbortedException)2 TaskPreemptedException (org.ow2.proactive.scheduler.common.exception.TaskPreemptedException)2 TaskRestartedException (org.ow2.proactive.scheduler.common.exception.TaskRestartedException)2 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)2 JobStatus (org.ow2.proactive.scheduler.common.job.JobStatus)2 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)2 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)2 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Semaphore (java.util.concurrent.Semaphore)1 MutableBoolean (org.apache.commons.lang3.mutable.MutableBoolean)1