use of org.ow2.proactive.scheduler.common.task.JavaTask in project scheduling by ow2-proactive.
the class TestLoadSchedulerClientState method checkTaskData.
private void checkTaskData(JavaTask expected, TaskState taskState, String... dependences) {
Assert.assertEquals(expected.getName(), taskState.getName());
Assert.assertEquals(expected.getDescription(), taskState.getDescription());
Assert.assertEquals(expected.getName(), taskState.getTaskInfo().getTaskId().getReadableName());
Assert.assertEquals(expected.getOnTaskErrorProperty().getValue(), taskState.getOnTaskErrorProperty().getValue());
Assert.assertEquals(expected.getMaxNumberOfExecution(), taskState.getMaxNumberOfExecution());
Assert.assertEquals(expected.isPreciousLogs(), taskState.isPreciousLogs());
Assert.assertEquals(expected.isPreciousResult(), taskState.isPreciousResult());
Assert.assertEquals(expected.isRunAsMe(), taskState.isRunAsMe());
Assert.assertEquals(expected.getWallTime(), taskState.getWallTime());
Assert.assertEquals("Unexpected number of dependencies", dependences.length, taskState.getDependences().size());
Set<String> dependenciesSet = new HashSet<>();
for (String dependecy : dependences) {
dependenciesSet.add(dependecy);
}
Set<String> actualDependenciesSet = new HashSet<>();
for (TaskState task : taskState.getDependences()) {
actualDependenciesSet.add(task.getName());
}
Assert.assertEquals("Unexpected dependencies", dependenciesSet, actualDependenciesSet);
}
use of org.ow2.proactive.scheduler.common.task.JavaTask in project scheduling by ow2-proactive.
the class TestLoadSchedulerClientState method testStateAfterTaskFinished.
@Test
public void testStateAfterTaskFinished() throws Exception {
TaskFlowJob jobDef = new TaskFlowJob();
JavaTask taskDef1 = createDefaultTask("task1");
JavaTask taskDef2 = createDefaultTask("task2");
taskDef2.addDependence(taskDef1);
jobDef.addTask(taskDef1);
jobDef.addTask(taskDef2);
InternalJob job = defaultSubmitJobAndLoadInternal(true, jobDef);
InternalTask task1 = job.getTask("task1");
job.start();
startTask(job, task1);
dbManager.jobTaskStarted(job, task1, true);
TaskResultImpl result = new TaskResultImpl(null, new TestResult(1, "res1"), null, 1000);
terminateTask(job, task1, result);
dbManager.updateAfterTaskFinished(job, task1, result);
SchedulerStateRecoverHelper stateRecoverHelper = new SchedulerStateRecoverHelper(dbManager);
RecoveredSchedulerState recovered;
recovered = stateRecoverHelper.recover(-1);
JobStateMatcher expectedJob;
expectedJob = job(job.getId(), JobStatus.STALLED).withFinished(task("task1", TaskStatus.FINISHED).checkFinished()).withPending(task("task2", TaskStatus.SUBMITTED), true).withEligible("task2");
checkRecoveredState(recovered, state().withRunning(expectedJob));
job = recovered.getRunningJobs().get(0);
InternalTask task2 = job.getTask("task2");
startTask(job, task2);
dbManager.jobTaskStarted(job, task2, false);
expectedJob = job(job.getId(), JobStatus.STALLED).withFinished(task("task1", TaskStatus.FINISHED).checkFinished()).withPending(task("task2", TaskStatus.SUBMITTED), true).withEligible("task2");
recovered = stateRecoverHelper.recover(-1);
checkRecoveredState(recovered, state().withRunning(expectedJob));
job = recovered.getRunningJobs().get(0);
task2 = job.getTask("task2");
startTask(job, task2);
dbManager.jobTaskStarted(job, task2, false);
terminateTask(job, task2, result);
dbManager.updateAfterTaskFinished(job, task2, result);
expectedJob = job(job.getId(), JobStatus.FINISHED).withFinished(task("task1", TaskStatus.FINISHED).checkFinished()).withFinished(task("task2", TaskStatus.FINISHED).checkFinished());
recovered = stateRecoverHelper.recover(-1);
checkRecoveredState(recovered, state().withFinished(expectedJob));
}
use of org.ow2.proactive.scheduler.common.task.JavaTask in project scheduling by ow2-proactive.
the class TestLoadSchedulerClientState method testClientStateLoading.
@Test
public void testClientStateLoading() throws Exception {
TaskFlowJob job1 = new TaskFlowJob();
job1.setName(this.getClass().getSimpleName());
job1.setDescription("desc1");
job1.setProjectName("p1");
job1.setInputSpace("is1");
job1.setOutputSpace("os1");
job1.setMaxNumberOfExecution(22);
job1.setOnTaskError(OnTaskError.CONTINUE_JOB_EXECUTION);
JavaTask task1 = createDefaultTask("task1");
task1.setDescription("d1");
task1.setOnTaskError(OnTaskError.CANCEL_JOB);
task1.setMaxNumberOfExecution(4);
task1.setPreciousLogs(true);
task1.setPreciousResult(true);
task1.setRunAsMe(true);
task1.setWallTime(440000);
JavaTask task2 = createDefaultTask("task2");
task2.setDescription("d2");
// If it is set to none, the job level behavior will overwrite the task level none behavior.
task2.setOnTaskError(OnTaskError.NONE);
task2.setMaxNumberOfExecution(3);
task2.setPreciousLogs(false);
task2.setPreciousResult(false);
task2.setRunAsMe(false);
task2.setWallTime(240000);
JavaTask task3 = createDefaultTask("task3");
task1.addDependence(task2);
task1.addDependence(task3);
task2.addDependence(task3);
job1.addTask(task1);
job1.addTask(task2);
job1.addTask(task3);
job1.setPriority(JobPriority.LOW);
Map<String, String> genericInfo = new HashMap<>();
genericInfo.put("p1", "v1");
genericInfo.put("p2", "v2");
job1.setGenericInformation(genericInfo);
InternalJob jobData1 = defaultSubmitJob(job1);
TaskFlowJob job2 = new TaskFlowJob();
job2.setName(this.getClass().getSimpleName() + "_2");
job2.setGenericInformation(new HashMap<String, String>());
job2.addTask(createDefaultTask("task1"));
job2.setPriority(JobPriority.HIGH);
InternalJob jobData2 = defaultSubmitJob(job2);
System.out.println("Load scheduler client state");
SchedulerStateRecoverHelper stateRecoverHelper = new SchedulerStateRecoverHelper(dbManager);
SchedulerState state = stateRecoverHelper.recover(-1).getSchedulerState();
Assert.assertEquals("Unexpected jobs number", 2, state.getPendingJobs().size());
JobState jobState;
jobState = checkJobData(state.getPendingJobs(), jobData1.getId(), job1, 3);
checkTaskData(task1, findTask(jobState, "task1"), "task2", "task3");
checkTaskData(task2, findTask(jobState, "task2"), "task3");
checkTaskData(task3, findTask(jobState, "task3"));
checkJobData(state.getPendingJobs(), jobData2.getId(), job2, 1);
}
use of org.ow2.proactive.scheduler.common.task.JavaTask in project scheduling by ow2-proactive.
the class TestRestoreWorkflowJobs method task.
static JavaTask task(String name) {
JavaTask task = new JavaTask();
task.setExecutableClassName(EmptyTask.class.getName());
task.setName(name);
return task;
}
use of org.ow2.proactive.scheduler.common.task.JavaTask in project scheduling by ow2-proactive.
the class TestRestoreWorkflowJobs method createJobWithAllKindOfScripts.
private TaskFlowJob createJobWithAllKindOfScripts() throws InvalidScriptException, UserException {
TaskFlowJob jobDef = new TaskFlowJob();
JavaTask t = task("T");
ForkEnvironment forkEnvironment = new ForkEnvironment();
SimpleScript aScript = new SimpleScript("", "");
forkEnvironment.setEnvScript(aScript);
t.setPreScript(aScript);
t.setPostScript(aScript);
t.setCleaningScript(aScript);
t.setSelectionScript(new SelectionScript("", ""));
t.setFlowScript(FlowScript.createContinueFlowScript());
t.setForkEnvironment(forkEnvironment);
jobDef.addTask(t);
return jobDef;
}
Aggregations