use of org.ow2.proactive_grid_cloud_portal.common.Session 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.common.Session in project scheduling by ow2-proactive.
the class SchedulerDBManager method saveTaskDependencies.
private void saveTaskDependencies(Session session, List<InternalTask> tasks, List<TaskData> taskRuntimeDataList) {
for (int i = 0; i < tasks.size(); i++) {
InternalTask task = tasks.get(i);
TaskData taskRuntimeData = taskRuntimeDataList.get(i);
saveSingleTaskDependencies(session, task, taskRuntimeData);
}
}
use of org.ow2.proactive_grid_cloud_portal.common.Session 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;
}
use of org.ow2.proactive_grid_cloud_portal.common.Session in project scheduling by ow2-proactive.
the class SchedulerDBManager method updateTaskData.
private int updateTaskData(final TaskState task, Session session) {
Query taskUpdateQuery = session.getNamedQuery("updateTaskData");
TaskInfo taskInfo = task.getTaskInfo();
return taskUpdateQuery.setParameter("taskStatus", taskInfo.getStatus()).setParameter("numberOfExecutionLeft", taskInfo.getNumberOfExecutionLeft()).setParameter("numberOfExecutionOnFailureLeft", taskInfo.getNumberOfExecutionOnFailureLeft()).setParameter("inErrorTime", taskInfo.getInErrorTime()).setParameter("taskId", taskId(task.getId())).executeUpdate();
}
use of org.ow2.proactive_grid_cloud_portal.common.Session in project scheduling by ow2-proactive.
the class TaskDBUtils method getTotalNumberOfTasks.
public static SessionWork<Integer> getTotalNumberOfTasks(final DBTaskDataParameters params) {
return new SessionWork<Integer>() {
@Override
public Integer doInTransaction(Session session) {
Set<TaskStatus> taskStatuses = params.getStatuses();
if (taskStatuses.isEmpty()) {
return 0;
}
boolean hasUser = params.hasUser();
boolean hasTag = params.hasTag();
boolean hasDateFrom = params.hasDateFrom();
boolean hasDateTo = params.hasDateTo();
String queryPrefix = "select count(*) from TaskData T where ";
Query query = getQuery(session, params, taskStatuses, hasUser, hasTag, hasDateFrom, hasDateTo, SortSpecifierContainer.EMPTY_CONTAINER, queryPrefix);
Long count = (Long) query.uniqueResult();
return count.intValue();
}
};
}
Aggregations