Search in sources :

Example 21 with JavaTask

use of org.ow2.proactive.scheduler.common.task.JavaTask 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 22 with JavaTask

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

the class TestJobRemove method testFullDataRemove1.

@Test
public void testFullDataRemove1() throws Exception {
    TaskFlowJob jobDef = new TaskFlowJob();
    JavaTask task1 = new JavaTask();
    task1.setName("task1");
    task1.setExecutableClassName(TestDummyExecutable.class.getName());
    jobDef.addTask(task1);
    InternalJob job = defaultSubmitJob(jobDef);
    System.out.println("Remove job");
    long start = System.currentTimeMillis();
    dbManager.removeJob(job.getId(), 0, true);
    System.out.println("Remove time (single task)" + (System.currentTimeMillis() - start));
    checkAllEntitiesDeleted();
}
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) Test(org.junit.Test)

Example 23 with JavaTask

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

the class TestJobRemove method testRuntimeDataRemoveAfterFinish.

@Test
public void testRuntimeDataRemoveAfterFinish() throws Throwable {
    TaskFlowJob jobDef = createJob(2);
    InternalJob job = defaultSubmitJobAndLoadInternal(false, jobDef);
    dbManager.updateAfterTaskFinished(job, job.getTask("javaTask-0"), new TaskResultImpl(null, "OK1", null, 0));
    dbManager.updateAfterTaskFinished(job, job.getTask("forkedJavaTask-0"), new TaskResultImpl(null, "OK2", null, 0));
    dbManager.updateAfterTaskFinished(job, job.getTask("nativeTask-0"), new TaskResultImpl(null, "OK3", null, 0));
    job.setStatus(JobStatus.FINISHED);
    dbManager.updateAfterTaskFinished(job, null, null);
    checkAllEntitiesDeleted(JobData.class.getName(), JobContent.class.getName(), TaskData.class.getName(), TaskResultData.class.getName());
    // check can still load task results
    Assert.assertEquals("OK1", dbManager.loadTaskResult(job.getTask("javaTask-0").getId(), 0).value());
    Assert.assertEquals("OK2", dbManager.loadTaskResult(job.getTask("forkedJavaTask-0").getId(), 0).value());
    Assert.assertEquals("OK3", dbManager.loadTaskResult(job.getTask("nativeTask-0").getId(), 0).value());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) JobContent(org.ow2.proactive.scheduler.core.db.JobContent) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) TaskResultData(org.ow2.proactive.scheduler.core.db.TaskResultData) JobData(org.ow2.proactive.scheduler.core.db.JobData) TaskData(org.ow2.proactive.scheduler.core.db.TaskData) Test(org.junit.Test)

Example 24 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 25 with JavaTask

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

the class TestJobRemove method testRuntimeDataRemoveAfterFinishParallel.

@Test
public void testRuntimeDataRemoveAfterFinishParallel() throws Throwable {
    int THREAD_COUNT = 4;
    ExecutorService executorService = Executors.newCachedThreadPool();
    List<InternalJob> jobs = new ArrayList<>(THREAD_COUNT);
    TaskFlowJob jobDef;
    for (int i = 0; i < THREAD_COUNT; i++) {
        jobDef = createJob(2);
        jobs.add(defaultSubmitJobAndLoadInternal(false, jobDef));
    }
    for (int i = 0; i < THREAD_COUNT; i++) {
        final InternalJob job = jobs.get(i);
        executorService.submit(new Runnable() {

            @Override
            public void run() {
                try {
                    dbManager.updateAfterTaskFinished(job, job.getTask("javaTask-0"), new TaskResultImpl(null, "OK1", null, 0));
                    dbManager.updateAfterTaskFinished(job, job.getTask("forkedJavaTask-0"), new TaskResultImpl(null, "OK2", null, 0));
                    dbManager.updateAfterTaskFinished(job, job.getTask("nativeTask-0"), new TaskResultImpl(null, "OK3", null, 0));
                    job.setStatus(JobStatus.FINISHED);
                    dbManager.updateAfterTaskFinished(job, null, null);
                } catch (Throwable throwable) {
                    throwable.printStackTrace();
                }
            }
        });
    }
    executorService.shutdown();
    executorService.awaitTermination(30, TimeUnit.SECONDS);
    for (int i = 0; i < THREAD_COUNT; i++) {
        final InternalJob job = jobs.get(i);
        List<InternalJob> jobsNotFinished = dbManager.loadNotFinishedJobs(true);
        Assert.assertEquals("All jobs should be finished", 0, jobsNotFinished.size());
        checkAllEntitiesDeleted(JobData.class.getName(), JobContent.class.getName(), TaskData.class.getName(), TaskResultData.class.getName());
        // check can still load task results
        Assert.assertEquals("OK1", dbManager.loadTaskResult(job.getTask("javaTask-0").getId(), 0).value());
        Assert.assertEquals("OK2", dbManager.loadTaskResult(job.getTask("forkedJavaTask-0").getId(), 0).value());
        Assert.assertEquals("OK3", dbManager.loadTaskResult(job.getTask("nativeTask-0").getId(), 0).value());
    }
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) ArrayList(java.util.ArrayList) TaskResultData(org.ow2.proactive.scheduler.core.db.TaskResultData) TaskData(org.ow2.proactive.scheduler.core.db.TaskData) JobContent(org.ow2.proactive.scheduler.core.db.JobContent) ExecutorService(java.util.concurrent.ExecutorService) JobData(org.ow2.proactive.scheduler.core.db.JobData) Test(org.junit.Test)

Aggregations

JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)96 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)92 Test (org.junit.Test)40 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)22 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)18 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)17 JobId (org.ow2.proactive.scheduler.common.job.JobId)14 NativeTask (org.ow2.proactive.scheduler.common.task.NativeTask)12 EmptyTask (org.ow2.proactive.scheduler.examples.EmptyTask)11 SelectionScript (org.ow2.proactive.scripting.SelectionScript)10 SimpleScript (org.ow2.proactive.scripting.SimpleScript)10 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)9 File (java.io.File)8 HashMap (java.util.HashMap)7 Task (org.ow2.proactive.scheduler.common.task.Task)7 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)6 EmptyExecutable (functionaltests.executables.EmptyExecutable)5 JobDescriptor (org.ow2.proactive.scheduler.common.JobDescriptor)5 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)5 TaskDescriptor (org.ow2.proactive.scheduler.common.TaskDescriptor)4