use of org.ow2.proactive.scheduler.common.util.logforwarder.LogForwardingException in project scheduling by ow2-proactive.
the class EnabledListenJobLogsSupport method listenJobLogs.
@Override
public synchronized void listenJobLogs(JobId jobId, AppenderProvider appenderProvider) throws UnknownJobException {
jlogger.info(jobId, "listening logs");
// create the appender to the remote listener
Appender clientAppender = null;
try {
clientAppender = appenderProvider.getAppender();
} catch (LogForwardingException e) {
jlogger.error(jobId, "cannot create an appender", e);
throw new InternalException("Cannot create an appender for job " + jobId, e);
}
boolean logIsAlreadyInitialized = jobsToBeLogged.contains(jobId);
initJobLogging(jobId, clientAppender);
JobResult result = dbManager.loadJobResult(jobId);
if (result == null) {
throw new UnknownJobException(jobId);
}
// for finished tasks, add logs events "manually"
Collection<TaskResult> allRes = result.getAllResults().values();
for (TaskResult tr : allRes) {
this.flushTaskLogs(tr, clientAppender, jobId);
}
for (RunningTaskData taskData : liveJobs.getRunningTasks(jobId)) {
jlogger.debug(jobId, "Handling log initialization for task " + taskData.getTask().getName());
try {
TaskLauncher taskLauncher = taskData.getLauncher();
if (logIsAlreadyInitialized) {
jlogger.debug(jobId, "Call getStoredLogs");
taskLauncher.getStoredLogs(appenderProvider);
} else {
jlogger.debug(jobId, "Call activateLogs");
taskLauncher.activateLogs(lfs.getAppenderProvider());
}
} catch (Exception e) {
tlogger.error(taskData.getTask().getId(), "cannot create an appender provider", e);
}
}
if (!result.getJobInfo().getStatus().isJobAlive()) {
jlogger.info(jobId, "cleaning loggers for already finished job");
cleanLoggers(jobId);
}
}
use of org.ow2.proactive.scheduler.common.util.logforwarder.LogForwardingException in project scheduling by ow2-proactive.
the class TaskLogger method getStoredLogs.
public void getStoredLogs(AppenderProvider logSink) {
Appender appender;
try {
appender = logSink.getAppender();
} catch (LogForwardingException e) {
logger.error("Cannot create log appender.", e);
return;
}
taskLogAppender.appendStoredEvents(appender);
}
Aggregations