Search in sources :

Example 16 with TaskResultData

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData in project scheduling by ow2-proactive.

the class SchedulerDBManager method loadTaskResult.

@SuppressWarnings("unchecked")
private TaskResult loadTaskResult(Session session, TaskId taskId, int resultIndex) {
    DBTaskId dbTaskId = taskId(taskId);
    TaskData task = session.load(TaskData.class, dbTaskId);
    Query query = session.getNamedQuery("loadTasksResultByTask").setParameter("task", task);
    query.setMaxResults(1);
    query.setFirstResult(resultIndex);
    List<TaskResultData> results = (List<TaskResultData>) query.list();
    if (results.isEmpty()) {
        return null;
    } else {
        return results.get(0).toTaskResult(taskId);
    }
}
Also used : DBTaskId(org.ow2.proactive.scheduler.core.db.TaskData.DBTaskId) Query(org.hibernate.Query)

Example 17 with TaskResultData

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData in project scheduling by ow2-proactive.

the class SchedulerStateRestJobTaskResultTest method testValueOfJobResult.

@Test
public void testValueOfJobResult() throws Throwable {
    TaskResultImpl taskResult = new TaskResultImpl(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("42"), "mytask", 1), ObjectToByteConverter.ObjectStream.convert("hello"), null, null, false);
    JobResultImpl jobResultWithValue = new JobResultImpl();
    JobInfoImpl jobInfo = new JobInfoImpl();
    jobInfo.setJobId(new JobIdImpl(12, "myjob"));
    jobResultWithValue.setJobInfo(jobInfo);
    jobResultWithValue.addTaskResult("mytask", taskResult, false);
    when(mockOfScheduler.getJobResult("42")).thenReturn(jobResultWithValue);
    JobResultData jobResultData = restInterface.jobResult(sessionId, "42");
    TaskResultData taskResultData = jobResultData.getAllResults().get("mytask");
    assertNotNull(taskResultData);
    assertNotNull(taskResultData.getValue());
    assertEquals("hello", taskResultData.getValue());
    Map<String, String> jobResult = restInterface.jobResultValue(sessionId, "42");
    String result = jobResult.get("mytask");
    assertNotNull(result);
    assertEquals("hello", result);
}
Also used : JobResultImpl(org.ow2.proactive.scheduler.job.JobResultImpl) JobResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobResultData) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) TaskResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl) Test(org.junit.Test)

Aggregations

TaskResultData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData)11 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)4 DBTaskId (org.ow2.proactive.scheduler.core.db.TaskData.DBTaskId)4 JobResultData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobResultData)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)3 SchedulerRestInterface (org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface)3 Serializable (java.io.Serializable)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Query (org.hibernate.Query)2 GZIP (org.jboss.resteasy.annotations.GZIP)2 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)2 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)2 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)2 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)2 JobResultImpl (org.ow2.proactive.scheduler.job.JobResultImpl)2 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)2