use of org.ow2.proactive.scheduler.task.internal.InternalTask 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.task.internal.InternalTask 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.task.internal.InternalTask in project scheduling by ow2-proactive.
the class TestJobRuntimeData method testJobRuntimeData.
@Test
public void testJobRuntimeData() throws Exception {
TaskFlowJob job = new TaskFlowJob();
job.setName(this.getClass().getSimpleName());
job.addTask(createDefaultTask("task1"));
job.setPriority(JobPriority.LOW);
System.out.println("Submit and load job");
InternalJob runtimeData = defaultSubmitJobAndLoadInternal(true, job);
Assert.assertEquals(JobStatus.PENDING, runtimeData.getStatus());
Assert.assertEquals(DEFAULT_USER_NAME, runtimeData.getOwner());
Assert.assertEquals(JobPriority.LOW, runtimeData.getPriority());
Assert.assertEquals(0, runtimeData.getNumberOfPendingTasks());
Assert.assertEquals(1, runtimeData.getTotalNumberOfTasks());
Assert.assertEquals(0, runtimeData.getNumberOfFinishedTasks());
Assert.assertEquals(0, runtimeData.getNumberOfRunningTasks());
Assert.assertEquals(this.getClass().getSimpleName(), runtimeData.getName());
Assert.assertNotNull(runtimeData.getCredentials());
Assert.assertEquals(1, runtimeData.getITasks().size());
runtimeData.start();
InternalTask internalTask = startTask(runtimeData, runtimeData.getITasks().get(0));
System.out.println("Update started task data");
dbManager.jobTaskStarted(runtimeData, internalTask, false);
System.out.println("Load internal job");
runtimeData = loadInternalJob(true, runtimeData.getId());
Assert.assertEquals(this.getClass().getSimpleName(), runtimeData.getJobInfo().getJobId().getReadableName());
Assert.assertEquals(JobStatus.RUNNING, runtimeData.getStatus());
Assert.assertEquals(1, runtimeData.getNumberOfRunningTasks());
Assert.assertEquals(0, runtimeData.getNumberOfFinishedTasks());
Assert.assertEquals(0, runtimeData.getNumberOfPendingTasks());
Assert.assertTrue(runtimeData.getStartTime() > 0);
internalTask = runtimeData.getITasks().get(0);
Assert.assertEquals(TaskStatus.RUNNING, internalTask.getStatus());
Assert.assertTrue(internalTask.getStartTime() > 0);
Assert.assertNotNull(internalTask.getExecutionHostName());
}
use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.
the class TestLoadJobResult method testEmptyResult.
@Test
public void testEmptyResult() throws Throwable {
TaskFlowJob jobDef = new TaskFlowJob();
jobDef.addTask(createDefaultTask("task1"));
InternalJob job = defaultSubmitJobAndLoadInternal(true, jobDef);
InternalTask task1 = job.getTask("task1");
JobResult result;
result = dbManager.loadJobResult(job.getId());
Assert.assertNotNull(result.getJobInfo());
Assert.assertEquals(0, result.getAllResults().size());
Assert.assertEquals(1, result.getJobInfo().getTotalNumberOfTasks());
dbManager.updateAfterTaskFinished(job, task1, new TaskResultImpl(null, new TestResult(0, "1_1"), null, 0));
result = dbManager.loadJobResult(job.getId());
Assert.assertNotNull(result.getJobInfo());
Assert.assertEquals(1, result.getAllResults().size());
Assert.assertEquals(1, result.getJobInfo().getTotalNumberOfTasks());
}
use of org.ow2.proactive.scheduler.task.internal.InternalTask in project scheduling by ow2-proactive.
the class TestLoadJobsPagination method testSorting.
@Test
public void testSorting() throws Exception {
// 1
InternalJob job1 = defaultSubmitJob(createJob("A", JobPriority.IDLE), "user_a");
// 2
defaultSubmitJob(createJob("B", JobPriority.LOWEST), "user_b");
// 3
InternalJob job3 = defaultSubmitJob(createJob("C", JobPriority.LOW), "user_c");
// 4
defaultSubmitJob(createJob("A", JobPriority.NORMAL), "user_d");
// 5
InternalJob job5 = defaultSubmitJob(createJob("B", JobPriority.HIGH), "user_e");
// 6
defaultSubmitJob(createJob("C", JobPriority.HIGHEST), "user_f");
// change status for some jobs
job1.failed(null, JobStatus.KILLED);
dbManager.updateAfterJobKilled(job1, Collections.<TaskId>emptySet());
job3.setPaused();
dbManager.updateJobAndTasksState(job3);
job5.start();
InternalTask taskJob5 = startTask(job5, job5.getITasks().get(0));
dbManager.jobTaskStarted(job5, taskJob5, true);
List<JobInfo> jobs;
jobs = dbManager.getJobs(0, 10, null, true, true, true, sortParameters(new SortParameter<>(JobSortParameter.ID, SortOrder.ASC))).getList();
checkJobs(jobs, 1, 2, 3, 4, 5, 6);
jobs = dbManager.getJobs(0, 10, null, true, true, true, sortParameters(new SortParameter<>(JobSortParameter.ID, SortOrder.DESC))).getList();
checkJobs(jobs, 6, 5, 4, 3, 2, 1);
jobs = dbManager.getJobs(0, 10, null, true, true, true, sortParameters(new SortParameter<>(JobSortParameter.NAME, SortOrder.ASC), new SortParameter<>(JobSortParameter.ID, SortOrder.ASC))).getList();
checkJobs(jobs, 1, 4, 2, 5, 3, 6);
jobs = dbManager.getJobs(0, 10, null, true, true, true, sortParameters(new SortParameter<>(JobSortParameter.NAME, SortOrder.ASC), new SortParameter<>(JobSortParameter.ID, SortOrder.DESC))).getList();
checkJobs(jobs, 4, 1, 5, 2, 6, 3);
jobs = dbManager.getJobs(0, 10, null, true, true, true, sortParameters(new SortParameter<>(JobSortParameter.OWNER, SortOrder.ASC))).getList();
checkJobs(jobs, 1, 2, 3, 4, 5, 6);
jobs = dbManager.getJobs(0, 10, null, true, true, true, sortParameters(new SortParameter<>(JobSortParameter.OWNER, SortOrder.DESC))).getList();
checkJobs(jobs, 6, 5, 4, 3, 2, 1);
jobs = dbManager.getJobs(0, 10, null, true, true, true, sortParameters(new SortParameter<>(JobSortParameter.PRIORITY, SortOrder.ASC))).getList();
checkJobs(jobs, 1, 2, 3, 4, 5, 6);
jobs = dbManager.getJobs(0, 10, null, true, true, true, sortParameters(new SortParameter<>(JobSortParameter.PRIORITY, SortOrder.DESC))).getList();
checkJobs(jobs, 6, 5, 4, 3, 2, 1);
jobs = dbManager.getJobs(0, 10, null, true, true, true, sortParameters(new SortParameter<>(JobSortParameter.STATE, SortOrder.ASC), new SortParameter<>(JobSortParameter.ID, SortOrder.ASC))).getList();
checkJobs(jobs, 2, 4, 6, 3, 5, 1);
jobs = dbManager.getJobs(0, 10, null, true, true, true, sortParameters(new SortParameter<>(JobSortParameter.STATE, SortOrder.DESC), new SortParameter<>(JobSortParameter.ID, SortOrder.ASC))).getList();
checkJobs(jobs, 1, 3, 5, 2, 4, 6);
}
Aggregations