use of org.ow2.proactive.scheduler.common.task.flow.FlowScript in project scheduling by ow2-proactive.
the class TerminateLoopHandler method terminateLoopTask.
public boolean terminateLoopTask(FlowAction action, InternalTask initiator, ChangedTasksInfo changesInfo, SchedulerStateUpdate frontend) {
// find the target of the loop
InternalTask target = null;
if (action.getTarget().equals(initiator.getName())) {
target = initiator;
} else {
target = internalJob.findTaskUp(action.getTarget(), initiator);
}
boolean replicateForNextLoopIteration = internalJob.replicateForNextLoopIteration(initiator, target, changesInfo, frontend, action);
if (replicateForNextLoopIteration && action.getCronExpr() != null) {
for (TaskId tid : changesInfo.getNewTasks()) {
InternalTask newTask = internalJob.getIHMTasks().get(tid);
try {
Date startAt = (new Predictor(action.getCronExpr())).nextMatchingDate();
newTask.addGenericInformation(InternalJob.GENERIC_INFO_START_AT_KEY, ISO8601DateUtil.parse(startAt));
newTask.setScheduledTime(startAt.getTime());
} catch (InvalidPatternException e) {
// this will not happen as the cron expression is
// already being validated in FlowScript class.
LOGGER.debug(e.getMessage());
}
}
}
return replicateForNextLoopIteration;
}
use of org.ow2.proactive.scheduler.common.task.flow.FlowScript in project scheduling by ow2-proactive.
the class TestRestoreWorkflowJobs2 method createJob.
private TaskFlowJob createJob() throws Exception {
TaskFlowJob job = new TaskFlowJob();
JavaTask A = task("A");
FlowScript ifScript = FlowScript.createIfFlowScript("branch = \"if\";", "B", "C", null);
A.setFlowScript(ifScript);
job.addTask(A);
JavaTask B = task("B");
job.addTask(B);
JavaTask C = task("C");
job.addTask(C);
return job;
}
use of org.ow2.proactive.scheduler.common.task.flow.FlowScript in project scheduling by ow2-proactive.
the class CheckEligibleTaskDescriptorScriptTest method testOnlyInternalScriptContainsAPIBinding.
@Test
public void testOnlyInternalScriptContainsAPIBinding() throws InvalidScriptException {
Script s = scriptWithApiBindingGlobal();
Script s2 = scriptWithoutApiBinding();
FlowScript fs = flowScriptWithoutApiBinding();
Mockito.when(((EligibleTaskDescriptorImpl) etd).getInternal()).thenReturn(ist);
Mockito.when(ist.getPreScript()).thenReturn(s2);
Mockito.when(ist.getPostScript()).thenReturn(s2);
Mockito.when(it.getCleaningScript()).thenReturn(s2);
Mockito.when(sec.getScript()).thenReturn(s);
Mockito.when(fe.getEnvScript()).thenReturn(s2);
Mockito.when(it.getFlowScript()).thenReturn(fs);
assertTrue(new CheckEligibleTaskDescriptorScript().isTaskContainsAPIBinding(etd));
}
use of org.ow2.proactive.scheduler.common.task.flow.FlowScript in project scheduling by ow2-proactive.
the class CheckEligibleTaskDescriptorScriptTest method testOnlyEnvScriptContainsAPIBinding.
@Test
public void testOnlyEnvScriptContainsAPIBinding() throws InvalidScriptException {
Script s = scriptWithApiBindingUser();
FlowScript fs = flowScriptWithoutApiBinding();
Script s2 = scriptWithoutApiBinding();
Mockito.when(it.getPreScript()).thenReturn(s2);
Mockito.when(it.getPostScript()).thenReturn(s2);
Mockito.when(it.getCleaningScript()).thenReturn(s2);
Mockito.when(sec.getScript()).thenReturn(s2);
Mockito.when(fe.getEnvScript()).thenReturn(s);
Mockito.when(it.getFlowScript()).thenReturn(fs);
assertTrue(new CheckEligibleTaskDescriptorScript().isTaskContainsAPIBinding(etd));
}
use of org.ow2.proactive.scheduler.common.task.flow.FlowScript in project scheduling by ow2-proactive.
the class CheckEligibleTaskDescriptorScriptTest method testAllScriptsNull.
@Test
public void testAllScriptsNull() throws InvalidScriptException {
Script s = null;
FlowScript fs = null;
Mockito.when(it.getPreScript()).thenReturn(s);
Mockito.when(it.getPostScript()).thenReturn(s);
Mockito.when(it.getCleaningScript()).thenReturn(s);
Mockito.when(fe.getEnvScript()).thenReturn(s);
Mockito.when(sec.getScript()).thenReturn(s);
Mockito.when(it.getFlowScript()).thenReturn(fs);
assertFalse(new CheckEligibleTaskDescriptorScript().isTaskContainsAPIBinding(etd));
}
Aggregations