Search in sources :

Example 41 with Session

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;
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) UniqueID(org.objectweb.proactive.core.UniqueID) MethodCallPermission(org.ow2.proactive.permissions.MethodCallPermission)

Example 42 with Session

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;
}
Also used : UniqueID(org.objectweb.proactive.core.UniqueID) UserData(org.ow2.proactive.authentication.UserData) UserIdentificationImpl(org.ow2.proactive.scheduler.job.UserIdentificationImpl)

Example 43 with Session

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);
    }
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) List(java.util.List) ArrayList(java.util.ArrayList)

Example 44 with Session

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;
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) Query(org.hibernate.Query) ArrayList(java.util.ArrayList)

Example 45 with Session

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());
    }
}
Also used : DBTaskId(org.ow2.proactive.scheduler.core.db.TaskData.DBTaskId) Task(org.ow2.proactive.scheduler.common.task.Task) InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InternalForkedScriptTask(org.ow2.proactive.scheduler.task.internal.InternalForkedScriptTask) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) ArrayList(java.util.ArrayList)

Aggregations

Path (javax.ws.rs.Path)49 Produces (javax.ws.rs.Produces)47 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)39 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)37 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)36 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)34 GET (javax.ws.rs.GET)32 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)29 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)25 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)24 GZIP (org.jboss.resteasy.annotations.GZIP)23 Session (org.ow2.proactive_grid_cloud_portal.common.Session)18 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)17 ArrayList (java.util.ArrayList)16 ResteasyClient (org.jboss.resteasy.client.jaxrs.ResteasyClient)15 ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)15 ResteasyWebTarget (org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)15 JobState (org.ow2.proactive.scheduler.common.job.JobState)12 IOException (java.io.IOException)11 POST (javax.ws.rs.POST)11