use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class TestReportingQueries method checkMeanTaskPendingTime.
private void checkMeanTaskPendingTime(InternalJob job) {
job = loadInternalJob(true, job.getId());
double expected = 0;
int counter = 0;
for (InternalTask task : job.getITasks()) {
if (task.getStartTime() > 0) {
expected += task.getStartTime() - job.getSubmittedTime();
counter++;
}
}
if (counter == 0) {
expected = 0;
} else {
expected /= counter;
}
Assert.assertEquals(expected, dbManager.getMeanTaskPendingTime(job.getJobInfo().getJobId().value()), 001);
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class TestReportingQueries method checkMeanExecutionTime.
private void checkMeanExecutionTime(InternalJob... jobs) {
double expected = 0;
if (jobs.length > 0) {
for (InternalJob job : jobs) {
expected += (job.getFinishedTime() - job.getStartTime());
}
expected /= jobs.length;
}
Assert.assertEquals(expected, dbManager.getMeanJobExecutionTime(), 0.001);
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class TestRestoreWorkflowJobs method test.
@Test
public void test() throws Exception {
TaskFlowJob jobDef = createJob();
InternalJob job = defaultSubmitJobAndLoadInternal(true, jobDef);
job.start();
InternalTask mainTask = job.getTask("T");
startTask(job, mainTask);
dbManager.jobTaskStarted(job, mainTask, true);
TaskResultImpl result = new TaskResultImpl(mainTask.getId(), "ok", null, 0);
FlowAction action = new FlowAction(FlowActionType.REPLICATE);
action.setDupNumber(2);
ChangedTasksInfo changesInfo = job.terminateTask(false, mainTask.getId(), null, action, result);
dbManager.updateAfterWorkflowTaskFinished(job, changesInfo, result);
SchedulerStateRecoverHelper recoverHelper = new SchedulerStateRecoverHelper(dbManager);
JobStateMatcher expectedJob;
expectedJob = job(job.getId(), JobStatus.STALLED).withFinished(task("T", TaskStatus.FINISHED).checkFinished(), true).withPending(task("T1", TaskStatus.PENDING), true).withPending(task("T1*1", TaskStatus.SUBMITTED), true).withPending(task("T2", TaskStatus.PENDING), true).withPending(task("T3", TaskStatus.PENDING), true).withPending(task("T2*1", TaskStatus.SUBMITTED), true).withPending(task("T3*1", TaskStatus.SUBMITTED), true).withPending(task("T4", TaskStatus.PENDING), true).withEligible("T1", "T1*1");
checkRecoveredState(recoverHelper.recover(-1), state().withRunning(expectedJob));
}
use of org.ow2.proactive.scheduler.job.InternalJob 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");
}
use of org.ow2.proactive.scheduler.job.InternalJob in project scheduling by ow2-proactive.
the class TestTaskAttributes method testScripts.
@Test
public void testScripts() throws Exception {
TaskFlowJob jobDef = new TaskFlowJob();
JavaTask task1 = createDefaultTask("task1");
task1.addSelectionScript(new SelectionScript("selection1", "js", new String[] { "param1", "param2" }, true));
task1.addSelectionScript(new SelectionScript("selection2", "js", new String[] { "param3" }, false));
task1.addSelectionScript(new SelectionScript("selection3", "js"));
task1.setCleaningScript(new SimpleScript("cleanscript", "js", new String[] { "p1", "p2" }));
task1.setPreScript(new SimpleScript("prescript", "js", new String[] { "p1", "p2" }));
task1.setPostScript(new SimpleScript("postscript", "js", new String[] { "p1", "p2" }));
task1.setFlowScript(FlowScript.createContinueFlowScript());
jobDef.addTask(task1);
InternalJob job = defaultSubmitJobAndLoadInternal(true, jobDef);
InternalTask task = job.getTask("task1");
Assert.assertEquals("cleanscript", task.getCleaningScript().getScript());
Assert.assertArrayEquals(new String[] { "p1", "p2" }, task.getCleaningScript().getParameters());
Assert.assertEquals("prescript", task.getPreScript().getScript());
Assert.assertArrayEquals(new String[] { "p1", "p2" }, task.getPreScript().getParameters());
Assert.assertEquals("postscript", task.getPostScript().getScript());
Assert.assertArrayEquals(new String[] { "p1", "p2" }, task.getPostScript().getParameters());
Assert.assertEquals(FlowActionType.CONTINUE.toString(), task.getFlowScript().getActionType());
Assert.assertEquals(3, task.getSelectionScripts().size());
Set<String> scripts = new HashSet<>();
for (SelectionScript script : task.getSelectionScripts()) {
scripts.add(script.getScript());
if (script.getScript().equals("selection1")) {
Assert.assertArrayEquals(new String[] { "param1", "param2" }, script.getParameters());
}
if (script.getScript().equals("selection2")) {
Assert.assertArrayEquals(new String[] { "param3" }, script.getParameters());
}
if (script.getScript().equals("selection3")) {
Assert.assertArrayEquals(new String[] {}, script.getParameters());
}
}
Set<String> expected = new HashSet<>();
expected.add("selection1");
expected.add("selection2");
expected.add("selection3");
Assert.assertEquals(expected, scripts);
}
Aggregations