Search in sources :

Example 1 with JobResult

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

the class SchedulerStateRestJobLogsTest method createJobResult.

private JobResultImpl createJobResult(String taskOutput, String taskErrput) {
    JobResultImpl jobResult = new JobResultImpl();
    jobResult.addTaskResult("OneTask", new TaskResultImpl(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("123"), "OneTask", 1), "result", new SimpleTaskLogs(taskOutput, taskErrput), 100), false);
    return jobResult;
}
Also used : JobResultImpl(org.ow2.proactive.scheduler.job.JobResultImpl) SimpleTaskLogs(org.ow2.proactive.scheduler.common.task.SimpleTaskLogs) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl)

Example 2 with JobResult

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

the class SchedulerStateRestJobLogsTest method jobLogs_finished.

@Test
public void jobLogs_finished() throws Exception {
    JobResultImpl jobResult = createJobResult("Hello", "");
    when(mockScheduler.getJobResult("123")).thenReturn(jobResult);
    String jobLogs = restScheduler.jobLogs(validSessionId, "123");
    assertEquals("Hello", jobLogs);
}
Also used : JobResultImpl(org.ow2.proactive.scheduler.job.JobResultImpl) Test(org.junit.Test)

Example 3 with JobResult

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

the class GetJobResultCommandTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    DataFaker<JobResultData> jobResultFaker = new DataFaker<JobResultData>(JobResultData.class);
    jobResultFaker.setGenerator("id.readableName", new PrefixPropertyGenerator("job", 1));
    jobResultFaker.setGenerator("allResults.key", new PrefixPropertyGenerator("task", 1));
    jobResultFaker.setGenerator("allResults.value.id.readableName", new PrefixPropertyGenerator("task", 1));
    jobResultFaker.setGenerator("allResults.value.serializedValue", new FixedPropertyGenerator(ObjectByteConverter.serializableToBase64String("Hello")));
    jobResult = jobResultFaker.fake();
    DataFaker<TaskResultData> taskResultsDataFaker = new DataFaker<TaskResultData>(TaskResultData.class);
    taskResultsDataFaker.setGenerator("id.readableName", new PrefixPropertyGenerator("task", 4));
    taskResultsDataFaker.setGenerator("serializedValue", new FixedPropertyGenerator(ObjectByteConverter.serializableToBase64String("Hello")));
    taskResults = taskResultsDataFaker.fakeList(3);
}
Also used : PrefixPropertyGenerator(objectFaker.propertyGenerator.PrefixPropertyGenerator) JobResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobResultData) DataFaker(objectFaker.DataFaker) TaskResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData) FixedPropertyGenerator(objectFaker.propertyGenerator.FixedPropertyGenerator) Before(org.junit.Before)

Example 4 with JobResult

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

the class LiveJobs method endJob.

private void endJob(JobData jobData, TerminationData terminationData, InternalTask task, TaskResultImpl taskResult, String errorMsg, JobStatus jobStatus) {
    JobId jobId = jobData.job.getId();
    jobs.remove(jobId);
    terminationData.addJobToTerminate(jobId);
    InternalJob job = jobData.job;
    SchedulerEvent event;
    if (job.getStatus() == JobStatus.PENDING) {
        event = SchedulerEvent.JOB_PENDING_TO_FINISHED;
    } else {
        event = SchedulerEvent.JOB_RUNNING_TO_FINISHED;
    }
    if (task != null) {
        jlogger.info(job.getId(), "ending request caused by task " + task.getId());
    } else {
        jlogger.info(job.getId(), "ending request");
    }
    for (Iterator<RunningTaskData> i = runningTasksData.values().iterator(); i.hasNext(); ) {
        RunningTaskData taskData = i.next();
        if (taskData.getTask().getJobId().equals(jobId)) {
            i.remove();
            // remove previous read progress
            taskData.getTask().setProgress(0);
            terminationData.addTaskData(job, taskData, TerminationData.TerminationStatus.ABORTED, taskResult);
        }
    }
    // if job has been killed
    if (jobStatus == JobStatus.KILLED) {
        Set<TaskId> tasksToUpdate = job.failed(null, jobStatus);
        dbManager.updateAfterJobKilled(job, tasksToUpdate);
        updateTasksInSchedulerState(job, tasksToUpdate);
    } else {
        // finished state (failed/canceled)
        if (jobStatus != JobStatus.FINISHED) {
            Set<TaskId> tasksToUpdate = job.failed(task.getId(), jobStatus);
            // store the exception into jobResult / To prevent from empty
            // task result (when job canceled), create one
            boolean noResult = (jobStatus == JobStatus.CANCELED && taskResult == null);
            if (jobStatus == JobStatus.FAILED || noResult) {
                taskResult = new TaskResultImpl(task.getId(), new Exception(errorMsg), new SimpleTaskLogs("", errorMsg), -1);
            }
            dbManager.updateAfterJobFailed(job, task, taskResult, tasksToUpdate);
            updateTasksInSchedulerState(job, tasksToUpdate);
        }
    }
    // update job and tasks events list and send it to front-end
    updateJobInSchedulerState(job, event);
    jlogger.info(job.getId(), "finished (" + jobStatus + ")");
}
Also used : SimpleTaskLogs(org.ow2.proactive.scheduler.common.task.SimpleTaskLogs) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) JobId(org.ow2.proactive.scheduler.common.job.JobId) TaskAbortedException(org.ow2.proactive.scheduler.common.exception.TaskAbortedException) TaskPreemptedException(org.ow2.proactive.scheduler.common.exception.TaskPreemptedException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) TaskRestartedException(org.ow2.proactive.scheduler.common.exception.TaskRestartedException) SchedulerEvent(org.ow2.proactive.scheduler.common.SchedulerEvent)

Example 5 with JobResult

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

the class SubmitJob method jobStateUpdatedEvent.

// get the running to finished event of my job
public void jobStateUpdatedEvent(NotificationData<JobInfo> notification) {
    if (myJobId.equals(notification.getData().getJobId())) {
        // test if it is my job
        System.out.print("Job " + myJobId + " terminated in ");
        // get the job result
        try {
            // 1. get the job result
            JobResult result = user.getJobResult(myJobId);
            System.out.println(result.getJobInfo().getFinishedTime() - result.getJobInfo().getStartTime() + "ms");
            // notify the test that it is terminated
            user.removeJob(notification.getData().getJobId());
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
}
Also used : JobResult(org.ow2.proactive.scheduler.common.job.JobResult)

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