Search in sources :

Example 76 with InternalJob

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

the class TestTaskRuntimeData method testStartJobExecution.

@Test
public void testStartJobExecution() throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    job.addTask(createDefaultTask("task1"));
    job.addTask(createDefaultTask("task2"));
    job.addTask(createDefaultTask("task3"));
    InternalJob internalJob = defaultSubmitJobAndLoadInternal(true, job);
    Assert.assertEquals(TaskStatus.SUBMITTED, internalJob.getTask("task1").getStatus());
    Assert.assertEquals(TaskStatus.SUBMITTED, internalJob.getTask("task2").getStatus());
    Assert.assertEquals(TaskStatus.SUBMITTED, internalJob.getTask("task3").getStatus());
    internalJob.start();
    InternalTask task = startTask(internalJob, internalJob.getTask("task1"));
    System.out.println("Job started");
    dbManager.jobTaskStarted(internalJob, task, true);
    internalJob = loadInternalJob(true, internalJob.getId());
    Assert.assertEquals(TaskStatus.RUNNING, internalJob.getTask("task1").getStatus());
    Assert.assertEquals(TaskStatus.PENDING, internalJob.getTask("task2").getStatus());
    Assert.assertEquals(TaskStatus.PENDING, internalJob.getTask("task3").getStatus());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) Test(org.junit.Test)

Example 77 with InternalJob

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

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

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

the class SchedulerDBManagerTest method createTestJob.

private InternalJob createTestJob(String jobName, String taskTag, int nbTasks) throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    job.setName(jobName);
    for (int i = 1; i <= nbTasks; i++) {
        JavaTask task = new JavaTask();
        task.setName(jobName + "-TASK-" + i + "/" + nbTasks);
        task.setExecutableClassName("class");
        task.setTag(taskTag);
        job.addTask(task);
    }
    return createJob(job);
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask)

Example 80 with InternalJob

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

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