Search in sources :

Example 96 with JavaTask

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

Example 97 with JavaTask

use of org.ow2.proactive.scheduler.common.task.JavaTask 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 98 with JavaTask

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

the class TestDataspaceSelectorsData method testEmptyFileSelector.

@Test
public void testEmptyFileSelector() throws Exception {
    TaskFlowJob jobDef = new TaskFlowJob();
    JavaTask task = createDefaultTask("task1");
    task.addInputFiles(new FileSelector(), InputAccessMode.none);
    task.addOutputFiles(new FileSelector(), OutputAccessMode.none);
    jobDef.addTask(task);
    InternalJob job = defaultSubmitJobAndLoadInternal(true, jobDef);
    InternalTask task1 = job.getTask("task1");
    Assert.assertEquals(1, task1.getInputFilesList().size());
    Assert.assertEquals(InputAccessMode.none, task1.getInputFilesList().get(0).getMode());
    Assert.assertEquals(1, task1.getOutputFilesList().size());
    Assert.assertEquals(OutputAccessMode.none, task1.getOutputFilesList().get(0).getMode());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) FileSelector(org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) Test(org.junit.Test)

Example 99 with JavaTask

use of org.ow2.proactive.scheduler.common.task.JavaTask 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 100 with JavaTask

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

the class TestLoadJobResult method testLoadJobResultMap.

@Test
public void testLoadJobResultMap() throws Throwable {
    TaskFlowJob job = new TaskFlowJob();
    // add first task
    job.addTask(createDefaultTask("task1"));
    // add second task
    JavaTask javaTask2 = createDefaultTask("task2");
    job.addTask(javaTask2);
    InternalJob internalJob = defaultSubmitJobAndLoadInternal(true, job);
    internalJob.setNumberOfFinishedTasks(1);
    // add result map to the first task
    TaskResultImpl taskResult = new TaskResultImpl(null, new TestResult(0, "1_1"), null, 0);
    Map<String, Serializable> resultMap = new HashMap();
    resultMap.put("A", "one");
    taskResult.setResultMap(resultMap);
    internalJob.getResultMap().putAll(resultMap);
    InternalTask task1 = internalJob.getTask("task1");
    dbManager.updateAfterTaskFinished(internalJob, task1, taskResult);
    InternalTask task2 = internalJob.getTask("task2");
    dbManager.updateAfterTaskFinished(internalJob, task2, new TaskResultImpl(null, new TestResult(0, "2_1"), null, 0));
    System.out.println("Load result map");
    JobResult result = dbManager.loadJobResult(internalJob.getId());
    Assert.assertNotNull(result.getJobInfo());
    Assert.assertEquals(2, result.getJobInfo().getTotalNumberOfTasks());
    assertFalse(result.getResultMap().isEmpty());
    Assert.assertEquals(result.getResultMap().get("A"), "one");
}
Also used : Serializable(java.io.Serializable) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) HashMap(java.util.HashMap) 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) Test(org.junit.Test)

Aggregations

TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)104 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)104 Test (org.junit.Test)44 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)24 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)20 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)18 JobId (org.ow2.proactive.scheduler.common.job.JobId)14 NativeTask (org.ow2.proactive.scheduler.common.task.NativeTask)14 EmptyTask (org.ow2.proactive.scheduler.examples.EmptyTask)13 SelectionScript (org.ow2.proactive.scripting.SelectionScript)12 SimpleScript (org.ow2.proactive.scripting.SimpleScript)12 File (java.io.File)11 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)11 HashMap (java.util.HashMap)10 Task (org.ow2.proactive.scheduler.common.task.Task)9 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)7 ScriptTask (org.ow2.proactive.scheduler.common.task.ScriptTask)6 EmptyExecutable (functionaltests.executables.EmptyExecutable)5 JobDescriptor (org.ow2.proactive.scheduler.common.JobDescriptor)5 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)5