use of org.ow2.proactive.scheduler.common.SortSpecifierContainer 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.SortSpecifierContainer in project scheduling by ow2-proactive.
the class SchedulerStateRestTaskCentricTest method testGetTaskStatesByTagSortByJobIdAsc.
@Test
public void testGetTaskStatesByTagSortByJobIdAsc() throws Throwable {
int nbTasksInPage = 6;
int nbTotalTasks = 6;
ArrayList<String> jobIds = new ArrayList<String>(Arrays.asList("1", "8", "4", "4", "6", "2"));
String tag = "TAG-TEST";
Page<TaskState> expectedPage = RestTestUtils.newMockedTaskStatePage(jobIds, 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(".jobData.id,ascending"));
RestTestUtils.assertTaskStates(expectedPage, page);
}
use of org.ow2.proactive.scheduler.common.SortSpecifierContainer in project scheduling by ow2-proactive.
the class SchedulerStateRestTaskCentricTest method testGetTaskStatesByTagSortByTaskIdDesc.
@Test
public void testGetTaskStatesByTagSortByTaskIdDesc() 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(".id.taskId,descending"));
RestTestUtils.assertTaskStates(expectedPage, page);
// let's check only the first two as the string comparison is not valid
// after that case : "JOB-1-TASK-1/50".compareTo("JOB-1-TASK-10/50")
List<TaskStateData> tasks = page.getList();
TaskStateData previousTask = tasks.get(0);
TaskStateData currentTask = tasks.get(1);
assertTrue(previousTask.getName().compareTo(currentTask.getName()) < 0);
}
use of org.ow2.proactive.scheduler.common.SortSpecifierContainer in project scheduling by ow2-proactive.
the class SchedulerClient method getTaskStates.
@Override
public Page<TaskState> getTaskStates(String taskTag, long from, long to, boolean mytasks, boolean running, boolean pending, boolean finished, int offset, int limit, SortSpecifierContainer sortParams) throws NotConnectedException, PermissionException {
RestPage<TaskStateData> page = null;
SortSpecifierContainer sortContainer = new SortSpecifierContainer(sortParams.toString());
try {
page = restApi().getTaskStates(sid, from, to, mytasks, running, pending, finished, offset, limit, sortContainer);
} catch (NotConnectedRestException e) {
throw new NotConnectedException(e);
} catch (PermissionRestException e) {
throw new PermissionException(e);
}
List<TaskState> lTaskStates = new ArrayList<TaskState>(page.getList().size());
for (TaskStateData taskStateData : page.getList()) {
lTaskStates.add(new TaskStateImpl(taskStateData));
}
return new Page<TaskState>(lTaskStates, page.getSize());
}
use of org.ow2.proactive.scheduler.common.SortSpecifierContainer in project scheduling by ow2-proactive.
the class SchedulerDBManagerTest method testUpdateTaskState.
@Test
public void testUpdateTaskState() throws Exception {
InternalJob job = createTestJob("test", "tag", 1);
service.submitJob(job);
InternalTask internalTask = job.getITasks().get(0);
internalTask.setStatus(TaskStatus.ABORTED);
dbManager.updateTaskState(internalTask);
Page<TaskState> tasks = dbManager.getTaskStates(0, 10, null, 0, 10, null, true, true, true, new SortSpecifierContainer());
assertThat(tasks.getSize()).isEqualTo(1);
TaskState taskState = tasks.getList().get(0);
assertThat(taskState.getStatus()).isEqualTo(TaskStatus.ABORTED);
}
Aggregations