use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData in project scheduling by ow2-proactive.
the class SchedulerStateRest method getJobTaskStatesPaginated.
/**
* Returns a list of taskState with pagination
*
* @param sessionId
* a valid session id
* @param jobId
* the job id
* @param offset
* the index of the first TaskState to return
* @param limit
* the index (non inclusive) of the last TaskState to return
* @return a list of task' states of the job <code>jobId</code>
*/
@Override
@GET
@GZIP
@Path("jobs/{jobid}/taskstates/paginated")
@Produces("application/json")
public RestPage<TaskStateData> getJobTaskStatesPaginated(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @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/paginated");
JobState jobState = s.getJobState(jobId);
TaskStatesPage page = jobState.getTasksPaginated(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 RestTestUtils method newMockedTaskStateData.
protected static TaskStateData newMockedTaskStateData(String jobIdStr, String tag, long cnt, int nbTasks) {
TaskStateData mockedTaskStateData = mock(TaskStateData.class);
TaskInfoData mockedTaskInfoData = mock(TaskInfoData.class);
TaskIdData mockedTaskIdData = mock(TaskIdData.class);
when(mockedTaskIdData.getReadableName()).thenReturn(generateReadableName(jobIdStr, cnt, nbTasks));
when(mockedTaskIdData.getId()).thenReturn(cnt);
when(mockedTaskInfoData.getTaskId()).thenReturn(mockedTaskIdData);
when(mockedTaskStateData.getTaskInfo()).thenReturn(mockedTaskInfoData);
when(mockedTaskStateData.getTag()).thenReturn(tag);
return mockedTaskStateData;
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData in project scheduling by ow2-proactive.
the class RestTestUtils method assertTaskStates.
protected static void assertTaskStates(Page<TaskState> expected, RestPage<TaskStateData> actual) {
assertEquals("Number of tasks in page is incorrect", expected.getList().size(), actual.getList().size());
assertEquals("Total number of tasks is incorrect", expected.getSize(), actual.getSize());
for (int i = 0; i < expected.getList().size(); i++) {
TaskState tExpected = expected.getList().get(i);
TaskStateData tActual = actual.getList().get(i);
assertEquals("readableName incorrect", tExpected.getId().getReadableName(), tActual.getName());
assertEquals("tag incorrect", tExpected.getTag(), tActual.getTag());
}
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData in project scheduling by ow2-proactive.
the class SchedulerStateRestTaskCentricTest method testGetTaskStatesByTagNoSorting.
@Test
public void testGetTaskStatesByTagNoSorting() throws Throwable {
int nbTasksInPage = 50;
int nbTotalTasks = 100;
String jobIdStr = "1";
String tag = "TAG-TEST";
Page<TaskState> expectedPage = RestTestUtils.newMockedTaskStatePage(jobIdStr, tag, nbTasksInPage, nbTotalTasks);
when(mockOfScheduler.getTaskStates(anyString(), anyLong(), anyLong(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyInt(), anyInt(), any(SortSpecifierContainer.class))).thenReturn(expectedPage);
RestPage<TaskStateData> page = restInterface.getTaskStatesByTag(sessionId, tag, 0, 0, false, true, true, true, 0, nbTasksInPage, new SortSpecifierContainer());
RestTestUtils.assertTaskStates(expectedPage, page);
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData in project scheduling by ow2-proactive.
the class JobStateImpl method getTasksByTag.
@Override
public List<TaskState> getTasksByTag(String tag) {
Map<String, TaskStateData> taskStateMap = jobStateData.getTasks();
List<TaskState> taskStateList = new ArrayList<>(taskStateMap.size());
for (TaskStateData ts : taskStateMap.values()) {
String taskTag = ts.getTag();
if (taskTag != null && taskTag.equals(tag)) {
taskStateList.add(DataUtility.taskState(ts));
}
}
return taskStateList;
}
Aggregations