Search in sources :

Example 51 with JavaTask

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

the class TestJobRemove method removeScenario.

private void removeScenario(int tasksNumber) throws Exception {
    TaskFlowJob jobDef = createJob(tasksNumber);
    InternalJob job = defaultSubmitJobAndLoadInternal(false, jobDef);
    for (int i = 0; i < tasksNumber; i++) {
        dbManager.updateAfterTaskFinished(job, job.getTask("javaTask-" + i), new TaskResultImpl(null, "OK", null, 0));
        dbManager.updateAfterTaskFinished(job, job.getTask("javaTask-" + i), new TaskResultImpl(null, "OK", null, 0));
        dbManager.updateAfterTaskFinished(job, job.getTask("forkedJavaTask-" + i), new TaskResultImpl(null, "OK", null, 0));
        dbManager.updateAfterTaskFinished(job, job.getTask("forkedJavaTask-" + i), new TaskResultImpl(null, "OK", null, 0));
        dbManager.updateAfterTaskFinished(job, job.getTask("nativeTask-" + i), new TaskResultImpl(null, "OK", null, 0));
        dbManager.updateAfterTaskFinished(job, job.getTask("nativeTask-" + i), new TaskResultImpl(null, "OK", null, 0));
    }
    System.out.println("Remove job");
    long start = System.currentTimeMillis();
    dbManager.removeJob(job.getId(), 0, true);
    System.out.println("Remove time (tasks: " + tasksNumber + ")" + (System.currentTimeMillis() - start));
    checkAllEntitiesDeleted();
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob)

Example 52 with JavaTask

use of org.ow2.proactive.scheduler.common.task.JavaTask 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, 0, 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, 1, 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);
    checkMeanPendingTime(job1, job2);
    checkMeanExecutionTime(job1, job2);
    checkMeanSubmittingPeriod(job1, job2);
    // remove job2
    dbManager.removeJob(job2.getId(), System.currentTimeMillis(), true);
    checkJobAndTasksNumbers(0, 0, 1, 1, 0, 0, 3, 3);
    InternalJob job3 = defaultSubmitJobAndLoadInternal(true, jobDef1);
    checkMeanSubmittingPeriod(job1, 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 53 with JavaTask

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

the class TestRestoreWorkflowJobs2 method task.

static JavaTask task(String name) {
    JavaTask task = new JavaTask();
    task.setExecutableClassName(TestTask.class.getName());
    task.setName(name);
    return task;
}
Also used : JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask)

Example 54 with JavaTask

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

the class TestRestoreWorkflowJobs2 method createJob.

private TaskFlowJob createJob() throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    JavaTask A = task("A");
    FlowScript ifScript = FlowScript.createIfFlowScript("branch = \"if\";", "B", "C", null);
    A.setFlowScript(ifScript);
    job.addTask(A);
    JavaTask B = task("B");
    job.addTask(B);
    JavaTask C = task("C");
    job.addTask(C);
    return job;
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript)

Example 55 with JavaTask

use of org.ow2.proactive.scheduler.common.task.JavaTask 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
    accountData.pendingJobsCount++;
    accountData.pendingTasksCount = 3;
    checkAccount(invalidUser);
    checkAccount(accountData);
    // task1 started
    job1.start();
    startTask(job1, job1.getTask("task1"));
    dbManager.jobTaskStarted(job1, job1.getTask("task1"), true);
    accountData.pendingJobsCount--;
    accountData.runningJobsCount++;
    accountData.pendingTasksCount--;
    accountData.currentTasksCount++;
    checkAccount(invalidUser);
    checkAccount(accountData);
    // task1 finished
    accountData.taskTime += finishTask(job1, "task1");
    accountData.currentTasksCount--;
    accountData.pastTasksCount++;
    accountData.taskCount++;
    accountData.runningJobsCount--;
    accountData.stalledJobsCount++;
    checkAccount(invalidUser);
    checkAccount(accountData);
    // task2 and task3 started
    startTask(job1, job1.getTask("task2"));
    dbManager.jobTaskStarted(job1, job1.getTask("task2"), true);
    accountData.pendingTasksCount--;
    accountData.currentTasksCount++;
    startTask(job1, job1.getTask("task3"));
    dbManager.jobTaskStarted(job1, job1.getTask("task3"), true);
    accountData.pendingTasksCount--;
    accountData.currentTasksCount++;
    accountData.runningJobsCount++;
    accountData.stalledJobsCount--;
    checkAccount(invalidUser);
    checkAccount(accountData);
    // task2 finished
    accountData.taskTime += finishTask(job1, "task2");
    accountData.currentTasksCount--;
    accountData.pastTasksCount++;
    accountData.taskCount++;
    checkAccount(invalidUser);
    checkAccount(accountData);
    // task3 and job finished
    accountData.taskTime += finishTask(job1, "task3");
    accountData.currentTasksCount--;
    accountData.pastTasksCount++;
    accountData.taskCount++;
    accountData.jobCount++;
    accountData.finishedJobsCount++;
    accountData.runningJobsCount--;
    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)

Aggregations

TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)104 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)104 Test (org.junit.Test)44 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)24 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)20 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)18 JobId (org.ow2.proactive.scheduler.common.job.JobId)14 NativeTask (org.ow2.proactive.scheduler.common.task.NativeTask)14 EmptyTask (org.ow2.proactive.scheduler.examples.EmptyTask)13 SelectionScript (org.ow2.proactive.scripting.SelectionScript)12 SimpleScript (org.ow2.proactive.scripting.SimpleScript)12 File (java.io.File)11 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)11 HashMap (java.util.HashMap)10 Task (org.ow2.proactive.scheduler.common.task.Task)9 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)7 ScriptTask (org.ow2.proactive.scheduler.common.task.ScriptTask)6 EmptyExecutable (functionaltests.executables.EmptyExecutable)5 JobDescriptor (org.ow2.proactive.scheduler.common.JobDescriptor)5 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)5