Search in sources :

Example 36 with TaskResultImpl

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

the class TestUsageData method finishTask.

private void finishTask(InternalJob job, InternalTask task) throws Exception {
    Thread.sleep(10);
    TaskResultImpl res = new TaskResultImpl(null, "ok", null, 42);
    job.terminateTask(false, task.getId(), null, null, res);
    if (job.isFinished()) {
        job.terminate();
    }
    dbManager.updateAfterTaskFinished(job, task, res);
}
Also used : TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl)

Example 37 with TaskResultImpl

use of org.ow2.proactive.scheduler.task.TaskResultImpl 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 38 with TaskResultImpl

use of org.ow2.proactive.scheduler.task.TaskResultImpl 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 39 with TaskResultImpl

use of org.ow2.proactive.scheduler.task.TaskResultImpl 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 40 with TaskResultImpl

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

the class TestReportingQueries method finishTask.

private long finishTask(InternalJob job, String taskName) throws Exception {
    Thread.sleep(100);
    InternalTask task = job.getTask(taskName);
    TaskResultImpl res = new TaskResultImpl(null, "ok", null, 0);
    job.terminateTask(false, task.getId(), null, null, res);
    if (job.isFinished()) {
        job.terminate();
    }
    dbManager.updateAfterTaskFinished(job, task, res);
    return task.getFinishedTime() - task.getStartTime();
}
Also used : TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask)

Aggregations

TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)79 Test (org.junit.Test)77 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)35 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)35 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)30 SimpleScript (org.ow2.proactive.scripting.SimpleScript)30 TaskScript (org.ow2.proactive.scripting.TaskScript)30 TaskContext (org.ow2.proactive.scheduler.task.context.TaskContext)29 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)26 NodeDataSpacesURIs (org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs)26 NodeInfo (org.ow2.proactive.scheduler.task.context.NodeInfo)26 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)22 InProcessTaskExecutor (org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor)19 HashMap (java.util.HashMap)17 JobId (org.ow2.proactive.scheduler.common.job.JobId)17 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)16 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)13 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)13 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)13 SimpleTaskLogs (org.ow2.proactive.scheduler.common.task.SimpleTaskLogs)12