Search in sources :

Example 11 with SchedulerStateRecoverHelper

use of org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper in project scheduling by ow2-proactive.

the class TestRestoreWorkflowJobs method finishedJobWithScriptsCanBeRecoveredAndLoaded.

@Test
public void finishedJobWithScriptsCanBeRecoveredAndLoaded() throws Exception {
    InternalJob job = defaultSubmitJobAndLoadInternal(true, createJobWithAllKindOfScripts());
    job.start();
    InternalTask mainTask = job.getTask("T");
    startTask(job, mainTask);
    dbManager.jobTaskStarted(job, mainTask, true);
    TaskResultImpl result = new TaskResultImpl(mainTask.getId(), "ok", null, 0);
    ChangedTasksInfo changesInfo = job.terminateTask(false, mainTask.getId(), null, null, result);
    job.setStatus(JobStatus.FINISHED);
    dbManager.updateAfterWorkflowTaskFinished(job, changesInfo, result);
    SchedulerStateRecoverHelper recoverHelper = new SchedulerStateRecoverHelper(dbManager);
    JobStateMatcher expectedJob = job(job.getId(), JobStatus.FINISHED).withFinished(task("T", TaskStatus.FINISHED).checkFinished(), true);
    checkRecoveredState(recoverHelper.recover(-1), state().withFinished(expectedJob));
    List<InternalJob> finishedJobs = dbManager.loadFinishedJobs(true, -1);
    assertEquals(1, finishedJobs.size());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) ChangedTasksInfo(org.ow2.proactive.scheduler.job.ChangedTasksInfo) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) SchedulerStateRecoverHelper(org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper) Test(org.junit.Test)

Example 12 with SchedulerStateRecoverHelper

use of org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper in project scheduling by ow2-proactive.

the class TestSetJobToBeRemoved method test.

@Test
public void test() throws Exception {
    InternalJob job = defaultSubmitJobAndLoadInternal(false, new TaskFlowJob());
    Assert.assertFalse(job.isToBeRemoved());
    job.setToBeRemoved();
    System.out.println("Set job to be removed");
    dbManager.jobSetToBeRemoved(job.getId());
    SchedulerStateRecoverHelper recoverHelper = new SchedulerStateRecoverHelper(dbManager);
    Collection<InternalJob> jobs = recoverHelper.recover(-1).getPendingJobs();
    Assert.assertEquals(1, jobs.size());
    job = jobs.iterator().next();
    Assert.assertTrue(job.isToBeRemoved());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SchedulerStateRecoverHelper(org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper) Test(org.junit.Test)

Example 13 with SchedulerStateRecoverHelper

use of org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper in project scheduling by ow2-proactive.

the class TestTaskIdGeneration method test.

@Test
public void test() throws Exception {
    TaskFlowJob jobDef = new TaskFlowJob();
    jobDef.addTask(createDefaultTask("task1"));
    jobDef.addTask(createDefaultTask("task2"));
    jobDef.addTask(createDefaultTask("task3"));
    InternalJob job = InternalJobFactory.createJob(jobDef, getDefaultCredentials());
    job.setOwner(DEFAULT_USER_NAME);
    dbManager.newJobSubmitted(job);
    for (InternalTask task : job.getITasks()) {
        Assert.assertSame(task, job.getIHMTasks().get(task.getId()));
    }
    for (TaskDescriptor task : job.getJobDescriptor().getEligibleTasks()) {
        Assert.assertNotNull(job.getIHMTasks().get(task.getTaskId()));
    }
    checkIds(job);
    SchedulerStateRecoverHelper recoverHelper = new SchedulerStateRecoverHelper(dbManager);
    RecoveredSchedulerState state = recoverHelper.recover(-1);
    Collection<InternalJob> jobs = state.getPendingJobs();
    Assert.assertEquals(1, jobs.size());
    job = jobs.iterator().next();
    checkIds(job);
    JobState jobState = state.getSchedulerState().getPendingJobs().iterator().next();
    checkIds(jobState);
}
Also used : TaskDescriptor(org.ow2.proactive.scheduler.common.TaskDescriptor) RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SchedulerStateRecoverHelper(org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper) JobState(org.ow2.proactive.scheduler.common.job.JobState) Test(org.junit.Test)

Example 14 with SchedulerStateRecoverHelper

use of org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper in project scheduling by ow2-proactive.

the class SchedulerStateRecoverHelperTest method testRecoverWithIncorrectStatusForLoadedNotFinishedJobs.

public void testRecoverWithIncorrectStatusForLoadedNotFinishedJobs(JobStatus jobStatus) {
    InternalJob job = new InternalTaskFlowJob();
    job.setStatus(jobStatus);
    SchedulerDBManager dbManager = Mockito.mock(SchedulerDBManager.class);
    SchedulerStateRecoverHelper stateRecoverHelper = new SchedulerStateRecoverHelper(dbManager);
    Mockito.when(dbManager.loadNotFinishedJobs(true)).thenReturn(ImmutableList.of(job));
    stateRecoverHelper.recover(-1);
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) SchedulerStateRecoverHelper(org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob)

Aggregations

SchedulerStateRecoverHelper (org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper)14 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)12 Test (org.junit.Test)11 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)9 RecoveredSchedulerState (org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState)8 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)8 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)5 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)3 TaskDescriptor (org.ow2.proactive.scheduler.common.TaskDescriptor)2 JobState (org.ow2.proactive.scheduler.common.job.JobState)2 FlowAction (org.ow2.proactive.scheduler.common.task.flow.FlowAction)2 SchedulerDBManager (org.ow2.proactive.scheduler.core.db.SchedulerDBManager)2 ChangedTasksInfo (org.ow2.proactive.scheduler.job.ChangedTasksInfo)2 ImmutableList (com.google.common.collect.ImmutableList)1 KeyException (java.security.KeyException)1 HashMap (java.util.HashMap)1 ExecutorService (java.util.concurrent.ExecutorService)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 TimeUnit (java.util.concurrent.TimeUnit)1