use of org.ow2.proactive.scheduler.common.util.TaskLoggerRelativePathGenerator 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.util.TaskLoggerRelativePathGenerator 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.util.TaskLoggerRelativePathGenerator in project scheduling by ow2-proactive.
the class TaskLoggerTest method createFileAppenderTest.
@Test
public void createFileAppenderTest() throws Exception {
JobId jobid = new JobIdImpl(1000, "job");
TaskId taskId = TaskIdImpl.createTaskId(jobid, "task", 42L);
taskLogger = new TaskLogger(taskId, "myhost");
File logFolder = tempFolder.newFolder("logfolder");
File logAppender = taskLogger.createFileAppender(logFolder);
System.out.println(logAppender.getParentFile().getName());
assertEquals(logAppender.getParentFile().getName(), jobid.value());
assertEquals(logAppender.getName(), new TaskLoggerRelativePathGenerator(taskId).getFileName());
}
use of org.ow2.proactive.scheduler.common.util.TaskLoggerRelativePathGenerator in project scheduling by ow2-proactive.
the class TaskLauncher method copyTaskLogsToUserSpace.
private void copyTaskLogsToUserSpace(File taskLogFile, TaskDataspaces dataspaces) {
if (initializer.isPreciousLogs()) {
try {
FileSelector taskLogFileSelector = new FileSelector(taskLogFile.getName());
taskLogFileSelector.setIncludes(new TaskLoggerRelativePathGenerator(taskId).getRelativePath());
dataspaces.copyScratchDataToOutput(Collections.singletonList(new OutputSelector(taskLogFileSelector, OutputAccessMode.TransferToUserSpace)));
} catch (FileSystemException e) {
logger.warn("Cannot copy logs of task to user data spaces", e);
}
}
}
use of org.ow2.proactive.scheduler.common.util.TaskLoggerRelativePathGenerator 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;
}
Aggregations