Search in sources :

Example 6 with TaskState

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

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

the class NoVncSecuredTargetResolverTest method mockSchedulerState.

@Before
public void mockSchedulerState() throws NotConnectedException, UnknownJobException, PermissionException {
    JobState jobState = mock(JobState.class);
    when(schedulerMock.getJobState("42")).thenReturn(jobState);
    TaskState taskState = mock(TaskState.class);
    when(taskState.getName()).thenReturn("remoteVisuTask");
    TaskId taskId = mock(TaskId.class);
    when(taskId.value()).thenReturn("1");
    when(taskState.getId()).thenReturn(taskId);
    when(jobState.getHMTasks()).thenReturn(Collections.singletonMap(taskId, taskState));
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Before(org.junit.Before)

Example 8 with TaskState

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

the class JobState method getTaskStatesPage.

private TaskStatesPage getTaskStatesPage(int offset, int limit, List<TaskState> tasks) {
    PageBoundaries pageBoundaries = Pagination.getTasksPageBoundaries(offset, limit, PASchedulerProperties.TASKS_PAGE_SIZE.getValueAsInt());
    int nbTasks = tasks.size();
    int indexLastItemToReturn = pageBoundaries.getOffset() + pageBoundaries.getLimit();
    offset = pageBoundaries.getOffset();
    if (offset >= nbTasks) {
        offset = 0;
    }
    if (indexLastItemToReturn >= nbTasks) {
        indexLastItemToReturn = nbTasks;
    }
    return new TaskStatesPage(tasks.subList(offset, indexLastItemToReturn), nbTasks);
}
Also used : PageBoundaries(org.ow2.proactive.scheduler.common.util.PageBoundaries) TaskStatesPage(org.ow2.proactive.scheduler.common.task.TaskStatesPage)

Example 9 with TaskState

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

the class JobState method getTags.

/**
 * To get the list of available tags in a job.
 * @return the list of tags.
 */
public List<String> getTags() {
    Set<String> result = new HashSet<>();
    String tag = null;
    for (TaskState task : this.getTasks()) {
        tag = task.getTag();
        if (tag != null) {
            result.add(task.getTag());
        }
    }
    return new ArrayList<>(result);
}
Also used : TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Example 10 with TaskState

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

the class SchedulerClient method isTaskFinished.

@Override
public boolean isTaskFinished(String jobId, String taskName) throws UnknownJobException, NotConnectedException, PermissionException, UnknownTaskException {
    boolean finished = false;
    try {
        TaskStateData taskStateData = restApi().jobTask(sid, jobId, taskName);
        TaskState taskState = taskState(taskStateData);
        finished = !taskState.getStatus().isTaskAlive();
    } catch (Exception e) {
        throwUJEOrNCEOrPEOrUTE(e);
    }
    return finished;
}
Also used : TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) KeyException(java.security.KeyException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) SchedulerRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.SchedulerRestException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) IOException(java.io.IOException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) TimeoutException(java.util.concurrent.TimeoutException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)

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