use of org.ow2.proactive.scheduler.common.task.TaskLogs 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.task.TaskLogs 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.task.TaskLogs in project scheduling by ow2-proactive.
the class TaskLoggerRelativePathGeneratorTest method testGetRelativePath.
@Test
public void testGetRelativePath() {
TaskId taskId = TaskIdImpl.createTaskId(new JobIdImpl(1000, "job"), "task", 42L);
assertThat(new TaskLoggerRelativePathGenerator(taskId).getRelativePath(), is("1000/TaskLogs-1000-42.log"));
}
use of org.ow2.proactive.scheduler.common.task.TaskLogs in project scheduling by ow2-proactive.
the class TaskLoggerRelativePathGeneratorTest method testGetFileName.
@Test
public void testGetFileName() {
TaskId taskId = TaskIdImpl.createTaskId(new JobIdImpl(1000, "job"), "task", 42L);
assertThat(new TaskLoggerRelativePathGenerator(taskId).getFileName(), is("TaskLogs-1000-42.log"));
}
use of org.ow2.proactive.scheduler.common.task.TaskLogs in project scheduling by ow2-proactive.
the class EnabledListenJobLogsSupport method flushTaskLogs.
private void flushTaskLogs(TaskResult tr, Appender a, JobId jobId) {
// if taskResult is not awaited, task is terminated
TaskLogs logs = tr.getOutput();
if (logs instanceof Log4JTaskLogs) {
for (LoggingEvent le : ((Log4JTaskLogs) logs).getAllEvents()) {
// write into socket appender directly to avoid double lines on other listeners
a.doAppend(le);
}
} else {
a.doAppend(createLoggingEvent(jobId, logs.getStdoutLogs(false), Level.INFO));
a.doAppend(createLoggingEvent(jobId, logs.getStderrLogs(false), Level.DEBUG));
}
}
Aggregations