Search in sources :

Example 36 with JobResult

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

the class ComplexTypeArgsTest method testComplexTypeArgs.

@Test
public void testComplexTypeArgs() throws Throwable {
    TaskFlowJob submittedJob = new TaskFlowJob();
    JavaTask task = new JavaTask();
    task.setName("t1");
    task.setExecutableClassName(ComplexParamsExecutable.class.getName());
    task.addArgument("param1", new UserTypeA(3));
    submittedJob.addTask(task);
    // test submission and event reception
    JobId id = schedulerHelper.testJobSubmission(submittedJob);
    // check job results
    JobResult res = schedulerHelper.getJobResult(id);
    assertFalse(res.hadException());
}
Also used : JobResult(org.ow2.proactive.scheduler.common.job.JobResult) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) ComplexParamsExecutable(functionaltests.executables.ComplexParamsExecutable) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 37 with JobResult

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

the class TestMultipleUsersMakingMassivGetResultRequest method testMultipleUsersMakingMassivGetResultRequest.

@Test
public void testMultipleUsersMakingMassivGetResultRequest() throws Throwable {
    final SchedulerAuthenticationInterface auth = schedulerHelper.getSchedulerAuth();
    // create a job
    final TaskFlowJob job = new TaskFlowJob();
    for (int i = 0; i < taskPerJob; i++) {
        JavaTask task = new JavaTask();
        task.setName("jt" + i);
        task.setExecutableClassName(EmptyTask.class.getName());
        job.addTask(task);
    }
    // start threads
    for (int i = 0; i < ThreadNumber; i++) {
        new Thread() {

            @Override
            public void run() {
                try {
                    // connect the scheduler
                    log(Thread.currentThread().getName() + " -> Connecting the scheduler");
                    Credentials cred = Credentials.createCredentials(new CredData(TestUsers.DEMO.username, TestUsers.DEMO.password), auth.getPublicKey());
                    Scheduler user = auth.login(cred);
                    log(Thread.currentThread().getName() + " -> Connected");
                    long start = System.currentTimeMillis();
                    int submitted = 1;
                    while (true) {
                        log(Thread.currentThread().getName() + " -> Submit (" + submitted + ")");
                        JobId id = user.submit(job);
                        JobResult jr = null;
                        while (jr == null) {
                            Thread.sleep(getResultDelay);
                            jr = user.getJobResult(id);
                        }
                        if (System.currentTimeMillis() - start > jobSubmissionDuration) {
                            log(Thread.currentThread().getName() + " -> Terminate");
                            nbFinished++;
                            break;
                        }
                        submitted++;
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }.start();
    }
    while (nbFinished < ThreadNumber) {
        Thread.sleep(100);
    }
    log("All threads terminated.");
}
Also used : JobResult(org.ow2.proactive.scheduler.common.job.JobResult) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) CredData(org.ow2.proactive.authentication.crypto.CredData) SchedulerAuthenticationInterface(org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) EmptyTask(org.ow2.proactive.scheduler.examples.EmptyTask) Credentials(org.ow2.proactive.authentication.crypto.Credentials) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 38 with JobResult

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

the class TestCleanTaskWorkingDir method input_files_are_in_working_dir_for_forked_tasks.

@Test
public void input_files_are_in_working_dir_for_forked_tasks() throws Throwable {
    TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(new File(TestCleanTaskWorkingDir.class.getResource("/functionaltests/descriptors/Job_fill_working_dir_script_task.xml").toURI()).getAbsolutePath());
    JobId id = schedulerHelper.testJobSubmission(job);
    assertFalse(schedulerHelper.getJobResult(id).hadException());
    JobResult jobResult = schedulerHelper.getJobResult(id);
    TaskResult taskResult = jobResult.getResult("fill_working_dir_task");
    String workingDirPath = taskResult.getOutput().getAllLogs(false);
    Assert.assertFalse(new File(workingDirPath).exists());
}
Also used : JobResult(org.ow2.proactive.scheduler.common.job.JobResult) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) File(java.io.File) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 39 with JobResult

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

the class SchedulerDBManager method loadJobResult.

@SuppressWarnings("unchecked")
private JobResultImpl loadJobResult(Session session, Query query, JobData job, JobId jobId) {
    JobResultImpl jobResult = new JobResultImpl();
    jobResult.setJobInfo(job.createJobInfo(jobId));
    DBTaskId currentTaskId = null;
    List<Object[]> resultList = (List<Object[]>) query.list();
    if (resultList.isEmpty()) {
        return jobResult;
    }
    int counter = 0;
    for (Object[] result : resultList) {
        TaskResultData resultData = (TaskResultData) result[0];
        DBTaskId dbTaskId = (DBTaskId) result[1];
        String taskName = (String) result[2];
        Boolean preciousResult = (Boolean) result[3];
        boolean nextTask = !dbTaskId.equals(currentTaskId);
        if (nextTask) {
            TaskId taskId = TaskIdImpl.createTaskId(jobId, taskName, dbTaskId.getTaskId());
            jobResult.addTaskResult(taskName, resultData.toTaskResult(taskId), preciousResult);
            currentTaskId = dbTaskId;
        }
        if (++counter % 100 == 0) {
            session.clear();
        }
    }
    return jobResult;
}
Also used : JobResultImpl(org.ow2.proactive.scheduler.job.JobResultImpl) DBTaskId(org.ow2.proactive.scheduler.core.db.TaskData.DBTaskId) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) DBTaskId(org.ow2.proactive.scheduler.core.db.TaskData.DBTaskId) List(java.util.List) ArrayList(java.util.ArrayList)

Example 40 with JobResult

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

the class TestKillWhenInStoppedState method printJobResult.

private void printJobResult(Scheduler scheduler, JobId jobId) throws Exception {
    JobResult jobResult = scheduler.getJobResult(jobId);
    for (TaskResult taskResult : jobResult.getAllResults().values()) {
        System.out.println("Task " + taskResult.getTaskId());
        if (taskResult.getException() != null) {
            System.out.println("Exception: " + taskResult.getException());
        }
        System.out.println("Task output:");
        System.out.println(taskResult.getOutput().getAllLogs(false));
    }
}
Also used : JobResult(org.ow2.proactive.scheduler.common.job.JobResult) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult)

Aggregations

JobResult (org.ow2.proactive.scheduler.common.job.JobResult)39 JobId (org.ow2.proactive.scheduler.common.job.JobId)26 Test (org.junit.Test)25 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)24 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)22 File (java.io.File)16 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)9 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)7 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)6 NativeTask (org.ow2.proactive.scheduler.common.task.NativeTask)6 JobResultImpl (org.ow2.proactive.scheduler.job.JobResultImpl)6 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)6 Job (org.ow2.proactive.scheduler.common.job.Job)4 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)4 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)4 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)4 NonTerminatingJob (functionaltests.jobs.NonTerminatingJob)3 SimpleJob (functionaltests.jobs.SimpleJob)3 HashMap (java.util.HashMap)3 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)3