Search in sources :

Example 36 with TaskScript

use of org.ow2.proactive.scripting.TaskScript in project scheduling by ow2-proactive.

the class TestUnauthorizedScripts method createJob.

public Job createJob(String forkScriptContent, String cleanScriptContent) throws InvalidScriptException, UserException {
    TaskFlowJob job = new TaskFlowJob();
    job.setName(this.getClass().getSimpleName() + "_forkAndClean");
    ScriptTask taskWithFork = new ScriptTask();
    taskWithFork.setScript(new TaskScript(new SimpleScript("println 'Hello'", "groovy")));
    ForkEnvironment forkEnvironment = new ForkEnvironment();
    forkEnvironment.setEnvScript(new SimpleScript(forkScriptContent, "groovy"));
    taskWithFork.setForkEnvironment(forkEnvironment);
    ScriptTask taskWithClean = new ScriptTask();
    taskWithClean.setScript(new TaskScript(new SimpleScript("println 'Hello'", "groovy")));
    taskWithClean.setCleaningScript(new SimpleScript(cleanScriptContent, "groovy"));
    job.addTask(taskWithFork);
    job.addTask(taskWithClean);
    return job;
}
Also used : ScriptTask(org.ow2.proactive.scheduler.common.task.ScriptTask) TaskScript(org.ow2.proactive.scripting.TaskScript) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment)

Example 37 with TaskScript

use of org.ow2.proactive.scripting.TaskScript in project scheduling by ow2-proactive.

the class TestUnauthorizedScripts method createJobSelection.

public Job createJobSelection(String selectionScriptContent) throws InvalidScriptException, UserException {
    TaskFlowJob job = new TaskFlowJob();
    job.setName(this.getClass().getSimpleName() + "_selection");
    ScriptTask taskWithSelection = new ScriptTask();
    taskWithSelection.setScript(new TaskScript(new SimpleScript("println 'Hello'", "groovy")));
    taskWithSelection.addSelectionScript(new SelectionScript(new SimpleScript(selectionScriptContent, "groovy"), true));
    job.addTask(taskWithSelection);
    return job;
}
Also used : SelectionScript(org.ow2.proactive.scripting.SelectionScript) ScriptTask(org.ow2.proactive.scheduler.common.task.ScriptTask) TaskScript(org.ow2.proactive.scripting.TaskScript) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SimpleScript(org.ow2.proactive.scripting.SimpleScript)

Example 38 with TaskScript

use of org.ow2.proactive.scripting.TaskScript in project scheduling by ow2-proactive.

the class SchedulerEfficiencyMetricsTest method createJob.

public static TaskFlowJob createJob(int taskNumber, int taskDuration) throws Exception {
    final TaskFlowJob job = new TaskFlowJob();
    job.setName(String.format("EP_%d_NO_MERGE_%dSEC", taskNumber, taskDuration));
    job.setOnTaskError(OnTaskError.CANCEL_JOB);
    job.getVariables().put(OPTIMAL_JOB_DURATION, new JobVariable(OPTIMAL_JOB_DURATION, String.valueOf(taskDuration)));
    for (int i = 0; i < taskNumber; i++) {
        ScriptTask task = new ScriptTask();
        task.setName("process_" + i);
        task.setScript(new TaskScript(new SimpleScript(String.format("Thread.sleep(%s)", taskDuration), "groovy")));
        job.addTask(task);
    }
    return job;
}
Also used : ScriptTask(org.ow2.proactive.scheduler.common.task.ScriptTask) TaskScript(org.ow2.proactive.scripting.TaskScript) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SimpleScript(org.ow2.proactive.scripting.SimpleScript) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable)

Example 39 with TaskScript

use of org.ow2.proactive.scripting.TaskScript in project scheduling by ow2-proactive.

the class TestJobSchedulerHome method pahomeScriptTask.

public void pahomeScriptTask() throws Throwable {
    log("Test ProActive Home Script Task...");
    String tname = "pahomeScriptTask";
    TaskFlowJob job = new TaskFlowJob();
    job.setName(this.getClass().getSimpleName() + "_" + tname);
    ScriptTask task1 = new ScriptTask();
    task1.setName(tname);
    Script pahomeScript = new SimpleScript(TestJobSchedulerHome.class.getResource("/functionaltests/scripts/schedulerHome.js"), new String[] { schedulerHomePath });
    ;
    TaskScript ts = new TaskScript(pahomeScript);
    task1.setScript(ts);
    job.addTask(task1);
    submitAndCheckJob(job, tname, false);
}
Also used : SimpleScript(org.ow2.proactive.scripting.SimpleScript) TaskScript(org.ow2.proactive.scripting.TaskScript) Script(org.ow2.proactive.scripting.Script) TaskScript(org.ow2.proactive.scripting.TaskScript) SimpleScript(org.ow2.proactive.scripting.SimpleScript)

Example 40 with TaskScript

use of org.ow2.proactive.scripting.TaskScript in project scheduling by ow2-proactive.

the class TestJobWalltime method walltimeScriptTask.

public JobId walltimeScriptTask() throws Throwable {
    log("Test WallTime Script Task...");
    String tname = "walltimeScriptTask";
    // pre script interruption
    TaskFlowJob job = new TaskFlowJob();
    job.setName(this.getClass().getSimpleName() + "_" + tname);
    ScriptTask task1 = new ScriptTask();
    task1.setName(tname);
    task1.setWallTime(5000);
    task1.setScript(new TaskScript(new SimpleScript("while(true){java.lang.Thread.sleep(500);}", "javascript")));
    job.addTask(task1);
    return submitJob(job);
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) SimpleScript(org.ow2.proactive.scripting.SimpleScript)

Aggregations

TaskScript (org.ow2.proactive.scripting.TaskScript)78 SimpleScript (org.ow2.proactive.scripting.SimpleScript)76 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)64 Test (org.junit.Test)59 NodeDataSpacesURIs (org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs)31 TaskContext (org.ow2.proactive.scheduler.task.context.TaskContext)31 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)19 TaskLauncherInitializer (org.ow2.proactive.scheduler.task.TaskLauncherInitializer)19 InProcessTaskExecutor (org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor)19 ScriptTask (org.ow2.proactive.scheduler.common.task.ScriptTask)12 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)11 Serializable (java.io.Serializable)10 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)10 File (java.io.File)9 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)9 TestTaskOutput (org.ow2.proactive.scheduler.task.TestTaskOutput)9 ForkedTaskExecutor (org.ow2.proactive.scheduler.task.executors.ForkedTaskExecutor)9 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)8 HashMap (java.util.HashMap)6 Semaphore (java.util.concurrent.Semaphore)5