Search in sources :

Example 56 with ForkEnvironment

use of org.ow2.proactive.scheduler.common.task.ForkEnvironment 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)

Example 57 with ForkEnvironment

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

the class TestLoadJobResult method testLoadJobResult.

@Test
public void testLoadJobResult() throws Throwable {
    TaskFlowJob job = new TaskFlowJob();
    ForkEnvironment forkEnvironment = new ForkEnvironment();
    forkEnvironment.addAdditionalClasspath("/path1/path1");
    forkEnvironment.addAdditionalClasspath("/path2/path2");
    JavaTask javaTask1 = createDefaultTask("task1");
    javaTask1.setPreciousResult(true);
    javaTask1.setForkEnvironment(forkEnvironment);
    job.addTask(javaTask1);
    for (int i = 2; i <= 4; i++) {
        JavaTask task = createDefaultTask("task" + i);
        task.setForkEnvironment(forkEnvironment);
        job.addTask(task);
    }
    JavaTask javaTask5 = createDefaultTask("task5");
    javaTask5.setPreciousResult(true);
    javaTask5.setForkEnvironment(forkEnvironment);
    job.addTask(javaTask5);
    InternalJob internalJob = defaultSubmitJobAndLoadInternal(true, job);
    InternalTask task1 = internalJob.getTask("task1");
    InternalTask task2 = internalJob.getTask("task2");
    InternalTask task3 = internalJob.getTask("task3");
    InternalTask task4 = internalJob.getTask("task4");
    InternalTask task5 = internalJob.getTask("task5");
    dbManager.updateAfterTaskFinished(internalJob, task1, new TaskResultImpl(null, new TestResult(0, "1_1"), null, 0));
    dbManager.updateAfterTaskFinished(internalJob, task1, new TaskResultImpl(null, new TestResult(0, "1_2"), null, 0));
    dbManager.updateAfterTaskFinished(internalJob, task2, new TaskResultImpl(null, new TestResult(0, "2_1"), null, 0));
    dbManager.updateAfterTaskFinished(internalJob, task2, new TaskResultImpl(null, new TestResult(0, "2_2"), null, 0));
    dbManager.updateAfterTaskFinished(internalJob, task3, new TaskResultImpl(null, new TestResult(0, "3_1"), null, 0));
    dbManager.updateAfterTaskFinished(internalJob, task4, new TaskResultImpl(null, new TestException("message4_1", "data4_1"), null, 0));
    dbManager.updateAfterTaskFinished(internalJob, task4, new TaskResultImpl(null, new TestException("message4_2", "data4_2"), null, 0));
    dbManager.updateAfterTaskFinished(internalJob, task5, new TaskResultImpl(null, new TestException("message5_1", "data5_1"), null, 0));
    TaskFlowJob job2 = new TaskFlowJob();
    job2.addTask(createDefaultTask("job2 task1"));
    InternalJob internalJob2 = defaultSubmitJobAndLoadInternal(true, job2);
    InternalTask task2_1 = internalJob2.getTask("job2 task1");
    dbManager.updateAfterTaskFinished(internalJob2, task2_1, new TaskResultImpl(null, new TestResult(0, "job2_task1"), null, 0));
    System.out.println("Load job result1");
    JobResult result = dbManager.loadJobResult(internalJob.getId());
    Assert.assertEquals(5, result.getAllResults().size());
    Assert.assertEquals(2, result.getExceptionResults().size());
    Assert.assertEquals(2, result.getPreciousResults().size());
    Assert.assertNotNull(result.getJobInfo());
    Assert.assertEquals(internalJob.getId(), result.getJobId());
    Assert.assertEquals(5, result.getJobInfo().getTotalNumberOfTasks());
    TestResult taskResultValue;
    taskResultValue = (TestResult) result.getResult("task1").value();
    Assert.assertEquals("1_2", taskResultValue.getB());
    taskResultValue = (TestResult) result.getResult("task2").value();
    Assert.assertEquals("2_2", taskResultValue.getB());
    taskResultValue = (TestResult) result.getResult("task3").value();
    Assert.assertEquals("3_1", taskResultValue.getB());
    TestException taskException;
    taskException = (TestException) result.getResult("task4").getException();
    Assert.assertEquals("message4_2", taskException.getMessage());
    taskException = (TestException) result.getResult("task5").getException();
    Assert.assertEquals("message5_1", taskException.getMessage());
    System.out.println("Load job result2");
    result = dbManager.loadJobResult(internalJob2.getId());
    Assert.assertEquals(1, result.getAllResults().size());
    Assert.assertEquals(0, result.getExceptionResults().size());
    Assert.assertEquals(0, result.getPreciousResults().size());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) JobResult(org.ow2.proactive.scheduler.common.job.JobResult) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) Test(org.junit.Test)

Example 58 with ForkEnvironment

use of org.ow2.proactive.scheduler.common.task.ForkEnvironment 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;
}
Also used : SelectionScript(org.ow2.proactive.scripting.SelectionScript) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SimpleScript(org.ow2.proactive.scripting.SimpleScript) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment)

Example 59 with ForkEnvironment

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

the class TestTaskRuntimeData method testTaskTypes.

@Test
public void testTaskTypes() throws Exception {
    TaskFlowJob jobDef = new TaskFlowJob();
    JavaTask taskDef1 = createDefaultTask("task1");
    jobDef.addTask(taskDef1);
    JavaTask taskDef2 = createDefaultTask("task2");
    taskDef2.setForkEnvironment(new ForkEnvironment());
    jobDef.addTask(taskDef2);
    NativeTask taskDef3 = new NativeTask();
    taskDef3.setName("task3");
    taskDef3.setCommandLine("commandline");
    jobDef.addTask(taskDef3);
    InternalJob job = defaultSubmitJobAndLoadInternal(false, jobDef);
    // by default all tasks are executed in a forked JVM
    for (int i = 1; i <= 3; i++) {
        Assert.assertEquals(InternalForkedScriptTask.class, job.getTask("task" + i).getClass());
    }
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) NativeTask(org.ow2.proactive.scheduler.common.task.NativeTask) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) Test(org.junit.Test)

Aggregations

ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)54 Test (org.junit.Test)27 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)25 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)22 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)17 TaskContext (org.ow2.proactive.scheduler.task.context.TaskContext)15 TaskLauncherInitializer (org.ow2.proactive.scheduler.task.TaskLauncherInitializer)14 SimpleScript (org.ow2.proactive.scripting.SimpleScript)14 NodeDataSpacesURIs (org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs)13 VariablesMap (org.ow2.proactive.scheduler.task.utils.VariablesMap)9 ScriptHandler (org.ow2.proactive.scripting.ScriptHandler)9 File (java.io.File)8 NativeTask (org.ow2.proactive.scheduler.common.task.NativeTask)8 TaskScript (org.ow2.proactive.scripting.TaskScript)8 JobId (org.ow2.proactive.scheduler.common.job.JobId)7 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)5 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)5 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)5 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)5 FileNotFoundException (java.io.FileNotFoundException)4