Search in sources :

Example 56 with InternalTask

use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.

the class TestUsageData method finishTask.

private void finishTask(InternalJob job, InternalTask task) throws Exception {
    Thread.sleep(10);
    TaskResultImpl res = new TaskResultImpl(null, "ok", null, 42);
    job.terminateTask(false, task.getId(), null, null, res);
    if (job.isFinished()) {
        job.terminate();
    }
    dbManager.updateAfterTaskFinished(job, task, res);
}
Also used : TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl)

Example 57 with InternalTask

use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.

the class SchedulerDBManagerTest method startJob.

private void startJob(int jobIndex) throws Throwable {
    InternalJob startedJob = actualInternalJobs.get(jobIndex);
    startedJob.start();
    for (InternalTask task : startedJob.getITasks()) {
        task.setStatus(TaskStatus.RUNNING);
    }
    dbManager.updateJobAndTasksState(startedJob);
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask)

Example 58 with InternalTask

use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.

the class SchedulerDBManagerTest method testUpdateTaskState.

@Test
public void testUpdateTaskState() throws Exception {
    InternalJob job = createTestJob("test", "tag", 1);
    service.submitJob(job);
    InternalTask internalTask = job.getITasks().get(0);
    internalTask.setStatus(TaskStatus.ABORTED);
    dbManager.updateTaskState(internalTask);
    Page<TaskState> tasks = dbManager.getTaskStates(0, 10, null, 0, 10, null, true, true, true, new SortSpecifierContainer());
    assertThat(tasks.getSize()).isEqualTo(1);
    TaskState taskState = tasks.getList().get(0);
    assertThat(taskState.getStatus()).isEqualTo(TaskStatus.ABORTED);
}
Also used : SortSpecifierContainer(org.ow2.proactive.scheduler.common.SortSpecifierContainer) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Test(org.junit.Test)

Example 59 with InternalTask

use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.

the class SchedulerDBManagerTest method terminateJob.

private void terminateJob(int jobIndex, long finishedTime) throws Throwable {
    InternalJob finishedJob = actualInternalJobs.get(jobIndex);
    finishedJob.start();
    finishedJob.terminate();
    for (InternalTask task : finishedJob.getITasks()) {
        TaskResultImpl result = new TaskResultImpl(task.getId(), "ok", null, 0);
        FlowAction action = new FlowAction(FlowActionType.CONTINUE);
        ChangedTasksInfo changesInfo = finishedJob.terminateTask(false, task.getId(), null, action, result);
        task.setFinishedTime(finishedTime);
        dbManager.updateAfterWorkflowTaskFinished(finishedJob, changesInfo, result);
    }
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) ChangedTasksInfo(org.ow2.proactive.scheduler.job.ChangedTasksInfo) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) FlowAction(org.ow2.proactive.scheduler.common.task.flow.FlowAction) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask)

Example 60 with InternalTask

use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.

the class SchedulerDbManagerRecoveryTest method testJobRecoveryWithIfInALoop.

/**
 * Regression test related to issue #1988:
 * <p>
 * https://github.com/ow2-proactive/scheduling/issues/1988
 */
@Test
public void testJobRecoveryWithIfInALoop() throws Exception {
    InternalJob reloadedJob = testJobRecovery("flow_if_in_a_loop.xml");
    // joined branches should be saved and restored
    InternalTask task = reloadedJob.getTask("Loop");
    assertThat(task).isNotNull();
    assertThat(task.getJoinedBranches()).isNotEmpty();
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) Test(org.junit.Test) ProActiveTest(org.ow2.tests.ProActiveTest)

Aggregations

InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)142 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)74 Test (org.junit.Test)72 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)39 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)37 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)32 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)31 ArrayList (java.util.ArrayList)30 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)25 JobId (org.ow2.proactive.scheduler.common.job.JobId)22 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)18 ExecuterInformation (org.ow2.proactive.scheduler.task.internal.ExecuterInformation)16 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)13 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)12 HashMap (java.util.HashMap)10 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)10 ProActiveTest (org.ow2.tests.ProActiveTest)10 TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)9 HashSet (java.util.HashSet)8 SchedulerStateRecoverHelper (org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper)8