use of org.ow2.proactive.scheduler.common.task.TaskId in project scheduling by ow2-proactive.
the class TaskLogger method createFileAppender.
public File createFileAppender(File pathToFolder) throws IOException {
if (taskLogAppender.getAppender(FILE_APPENDER_NAME) != null) {
throw new IllegalStateException("Only one file appender can be created");
}
File logFile = new File(pathToFolder, new TaskLoggerRelativePathGenerator(taskId).getRelativePath());
logFile.getParentFile().mkdirs();
FileUtils.touch(logFile);
logFile.setWritable(true, false);
FileAppender fap = new FileAppender(Log4JTaskLogs.getTaskLogLayout(), logFile.getAbsolutePath(), false);
fap.setName(FILE_APPENDER_NAME);
taskLogAppender.addAppender(fap);
return logFile;
}
use of org.ow2.proactive.scheduler.common.task.TaskId in project scheduling by ow2-proactive.
the class SchedulerStateRest method getTaskIdsByTag.
@Override
public RestPage<String> getTaskIdsByTag(String sessionId, String taskTag, long from, long to, boolean mytasks, boolean running, boolean pending, boolean finished, int offset, int limit) throws NotConnectedRestException, PermissionRestException {
Scheduler s = checkAccess(sessionId, "tasks");
PageBoundaries boundaries = Pagination.getTasksPageBoundaries(offset, limit, TASKS_PAGE_SIZE);
Page<TaskId> page = null;
try {
page = s.getTaskIds(taskTag, from, to, mytasks, running, pending, finished, boundaries.getOffset(), boundaries.getLimit());
List<TaskId> taskIds = page.getList();
List<String> taskNames = new ArrayList<>(taskIds.size());
for (TaskId taskId : taskIds) {
taskNames.add(taskId.getReadableName());
}
return new RestPage<String>(taskNames, page.getSize());
} catch (NotConnectedException e) {
throw new NotConnectedRestException(e);
} catch (PermissionException e) {
throw new PermissionRestException(e);
}
}
use of org.ow2.proactive.scheduler.common.task.TaskId in project scheduling by ow2-proactive.
the class RestTestUtils method newTaskState.
protected static TaskState newTaskState(String jobIdStr, String tag, long cnt, int nbTasks) {
TaskId mockedTaskId = mock(TaskId.class);
TaskState mockedState = mock(TaskState.class);
when(mockedTaskId.getReadableName()).thenReturn(generateReadableName(jobIdStr, cnt, nbTasks));
when(mockedTaskId.longValue()).thenReturn(cnt);
when(mockedState.getTag()).thenReturn(tag);
when(mockedState.getId()).thenReturn(mockedTaskId);
when(mockedState.getName()).thenReturn(generateReadableName(jobIdStr, cnt, nbTasks));
return mockedState;
}
use of org.ow2.proactive.scheduler.common.task.TaskId in project scheduling by ow2-proactive.
the class RestTestUtils method newMockedTaskIdPage.
protected static Page<TaskId> newMockedTaskIdPage(String jobIdStr, int nbTasks, String tag) {
List<TaskId> lTaskId = new ArrayList<TaskId>(nbTasks);
for (int i = 0; i < nbTasks; i++) {
TaskId mockedTaskId = mock(TaskId.class);
when(mockedTaskId.getReadableName()).thenReturn(generateReadableName(jobIdStr, i, nbTasks));
when(mockedTaskId.getTag()).thenReturn(tag);
lTaskId.add(mockedTaskId);
}
return new Page<TaskId>(lTaskId, nbTasks);
}
use of org.ow2.proactive.scheduler.common.task.TaskId 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;
}
Aggregations