Search in sources :

Example 16 with Page

use of org.ow2.proactive.scheduler.common.Page in project scheduling by ow2-proactive.

the class SchedulerFrontend method getTaskIds.

@Override
public Page<TaskId> getTaskIds(String taskTag, long from, long to, boolean mytasks, boolean running, boolean pending, boolean finished, int offset, int limit) throws NotConnectedException, PermissionException {
    RestPageParameters params = new RestPageParameters(frontendState, "getTaskIds", from, to, mytasks, running, pending, finished, offset, limit, taskTag, SortSpecifierContainer.EMPTY_CONTAINER);
    Page<TaskInfo> pTaskInfo;
    pTaskInfo = dbManager.getTasks(params.getFrom(), params.getTo(), params.getTag(), params.getOffset(), params.getLimit(), params.getUserName(), params.isPending(), params.isRunning(), params.isFinished());
    List<TaskId> lTaskId = new ArrayList<TaskId>(pTaskInfo.getList().size());
    for (TaskInfo taskInfo : pTaskInfo.getList()) {
        lTaskId.add(taskInfo.getTaskId());
    }
    return new Page<TaskId>(lTaskId, pTaskInfo.getSize());
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) ArrayList(java.util.ArrayList) Page(org.ow2.proactive.scheduler.common.Page)

Example 17 with Page

use of org.ow2.proactive.scheduler.common.Page in project scheduling by ow2-proactive.

the class SchedulerFrontend method getJobs.

/**
 * {@inheritDoc}
 */
@Override
@ImmediateService
public Page<JobInfo> getJobs(int offset, int limit, JobFilterCriteria filterCriteria, List<SortParameter<JobSortParameter>> sortParameters) throws NotConnectedException, PermissionException {
    UserIdentificationImpl ident = frontendState.checkPermission("getJobs", "You don't have permissions to load jobs");
    boolean myJobsOnly = filterCriteria.isMyJobsOnly();
    String user;
    if (myJobsOnly) {
        user = ident.getUsername();
    } else {
        user = null;
    }
    return dbManager.getJobs(offset, limit, user, filterCriteria.isPending(), filterCriteria.isRunning(), filterCriteria.isFinished(), sortParameters);
}
Also used : UserIdentificationImpl(org.ow2.proactive.scheduler.job.UserIdentificationImpl) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Example 18 with Page

use of org.ow2.proactive.scheduler.common.Page in project scheduling by ow2-proactive.

the class SchedulerStateRest method getTaskIdsByTag.

@Override
public RestPage<String> getTaskIdsByTag(String sessionId, String taskTag, long from, long to, boolean mytasks, boolean running, boolean pending, boolean finished, int offset, int limit) throws NotConnectedRestException, PermissionRestException {
    Scheduler s = checkAccess(sessionId, "tasks");
    PageBoundaries boundaries = Pagination.getTasksPageBoundaries(offset, limit, TASKS_PAGE_SIZE);
    Page<TaskId> page = null;
    try {
        page = s.getTaskIds(taskTag, from, to, mytasks, running, pending, finished, boundaries.getOffset(), boundaries.getLimit());
        List<TaskId> taskIds = page.getList();
        List<String> taskNames = new ArrayList<>(taskIds.size());
        for (TaskId taskId : taskIds) {
            taskNames.add(taskId.getReadableName());
        }
        return new RestPage<String>(taskNames, page.getSize());
    } catch (NotConnectedException e) {
        throw new NotConnectedRestException(e);
    } catch (PermissionException e) {
        throw new PermissionRestException(e);
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) ArrayList(java.util.ArrayList) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) RestPage(org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage) PageBoundaries(org.ow2.proactive.scheduler.common.util.PageBoundaries)

Example 19 with Page

use of org.ow2.proactive.scheduler.common.Page in project scheduling by ow2-proactive.

the class SchedulerStateRest method getJobTasksIdsByTagPaginated.

