Search in sources :

Example 56 with TaskFlowJob

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

the class TestLoadJobsPagination method createJob.

private TaskFlowJob createJob() throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    job.setName(this.getClass().getSimpleName());
    job.setDescription("TestLoadJobsPagination desc");
    JavaTask task = new JavaTask();
    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 57 with TaskFlowJob

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

the class TestMultipleTasks method testManyTasks.

@Test
public void testManyTasks() throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    final int TASKS_NUMBER = 1000;
    for (int i = 0; i < TASKS_NUMBER; i++) {
        job.addTask(createDefaultTask("task-" + i));
    }
    InternalJob jobData = defaultSubmitJobAndLoadInternal(true, job);
    Assert.assertEquals(TASKS_NUMBER, jobData.getTasks().size());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) Test(org.junit.Test)

Example 58 with TaskFlowJob

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

the class TestReadSchedulerAccount method singleJobScenario.

private void singleJobScenario(AccountData accountData) throws Exception {
    TaskFlowJob jobDef1 = new TaskFlowJob();
    JavaTask javaTask = new JavaTask();
    javaTask.setExecutableClassName(TestDummyExecutable.class.getName());
    javaTask.setName("task1");
    jobDef1.addTask(javaTask);
    JavaTask forkJavaTask = createDefaultTask("task2");
    forkJavaTask.setExecutableClassName(TestDummyExecutable.class.getName());
    forkJavaTask.setForkEnvironment(new ForkEnvironment());
    jobDef1.addTask(forkJavaTask);
    NativeTask nativeTask = new NativeTask();
    nativeTask.setName("task3");
    nativeTask.setCommandLine("command");
    jobDef1.addTask(nativeTask);
    InternalJob job1 = defaultSubmitJobAndLoadInternal(true, jobDef1, accountData.userName);
    // job is submitted
    checkAccount(invalidUser);
    checkAccount(accountData);
    // task1 started
    job1.start();
    startTask(job1, job1.getTask("task1"));
    dbManager.jobTaskStarted(job1, job1.getTask("task1"), true);
    checkAccount(invalidUser);
    checkAccount(accountData);
    // task1 finished
    accountData.taskTime += finishTask(job1, "task1");
    accountData.taskCount++;
    checkAccount(invalidUser);
    checkAccount(accountData);
    // task2 and task3 started
    startTask(job1, job1.getTask("task2"));
    dbManager.jobTaskStarted(job1, job1.getTask("task2"), true);
    startTask(job1, job1.getTask("task3"));
    dbManager.jobTaskStarted(job1, job1.getTask("task3"), true);
    checkAccount(invalidUser);
    checkAccount(accountData);
    // task2 finished
    accountData.taskTime += finishTask(job1, "task2");
    accountData.taskCount++;
    checkAccount(invalidUser);
    checkAccount(accountData);
    // task3 and job finished
    accountData.taskTime += finishTask(job1, "task3");
    accountData.taskCount++;
    accountData.jobCount++;
    accountData.jobTime += job1.getFinishedTime() - job1.getStartTime();
    checkAccount(invalidUser);
    checkAccount(accountData);
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) NativeTask(org.ow2.proactive.scheduler.common.task.NativeTask) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment)

Example 59 with TaskFlowJob

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

the class TestReportingQueries method doTest.

