Search in sources :

Example 1 with FlowScript

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;
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) InvalidPatternException(it.sauronsoftware.cron4j.InvalidPatternException) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) Predictor(it.sauronsoftware.cron4j.Predictor) Date(java.util.Date)

Example 2 with FlowScript

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;
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript)

Example 3 with FlowScript

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));
}
Also used : SimpleScript(org.ow2.proactive.scripting.SimpleScript) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Script(org.ow2.proactive.scripting.Script) EligibleTaskDescriptorImpl(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptorImpl) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Test(org.junit.Test)

Example 4 with FlowScript

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));
}
Also used : SimpleScript(org.ow2.proactive.scripting.SimpleScript) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Script(org.ow2.proactive.scripting.Script) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Test(org.junit.Test)

Example 5 with FlowScript

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));
}
Also used : SimpleScript(org.ow2.proactive.scripting.SimpleScript) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Script(org.ow2.proactive.scripting.Script) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Test(org.junit.Test)

Aggregations

FlowScript (org.ow2.proactive.scheduler.common.task.flow.FlowScript)18 SimpleScript (org.ow2.proactive.scripting.SimpleScript)11 Test (org.junit.Test)9 Script (org.ow2.proactive.scripting.Script)9 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)4 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)4 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)2 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)2 EmptyExecutable (functionaltests.executables.EmptyExecutable)1 InvalidPatternException (it.sauronsoftware.cron4j.InvalidPatternException)1 Predictor (it.sauronsoftware.cron4j.Predictor)1 FileNotFoundException (java.io.FileNotFoundException)1 Date (java.util.Date)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 VerifierConfigurationException (org.iso_relax.verifier.VerifierConfigurationException)1 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)1 JobValidationException (org.ow2.proactive.scheduler.common.exception.JobValidationException)1 JobId (org.ow2.proactive.scheduler.common.job.JobId)1 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)1 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)1