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);
}
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));
}
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);
}
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);
}
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;
}
Aggregations