/**
 * Returns a list of the name of the tasks belonging to job
 * <code>jobId</code> (with pagination)
 *
 * @param sessionId
 *            a valid session id.
 * @param jobId
 *            the job id.
 * @param taskTag
 *            the tag used to filter the tasks.
 * @param offset
 *            the number of the first task to fetch
 * @param limit
 *            the number of the last task to fetch (non inclusive)
 * @return a list of task' states of the job <code>jobId</code> filtered by
 *         a given tag, for a given pagination.
 */
@Override
@GET
@GZIP
@Path("jobs/{jobid}/tasks/tag/{tasktag}/paginated")
@Produces("application/json")
public RestPage<String> getJobTasksIdsByTagPaginated(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("tasktag") String taskTag, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("-1") int limit) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException {
    if (limit == -1)
        limit = TASKS_PAGE_SIZE;
    try {
        Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks/" + taskTag + "/paginated");
        JobState jobState = s.getJobState(jobId);
        TaskStatesPage page = jobState.getTaskByTagPaginated(taskTag, offset, limit);
        List<TaskState> tasks = page.getTaskStates();
        List<String> tasksName = new ArrayList<>(tasks.size());
        for (TaskState ts : tasks) {
            tasksName.add(ts.getId().getReadableName());
        }
        return new RestPage<String>(tasksName, page.getSize());
    } catch (PermissionException e) {
        throw new PermissionRestException(e);
    } catch (UnknownJobException e) {
        throw new UnknownJobRestException(e);
    } catch (NotConnectedException e) {
        throw new NotConnectedRestException(e);
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) ArrayList(java.util.ArrayList) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) TaskStatesPage(org.ow2.proactive.scheduler.common.task.TaskStatesPage) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) RestPage(org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) GZIP(org.jboss.resteasy.annotations.GZIP)

Example 20 with Page

use of org.ow2.proactive.scheduler.common.Page in project scheduling by ow2-proactive.

the class SchedulerStateRest method getJobTasksIdsByTag.

/**
 * Returns a list of the name of the tasks belonging to job and filtered by
 * a given tag. <code>jobId</code>
 *
 * @param sessionId
 *            a valid session id
 * @param jobId
 *            jobid one wants to list the tasks' name
 * @param taskTag
 *            the tag used to filter the tasks.
 * @return the list of task ids with the total number of them
 */
@Override
@GET
@Path("jobs/{jobid}/tasks/tag/{tasktag}")
@Produces("application/json")
public RestPage<String> getJobTasksIdsByTag(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("tasktag") String taskTag) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException {
    try {
        Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks");
        JobState jobState = s.getJobState(jobId);
        TaskStatesPage page = jobState.getTaskByTagPaginated(taskTag, 0, TASKS_PAGE_SIZE);
        List<TaskState> tasks = page.getTaskStates();
        List<String> tasksName = new ArrayList<>(tasks.size());
        for (TaskState ts : tasks) {
            tasksName.add(ts.getId().getReadableName());
        }
        return new RestPage<String>(tasksName, page.getSize());
    } catch (PermissionException e) {
        throw new PermissionRestException(e);
    } catch (UnknownJobException e) {
        throw new UnknownJobRestException(e);
    } catch (NotConnectedException e) {
        throw new NotConnectedRestException(e);
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) ArrayList(java.util.ArrayList) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) TaskStatesPage(org.ow2.proactive.scheduler.common.task.TaskStatesPage) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) RestPage(org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

ArrayList (java.util.ArrayList)13 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)13 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)13 RestPage (org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage)13 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)13 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)13 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)12 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)11 TaskStateData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData)11 Test (org.junit.Test)10 JobState (org.ow2.proactive.scheduler.common.job.JobState)10 GET (javax.ws.rs.GET)9 Path (javax.ws.rs.Path)9 Produces (javax.ws.rs.Produces)9 SortSpecifierContainer (org.ow2.proactive.scheduler.common.SortSpecifierContainer)7 TaskStatesPage (org.ow2.proactive.scheduler.common.task.TaskStatesPage)7 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)7 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)6 GZIP (org.jboss.resteasy.annotations.GZIP)5 Page (org.ow2.proactive.scheduler.common.Page)4