Search in sources :

Example 16 with ScriptTask

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

the class Job2XMLTransformerTest method argumentsInScript.

@Test
public void argumentsInScript() throws Exception {
    File xmlFile = tmpFolder.newFile();
    TaskFlowJob job = new TaskFlowJob();
    job.setName("simpleJob");
    String[] params = { "param1", "param2" };
    SimpleScript script = new SimpleScript("\nprint('arguments[0]='+arguments[0])\n", "javascript", params);
    ScriptTask task = new ScriptTask();
    task.setName("testTask");
    task.setScript(new TaskScript(script));
    job.addTask(task);
    new Job2XMLTransformer().job2xmlFile(job, xmlFile);
    TaskFlowJob recreatedJob = (TaskFlowJob) (JobFactory.getFactory().createJob(xmlFile.getAbsolutePath()));
    Assert.assertEquals("param1", ((ScriptTask) recreatedJob.getTask("testTask")).getScript().getParameters()[0].toString());
    Assert.assertEquals("param2", ((ScriptTask) recreatedJob.getTask("testTask")).getScript().getParameters()[1].toString());
}
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) File(java.io.File) Test(org.junit.Test)

Example 17 with ScriptTask

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

the class RestSmartProxyTest method createInErrorJob.

private TaskFlowJob createInErrorJob() throws InvalidScriptException, UserException {
    TaskFlowJob job = new TaskFlowJob();
    job.setName("JobWithInErrorTask");
    ScriptTask scriptTask = new ScriptTask();
    scriptTask.setName(inerrorTaskName);
    scriptTask.setScript(new TaskScript(new SimpleScript("syntax error", "python")));
    scriptTask.setOnTaskError(OnTaskError.PAUSE_TASK);
    scriptTask.setMaxNumberOfExecution(2);
    job.addTask(scriptTask);
    job.setInputSpace(userspace);
    job.setOutputSpace(userspace);
    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)

Example 18 with ScriptTask

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

the class InternalJobFactory method createTask.

private static InternalTask createTask(Job userJob, InternalJob internalJob, ScriptTask task) throws JobCreationException {
    InternalTask scriptTask;
    if (isForkingTask()) {
        scriptTask = new InternalForkedScriptTask(new ScriptExecutableContainer(task.getScript()), internalJob);
        configureRunAsMe(task);
    } else {
        scriptTask = new InternalScriptTask(new ScriptExecutableContainer(task.getScript()), internalJob);
    }
    // set task common properties
    try {
        setTaskCommonProperties(userJob, task, scriptTask);
    } catch (Exception e) {
        throw new JobCreationException(e);
    }
    return scriptTask;
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) InternalForkedScriptTask(org.ow2.proactive.scheduler.task.internal.InternalForkedScriptTask) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) InvalidScriptException(org.ow2.proactive.scripting.InvalidScriptException) InternalException(org.ow2.proactive.scheduler.common.exception.InternalException)

Example 19 with ScriptTask

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

the class TestDataspaceConcurrentKilling method createJobWithFileTransfers.

public Job createJobWithFileTransfers() throws UserException, InvalidScriptException {
    TaskFlowJob job = new TaskFlowJob();
    job.setName(JOB_NAME);
    job.setOnTaskError(OnTaskError.CONTINUE_JOB_EXECUTION);
    for (int i = 0; i < NB_TASKS; i++) {
        ScriptTask st = new ScriptTask();
        st.setName(TASK_NAME + i);
        st.setScript(new TaskScript(new SimpleScript("new File(localspace, \"" + FILE_NAME + i + "\").createNewFile(); java.lang.Thread.sleep(1000)", "groovy")));
        st.addOutputFiles(FILE_NAME + i, OutputAccessMode.TransferToUserSpace);
        job.addTask(st);
    }
    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)

Example 20 with ScriptTask

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

the class TestKillTaskWhileExecutingScripts method killEndlessScriptTask.

public void killEndlessScriptTask() throws Throwable {
    log("Test : killing an Endless Script Task...");
    String tname = "killEndlessScriptTask";
    // pre script interruption
    TaskFlowJob job = new TaskFlowJob();
    job.setName(this.getClass().getSimpleName() + "_" + tname);
    ScriptTask task1 = new ScriptTask();
    task1.setName(tname);
    task1.setScript(new TaskScript(endlessScript));
    job.addTask(task1);
    submitAndCheckJob(job, tname);
}
Also used : ScriptTask(org.ow2.proactive.scheduler.common.task.ScriptTask) TaskScript(org.ow2.proactive.scripting.TaskScript) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob)

Aggregations

ScriptTask (org.ow2.proactive.scheduler.common.task.ScriptTask)16 TaskScript (org.ow2.proactive.scripting.TaskScript)15 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)14 SimpleScript (org.ow2.proactive.scripting.SimpleScript)13 Task (org.ow2.proactive.scheduler.common.task.Task)5 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)4 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)4 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)4 NativeTask (org.ow2.proactive.scheduler.common.task.NativeTask)4 File (java.io.File)3 JobId (org.ow2.proactive.scheduler.common.job.JobId)3 SelectionScript (org.ow2.proactive.scripting.SelectionScript)3 FileNotFoundException (java.io.FileNotFoundException)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 VerifierConfigurationException (org.iso_relax.verifier.VerifierConfigurationException)2 InternalException (org.ow2.proactive.scheduler.common.exception.InternalException)2 JobValidationException (org.ow2.proactive.scheduler.common.exception.JobValidationException)2 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)2 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)2 InternalForkedScriptTask (org.ow2.proactive.scheduler.task.internal.InternalForkedScriptTask)2