use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData in project scheduling by ow2-proactive.
the class SchedulerStateRest method getJobTaskStatesByTagPaginated.
/**
* {@inheritDoc}
*/
@Override
@GET
@GZIP
@Path("jobs/{jobid}/taskstates/{tasktag}/paginated")
@Produces("application/json")
public RestPage<TaskStateData> getJobTaskStatesByTagPaginated(@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 + "/taskstates/" + taskTag + "/paginated");
JobState jobState = s.getJobState(jobId);
TaskStatesPage page = jobState.getTaskByTagPaginated(taskTag, offset, limit);
List<TaskStateData> tasks = map(page.getTaskStates(), TaskStateData.class);
return new RestPage<TaskStateData>(tasks, page.getSize());
} catch (PermissionException e) {
throw new PermissionRestException(e);
} catch (UnknownJobException e) {
throw new UnknownJobRestException(e);
} catch (NotConnectedException e) {
throw new NotConnectedRestException(e);
}
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData 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_grid_cloud_portal.scheduler.dto.TaskStateData in project scheduling by ow2-proactive.
the class SchedulerStateRest method getJobTaskStatesByTag.
/**
* Returns a list of taskState of the tasks filtered by a given tag.
*
* @param sessionId
* a valid session id
* @param jobId
* the job id
* @param taskTag
* the tag used to filter the tasks
* @return a list of task' states of the job <code>jobId</code> filtered by
* a given tag.
*/
@Override
@GET
@GZIP
@Path("jobs/{jobid}/taskstates/{tasktag}")
@Produces("application/json")
public RestPage<TaskStateData> getJobTaskStatesByTag(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("tasktag") String taskTag) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException {
try {
Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/taskstates/" + taskTag);
JobState jobState = s.getJobState(jobId);
TaskStatesPage page = jobState.getTaskByTagPaginated(taskTag, 0, TASKS_PAGE_SIZE);
List<TaskStateData> tasks = map(page.getTaskStates(), TaskStateData.class);
return new RestPage<TaskStateData>(tasks, page.getSize());
} catch (PermissionException e) {
throw new PermissionRestException(e);
} catch (UnknownJobException e) {
throw new UnknownJobRestException(e);
} catch (NotConnectedException e) {
throw new NotConnectedRestException(e);
}
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData in project scheduling by ow2-proactive.
the class SchedulerStateRestPaginationTest method testGetJobTaskStatesByTagPaginated.
@Test
public void testGetJobTaskStatesByTagPaginated() throws Throwable {
JobState job = newMockedJob(jobIdStr, nbTasks);
when(mockOfScheduler.getJobState(jobIdStr)).thenReturn(job);
List<TaskStateData> res = restInterface.getJobTaskStatesByTagPaginated(sessionId, jobIdStr, "", 0, nbTasks).getList();
assertEquals("Number of tasks is incorrect", nbTasks, res.size());
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData in project scheduling by ow2-proactive.
the class SchedulerStateRestPaginationTest method testGetJobTaskStatesPaginated.
@Test
public void testGetJobTaskStatesPaginated() throws Throwable {
JobState job = newMockedJob(jobIdStr, nbTasks);
when(mockOfScheduler.getJobState(jobIdStr)).thenReturn(job);
List<TaskStateData> res = restInterface.getJobTaskStatesPaginated(sessionId, jobIdStr, 0, nbTasks).getList();
assertEquals("Number of tasks is incorrect", nbTasks, res.size());
}
Aggregations