Search in sources :

Example 6 with TaskStateData

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData 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 7 with TaskStateData

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData in project scheduling by ow2-proactive.

the class SchedulerStateRestTaskCentricTest method testGetJobTaskStatesPaginated.

@Test
public void testGetJobTaskStatesPaginated() throws Throwable {
    int nbTasks = 50;
    String jobIdStr = "1";
    JobState job = RestTestUtils.newMockedJob(jobIdStr, null, 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());
}
Also used : TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) JobState(org.ow2.proactive.scheduler.common.job.JobState) Test(org.junit.Test)

Example 8 with TaskStateData

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData 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 9 with TaskStateData

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData in project scheduling by ow2-proactive.

the class ListTaskStatesCommandTest method testCommandJobIdUnknownTag.

@Test
public void testCommandJobIdUnknownTag() throws Exception {
    when(restApi.getJobTaskStatesByTag(anyString(), eq("1"), eq("unknownTag"))).thenReturn(new RestPage(new ArrayList<TaskStateData>(), 0));
    executeTest(jobId, unknownTag);
    String out = capturedOutput.toString();
    System.out.println(out);
    assertThat(out, not(containsString("task")));
    assertThat(out, containsString("ID     NAME"));
}
Also used : RestPage(org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 10 with TaskStateData

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData in project scheduling by ow2-proactive.

the class SchedulerClient method getTaskIds.

@Override
public Page<TaskId> getTaskIds(String taskTag, long from, long to, boolean mytasks, boolean running, boolean pending, boolean finished, int offset, int limit) throws NotConnectedException, PermissionException {
    RestPage<TaskStateData> page = null;
    try {
        page = restApi().getTaskStates(sid, from, to, mytasks, running, pending, finished, offset, limit, null);
    } catch (NotConnectedRestException e) {
        throw new NotConnectedException(e);
    } catch (PermissionRestException e) {
        throw new PermissionException(e);
    }
    List<TaskId> lTaskIds = new ArrayList<TaskId>(page.getList().size());
    for (TaskStateData taskStateData : page.getList()) {
        TaskInfoData taskInfo = taskStateData.getTaskInfo();
        TaskIdData taskIdData = taskInfo.getTaskId();
        JobId jobId = new JobIdImpl(taskInfo.getJobId().getId(), taskInfo.getJobId().getReadableName());
        TaskId taskId = TaskIdImpl.createTaskId(jobId, taskIdData.getReadableName(), taskIdData.getId());
        lTaskIds.add(taskId);
    }
    return new Page<TaskId>(lTaskIds, page.getSize());
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) TaskInfoData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskInfoData) ArrayList(java.util.ArrayList) 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) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) TaskIdData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Aggregations

TaskStateData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData)22 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)11 ArrayList (java.util.ArrayList)8 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)8 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)8 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)8 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)8 Test (org.junit.Test)7 JobState (org.ow2.proactive.scheduler.common.job.JobState)7 RestPage (org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage)7 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)6 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)5 SortSpecifierContainer (org.ow2.proactive.scheduler.common.SortSpecifierContainer)5 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)5 GET (javax.ws.rs.GET)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 TaskIdData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData)4 GZIP (org.jboss.resteasy.annotations.GZIP)3 TaskStatesPage (org.ow2.proactive.scheduler.common.task.TaskStatesPage)3