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;
}
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);
}
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);
}
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 + ")");
}
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();
}
}
}
Aggregations