use of org.ow2.proactive.scheduler.util.TaskLogger in project scheduling by ow2-proactive.
the class TaskLauncher method initActivity.
@Override
public void initActivity(Body body) {
this.taskId = initializer.getTaskId();
this.taskLogger = new TaskLogger(taskId, getHostname());
this.progressFileReader = new ProgressFileReader();
this.taskKiller = new TaskKiller(Thread.currentThread(), new CleanupTimeoutGetter());
nodeShutdownHook = new Thread(new Runnable() {
@Override
public void run() {
kill();
}
});
}
use of org.ow2.proactive.scheduler.util.TaskLogger in project scheduling by ow2-proactive.
the class TaskLoggerTest method getStoredLogs.
@Test
public void getStoredLogs() throws Exception {
taskLogger = new TaskLogger(TaskIdImpl.createTaskId(new JobIdImpl(1000, "job"), "task", 42L), "myhost");
final StringWriter stringAppender = new StringWriter();
AppenderProvider stringAppenderProvider = new AppenderProvider() {
@Override
public Appender getAppender() throws LogForwardingException {
return new WriterAppender(new PatternLayout("%m%n"), stringAppender);
}
};
taskLogger.getStoredLogs(stringAppenderProvider);
assertEquals("", stringAppender.toString());
taskLogger.getOutputSink().println("hello");
taskLogger.getStoredLogs(stringAppenderProvider);
assertEquals(String.format("hello%n"), stringAppender.toString());
}
use of org.ow2.proactive.scheduler.util.TaskLogger in project scheduling by ow2-proactive.
the class TaskLoggerTest method logPattern.
@Test
public void logPattern() throws Exception {
TaskId taskId = TaskIdImpl.createTaskId(new JobIdImpl(1000, "job"), "task", 42L);
taskLogger = new TaskLogger(taskId, "myhost");
assertEquals("", taskLogger.getLogs().getAllLogs(false));
taskLogger.getOutputSink().println("hello");
String quotedStringTaskId = Pattern.quote(taskId.toString());
assertTrue(taskLogger.getLogs().getAllLogs(true).matches("\\[" + quotedStringTaskId + "@myhost;[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\\] hello \r?\n"));
taskLogger.getErrorSink().println("error");
assertTrue(taskLogger.getLogs().getStderrLogs(true).matches("\\[" + quotedStringTaskId + "@myhost;[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\\] error \r?\n"));
}
use of org.ow2.proactive.scheduler.util.TaskLogger in project scheduling by ow2-proactive.
the class TaskLoggerTest method logStreaming.
@Test
public void logStreaming() throws Exception {
taskLogger = new TaskLogger(TaskIdImpl.createTaskId(new JobIdImpl(1000, "job"), "task", 42L), "myhost");
final StringWriter stringAppender = new StringWriter();
AppenderProvider stringAppenderProvider = new AppenderProvider() {
@Override
public Appender getAppender() throws LogForwardingException {
return new WriterAppender(new PatternLayout("%m%n"), stringAppender);
}
};
taskLogger.activateLogs(stringAppenderProvider);
assertEquals("", stringAppender.toString());
taskLogger.getOutputSink().println("hello");
// async appender, it gets buffered
assertEquals("", stringAppender.toString());
for (int i = 0; i < 1000; i++) {
taskLogger.getOutputSink().println("hello");
}
assertNotEquals("", stringAppender.toString());
}
use of org.ow2.proactive.scheduler.util.TaskLogger in project scheduling by ow2-proactive.
the class RMProxyActiveObject method printCleaningScriptInformations.
private void printCleaningScriptInformations(NodeSet nodes, ScriptResult<?> sResult, TaskId taskId) {
if (logger.isInfoEnabled()) {
TaskLogger instance = TaskLogger.getInstance();
String nodeUrl = nodes.get(0).getNodeInformation().getURL();
if (sResult.errorOccured()) {
instance.error(taskId, "Exception while running cleaning script on " + nodeUrl, sResult.getException());
} else {
instance.info(taskId, "Cleaning script successful.");
}
if (sResult.getOutput() != null && !sResult.getOutput().isEmpty()) {
instance.info(taskId, "Cleaning script output on node " + nodeUrl + ":");
instance.info(taskId, sResult.getOutput());
}
}
}
Aggregations