use of org.ow2.proactive.scheduler.common.job.TaskFlowJob 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);
task = job.getJobDescriptor().getEligibleTasks().iterator().next();
Assert.assertEquals(2, task.getChildren().size());
Assert.assertEquals(0, task.getParents().size());
}
use of org.ow2.proactive.scheduler.common.job.TaskFlowJob 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.PENDING), 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.common.job.TaskFlowJob in project scheduling by ow2-proactive.
the class TestDataspaceSelectorsData method testSelectors.
@Test
public void testSelectors() throws Exception {
TaskFlowJob jobDef = new TaskFlowJob();
JavaTask task = createDefaultTask("task1");
Set<String> inInclude1 = Sets.newHashSet("inInclude1_1", "inInclude1_2");
Set<String> inExclude1 = Sets.newHashSet("inExclude1_1", "inExclude1_2");
Set<String> outInclude1 = Sets.newHashSet("outInclude1_1", "outInclude1_2");
Set<String> outExclude1 = Sets.newHashSet("outExclude1_1", "outExclude1_2");
Set<String> inInclude2 = Sets.newHashSet("inInclude" + createString(500));
Set<String> inExclude2 = Sets.newHashSet("inExclude" + createString(500));
Set<String> outInclude2 = Sets.newHashSet("outInclude" + createString(500));
Set<String> outExclude2 = Sets.newHashSet("outExclude" + createString(500));
FileSelector fileSelector;
task.addInputFiles(new FileSelector(inInclude1, inExclude1), InputAccessMode.TransferFromGlobalSpace);
task.addInputFiles(new FileSelector(inInclude1, inExclude1), InputAccessMode.TransferFromUserSpace);
fileSelector = new FileSelector(inInclude2, inExclude2);
task.addInputFiles(fileSelector, InputAccessMode.TransferFromInputSpace);
task.addOutputFiles(new FileSelector(outInclude1, outExclude1), OutputAccessMode.TransferToGlobalSpace);
task.addOutputFiles(new FileSelector(outInclude1, outExclude1), OutputAccessMode.TransferToUserSpace);
fileSelector = new FileSelector(outInclude2, outExclude2);
task.addOutputFiles(fileSelector, OutputAccessMode.TransferToOutputSpace);
jobDef.addTask(task);
InternalJob job = defaultSubmitJobAndLoadInternal(true, jobDef);
InternalTask task1 = job.getTask("task1");
Assert.assertEquals(3, task1.getInputFilesList().size());
Assert.assertEquals(InputAccessMode.TransferFromGlobalSpace, task1.getInputFilesList().get(0).getMode());
Assert.assertEquals(InputAccessMode.TransferFromUserSpace, task1.getInputFilesList().get(1).getMode());
Assert.assertEquals(3, task1.getOutputFilesList().size());
checkSelector(task1.getInputFilesList().get(0).getInputFiles(), inInclude1, inExclude1, true);
checkSelector(task1.getInputFilesList().get(1).getInputFiles(), inInclude1, inExclude1, true);
checkSelector(task1.getInputFilesList().get(2).getInputFiles(), inInclude2, inExclude2, false);
checkSelector(task1.getOutputFilesList().get(0).getOutputFiles(), outInclude1, outExclude1, true);
checkSelector(task1.getOutputFilesList().get(1).getOutputFiles(), outInclude1, outExclude1, true);
checkSelector(task1.getOutputFilesList().get(2).getOutputFiles(), outInclude2, outExclude2, false);
}
use of org.ow2.proactive.scheduler.common.job.TaskFlowJob in project scheduling by ow2-proactive.
the class TestInMemorySchedulerDB method sanityLastUpdatedTimeTest.
@Test
public void sanityLastUpdatedTimeTest() throws Exception {
SchedulerDBManager dbManager = SchedulerDBManager.createInMemorySchedulerDBManager();
TaskFlowJob jobDef = new TaskFlowJob();
jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task1"));
InternalJob job = InternalJobFactory.createJob(jobDef, BaseSchedulerDBTest.getDefaultCredentials());
job.setOwner("test");
dbManager.newJobSubmitted(job);
List<InternalJob> jobs = dbManager.loadJobs(false, job.getId());
// when job is submitted, the last updated time is initialized as submitted time
Assert.assertThat(jobs.size(), is(1));
Assert.assertThat(jobs.get(0).getJobInfo().getLastUpdatedTime(), is(jobs.get(0).getJobInfo().getSubmittedTime()));
dbManager.changeJobPriority(job.getId(), JobPriority.HIGH);
jobs = dbManager.loadJobs(false, job.getId());
// job's priority was changed, the last update time must be greater than submitted time
long priorityChangedTime = jobs.get(0).getJobInfo().getLastUpdatedTime();
Assert.assertThat(priorityChangedTime - jobs.get(0).getJobInfo().getSubmittedTime() > 0, is(true));
dbManager.jobSetToBeRemoved(job.getId());
jobs = dbManager.loadJobs(false, job.getId());
// job's state was changed, the last update time must be greater than submitted time
Assert.assertThat(jobs.get(0).getJobInfo().getLastUpdatedTime() - priorityChangedTime > 0, is(true));
}
use of org.ow2.proactive.scheduler.common.job.TaskFlowJob in project scheduling by ow2-proactive.
the class TestInMemorySchedulerDB method sanityTest.
@Test
public void sanityTest() throws Exception {
SchedulerDBManager dbManager = SchedulerDBManager.createInMemorySchedulerDBManager();
TaskFlowJob jobDef = new TaskFlowJob();
jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task1"));
jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task2"));
jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task3"));
InternalJob job = InternalJobFactory.createJob(jobDef, BaseSchedulerDBTest.getDefaultCredentials());
job.setOwner("test");
dbManager.newJobSubmitted(job);
dbManager.readAccount("test");
dbManager.changeJobPriority(job.getId(), JobPriority.HIGH);
Assert.assertEquals(1, dbManager.loadNotFinishedJobs(true).size());
}
Aggregations