Search in sources :

Example 66 with TaskFlowJob

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

the class TestTaskResultData method testMultipleJobs.

@Test
public void testMultipleJobs() throws Throwable {
    // two jobs have tasks with the same name
    TaskFlowJob jobDef1 = new TaskFlowJob();
    jobDef1.addTask(createDefaultTask("task1"));
    TaskFlowJob jobDef2 = new TaskFlowJob();
    jobDef2.addTask(createDefaultTask("task1"));
    InternalJob job1 = defaultSubmitJobAndLoadInternal(true, jobDef1);
    InternalJob job2 = defaultSubmitJobAndLoadInternal(true, jobDef2);
    dbManager.updateAfterTaskFinished(job1, job1.getTask("task1"), new TaskResultImpl(null, new TestResult(0, "job1Res"), null, 0));
    dbManager.updateAfterTaskFinished(job2, job2.getTask("task1"), new TaskResultImpl(null, new TestResult(0, "job2Res"), null, 0));
    TestResult result;
    result = (TestResult) dbManager.loadTaskResult(job1.getId(), "task1", 0).value();
    Assert.assertEquals("job1Res", result.getB());
    result = (TestResult) dbManager.loadTaskResult(job2.getId(), "task1", 0).value();
    Assert.assertEquals("job2Res", result.getB());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) Test(org.junit.Test)

Example 67 with TaskFlowJob

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

the class TestTaskRuntimeData method testStartJobExecution.

@Test
public void testStartJobExecution() throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    job.addTask(createDefaultTask("task1"));
    job.addTask(createDefaultTask("task2"));
    job.addTask(createDefaultTask("task3"));
    InternalJob internalJob = defaultSubmitJobAndLoadInternal(true, job);
    Assert.assertEquals(TaskStatus.SUBMITTED, internalJob.getTask("task1").getStatus());
    Assert.assertEquals(TaskStatus.SUBMITTED, internalJob.getTask("task2").getStatus());
    Assert.assertEquals(TaskStatus.SUBMITTED, internalJob.getTask("task3").getStatus());
    internalJob.start();
    InternalTask task = startTask(internalJob, internalJob.getTask("task1"));
    System.out.println("Job started");
    dbManager.jobTaskStarted(internalJob, task, true);
    internalJob = loadInternalJob(true, internalJob.getId());
    Assert.assertEquals(TaskStatus.RUNNING, internalJob.getTask("task1").getStatus());
    Assert.assertEquals(TaskStatus.PENDING, internalJob.getTask("task2").getStatus());
    Assert.assertEquals(TaskStatus.PENDING, internalJob.getTask("task3").getStatus());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) Test(org.junit.Test)

Example 68 with TaskFlowJob

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

the class TestUsageData method createJob.

private TaskFlowJob createJob(String name, String... taskNames) throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    job.setName(name);
    job.setPriority(JobPriority.IDLE);
    for (String taskName : taskNames) {
        JavaTask task = new JavaTask();
        task.setName(taskName);
        task.setExecutableClassName("className");
        job.addTask(task);
    }
    return job;
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask)

Example 69 with TaskFlowJob

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

the class TestSmartProxy method createTestJob.

protected TaskFlowJob createTestJob(boolean isolateOutputs) throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    job.setName(this.getClass().getSimpleName());
    ForkEnvironment forkEnvironment = new ForkEnvironment();
    forkEnvironment.addAdditionalClasspath(getClasspath(job));
    for (int i = 0; i < NB_TASKS; i++) {
        JavaTask testTask = new JavaTask();
        testTask.setName(TASK_NAME + i);
        testTask.setExecutableClassName(SimpleJavaExecutable.class.getName());
        testTask.setForkEnvironment(forkEnvironment);
        // testTask.
        // ------------- create an input File ------------
        File inputFile = new File(inputLocalFolder, inputFileBaseName + "_" + i + inputFileExt);
        String outputFileName = outputFileBaseName + "_" + i + outputFileExt;
        // delete files after the test is finished
        File outputFile = new File(outputLocalFolder, outputFileName);
        outputFile.deleteOnExit();
        inputFile.deleteOnExit();
        FileWriter fw = new FileWriter(inputFile);
        for (int j = 0; j <= Math.round(Math.random() * 100) + 1; j++) fw.write("Some random input");
        fw.close();
        // Add dummy input files, make sure no error happen
        testTask.addInputFiles("DUMMY", InputAccessMode.TransferFromInputSpace);
        testTask.addInputFiles(inputFile.getName(), InputAccessMode.TransferFromInputSpace);
        if (isolateOutputs) {
            testTask.addOutputFiles("*" + outputFileExt, OutputAccessMode.TransferToOutputSpace);
        } else {
            testTask.addOutputFiles(outputFileName, OutputAccessMode.TransferToOutputSpace);
        }
        job.addTask(testTask);
    }
    job.setInputSpace(dataServerURI);
    job.setOutputSpace(dataServerURI);
    return job;
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) FileWriter(java.io.FileWriter) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) File(java.io.File)

Example 70 with TaskFlowJob

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

the class TestKillTaskWhileExecutingScripts method javaTaskKillEndlessPreScript.

public void javaTaskKillEndlessPreScript() throws Throwable {
    log("Test Java Task : killing an Endless PreScript ...");
    String tname = "javaTaskKillEndlessPreScript";
    // pre script interruption
    TaskFlowJob job = new TaskFlowJob();
    job.setName(this.getClass().getSimpleName() + "_" + tname);
    JavaTask task1 = new JavaTask();
    task1.setName(tname);
    task1.setExecutableClassName(EmptyExecutable.class.getName());
    task1.setPreScript(endlessScript);
    job.addTask(task1);
    submitAndCheckJob(job, tname);
}
Also used : EmptyExecutable(functionaltests.executables.EmptyExecutable) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask)

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