use of org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper in project scheduling by ow2-proactive.
the class SchedulerTasksStateRecoverIntegrationTest method testRecover.
@Test
public void testRecover() throws Exception {
SchedulerStateRecoverHelper recoverHelper = new SchedulerStateRecoverHelper(dbManager);
RecoveredSchedulerState state = recoverHelper.recover(-1);
Assert.assertEquals(0, state.getFinishedJobs().size());
Assert.assertEquals(0, state.getRunningJobs().size());
Assert.assertEquals(0, state.getPendingJobs().size());
TaskFlowJob job1 = new TaskFlowJob();
JavaTask task1 = createDefaultTask("task1");
JavaTask task2 = createDefaultTask("task2");
JavaTask task3 = createDefaultTask("task3");
task1.addDependence(task2);
task1.addDependence(task3);
task2.addDependence(task3);
job1.addTask(task1);
job1.addTask(task2);
job1.addTask(task3);
InternalJob job = defaultSubmitJob(job1);
JobStateMatcher expectedJob;
expectedJob = job(job.getId(), JobStatus.PENDING).withPending(task("task1", TaskStatus.SUBMITTED), false).withPending(task("task2", TaskStatus.SUBMITTED), false).withPending(task("task3", TaskStatus.SUBMITTED), false).withEligible("task3");
state = checkRecoveredState(recoverHelper.recover(-1), state().withPending(expectedJob));
job = state.getPendingJobs().get(0);
TaskDescriptor task = job.getJobDescriptor().getEligibleTasks().iterator().next();
Assert.assertEquals(2, task.getChildren().size());
Assert.assertEquals(0, task.getParents().size());
job.terminate();
dbManager.updateAfterTaskFinished(job, null, null);
expectedJob = job(job.getId(), JobStatus.FINISHED).withPending(task("task1", TaskStatus.SUBMITTED), false).withPending(task("task2", TaskStatus.SUBMITTED), false).withPending(task("task3", TaskStatus.SUBMITTED), false).withEligible("task3");
state = checkRecoveredState(recoverHelper.recover(-1), state().withFinished(expectedJob));
job = state.getFinishedJobs().get(0);
Assert.assertEquals(3, job.getJobDescriptor().getEligibleTasks().size());
task = job.getJobDescriptor().getEligibleTasks().iterator().next();
// finished jobs tasks have no dependency information
Assert.assertEquals(0, task.getChildren().size());
Assert.assertEquals(0, task.getParents().size());
}
use of org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper in project scheduling by ow2-proactive.
the class SchedulerTasksStateRecoverIntegrationTest method testRecoverAfterRestart.
@Test
public void testRecoverAfterRestart() throws Exception {
TaskFlowJob jobDef = new TaskFlowJob();
jobDef.addTask(createDefaultTask("task1"));
InternalJob job = defaultSubmitJobAndLoadInternal(true, jobDef);
InternalTask task = job.getTask("task1");
job.start();
startTask(job, task);
dbManager.jobTaskStarted(job, task, true);
SchedulerStateRecoverHelper recoverHelper = new SchedulerStateRecoverHelper(dbManager);
JobStateMatcher expectedJob;
expectedJob = job(job.getId(), JobStatus.STALLED).withPending(task("task1", TaskStatus.SUBMITTED), true).withEligible("task1");
RecoveredSchedulerState state;
state = checkRecoveredState(recoverHelper.recover(-1), state().withRunning(expectedJob));
job = state.getRunningJobs().get(0);
task = job.getTask("task1");
startTask(job, task);
dbManager.jobTaskStarted(job, task, true);
job.newWaitingTask();
job.reStartTask(task);
dbManager.taskRestarted(job, task, null);
state = checkRecoveredState(recoverHelper.recover(-1), state().withRunning(expectedJob));
// check it is possible to load ExecutableContainer for restored task
job = state.getRunningJobs().get(0);
ExecutableContainer container = dbManager.loadExecutableContainer(job.getTask("task1"));
Assert.assertNotNull(container);
}
use of org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper in project scheduling by ow2-proactive.
the class TestJobOperations method recoverJob.
private InternalJob recoverJob() {
SchedulerStateRecoverHelper recoverHelper = new SchedulerStateRecoverHelper(dbManager);
Collection<InternalJob> jobs = recoverHelper.recover(-1).getPendingJobs();
Assert.assertEquals(1, jobs.size());
return jobs.iterator().next();
}
use of org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper in project scheduling by ow2-proactive.
the class SchedulerStateRecoverHelperTest method testRecoverWithCopyAndSortThrowingRuntimeException.
@Test
public void testRecoverWithCopyAndSortThrowingRuntimeException() throws KeyException, JobCreationException {
RecoveredSchedulerState recoveredState = new Scenario(createJob(JobStatus.RUNNING)).execute(new SchedulerStateRecoverHelperSupplier() {
@Override
public SchedulerStateRecoverHelper get(SchedulerDBManager dbManager) {
return new SchedulerStateRecoverHelper(dbManager) {
@Override
protected List<InternalTask> copyAndSort(List<InternalTask> tasks) {
throw new RuntimeException("bouh!");
}
};
}
}, false);
assertThat(recoveredState.getFinishedJobs()).hasSize(1);
assertThat(recoveredState.getPendingJobs()).hasSize(0);
assertThat(recoveredState.getRunningJobs()).hasSize(0);
assertThat(recoveredState.getFinishedJobs().get(0).getStatus()).isEqualTo(JobStatus.CANCELED);
}
use of org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper in project scheduling by ow2-proactive.
the class TestRestoreWorkflowJobs2 method test.
@Test
public void test() throws Exception {
TaskFlowJob jobDef = createJob();
InternalJob job = defaultSubmitJobAndLoadInternal(true, jobDef);
job.start();
InternalTask mainTask = job.getTask("A");
startTask(job, mainTask);
dbManager.jobTaskStarted(job, mainTask, true);
TaskResultImpl result = new TaskResultImpl(mainTask.getId(), "ok", null, 0);
FlowAction action = new FlowAction(FlowActionType.IF);
action.setDupNumber(1);
action.setTarget("B");
action.setTargetElse("C");
ChangedTasksInfo changesInfo = job.terminateTask(false, mainTask.getId(), null, action, result);
dbManager.updateAfterWorkflowTaskFinished(job, changesInfo, result);
SchedulerStateRecoverHelper recoverHelper = new SchedulerStateRecoverHelper(dbManager);
RecoveredSchedulerState state = recoverHelper.recover(-1);
job = state.getRunningJobs().get(0);
System.out.println("OK");
}
Aggregations