Search in sources :

Example 36 with Task

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

the class SchedulerDbManagerConcurrencyTest method createAndInsertJob.

public InternalJob createAndInsertJob() throws Exception {
    TaskFlowJob jobDef = new TaskFlowJob();
    JavaTask javaTask = createDefaultTask("java task");
    javaTask.setExecutableClassName(TestDummyExecutable.class.getName());
    jobDef.addTask(javaTask);
    return defaultSubmitJob(jobDef);
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask)

Example 37 with Task

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

the class SchedulerTasksStateRecoverIntegrationTest method testRecover.

@Test
public void testRecover() throws Exception {
    SchedulerStateRecoverHelper recoverHelper = new SchedulerStateRecoverHelper(dbManager);
    RecoveredSchedulerState state = recoverHelper.recover(-1);
    Assert.assertEquals(0, state.getFinishedJobs().size());
    Assert.assertEquals(0, state.getRunningJobs().size());
    Assert.assertEquals(0, state.getPendingJobs().size());
    TaskFlowJob job1 = new TaskFlowJob();
    JavaTask task1 = createDefaultTask("task1");
    JavaTask task2 = createDefaultTask("task2");
    JavaTask task3 = createDefaultTask("task3");
    task1.addDependence(task2);
    task1.addDependence(task3);
    task2.addDependence(task3);
    job1.addTask(task1);
    job1.addTask(task2);
    job1.addTask(task3);
    InternalJob job = defaultSubmitJob(job1);
    JobStateMatcher expectedJob;
    expectedJob = job(job.getId(), JobStatus.PENDING).withPending(task("task1", TaskStatus.SUBMITTED), false).withPending(task("task2", TaskStatus.SUBMITTED), false).withPending(task("task3", TaskStatus.SUBMITTED), false).withEligible("task3");
    state = checkRecoveredState(recoverHelper.recover(-1), state().withPending(expectedJob));
    job = state.getPendingJobs().get(0);
    TaskDescriptor task = job.getJobDescriptor().getEligibleTasks().iterator().next();
    Assert.assertEquals(2, task.getChildren().size());
    Assert.assertEquals(0, task.getParents().size());
    job.terminate();
    dbManager.updateAfterTaskFinished(job, null, null);
    expectedJob = job(job.getId(), JobStatus.FINISHED).withPending(task("task1", TaskStatus.SUBMITTED), false).withPending(task("task2", TaskStatus.SUBMITTED), false).withPending(task("task3", TaskStatus.SUBMITTED), false).withEligible("task3");
    state = checkRecoveredState(recoverHelper.recover(-1), state().withFinished(expectedJob));
    job = state.getFinishedJobs().get(0);
    task = job.getJobDescriptor().getEligibleTasks().iterator().next();
    Assert.assertEquals(2, task.getChildren().size());
    Assert.assertEquals(0, task.getParents().size());
}
Also used : RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) TaskDescriptor(org.ow2.proactive.scheduler.common.TaskDescriptor) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) 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 38 with Task

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

the class SchedulerTasksStateRecoverIntegrationTest method testRecoverAfterRestart.

@Test
public void testRecoverAfterRestart() throws Exception {
    TaskFlowJob jobDef = new TaskFlowJob();
    jobDef.addTask(createDefaultTask("task1"));
    InternalJob job = defaultSubmitJobAndLoadInternal(true, jobDef);
    InternalTask task = job.getTask("task1");
    job.start();
    startTask(job, task);
    dbManager.jobTaskStarted(job, task, true);
    SchedulerStateRecoverHelper recoverHelper = new SchedulerStateRecoverHelper(dbManager);
    JobStateMatcher expectedJob;
    expectedJob = job(job.getId(), JobStatus.STALLED).withPending(task("task1", TaskStatus.PENDING), true).withEligible("task1");
    RecoveredSchedulerState state;
    state = checkRecoveredState(recoverHelper.recover(-1), state().withRunning(expectedJob));
    job = state.getRunningJobs().get(0);
    task = job.getTask("task1");
    startTask(job, task);
    dbManager.jobTaskStarted(job, task, true);
    job.newWaitingTask();
    job.reStartTask(task);
    dbManager.taskRestarted(job, task, null);
    state = checkRecoveredState(recoverHelper.recover(-1), state().withRunning(expectedJob));
    // check it is possible to load ExecutableContainer for restored task
    job = state.getRunningJobs().get(0);
    ExecutableContainer container = dbManager.loadExecutableContainer(job.getTask("task1"));
    Assert.assertNotNull(container);
}
Also used : RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) ExecutableContainer(org.ow2.proactive.scheduler.task.containers.ExecutableContainer) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SchedulerStateRecoverHelper(org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper) Test(org.junit.Test)

