Search in sources :

Example 71 with TaskFlowJob

use of org.ow2.proactive.scheduler.common.job.TaskFlowJob in project scheduling by ow2-proactive.

the class TestKillWhenInStoppedState method createPendingJob.

private TaskFlowJob createPendingJob() throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    job.setName("Test pending job");
    job.setOnTaskError(OnTaskError.CONTINUE_JOB_EXECUTION);
    JavaTask javaTask = new JavaTask();
    javaTask.setExecutableClassName(TestJavaTask.class.getName());
    javaTask.setName(TASK_NAME2);
    javaTask.setSelectionScript(new SelectionScript("selected = false;", "JavaScript", false));
    job.addTask(javaTask);
    return job;
}
Also used : SelectionScript(org.ow2.proactive.scripting.SelectionScript) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask)

Example 72 with TaskFlowJob

use of org.ow2.proactive.scheduler.common.job.TaskFlowJob in project scheduling by ow2-proactive.

the class TestProcessTreeKiller method createJavaExecutableJob.

public static TaskFlowJob createJavaExecutableJob(String name, boolean forked) throws UserException {
    TaskFlowJob job = new TaskFlowJob();
    job.setName(name);
    job.setDescription("A command that spawns processes");
    JavaTask task = new JavaTask();
    if (forked) {
        task.setForkEnvironment(new ForkEnvironment());
    }
    task.addArgument("sleep", 3);
    task.addArgument("tname", name);
    task.addArgument("home", PASchedulerProperties.SCHEDULER_HOME.getValueAsString());
    task.setName(name);
    task.setExecutableClassName(JavaSpawnExecutable.class.getName());
    job.addTask(task);
    return job;
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment)

Example 73 with TaskFlowJob

use of org.ow2.proactive.scheduler.common.job.TaskFlowJob in project scheduling by ow2-proactive.

the class TestForkedTaskWorkingDir method javaTaskTaskRestartedAnotherNode.

/*
     * SCHEDULING-2129 Mapping for a given space URI is already registered
     * 
     * Run a task, kill the node,let it restart on another node and check the the shared scratch
     * space was correctly setup by transferring a file created in working dir from the task
     */
private void javaTaskTaskRestartedAnotherNode() throws Exception {
    FileLock blockTaskFromTest = new FileLock();
    Path blockTaskFromTestPath = blockTaskFromTest.lock();
    FileLock blockTestBeforeKillingNode = new FileLock();
    Path blockTestBeforeKillingNodePath = blockTestBeforeKillingNode.lock();
    TaskFlowJob job = createFileInLocalSpaceJob(blockTaskFromTestPath.toString(), blockTestBeforeKillingNodePath.toString());
    JobId idJ1 = schedulerHelper.submitJob(job);
    SchedulerTHelper.log("Wait until task is in the middle of the run");
    final String taskNodeUrl = findNodeRunningTask();
    schedulerHelper.waitForEventTaskRunning(idJ1, "task1");
    FileLock.waitUntilUnlocked(blockTestBeforeKillingNodePath);
    SchedulerTHelper.log("Kill the node running the task");
    schedulerHelper.killNode(taskNodeUrl);
    SchedulerTHelper.log("Let the task finish");
    blockTaskFromTest.unlock();
    SchedulerTHelper.log("Waiting for job 1 to finish");
    schedulerHelper.waitForEventJobFinished(idJ1);
    String userSpaceUri = URI.create(schedulerHelper.getSchedulerInterface().getUserSpaceURIs().get(0)).getPath();
    assertTrue("Could not find expected output file", new File(userSpaceUri, "output_file.txt").exists());
}
Also used : Path(java.nio.file.Path) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) FileLock(org.ow2.proactive.scheduler.util.FileLock) File(java.io.File) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 74 with TaskFlowJob

use of org.ow2.proactive.scheduler.common.job.TaskFlowJob in project scheduling by ow2-proactive.

the class TestForkedTaskWorkingDir method nativeTask.

private void nativeTask() throws Exception {
    if (OperatingSystem.getOperatingSystem() == OperatingSystem.unix) {
        File input = createTempDirectory("test", ".input_native", null);
        File output = createTempDirectory("test", ".output_native", null);
        FileUtils.touch(new File(input, "inputFile_native.txt"));
        TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(new File(TestForkedTaskWorkingDir.class.getResource("/functionaltests/descriptors/Job_forked_native_task_working_dir.xml").toURI()).getAbsolutePath());
        job.setInputSpace(input.toURI().toString());
        job.setOutputSpace(output.toURI().toString());
        schedulerHelper.testJobSubmission(job);
        assertTrue(new File(output, "outputFile_native.txt").exists());
    }
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) File(java.io.File)

Example 75 with TaskFlowJob

use of org.ow2.proactive.scheduler.common.job.TaskFlowJob in project scheduling by ow2-proactive.

the class TestForkedTaskWorkingDir method createFileInLocalSpaceJob.

private TaskFlowJob createFileInLocalSpaceJob(String blockTaskFromTestUrl, String blockTestBeforeKillingNodeUrl) throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    JavaTask task1 = new JavaTask();
    task1.setForkEnvironment(new ForkEnvironment());
    task1.setName("task1");
    task1.setExecutableClassName(CreateFileInLocalSpaceTask.class.getName());
    task1.addArgument("blockTaskFromTestUrl", blockTaskFromTestUrl);
    task1.addArgument("blockTestBeforeKillingNodeUrl", blockTestBeforeKillingNodeUrl);
    task1.addOutputFiles("output_file.txt", OutputAccessMode.TransferToUserSpace);
    job.addTask(task1);
    return job;
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment)

Aggregations

TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)184 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)92 Test (org.junit.Test)81 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)49 JobId (org.ow2.proactive.scheduler.common.job.JobId)33 File (java.io.File)31 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)25 NativeTask (org.ow2.proactive.scheduler.common.task.NativeTask)22 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)21 SimpleScript (org.ow2.proactive.scripting.SimpleScript)20 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)18 ScriptTask (org.ow2.proactive.scheduler.common.task.ScriptTask)16 Task (org.ow2.proactive.scheduler.common.task.Task)16 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)13 TaskScript (org.ow2.proactive.scripting.TaskScript)13 JobState (org.ow2.proactive.scheduler.common.job.JobState)12 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)12 ArrayList (java.util.ArrayList)11 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)11 HashMap (java.util.HashMap)10