Search in sources :

Example 11 with InProcessTaskExecutor

use of org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor in project scheduling by ow2-proactive.

the class InProcessTaskExecutorTest method taskWithFlowScript.

@Test
public void taskWithFlowScript() throws Exception {
    TestTaskOutput taskOutput = new TestTaskOutput();
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setControlFlowScript(FlowScript.createReplicateFlowScript("print('flow'); runs=5", "groovy"));
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    TaskResultImpl result = new InProcessTaskExecutor().execute(new TaskContext(new ScriptExecutableContainer(new TaskScript(new SimpleScript("print('hello'); result='hello'", "groovy"))), initializer, null, new NodeDataSpacesURIs("", "", "", "", "", ""), "", ""), taskOutput.outputStream, taskOutput.error);
    assertEquals(FlowActionType.REPLICATE, result.getAction().getType());
    assertEquals("helloflow", taskOutput.output());
}
Also used : TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) TaskScript(org.ow2.proactive.scripting.TaskScript) InProcessTaskExecutor(org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) NodeDataSpacesURIs(org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs) Test(org.junit.Test)

Example 12 with InProcessTaskExecutor

use of org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor in project scheduling by ow2-proactive.

the class InProcessTaskExecutorTest method testPaUserVariableAvailabilityFromScriptEngine.

@Test
public void testPaUserVariableAvailabilityFromScriptEngine() throws Throwable {
    TestTaskOutput taskOutput = new TestTaskOutput();
    String jobOwner = "JohnDoe";
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setJobOwner(jobOwner);
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    new InProcessTaskExecutor().execute(new TaskContext(new ScriptExecutableContainer(new TaskScript(new SimpleScript("print variables.get('PA_USER')", "python"))), initializer, null, new NodeDataSpacesURIs("", "", "", "", "", ""), "", ""), taskOutput.outputStream, taskOutput.error);
    assertEquals(jobOwner, taskOutput.output().trim());
}
Also used : TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) TaskScript(org.ow2.proactive.scripting.TaskScript) InProcessTaskExecutor(org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) NodeDataSpacesURIs(org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs) Test(org.junit.Test)

Example 13 with InProcessTaskExecutor

use of org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor in project scheduling by ow2-proactive.

the class ExecuteForkedTaskInsideNewJvm method fromForkedJVM.

private void fromForkedJVM(String contextPath) {
    try {
        TaskContext container = deserializeContext(contextPath);
        TaskResultImpl result = new InProcessTaskExecutor().execute(container, System.out, System.err);
        serializeTaskResult(result, contextPath);
    } catch (Throwable throwable) {
        throwable.printStackTrace(System.err);
        try {
            serializeTaskResult(throwable, contextPath);
        } catch (Throwable couldNotSerializeException) {
            System.err.println("Could not serialize exception as task result:");
            couldNotSerializeException.printStackTrace(System.err);
        }
        System.exit(1);
    }
}
Also used : TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InProcessTaskExecutor(org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor)

Example 14 with InProcessTaskExecutor

use of org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor in project scheduling by ow2-proactive.

the class InProcessTaskExecutorTest method failingScript.

@Test
public void failingScript() throws Throwable {
    TestTaskOutput taskOutput = new TestTaskOutput();
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    TaskResultImpl result = new InProcessTaskExecutor().execute(new TaskContext(new ScriptExecutableContainer(new TaskScript(new SimpleScript("dsfsdfsdf", "groovy"))), initializer, null, new NodeDataSpacesURIs("", "", "", "", "", ""), "", ""), taskOutput.outputStream, taskOutput.error);
    assertTrue(result.hadException());
    assertFalse(taskOutput.error().isEmpty());
}
Also used : TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) TaskScript(org.ow2.proactive.scripting.TaskScript) InProcessTaskExecutor(org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) NodeDataSpacesURIs(org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs) Test(org.junit.Test)

Example 15 with InProcessTaskExecutor

use of org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor in project scheduling by ow2-proactive.

the class InProcessTaskExecutorTest method failingScriptTask.

@Test
public void failingScriptTask() throws Exception {
    TestTaskOutput taskOutput = new TestTaskOutput();
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    TaskResultImpl result = new InProcessTaskExecutor().execute(new TaskContext(new ScriptExecutableContainer(new TaskScript(new SimpleScript("return 10/0", "groovy"))), initializer, null, new NodeDataSpacesURIs("", "", "", "", "", ""), "", ""), taskOutput.outputStream, taskOutput.error);
    assertEquals("", taskOutput.output());
    assertNotEquals("", taskOutput.error());
    assertNotNull(result.getException());
}
Also used : TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) TaskScript(org.ow2.proactive.scripting.TaskScript) InProcessTaskExecutor(org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) NodeDataSpacesURIs(org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs) Test(org.junit.Test)

Aggregations

TaskContext (org.ow2.proactive.scheduler.task.context.TaskContext)20 InProcessTaskExecutor (org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor)20 Test (org.junit.Test)19 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)19 NodeDataSpacesURIs (org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs)19 SimpleScript (org.ow2.proactive.scripting.SimpleScript)19 TaskScript (org.ow2.proactive.scripting.TaskScript)19 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)7 Serializable (java.io.Serializable)3 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)2 HashMap (java.util.HashMap)1 JobVariable (org.ow2.proactive.scheduler.common.job.JobVariable)1 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)1 Decrypter (org.ow2.proactive.scheduler.task.utils.Decrypter)1