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