Search in sources :

Example 41 with TaskState

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

Example 42 with TaskState

use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.

the class SchedulerStateRestPaginationTest method newMockedJob.

private JobState newMockedJob(final String jobIdStr, final int nbTasks) {
    JobState mockedJob = mock(JobState.class);
    JobId mockedJobId = mock(JobId.class);
    List<TaskState> dumbList = new ArrayList<TaskState>(nbTasks);
    for (int i = 0; i < nbTasks; i++) {
        TaskState mockedTask = mock(TaskState.class);
        TaskId mockedTaskId = mock(TaskId.class);
        when(mockedTaskId.getReadableName()).thenReturn(generateReadableName(jobIdStr, i, nbTasks));
        when(mockedTask.getId()).thenReturn(mockedTaskId);
        dumbList.add(mockedTask);
    }
    when(mockedJobId.value()).thenReturn(jobIdStr);
    when(mockedJob.getId()).thenReturn(mockedJobId);
    when(mockedJob.getTasksPaginated(0, 50)).thenReturn(new TaskStatesPage(dumbList, nbTasks));
    when(mockedJob.getTaskByTagPaginated("", 0, 50)).thenReturn(new TaskStatesPage(dumbList, nbTasks));
    return mockedJob;
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) ArrayList(java.util.ArrayList) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskStatesPage(org.ow2.proactive.scheduler.common.task.TaskStatesPage) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 43 with TaskState

use of org.ow2.proactive.scheduler.common.task.TaskState 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);
}
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 44 with TaskState

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

Example 45 with TaskState

use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.

the class JobStateImpl method getTasks.

@Override
public List<TaskState> getTasks() {
    Map<String, TaskStateData> taskStateMap = jobStateData.getTasks();
    List<TaskState> taskStateList = new ArrayList<>(taskStateMap.size());
    for (TaskStateData ts : taskStateMap.values()) {
        taskStateList.add(DataUtility.taskState(ts));
    }
    return taskStateList;
}
Also used : TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) ArrayList(java.util.ArrayList) TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Aggregations

TaskState (org.ow2.proactive.scheduler.common.task.TaskState)54 JobState (org.ow2.proactive.scheduler.common.job.JobState)23 ArrayList (java.util.ArrayList)15 Test (org.junit.Test)14 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)13 TaskStateData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData)13 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)12 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)11 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)11 JobId (org.ow2.proactive.scheduler.common.job.JobId)10 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)10 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)10 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)9 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)9 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)8 TaskStatesPage (org.ow2.proactive.scheduler.common.task.TaskStatesPage)8 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)8 GET (javax.ws.rs.GET)7 Path (javax.ws.rs.Path)7 Produces (javax.ws.rs.Produces)7