Search in sources :

Example 11 with TaskResultData

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

the class SchedulerClient method getTaskResult.

@Override
public TaskResult getTaskResult(String jobId, String taskName) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException {
    TaskResultImpl taskResult = null;
    try {
        TaskResultData taskResultData = restApi().taskResult(sid, jobId, taskName);
        taskResult = (TaskResultImpl) toTaskResult(JobIdImpl.makeJobId(jobId), taskResultData);
        if (taskResult.value() == null) {
            Serializable value = restApi().valueOfTaskResult(sid, jobId, taskName);
            if (value != null) {
                taskResult.setValue(value);
            }
        }
    } catch (Throwable t) {
        throwUJEOrNCEOrPEOrUTE(exception(t));
    }
    return taskResult;
}
Also used : Serializable(java.io.Serializable) TaskResultImpl(org.ow2.proactive.scheduler.rest.data.TaskResultImpl) TaskResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData)

Example 12 with TaskResultData

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

the class GetJobResultCommand method execute.

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
    try {
        if (this.tag == null) {
            JobResultData results = scheduler.jobResult(currentContext.getSessionId(), jobId);
            resultStack(currentContext).push(results);
            if (!currentContext.isForced()) {
                writeLine(currentContext, "%s", StringUtility.jobResultAsString(job(), results));
            }
        } else {
            List<TaskResultData> results = scheduler.taskResultByTag(currentContext.getSessionId(), jobId, tag);
            resultStack(currentContext).push(results);
            if (!currentContext.isForced()) {
                writeLine(currentContext, "%s", StringUtility.taskResultsAsString(results));
            }
        }
    } catch (Exception e) {
        handleError(String.format("An error occurred while retrieving %s result:", job()), e, currentContext);
    }
}
Also used : JobResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobResultData) TaskResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData) SchedulerRestInterface(org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface) CLIException(org.ow2.proactive_grid_cloud_portal.cli.CLIException)

Example 13 with TaskResultData

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

the class StringUtility method taskResultsAsString.

public static String taskResultsAsString(List<TaskResultData> results) throws IOException, ClassNotFoundException {
    StringBuffer buf = new StringBuffer();
    for (TaskResultData currentResult : results) {
        buf.append(taskResultAsString(currentResult.getId().getReadableName(), currentResult));
        buf.append("\n");
    }
    return buf.toString();
}
Also used : TaskResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData)

Example 14 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) List(java.util.List) ArrayList(java.util.ArrayList)

Example 15 with TaskResultData

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData 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)

Aggregations

TaskResultData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData)12 ArrayList (java.util.ArrayList)4 JobResultData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobResultData)4 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)3 SchedulerRestInterface (org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface)3 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)3 File (java.io.File)2 List (java.util.List)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 GZIP (org.jboss.resteasy.annotations.GZIP)2 Test (org.junit.Test)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 DBTaskId (org.ow2.proactive.scheduler.core.db.TaskData.DBTaskId)2 JobResultImpl (org.ow2.proactive.scheduler.job.JobResultImpl)2 CLIException (org.ow2.proactive_grid_cloud_portal.cli.CLIException)2