Search in sources :

Example 1 with SortSpecifierContainer

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);
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) SortSpecifierContainer(org.ow2.proactive.scheduler.common.SortSpecifierContainer) TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) RestPage(org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) PageBoundaries(org.ow2.proactive.scheduler.common.util.PageBoundaries) TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Example 2 with SortSpecifierContainer

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);
}
Also used : SortSpecifierContainer(org.ow2.proactive.scheduler.common.SortSpecifierContainer) TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) ArrayList(java.util.ArrayList) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Test(org.junit.Test)

Example 3 with SortSpecifierContainer

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);
}
Also used : SortSpecifierContainer(org.ow2.proactive.scheduler.common.SortSpecifierContainer) TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Test(org.junit.Test)

Example 4 with SortSpecifierContainer

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());
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) SortSpecifierContainer(org.ow2.proactive.scheduler.common.SortSpecifierContainer) TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) ArrayList(java.util.ArrayList) TaskStateImpl(org.ow2.proactive.scheduler.rest.data.TaskStateImpl) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) Page(org.ow2.proactive.scheduler.common.Page) RestPage(org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage) TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Example 5 with SortSpecifierContainer

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);
}
Also used : SortSpecifierContainer(org.ow2.proactive.scheduler.common.SortSpecifierContainer) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Test(org.junit.Test)

Aggregations

SortSpecifierContainer (org.ow2.proactive.scheduler.common.SortSpecifierContainer)8 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)7 Test (org.junit.Test)6 TaskStateData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData)5 ArrayList (java.util.ArrayList)2 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)2 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)2 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)2 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)2 RestPage (org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage)2 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)2 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)2 Page (org.ow2.proactive.scheduler.common.Page)1 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)1 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)1 PageBoundaries (org.ow2.proactive.scheduler.common.util.PageBoundaries)1 TaskStateImpl (org.ow2.proactive.scheduler.rest.data.TaskStateImpl)1