use of org.ow2.proactive.scheduler.common.util.PageBoundaries in project scheduling by ow2-proactive.
the class SchedulerStateRest method getTaskStatesByTag.
@Override
public RestPage<TaskStateData> getTaskStatesByTag(String sessionId, String taskTag, long from, long to, boolean mytasks, boolean running, boolean pending, boolean finished, int offset, int limit, SortSpecifierContainer sortParams) throws NotConnectedRestException, PermissionRestException {
Scheduler s = checkAccess(sessionId, "tasks/tag/" + taskTag);
PageBoundaries boundaries = Pagination.getTasksPageBoundaries(offset, limit, TASKS_PAGE_SIZE);
Page<TaskState> page = null;
// sortParams will be null
if (sortParams == null) {
sortParams = new SortSpecifierContainer();
}
try {
page = s.getTaskStates(taskTag, from, to, mytasks, running, pending, finished, boundaries.getOffset(), boundaries.getLimit(), sortParams);
List<TaskStateData> tasks = map(page.getList(), TaskStateData.class);
return new RestPage<TaskStateData>(tasks, page.getSize());
} catch (NotConnectedException e) {
throw new NotConnectedRestException(e);
} catch (PermissionException e) {
throw new PermissionRestException(e);
}
}
use of org.ow2.proactive.scheduler.common.util.PageBoundaries in project scheduling by ow2-proactive.
the class JobState method getTaskStatesPage.
private TaskStatesPage getTaskStatesPage(int offset, int limit, List<TaskState> tasks) {
PageBoundaries pageBoundaries = Pagination.getTasksPageBoundaries(offset, limit, PASchedulerProperties.TASKS_PAGE_SIZE.getValueAsInt());
int nbTasks = tasks.size();
int indexLastItemToReturn = pageBoundaries.getOffset() + pageBoundaries.getLimit();
offset = pageBoundaries.getOffset();
if (offset >= nbTasks) {
offset = 0;
}
if (indexLastItemToReturn >= nbTasks) {
indexLastItemToReturn = nbTasks;
}
return new TaskStatesPage(tasks.subList(offset, indexLastItemToReturn), nbTasks);
}
use of org.ow2.proactive.scheduler.common.util.PageBoundaries 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);
}
}
Aggregations