Search in sources :

Example 86 with JavaTask

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

the class TestLoadSchedulerClientState method checkTaskData.

private void checkTaskData(JavaTask expected, TaskState taskState, String... dependences) {
    Assert.assertEquals(expected.getName(), taskState.getName());
    Assert.assertEquals(expected.getDescription(), taskState.getDescription());
    Assert.assertEquals(expected.getName(), taskState.getTaskInfo().getTaskId().getReadableName());
    Assert.assertEquals(expected.getOnTaskErrorProperty().getValue(), taskState.getOnTaskErrorProperty().getValue());
    Assert.assertEquals(expected.getMaxNumberOfExecution(), taskState.getMaxNumberOfExecution());
    Assert.assertEquals(expected.isPreciousLogs(), taskState.isPreciousLogs());
    Assert.assertEquals(expected.isPreciousResult(), taskState.isPreciousResult());
    Assert.assertEquals(expected.isRunAsMe(), taskState.isRunAsMe());
    Assert.assertEquals(expected.getWallTime(), taskState.getWallTime());
    Assert.assertEquals("Unexpected number of dependencies", dependences.length, taskState.getDependences().size());
    Set<String> dependenciesSet = new HashSet<>();
    for (String dependecy : dependences) {
        dependenciesSet.add(dependecy);
    }
    Set<String> actualDependenciesSet = new HashSet<>();
    for (TaskState task : taskState.getDependences()) {
        actualDependenciesSet.add(task.getName());
    }
    Assert.assertEquals("Unexpected dependencies", dependenciesSet, actualDependenciesSet);
}
Also used : TaskState(org.ow2.proactive.scheduler.common.task.TaskState) HashSet(java.util.HashSet)

Example 87 with JavaTask

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

the class TestLoadSchedulerClientState method testStateAfterTaskFinished.

@Test
public void testStateAfterTaskFinished() throws Exception {
    TaskFlowJob jobDef = new TaskFlowJob();
    JavaTask taskDef1 = createDefaultTask("task1");
    JavaTask taskDef2 = createDefaultTask("task2");
    taskDef2.addDependence(taskDef1);
    jobDef.addTask(taskDef1);
    jobDef.addTask(taskDef2);
    InternalJob job = defaultSubmitJobAndLoadInternal(true, jobDef);
    InternalTask task1 = job.getTask("task1");
    job.start();
    startTask(job, task1);
    dbManager.jobTaskStarted(job, task1, true);
    TaskResultImpl result = new TaskResultImpl(null, new TestResult(1, "res1"), null, 1000);
    terminateTask(job, task1, result);
    dbManager.updateAfterTaskFinished(job, task1, result);
    SchedulerStateRecoverHelper stateRecoverHelper = new SchedulerStateRecoverHelper(dbManager);
    RecoveredSchedulerState recovered;
    recovered = stateRecoverHelper.recover(-1);
    JobStateMatcher expectedJob;
    expectedJob = job(job.getId(), JobStatus.STALLED).withFinished(task("task1", TaskStatus.FINISHED).checkFinished()).withPending(task("task2", TaskStatus.SUBMITTED), true).withEligible("task2");
    checkRecoveredState(recovered, state().withRunning(expectedJob));
    job = recovered.getRunningJobs().get(0);
    InternalTask task2 = job.getTask("task2");
    startTask(job, task2);
    dbManager.jobTaskStarted(job, task2, false);
    expectedJob = job(job.getId(), JobStatus.STALLED).withFinished(task("task1", TaskStatus.FINISHED).checkFinished()).withPending(task("task2", TaskStatus.SUBMITTED), true).withEligible("task2");
    recovered = stateRecoverHelper.recover(-1);
    checkRecoveredState(recovered, state().withRunning(expectedJob));
    job = recovered.getRunningJobs().get(0);
    task2 = job.getTask("task2");
    startTask(job, task2);
    dbManager.jobTaskStarted(job, task2, false);
    terminateTask(job, task2, result);
    dbManager.updateAfterTaskFinished(job, task2, result);
    expectedJob = job(job.getId(), JobStatus.FINISHED).withFinished(task("task1", TaskStatus.FINISHED).checkFinished()).withFinished(task("task2", TaskStatus.FINISHED).checkFinished());
    recovered = stateRecoverHelper.recover(-1);
    checkRecoveredState(recovered, state().withFinished(expectedJob));
}
Also used : RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SchedulerStateRecoverHelper(org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) Test(org.junit.Test)

