Search in sources :

Example 41 with JavaTask

use of org.ow2.proactive.scheduler.common.task.JavaTask 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 42 with JavaTask

use of org.ow2.proactive.scheduler.common.task.JavaTask 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)

Example 43 with JavaTask

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

the class SchedulerDBManagerTest method createTestJob.

private InternalJob createTestJob(String jobName, String taskTag, int nbTasks) throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    job.setName(jobName);
    for (int i = 1; i <= nbTasks; i++) {
        JavaTask task = new JavaTask();
        task.setName(jobName + "-TASK-" + i + "/" + nbTasks);
        task.setExecutableClassName("class");
        task.setTag(taskTag);
        job.addTask(task);
    }
    return createJob(job);
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask)

Example 44 with JavaTask

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

the class SchedulingServiceTest2 method createTestJob.

private TaskFlowJob createTestJob() throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    job.setName(this.getClass().getSimpleName());
    JavaTask task1 = new JavaTask();
    task1.setName("javaTask");
    task1.setExecutableClassName("class");
    task1.setOnTaskError(OnTaskError.CANCEL_JOB);
    job.addTask(task1);
    NativeTask task2 = new NativeTask();
    task2.setName("nativeTask");
    task2.setCommandLine("command line");
    task2.setOnTaskError(OnTaskError.CANCEL_JOB);
    job.addTask(task2);
    return job;
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) NativeTask(org.ow2.proactive.scheduler.common.task.NativeTask)

Example 45 with JavaTask

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

the class SchedulingServiceTest2 method testFailedTask.

private void testFailedTask(boolean failNativeTask) throws Exception {
    service.submitJob(createJob(createTestJob()));
    listener.assertEvents(SchedulerEvent.JOB_SUBMITTED);
    Map<JobId, JobDescriptor> jobsMap;
    JobDescriptor jobDesc;
    jobsMap = service.lockJobsToSchedule();
    assertEquals(1, jobsMap.size());
    jobDesc = jobsMap.values().iterator().next();
    Assert.assertEquals(2, jobDesc.getEligibleTasks().size());
    for (TaskDescriptor taskDesc : jobDesc.getEligibleTasks()) {
        taskStarted(jobDesc, (EligibleTaskDescriptor) taskDesc);
    }
    service.unlockJobsToSchedule(jobsMap.values());
    if (failNativeTask) {
        InternalTask nativeTask = ((JobDescriptorImpl) jobDesc).getInternal().getTask("nativeTask");
        // native task terminates with code 1, flag 'cancelJobOnError' was
        // set so job should be cancelled
        service.taskTerminatedWithResult(nativeTask.getId(), new TaskResultImpl(nativeTask.getId(), new RuntimeException(), null, 0));
    } else {
        InternalTask javaTask = ((JobDescriptorImpl) jobDesc).getInternal().getTask("javaTask");
        // java task terminates with exception, flag 'cancelJobOnError' was
        // set so job should be cancelled
        service.taskTerminatedWithResult(javaTask.getId(), new TaskResultImpl(javaTask.getId(), new RuntimeException(), null, 0));
    }
    jobsMap = service.lockJobsToSchedule();
    assertEquals(0, jobsMap.size());
    listener.assertEvents(SchedulerEvent.JOB_PENDING_TO_RUNNING, SchedulerEvent.JOB_UPDATED, SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_RUNNING_TO_FINISHED, SchedulerEvent.TASK_RUNNING_TO_FINISHED, SchedulerEvent.JOB_RUNNING_TO_FINISHED, SchedulerEvent.JOB_UPDATED);
    infrastructure.assertRequests(2);
}
Also used : TaskDescriptor(org.ow2.proactive.scheduler.common.TaskDescriptor) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) JobDescriptor(org.ow2.proactive.scheduler.common.JobDescriptor) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Aggregations

JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)96 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)92 Test (org.junit.Test)40 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)22 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)18 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)17 JobId (org.ow2.proactive.scheduler.common.job.JobId)14 NativeTask (org.ow2.proactive.scheduler.common.task.NativeTask)12 EmptyTask (org.ow2.proactive.scheduler.examples.EmptyTask)11 SelectionScript (org.ow2.proactive.scripting.SelectionScript)10 SimpleScript (org.ow2.proactive.scripting.SimpleScript)10 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)9 File (java.io.File)8 HashMap (java.util.HashMap)7 Task (org.ow2.proactive.scheduler.common.task.Task)7 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)6 EmptyExecutable (functionaltests.executables.EmptyExecutable)5 JobDescriptor (org.ow2.proactive.scheduler.common.JobDescriptor)5 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)5 TaskDescriptor (org.ow2.proactive.scheduler.common.TaskDescriptor)4