use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class DozerMappingTest method createJobState.
private JobState createJobState() {
return new ClientJobState(new JobState() {
@Override
public void update(TaskInfo taskInfo) {
}
@Override
public void update(JobInfo jobInfo) {
}
@Override
public JobInfo getJobInfo() {
return new JobInfoImpl();
}
@Override
public ArrayList<TaskState> getTasks() {
return new ArrayList<>(getHMTasks().values());
}
@Override
public Map<TaskId, TaskState> getHMTasks() {
TaskId taskId = TaskIdImpl.createTaskId(new JobIdImpl(42, "job"), "remoteVisuTask", 1);
TaskState value = new ClientTaskState(new TaskState() {
@Override
public void update(TaskInfo taskInfo) {
}
@Override
public List<TaskState> getDependences() {
return null;
}
@Override
public TaskInfo getTaskInfo() {
TaskInfoImpl taskInfo = new TaskInfoImpl();
taskInfo.setTaskId(TaskIdImpl.createTaskId(new JobIdImpl(42, "job"), "remoteVisuTask", 1));
return taskInfo;
}
@Override
public int getMaxNumberOfExecutionOnFailure() {
return 0;
}
@Override
public TaskState replicate() throws Exception {
return null;
}
@Override
public int getIterationIndex() {
return 0;
}
@Override
public int getReplicationIndex() {
return 0;
}
});
return Collections.singletonMap(taskId, value);
}
@Override
public String getOwner() {
return null;
}
@Override
public JobType getType() {
return null;
}
});
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class SchedulerStateRestJobLogsTest method job_full_logs_sorted.
@Test
public void job_full_logs_sorted() throws Exception {
InternalTaskFlowJob jobState = new InternalTaskFlowJob();
addTask(jobState, 1, 10);
addTask(jobState, 10, 2);
addTask(jobState, 3, 3);
File logFolder = tempFolder.newFolder("123");
File logFile = new File(logFolder, "TaskLogs-123-10.log");
FileUtils.write(logFile, "10");
logFile = new File(logFolder, "TaskLogs-123-2.log");
FileUtils.write(logFile, "2");
logFile = new File(logFolder, "TaskLogs-123-3.log");
FileUtils.write(logFile, "3");
when(mockScheduler.getJobState("123")).thenReturn(jobState);
when(mockScheduler.getUserSpaceURIs()).thenReturn(Collections.singletonList(logFolder.getParent()));
when(mockScheduler.getGlobalSpaceURIs()).thenReturn(Collections.singletonList(logFolder.getParent()));
InputStream fullLogs = restScheduler.jobFullLogs(validSessionId, "123", validSessionId);
assertEquals("1032", IOUtils.toString(fullLogs));
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class SchedulerStateRestJobLogsTest method job_full_logs_finished.
@Test
public void job_full_logs_finished() throws Exception {
InternalTaskFlowJob jobState = new InternalTaskFlowJob();
InternalScriptTask task = new InternalScriptTask(jobState);
task.setPreciousLogs(true);
jobState.addTask(task);
File logFolder = tempFolder.newFolder("0");
File logFile = new File(logFolder, "TaskLogs-0-0.log");
FileUtils.write(logFile, "logs", Charset.defaultCharset());
when(mockScheduler.getJobState("0")).thenReturn(jobState);
when(mockScheduler.getUserSpaceURIs()).thenReturn(Collections.singletonList(logFolder.getParent()));
when(mockScheduler.getGlobalSpaceURIs()).thenReturn(Collections.singletonList(logFolder.getParent()));
InputStream fullLogs = restScheduler.jobFullLogs(validSessionId, "0", validSessionId);
assertEquals("logs", IOUtils.toString(fullLogs, Charset.defaultCharset()));
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class SchedulerStateRestJobLogsTest method addTask.
private static void addTask(InternalTaskFlowJob jobState, long finishedTime, long id) {
InternalScriptTask task = new InternalScriptTask(jobState);
task.setPreciousLogs(true);
task.setFinishedTime(finishedTime);
jobState.addTask(task);
task.setId(TaskIdImpl.createTaskId(new JobIdImpl(123, "job"), "task", id));
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class SchedulerStateRestPaginationTest method testGetJobTasksIdsPaginated.
@Test
public void testGetJobTasksIdsPaginated() throws Throwable {
JobState job = newMockedJob(jobIdStr, nbTasks);
when(mockOfScheduler.getJobState(jobIdStr)).thenReturn(job);
RestPage<String> page = restInterface.getTasksNamesPaginated(sessionId, jobIdStr, 0, nbTasks);
assertTasks(nbTasks, jobIdStr, page);
}
Aggregations