Example 88 with JavaTask

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

the class TestLoadSchedulerClientState method testClientStateLoading.

@Test
public void testClientStateLoading() throws Exception {
    TaskFlowJob job1 = new TaskFlowJob();
    job1.setName(this.getClass().getSimpleName());
    job1.setDescription("desc1");
    job1.setProjectName("p1");
    job1.setInputSpace("is1");
    job1.setOutputSpace("os1");
    job1.setMaxNumberOfExecution(22);
    job1.setOnTaskError(OnTaskError.CONTINUE_JOB_EXECUTION);
    JavaTask task1 = createDefaultTask("task1");
    task1.setDescription("d1");
    task1.setOnTaskError(OnTaskError.CANCEL_JOB);
    task1.setMaxNumberOfExecution(4);
    task1.setPreciousLogs(true);
    task1.setPreciousResult(true);
    task1.setRunAsMe(true);
    task1.setWallTime(440000);
    JavaTask task2 = createDefaultTask("task2");
    task2.setDescription("d2");
    // If it is set to none, the job level behavior will overwrite the task level none behavior.
    task2.setOnTaskError(OnTaskError.NONE);
    task2.setMaxNumberOfExecution(3);
    task2.setPreciousLogs(false);
    task2.setPreciousResult(false);
    task2.setRunAsMe(false);
    task2.setWallTime(240000);
    JavaTask task3 = createDefaultTask("task3");
    task1.addDependence(task2);
    task1.addDependence(task3);
    task2.addDependence(task3);
    job1.addTask(task1);
    job1.addTask(task2);
    job1.addTask(task3);
    job1.setPriority(JobPriority.LOW);
    Map<String, String> genericInfo = new HashMap<>();
    genericInfo.put("p1", "v1");
    genericInfo.put("p2", "v2");
    job1.setGenericInformation(genericInfo);
    InternalJob jobData1 = defaultSubmitJob(job1);
    TaskFlowJob job2 = new TaskFlowJob();
    job2.setName(this.getClass().getSimpleName() + "_2");
    job2.setGenericInformation(new HashMap<String, String>());
    job2.addTask(createDefaultTask("task1"));
    job2.setPriority(JobPriority.HIGH);
    InternalJob jobData2 = defaultSubmitJob(job2);
    System.out.println("Load scheduler client state");
    SchedulerStateRecoverHelper stateRecoverHelper = new SchedulerStateRecoverHelper(dbManager);
    SchedulerState state = stateRecoverHelper.recover(-1).getSchedulerState();
    Assert.assertEquals("Unexpected jobs number", 2, state.getPendingJobs().size());
    JobState jobState;
    jobState = checkJobData(state.getPendingJobs(), jobData1.getId(), job1, 3);
    checkTaskData(task1, findTask(jobState, "task1"), "task2", "task3");
    checkTaskData(task2, findTask(jobState, "task2"), "task3");
    checkTaskData(task3, findTask(jobState, "task3"));
    checkJobData(state.getPendingJobs(), jobData2.getId(), job2, 1);
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) SchedulerState(org.ow2.proactive.scheduler.common.SchedulerState) RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) HashMap(java.util.HashMap) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SchedulerStateRecoverHelper(org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper) JobState(org.ow2.proactive.scheduler.common.job.JobState) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) Test(org.junit.Test)

Example 89 with JavaTask

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

the class TestRestoreWorkflowJobs method task.

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

Example 90 with JavaTask

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

the class TestRestoreWorkflowJobs method createJobWithAllKindOfScripts.

private TaskFlowJob createJobWithAllKindOfScripts() throws InvalidScriptException, UserException {
    TaskFlowJob jobDef = new TaskFlowJob();
    JavaTask t = task("T");
    ForkEnvironment forkEnvironment = new ForkEnvironment();
    SimpleScript aScript = new SimpleScript("", "");
    forkEnvironment.setEnvScript(aScript);
    t.setPreScript(aScript);
    t.setPostScript(aScript);
    t.setCleaningScript(aScript);
    t.setSelectionScript(new SelectionScript("", ""));
    t.setFlowScript(FlowScript.createContinueFlowScript());
    t.setForkEnvironment(forkEnvironment);
    jobDef.addTask(t);
    return jobDef;
}
Also used : SelectionScript(org.ow2.proactive.scripting.SelectionScript) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SimpleScript(org.ow2.proactive.scripting.SimpleScript) 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)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