Search in sources :

Example 51 with TaskFlowJob

use of org.ow2.proactive.scheduler.common.job.TaskFlowJob 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 52 with TaskFlowJob

use of org.ow2.proactive.scheduler.common.job.TaskFlowJob 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 53 with TaskFlowJob

use of org.ow2.proactive.scheduler.common.job.TaskFlowJob 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)

Example 54 with TaskFlowJob

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

the class TestJobRuntimeData method testJobRuntimeData.

@Test
public void testJobRuntimeData() throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    job.setName(this.getClass().getSimpleName());
    job.addTask(createDefaultTask("task1"));
    job.setPriority(JobPriority.LOW);
    System.out.println("Submit and load job");
    InternalJob runtimeData = defaultSubmitJobAndLoadInternal(true, job);
    Assert.assertEquals(JobStatus.PENDING, runtimeData.getStatus());
    Assert.assertEquals(DEFAULT_USER_NAME, runtimeData.getOwner());
    Assert.assertEquals(JobPriority.LOW, runtimeData.getPriority());
    Assert.assertEquals(0, runtimeData.getNumberOfPendingTasks());
    Assert.assertEquals(1, runtimeData.getTotalNumberOfTasks());
    Assert.assertEquals(0, runtimeData.getNumberOfFinishedTasks());
    Assert.assertEquals(0, runtimeData.getNumberOfRunningTasks());
    Assert.assertEquals(this.getClass().getSimpleName(), runtimeData.getName());
    Assert.assertNotNull(runtimeData.getCredentials());
    Assert.assertEquals(1, runtimeData.getITasks().size());
    runtimeData.start();
    InternalTask internalTask = startTask(runtimeData, runtimeData.getITasks().get(0));
    System.out.println("Update started task data");
    dbManager.jobTaskStarted(runtimeData, internalTask, false);
    System.out.println("Load internal job");
    runtimeData = loadInternalJob(true, runtimeData.getId());
    Assert.assertEquals(this.getClass().getSimpleName(), runtimeData.getJobInfo().getJobId().getReadableName());
    Assert.assertEquals(JobStatus.RUNNING, runtimeData.getStatus());
    Assert.assertEquals(1, runtimeData.getNumberOfRunningTasks());
    Assert.assertEquals(0, runtimeData.getNumberOfFinishedTasks());
    Assert.assertEquals(0, runtimeData.getNumberOfPendingTasks());
    Assert.assertTrue(runtimeData.getStartTime() > 0);
    internalTask = runtimeData.getITasks().get(0);
    Assert.assertEquals(TaskStatus.RUNNING, internalTask.getStatus());
    Assert.assertTrue(internalTask.getStartTime() > 0);
    Assert.assertNotNull(internalTask.getExecutionHostName());
}
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) Test(org.junit.Test)

Example 55 with TaskFlowJob

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

the class TestLoadJobResult method testEmptyResult.

@Test
public void testEmptyResult() throws Throwable {
    TaskFlowJob jobDef = new TaskFlowJob();
    jobDef.addTask(createDefaultTask("task1"));
    InternalJob job = defaultSubmitJobAndLoadInternal(true, jobDef);
    InternalTask task1 = job.getTask("task1");
    JobResult result;
    result = dbManager.loadJobResult(job.getId());
    Assert.assertNotNull(result.getJobInfo());
    Assert.assertEquals(0, result.getAllResults().size());
    Assert.assertEquals(1, result.getJobInfo().getTotalNumberOfTasks());
    dbManager.updateAfterTaskFinished(job, task1, new TaskResultImpl(null, new TestResult(0, "1_1"), null, 0));
    result = dbManager.loadJobResult(job.getId());
    Assert.assertNotNull(result.getJobInfo());
    Assert.assertEquals(1, result.getAllResults().size());
    Assert.assertEquals(1, result.getJobInfo().getTotalNumberOfTasks());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) JobResult(org.ow2.proactive.scheduler.common.job.JobResult) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) 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