Search in sources :

Example 11 with ForkEnvironment

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

the class ForkedProcessBuilderCreator method executeForkEnvironmentScriptAndExtractVariables.

private ScriptResult executeForkEnvironmentScriptAndExtractVariables(TaskContext context, PrintStream outputSink, PrintStream errorSink, OSProcessBuilder processBuilder) throws Exception {
    ScriptResult forkEnvironmentScriptResult = null;
    ForkEnvironment forkEnvironment = context.getInitializer().getForkEnvironment();
    if (forkEnvironment != null) {
        if (forkEnvironment.getEnvScript() != null) {
            if (!context.getInitializer().isAuthorizedForkEnvironmentScript()) {
                throw new SecurityException("Unauthorized fork environment script: " + System.getProperty("line.separator") + forkEnvironment.getEnvScript().fetchScript());
            }
            forkEnvironmentScriptResult = forkEnvironmentScriptExecutor.executeForkEnvironmentScript(context, outputSink, errorSink);
        }
        try {
            processBuilder.environment().putAll(// by existing environment variables, variables and credentials
            taskContextVariableExtractor.extractVariablesThirdPartyCredentialsAndSystemEnvironmentVariables(context));
        } catch (IllegalArgumentException processEnvironmentReadOnly) {
            throw new IllegalStateException("Cannot use runAsMe mode and set system environment properties", processEnvironmentReadOnly);
        }
    }
    return forkEnvironmentScriptResult;
}
Also used : ScriptResult(org.ow2.proactive.scripting.ScriptResult) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment)

Example 12 with ForkEnvironment

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

the class ForkedJvmTaskExecutionCommandCreatorTest method testExecCommandOverwritesJavaHomeFromForkEnvironment.

@Test
public void testExecCommandOverwritesJavaHomeFromForkEnvironment() throws Exception {
    ForkEnvironment forkEnvironment = createForkEnvironment();
    forkEnvironment.setJavaHome(forkenvironmentJavaHome);
    javaCommandContains(Arrays.asList(forkenvironmentJavaHome), forkEnvironment);
}
Also used : ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) Test(org.junit.Test)

Example 13 with ForkEnvironment

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

the class ForkedJvmTaskExecutionCommandCreatorTest method createForkEnvironment.

private ForkEnvironment createForkEnvironment() {
    ForkEnvironment forkEnv = new ForkEnvironment();
    forkEnv.addJVMArgument(forkEnvJvmArguments[0]);
    forkEnv.addJVMArgument(forkEnvJvmArguments[1]);
    forkEnv.addAdditionalClasspath(additionalClasspath);
    return forkEnv;
}
Also used : ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment)

Example 14 with ForkEnvironment

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

the class ForkedTaskVariablesManagerTest method testAddBindingsToScriptHandlerContainsOutputURI.

@Test
public void testAddBindingsToScriptHandlerContainsOutputURI() throws InvalidScriptException, NodeException, NoSuchFieldException, IllegalAccessException {
    ScriptExecutableContainer scriptContainer = createScriptContainer();
    TaskLauncherInitializer taskLauncherInitializer = new TaskLauncherInitializer();
    taskLauncherInitializer.setForkEnvironment(new ForkEnvironment());
    TaskContext taskContext = new TaskContext(scriptContainer, taskLauncherInitializer, null, new NodeDataSpacesURIs(null, null, null, testSetString, null, null), null, null);
    // Expect taskResultArray to be inside the map
    validateThatScriptHandlerBindingsContain(new ScriptHandler(), taskContext, new VariablesMap(), new HashMap<String, String>(), new HashMap<String, String>(), SchedulerConstants.DS_OUTPUT_BINDING_NAME, testSetString);
}
Also used : TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) VariablesMap(org.ow2.proactive.scheduler.task.utils.VariablesMap) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) NodeDataSpacesURIs(org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs) TaskLauncherInitializer(org.ow2.proactive.scheduler.task.TaskLauncherInitializer) ScriptHandler(org.ow2.proactive.scripting.ScriptHandler) Test(org.junit.Test)

Example 15 with ForkEnvironment

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

the class ForkedTaskVariablesManagerTest method testExtractThirdPartyCredentials.

@Test
public void testExtractThirdPartyCredentials() throws Exception {
    ScriptExecutableContainer scriptContainer = createScriptContainer();
    TaskLauncherInitializer taskLauncherInitializer = new TaskLauncherInitializer();
    taskLauncherInitializer.setForkEnvironment(new ForkEnvironment());
    Decrypter decrypter = createCredentials(testUser, testPass);
    TaskContext taskContext = new TaskContext(scriptContainer, taskLauncherInitializer, null, new NodeDataSpacesURIs(null, null, null, null, null, null), null, null, decrypter);
    ForkedTaskVariablesManager forkedTaskVariablesManager = new ForkedTaskVariablesManager();
    Map<String, String> creds = forkedTaskVariablesManager.extractThirdPartyCredentials(taskContext);
    assertThat(creds.get(thirdPartyCred1Key), is(thirdPartyCred1Value));
}
Also used : TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) Decrypter(org.ow2.proactive.scheduler.task.utils.Decrypter) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) NodeDataSpacesURIs(org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs) TaskLauncherInitializer(org.ow2.proactive.scheduler.task.TaskLauncherInitializer) 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