use of org.ow2.proactive_grid_cloud_portal.common.Session in project scheduling by ow2-proactive.
the class SchedulerFrontendState method checkPermissionReturningListeningUser.
synchronized ListeningUser checkPermissionReturningListeningUser(String methodName, String permissionMsg) throws NotConnectedException, PermissionException {
UniqueID id = checkAccess();
ListeningUser ident = identifications.get(id);
// renew session for this user
renewUserSession(id, ident.getUser());
final String fullMethodName = SchedulerFrontend.class.getName() + "." + methodName;
final MethodCallPermission methodCallPermission = new MethodCallPermission(fullMethodName);
try {
ident.getUser().checkPermission(methodCallPermission, permissionMsg);
} catch (PermissionException ex) {
logger.warn(permissionMsg);
throw ex;
}
return ident;
}
use of org.ow2.proactive_grid_cloud_portal.common.Session in project scheduling by ow2-proactive.
the class SchedulerFrontendState method getCurrentUserData.
public UserData getCurrentUserData() throws NotConnectedException {
UniqueID id = checkAccess();
UserIdentificationImpl ident = identifications.get(id).getUser();
// renew session for this user
renewUserSession(id, ident);
UserData userData = new UserData();
userData.setUserName(ident.getUsername());
userData.setGroups(ident.getGroups());
return userData;
}
use of org.ow2.proactive_grid_cloud_portal.common.Session in project scheduling by ow2-proactive.
the class SchedulerDBManager method batchLoadJobs.
// Executed in a transaction from the caller
private void batchLoadJobs(Session session, boolean fullState, Query jobQuery, List<Long> ids, Collection<InternalJob> jobs) {
Map<Long, List<TaskData>> tasksMap = loadJobsTasks(session, ids);
jobQuery.setParameterList("ids", ids);
List<JobData> jobsList = (List<JobData>) jobQuery.list();
for (JobData jobData : jobsList) {
InternalJob internalJob = jobData.toInternalJob();
internalJob.setTasks(toInternalTasks(fullState, internalJob, tasksMap.get(jobData.getId())));
jobs.add(internalJob);
}
}
use of org.ow2.proactive_grid_cloud_portal.common.Session in project scheduling by ow2-proactive.
the class SchedulerDBManager method loadInternalJobs.
// Executed in a transaction from the caller
private List<InternalJob> loadInternalJobs(boolean fullState, Session session, List<Long> ids) {
Query jobQuery = session.getNamedQuery("loadInternalJobs");
List<InternalJob> result = new ArrayList<>(ids.size());
List<Long> batchLoadIds = new ArrayList<>(RECOVERY_LOAD_JOBS_BATCH_SIZE);
int batchIndex = 1;
for (Long id : ids) {
batchLoadIds.add(id);
if (batchLoadIds.size() == RECOVERY_LOAD_JOBS_BATCH_SIZE) {
logger.info("Loading internal Jobs, batch number " + batchIndex);
batchLoadJobs(session, fullState, jobQuery, batchLoadIds, result);
batchLoadIds.clear();
session.clear();
logger.info("Fetched " + (batchIndex * RECOVERY_LOAD_JOBS_BATCH_SIZE) + " internal Jobs");
batchIndex++;
}
}
if (!batchLoadIds.isEmpty()) {
batchLoadJobs(session, fullState, jobQuery, batchLoadIds, result);
}
logger.info(ALL_REQUIRED_JOBS_HAVE_BEEN_FETCHED);
return result;
}
use of org.ow2.proactive_grid_cloud_portal.common.Session in project scheduling by ow2-proactive.
the class SchedulerDBManager method saveSingleTaskDependencies.
private void saveSingleTaskDependencies(Session session, InternalTask task, TaskData taskRuntimeData) {
if (task.hasDependences()) {
List<DBTaskId> dependencies = new ArrayList<>(task.getDependences().size());
for (Task dependency : task.getDependences()) {
dependencies.add(taskId((InternalTask) dependency));
}
taskRuntimeData.setDependentTasks(dependencies);
} else {
taskRuntimeData.setDependentTasks(Collections.<DBTaskId>emptyList());
}
if (task.getIfBranch() != null) {
InternalTask ifBranch = task.getIfBranch();
taskRuntimeData.setIfBranch(getTaskReference(session, ifBranch));
} else {
taskRuntimeData.setIfBranch(null);
}
if (task.getJoinedBranches() != null && !task.getJoinedBranches().isEmpty()) {
List<DBTaskId> joinedBranches = new ArrayList<>(task.getJoinedBranches().size());
for (InternalTask joinedBranch : task.getJoinedBranches()) {
joinedBranches.add(taskId(joinedBranch));
}
taskRuntimeData.setJoinedBranches(joinedBranches);
} else {
taskRuntimeData.setJoinedBranches(Collections.<DBTaskId>emptyList());
}
}
Aggregations