Search in sources :

Example 16 with FlowScript

use of org.ow2.proactive.scheduler.common.task.flow.FlowScript in project scheduling by ow2-proactive.

the class CheckEligibleTaskDescriptorScriptTest method testAllScriptsContainAPIBinding.

@Test
public void testAllScriptsContainAPIBinding() throws InvalidScriptException {
    Script s = scriptWithApiBindingClient();
    Script s1 = scriptWithApiBindingUser();
    Script s2 = scriptWithApiBindingGlobal();
    FlowScript fs = flowScriptWithApiBindingClient();
    Mockito.when(it.getPreScript()).thenReturn(s1);
    Mockito.when(it.getPostScript()).thenReturn(s2);
    Mockito.when(it.getCleaningScript()).thenReturn(s2);
    Mockito.when(sec.getScript()).thenReturn(s);
    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 17 with FlowScript

use of org.ow2.proactive.scheduler.common.task.flow.FlowScript in project scheduling by ow2-proactive.

the class CheckEligibleTaskDescriptorScriptTest method testAllScriptsNotContainAPIBinding.

@Test
public void testAllScriptsNotContainAPIBinding() throws InvalidScriptException {
    Script s = scriptWithoutApiBinding();
    FlowScript fs = flowScriptWithoutApiBinding();
    Mockito.when(it.getPreScript()).thenReturn(s);
    Mockito.when(it.getPostScript()).thenReturn(s);
    Mockito.when(it.getCleaningScript()).thenReturn(s);
    Mockito.when(sec.getScript()).thenReturn(s);
    Mockito.when(fe.getEnvScript()).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)

Example 18 with FlowScript

use of org.ow2.proactive.scheduler.common.task.flow.FlowScript in project scheduling by ow2-proactive.

the class JobDescriptorImpl method isEntryPoint.

/**
 * Tags all startable tasks as entry point
 * a startable task : has no dependency, and is not target of an if control flow action
 *
 * @param t a Task
 * @param otherTasks the other tasks contained in the job containing task t
 * @return true if t is an entry point among all tasks in otherTasks, or false
 */
private boolean isEntryPoint(InternalTask t, List<InternalTask> otherTasks) {
    List<TaskState> deps = t.getDependences();
    boolean entryPoint = false;
    // an entry point has no dependency
    if (deps == null || deps.size() == 0) {
        entryPoint = true;
    } else {
        return false;
    }
    // a entry point is not target of an if
    for (Task t2 : otherTasks) {
        if (t.equals(t2)) {
            continue;
        }
        FlowScript sc = t2.getFlowScript();
        if (sc != null) {
            String actionType = sc.getActionType();
            if (FlowActionType.parse(actionType).equals(FlowActionType.IF)) {
                String tIf = sc.getActionTarget();
                String tElse = sc.getActionTargetElse();
                String tJoin = sc.getActionContinuation();
                if (tIf != null && tIf.equals(t.getName())) {
                    return false;
                }
                if (tElse != null && tElse.equals(t.getName())) {
                    return false;
                }
                if (tJoin != null && tJoin.equals(t.getName())) {
                    return false;
                }
            }
        }
    }
    return entryPoint;
}
Also used : Task(org.ow2.proactive.scheduler.common.task.Task) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript)

Example 19 with FlowScript

use of org.ow2.proactive.scheduler.common.task.flow.FlowScript in project scheduling by ow2-proactive.

the class TestKillTaskWhileExecutingScripts method javaTaskKillEndlessFlowScript.

public void javaTaskKillEndlessFlowScript() throws Throwable {
    log("Test Java Task : killing an Endless FlowScript ...");
    String tname = "javaTaskKillEndlessFlowScript";
    // pre script interruption
    TaskFlowJob job = new TaskFlowJob();
    job.setName(this.getClass().getSimpleName() + "_" + tname);
    JavaTask task1 = new JavaTask();
    task1.setName(tname);
    task1.setExecutableClassName(EmptyExecutable.class.getName());
    task1.setFlowScript(FlowScript.createLoopFlowScript(endlessScript, tname));
    job.addTask(task1);
    submitAndCheckJob(job, tname);
}
Also used : EmptyExecutable(functionaltests.executables.EmptyExecutable) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask)

Example 20 with FlowScript

use of org.ow2.proactive.scheduler.common.task.flow.FlowScript in project scheduling by ow2-proactive.

the class TestJobRemove method createJob.

private TaskFlowJob createJob(int tasksNumber) throws Exception {
    ForkEnvironment forkEnvironment = new ForkEnvironment();
    forkEnvironment.addAdditionalClasspath("lib/ProActive/ProActive.jar", "compile/lib/ant.jar");
    TaskFlowJob jobDef = new TaskFlowJob();
    jobDef.addGenericInformation("k1", "v1");
    jobDef.addGenericInformation("k2", "v2");
    // add data with non-null ifBranch
    JavaTask A = createDefaultTask("A");
    A.setForkEnvironment(forkEnvironment);
    FlowScript ifScript = FlowScript.createIfFlowScript("branch = \"if\";", "B", "C", null);
    A.setFlowScript(ifScript);
    jobDef.addTask(A);
    JavaTask B = createDefaultTask("B");
    B.setForkEnvironment(forkEnvironment);
    jobDef.addTask(B);
    JavaTask C = createDefaultTask("C");
    C.setForkEnvironment(forkEnvironment);
    jobDef.addTask(C);
    for (int i = 0; i < tasksNumber; i++) {
        JavaTask task1 = new JavaTask();
        task1.setName("javaTask-" + i);
        task1.setExecutableClassName(TestDummyExecutable.class.getName());
        task1.addArgument("arg1", "arg1");
        task1.addArgument("arg2", "arg2");
        setAttributes(task1);
        JavaTask task2 = new JavaTask();
        task2.setName("forkedJavaTask-" + i);
        task2.setExecutableClassName(TestDummyExecutable.class.getName());
        ForkEnvironment forkEnv = new ForkEnvironment();
        forkEnv.addAdditionalClasspath("lib/ProActive/ProActive.jar");
        forkEnv.addAdditionalClasspath("compile/lib/ant.jar");
        forkEnv.addJVMArgument("jvmArg1");
        forkEnv.addJVMArgument("jvmArg2");
        forkEnv.addSystemEnvironmentVariable("e1", "v1");
        forkEnv.addSystemEnvironmentVariable("e2", "v2");
        forkEnv.setEnvScript(new SimpleScript("env script", "javascript", new String[] { "param1", "param2" }));
        task2.setForkEnvironment(forkEnv);
        task2.addArgument("arg1", "arg1");
        task2.addArgument("arg2", "arg2");
        setAttributes(task2);
        NativeTask task3 = new NativeTask();
        task3.setName("nativeTask-" + i);
        task3.setCommandLine("command1", "command2", "command3");
        setAttributes(task3);
        task1.addDependence(task2);
        task3.addDependence(task2);
        task1.setForkEnvironment(forkEnvironment);
        task2.setForkEnvironment(forkEnvironment);
        task3.setForkEnvironment(forkEnvironment);
        jobDef.addTask(task1);
        jobDef.addTask(task2);
        jobDef.addTask(task3);
    }
    return jobDef;
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SimpleScript(org.ow2.proactive.scripting.SimpleScript) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) NativeTask(org.ow2.proactive.scheduler.common.task.NativeTask) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript)

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