@Test
public void doTest() throws Exception {
    checkInvalidIds();
    checkJobAndTasksNumbers(0, 0, 0, 0, 0, 0, 0, 0);
    checkMeanPendingTime();
    checkMeanExecutionTime();
    checkMeanSubmittingPeriod();
    TaskFlowJob jobDef1 = new TaskFlowJob();
    JavaTask javaTask = new JavaTask();
    javaTask.setExecutableClassName(TestDummyExecutable.class.getName());
    javaTask.setName("task1");
    jobDef1.addTask(javaTask);
    JavaTask forkJavaTask = createDefaultTask("task2");
    forkJavaTask.setExecutableClassName(TestDummyExecutable.class.getName());
    forkJavaTask.setForkEnvironment(new ForkEnvironment());
    jobDef1.addTask(forkJavaTask);
    NativeTask nativeTask = new NativeTask();
    nativeTask.setName("task3");
    nativeTask.setCommandLine("command");
    jobDef1.addTask(nativeTask);
    InternalJob job1 = defaultSubmitJobAndLoadInternal(true, jobDef1);
    try {
        dbManager.getJobPendingTime(job1.getJobInfo().getJobId().value());
        Assert.fail();
    } catch (RuntimeException e) {
    }
    try {
        dbManager.getJobRunningTime(job1.getJobInfo().getJobId().value());
        Assert.fail();
    } catch (RuntimeException e) {
    }
    checkJobAndTasksNumbers(1, 0, 0, 1, 3, 0, 0, 3);
    checkMeanSubmittingPeriod(job1);
    checkMeanTaskPendingTime(job1);
    checkMeanTaskRunningTime(job1);
    checkNumberOfHosts(job1, 0);
    Thread.sleep(100);
    InternalJob job2 = defaultSubmitJobAndLoadInternal(true, jobDef1);
    checkMeanSubmittingPeriod(job1, job2);
    checkJobAndTasksNumbers(2, 0, 0, 2, 6, 0, 0, 6);
    // job1: task1 started
    job1.start();
    startTask(job1, job1.getTask("task1"));
    dbManager.jobTaskStarted(job1, job1.getTask("task1"), true);
    checkNumberOfHosts(job1, 1);
    checkJobPendingTime(job1);
    checkMeanPendingTime(job1);
    checkMeanTaskPendingTime(job1);
    checkMeanTaskRunningTime(job1);
    checkJobAndTasksNumbers(1, 1, 0, 2, 5, 1, 0, 6);
    // job1: task1 finished
    finishTask(job1, "task1");
    checkJobAndTasksNumbers(1, 1, 0, 2, 5, 0, 1, 6);
    checkMeanTaskRunningTime(job1);
    checkNumberOfHosts(job1, 1);
    // job2: task1 started
    job2.start();
    startTask(job2, job2.getTask("task1"));
    dbManager.jobTaskStarted(job2, job2.getTask("task1"), true);
    checkMeanPendingTime(job1, job2);
    checkMeanTaskRunningTime(job2);
    checkJobAndTasksNumbers(0, 2, 0, 2, 4, 1, 1, 6);
    // job1: task2 and task3 started
    startTask(job1, job1.getTask("task2"));
    dbManager.jobTaskStarted(job1, job1.getTask("task2"), false);
    startTask(job1, job1.getTask("task3"));
    dbManager.jobTaskStarted(job1, job1.getTask("task3"), false);
    checkMeanTaskPendingTime(job1);
    checkMeanTaskRunningTime(job1);
    checkJobAndTasksNumbers(0, 2, 0, 2, 2, 3, 1, 6);
    // job1: task2 and task3 finished, job1 finished
    finishTask(job1, "task2");
    finishTask(job1, "task3");
    checkJobRunningTime(job1);
    checkMeanExecutionTime(job1);
    checkMeanTaskRunningTime(job1);
    checkJobAndTasksNumbers(0, 1, 1, 2, 2, 1, 3, 6);
    checkNumberOfHosts(job1, 1);
    // job2: task1, task2 and task3 finished, job2 finished
    finishTask(job2, "task1");
    finishTask(job2, "task2");
    finishTask(job2, "task3");
    checkJobRunningTime(job2);
    checkMeanExecutionTime(job1, job2);
    checkMeanTaskRunningTime(job2);
    checkJobAndTasksNumbers(0, 0, 2, 2, 0, 0, 6, 6);
    // remove job2
    dbManager.removeJob(job2.getId(), System.currentTimeMillis(), false);
    checkJobAndTasksNumbers(0, 0, 1, 1, 0, 0, 3, 3);
    checkMeanPendingTime(job1, job2);
    checkMeanExecutionTime(job1, job2);
    checkMeanSubmittingPeriod(job1, job2);
    InternalJob job3 = defaultSubmitJobAndLoadInternal(true, jobDef1);
    checkMeanSubmittingPeriod(job1, job2, job3);
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) NativeTask(org.ow2.proactive.scheduler.common.task.NativeTask) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) Test(org.junit.Test)

Example 60 with TaskFlowJob

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

the class TestRestoreWorkflowJobs method test.

@Test
public void test() throws Exception {
    TaskFlowJob jobDef = createJob();
    InternalJob job = defaultSubmitJobAndLoadInternal(true, jobDef);
    job.start();
    InternalTask mainTask = job.getTask("T");
    startTask(job, mainTask);
    dbManager.jobTaskStarted(job, mainTask, true);
    TaskResultImpl result = new TaskResultImpl(mainTask.getId(), "ok", null, 0);
    FlowAction action = new FlowAction(FlowActionType.REPLICATE);
    action.setDupNumber(2);
    ChangedTasksInfo changesInfo = job.terminateTask(false, mainTask.getId(), null, action, result);
    dbManager.updateAfterWorkflowTaskFinished(job, changesInfo, result);
    SchedulerStateRecoverHelper recoverHelper = new SchedulerStateRecoverHelper(dbManager);
    JobStateMatcher expectedJob;
    expectedJob = job(job.getId(), JobStatus.STALLED).withFinished(task("T", TaskStatus.FINISHED).checkFinished(), true).withPending(task("T1", TaskStatus.PENDING), true).withPending(task("T1*1", TaskStatus.SUBMITTED), true).withPending(task("T2", TaskStatus.PENDING), true).withPending(task("T3", TaskStatus.PENDING), true).withPending(task("T2*1", TaskStatus.SUBMITTED), true).withPending(task("T3*1", TaskStatus.SUBMITTED), true).withPending(task("T4", TaskStatus.PENDING), true).withEligible("T1", "T1*1");
    checkRecoveredState(recoverHelper.recover(-1), state().withRunning(expectedJob));
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) ChangedTasksInfo(org.ow2.proactive.scheduler.job.ChangedTasksInfo) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) FlowAction(org.ow2.proactive.scheduler.common.task.flow.FlowAction) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SchedulerStateRecoverHelper(org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper) Test(org.junit.Test)

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