Search in sources :

Example 51 with InternalJob

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

the class TestJobOperations method testPause.

@Test
public void testPause() throws Exception {
    InternalJob job = defaultSubmitJobAndLoadInternal(false, new TaskFlowJob());
    Assert.assertEquals(JobStatus.PENDING, job.getStatus());
    job.setPaused();
    dbManager.updateJobAndTasksState(job);
    job = recoverJob();
    Assert.assertEquals(JobStatus.PAUSED, job.getStatus());
    Assert.assertEquals(TaskStatus.PAUSED, job.getTasks().get(0).getStatus());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) Test(org.junit.Test)

Example 52 with InternalJob

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

the class TestJobOperations method testLoadJobWithTasksIfNotRemoved.

@Test
public void testLoadJobWithTasksIfNotRemoved() throws Exception {
    TaskFlowJob jobDef = new TaskFlowJob();
    jobDef.addTask(createDefaultTask("task1"));
    jobDef.addTask(createDefaultTask("task2"));
    jobDef.addTask(createDefaultTask("task3"));
    jobDef.setPriority(JobPriority.HIGHEST);
    InternalJob job = defaultSubmitJob(jobDef, "user1");
    List<InternalJob> jobs = dbManager.loadJobWithTasksIfNotRemoved(job.getId());
    Assert.assertEquals(1, jobs.size());
    job = jobs.get(0);
    Assert.assertEquals(3, job.getTasks().size());
    Assert.assertEquals("user1", job.getOwner());
    Assert.assertEquals(3, job.getJobInfo().getTotalNumberOfTasks());
    Assert.assertEquals(0, job.getJobInfo().getNumberOfFinishedTasks());
    Assert.assertEquals(0, job.getJobInfo().getNumberOfRunningTasks());
    Assert.assertEquals(0, job.getJobInfo().getNumberOfPendingTasks());
    Assert.assertEquals(JobStatus.PENDING, job.getJobInfo().getStatus());
    Assert.assertEquals(JobPriority.HIGHEST, job.getJobInfo().getPriority());
    dbManager.removeJob(job.getId(), System.currentTimeMillis(), false);
    Assert.assertTrue(dbManager.loadJobWithTasksIfNotRemoved(job.getId()).isEmpty());
    Assert.assertTrue(dbManager.loadJobWithTasksIfNotRemoved(JobIdImpl.makeJobId("123456789")).isEmpty());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) Test(org.junit.Test)

Example 53 with InternalJob

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

the class TestJobRemove method testFullDataRemove1.

@Test
public void testFullDataRemove1() throws Exception {
    TaskFlowJob jobDef = new TaskFlowJob();
    JavaTask task1 = new JavaTask();
    task1.setName("task1");
    task1.setExecutableClassName(TestDummyExecutable.class.getName());
    jobDef.addTask(task1);
    InternalJob job = defaultSubmitJob(jobDef);
    System.out.println("Remove job");
    long start = System.currentTimeMillis();
    dbManager.removeJob(job.getId(), 0, true);
    System.out.println("Remove time (single task)" + (System.currentTimeMillis() - start));
    checkAllEntitiesDeleted();
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) Test(org.junit.Test)

Example 54 with InternalJob

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

the class TestJobRemove method testRuntimeDataRemoveAfterFinish.

@Test
public void testRuntimeDataRemoveAfterFinish() throws Throwable {
    TaskFlowJob jobDef = createJob(2);
    InternalJob job = defaultSubmitJobAndLoadInternal(false, jobDef);
    dbManager.updateAfterTaskFinished(job, job.getTask("javaTask-0"), new TaskResultImpl(null, "OK1", null, 0));
    dbManager.updateAfterTaskFinished(job, job.getTask("forkedJavaTask-0"), new TaskResultImpl(null, "OK2", null, 0));
    dbManager.updateAfterTaskFinished(job, job.getTask("nativeTask-0"), new TaskResultImpl(null, "OK3", null, 0));
    job.setStatus(JobStatus.FINISHED);
    dbManager.updateAfterTaskFinished(job, null, null);
    checkAllEntitiesDeleted(JobData.class.getName(), JobContent.class.getName(), TaskData.class.getName(), TaskResultData.class.getName());
    // check can still load task results
    Assert.assertEquals("OK1", dbManager.loadTaskResult(job.getTask("javaTask-0").getId(), 0).value());
    Assert.assertEquals("OK2", dbManager.loadTaskResult(job.getTask("forkedJavaTask-0").getId(), 0).value());
    Assert.assertEquals("OK3", dbManager.loadTaskResult(job.getTask("nativeTask-0").getId(), 0).value());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) JobContent(org.ow2.proactive.scheduler.core.db.JobContent) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) TaskResultData(org.ow2.proactive.scheduler.core.db.TaskResultData) JobData(org.ow2.proactive.scheduler.core.db.JobData) TaskData(org.ow2.proactive.scheduler.core.db.TaskData) Test(org.junit.Test)

Example 55 with InternalJob

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

the class TestJobRemove method removeScenario.

private void removeScenario(int tasksNumber) throws Exception {
    TaskFlowJob jobDef = createJob(tasksNumber);
    InternalJob job = defaultSubmitJobAndLoadInternal(false, jobDef);
    for (int i = 0; i < tasksNumber; i++) {
        dbManager.updateAfterTaskFinished(job, job.getTask("javaTask-" + i), new TaskResultImpl(null, "OK", null, 0));
        dbManager.updateAfterTaskFinished(job, job.getTask("javaTask-" + i), new TaskResultImpl(null, "OK", null, 0));
        dbManager.updateAfterTaskFinished(job, job.getTask("forkedJavaTask-" + i), new TaskResultImpl(null, "OK", null, 0));
        dbManager.updateAfterTaskFinished(job, job.getTask("forkedJavaTask-" + i), new TaskResultImpl(null, "OK", null, 0));
        dbManager.updateAfterTaskFinished(job, job.getTask("nativeTask-" + i), new TaskResultImpl(null, "OK", null, 0));
        dbManager.updateAfterTaskFinished(job, job.getTask("nativeTask-" + i), new TaskResultImpl(null, "OK", null, 0));
    }
    System.out.println("Remove job");
    long start = System.currentTimeMillis();
    dbManager.removeJob(job.getId(), 0, true);
    System.out.println("Remove time (tasks: " + tasksNumber + ")" + (System.currentTimeMillis() - start));
    checkAllEntitiesDeleted();
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob)

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