Example 39 with Task

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

the class TestDataspaceSelectorsData method testSelectors.

@Test
public void testSelectors() throws Exception {
    TaskFlowJob jobDef = new TaskFlowJob();
    JavaTask task = createDefaultTask("task1");
    Set<String> inInclude1 = Sets.newHashSet("inInclude1_1", "inInclude1_2");
    Set<String> inExclude1 = Sets.newHashSet("inExclude1_1", "inExclude1_2");
    Set<String> outInclude1 = Sets.newHashSet("outInclude1_1", "outInclude1_2");
    Set<String> outExclude1 = Sets.newHashSet("outExclude1_1", "outExclude1_2");
    Set<String> inInclude2 = Sets.newHashSet("inInclude" + createString(500));
    Set<String> inExclude2 = Sets.newHashSet("inExclude" + createString(500));
    Set<String> outInclude2 = Sets.newHashSet("outInclude" + createString(500));
    Set<String> outExclude2 = Sets.newHashSet("outExclude" + createString(500));
    FileSelector fileSelector;
    task.addInputFiles(new FileSelector(inInclude1, inExclude1), InputAccessMode.TransferFromGlobalSpace);
    task.addInputFiles(new FileSelector(inInclude1, inExclude1), InputAccessMode.TransferFromUserSpace);
    fileSelector = new FileSelector(inInclude2, inExclude2);
    task.addInputFiles(fileSelector, InputAccessMode.TransferFromInputSpace);
    task.addOutputFiles(new FileSelector(outInclude1, outExclude1), OutputAccessMode.TransferToGlobalSpace);
    task.addOutputFiles(new FileSelector(outInclude1, outExclude1), OutputAccessMode.TransferToUserSpace);
    fileSelector = new FileSelector(outInclude2, outExclude2);
    task.addOutputFiles(fileSelector, OutputAccessMode.TransferToOutputSpace);
    jobDef.addTask(task);
    InternalJob job = defaultSubmitJobAndLoadInternal(true, jobDef);
    InternalTask task1 = job.getTask("task1");
    Assert.assertEquals(3, task1.getInputFilesList().size());
    Assert.assertEquals(InputAccessMode.TransferFromGlobalSpace, task1.getInputFilesList().get(0).getMode());
    Assert.assertEquals(InputAccessMode.TransferFromUserSpace, task1.getInputFilesList().get(1).getMode());
    Assert.assertEquals(3, task1.getOutputFilesList().size());
    checkSelector(task1.getInputFilesList().get(0).getInputFiles(), inInclude1, inExclude1, true);
    checkSelector(task1.getInputFilesList().get(1).getInputFiles(), inInclude1, inExclude1, true);
    checkSelector(task1.getInputFilesList().get(2).getInputFiles(), inInclude2, inExclude2, false);
    checkSelector(task1.getOutputFilesList().get(0).getOutputFiles(), outInclude1, outExclude1, true);
    checkSelector(task1.getOutputFilesList().get(1).getOutputFiles(), outInclude1, outExclude1, true);
    checkSelector(task1.getOutputFilesList().get(2).getOutputFiles(), outInclude2, outExclude2, false);
}
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) FileSelector(org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) Test(org.junit.Test)

Example 40 with Task

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

the class TestJobAttributes method testJobIdGeneration.

@Test
public void testJobIdGeneration() throws Exception {
    // test job ids are sequential
    for (int i = 0; i < 5; i++) {
        TaskFlowJob jobDef = new TaskFlowJob();
        for (int j = 0; j < 10; j++) {
            jobDef.addTask(createDefaultTask("task" + j));
        }
        InternalJob job = defaultSubmitJob(jobDef);
        Assert.assertEquals(String.valueOf(i + 1), job.getId().value());
    }
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)152 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)112 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)100 JobId (org.ow2.proactive.scheduler.common.job.JobId)73 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)69 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)68 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)60 ArrayList (java.util.ArrayList)49 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)48 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)43 Task (org.ow2.proactive.scheduler.common.task.Task)41 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)41 File (java.io.File)37 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)34 HashMap (java.util.HashMap)33 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)33 SimpleScript (org.ow2.proactive.scripting.SimpleScript)33 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)27 TaskScript (org.ow2.proactive.scripting.TaskScript)27 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)26