use of org.opennms.netmgt.syslogd.api.SyslogMessageDTO in project opennms by OpenNMS.
the class SyslogSinkConsumer method toEventLog.
public Log toEventLog(SyslogMessageLogDTO messageLog) {
final Log elog = new Log();
final Events events = new Events();
elog.setEvents(events);
for (SyslogMessageDTO message : messageLog.getMessages()) {
try {
LOG.debug("Converting syslog message into event.");
ConvertToEvent re = new ConvertToEvent(messageLog.getSystemId(), messageLog.getLocation(), messageLog.getSourceAddress(), messageLog.getSourcePort(), message.getBytes(), syslogdConfig);
events.addEvent(re.getEvent());
} catch (final MessageDiscardedException e) {
LOG.info("Message discarded, returning without enqueueing event.", e);
} catch (final Throwable e) {
LOG.error("Unexpected exception while processing SyslogConnection", e);
}
}
return elog;
}
use of org.opennms.netmgt.syslogd.api.SyslogMessageDTO in project opennms by OpenNMS.
the class SyslogSinkModule method getAggregationPolicy.
@Override
public AggregationPolicy<SyslogConnection, SyslogMessageLogDTO> getAggregationPolicy() {
final String systemId = distPollerDao.whoami().getId();
final String systemLocation = distPollerDao.whoami().getLocation();
return new AggregationPolicy<SyslogConnection, SyslogMessageLogDTO>() {
@Override
public int getCompletionSize() {
return config.getBatchSize();
}
@Override
public int getCompletionIntervalMs() {
return config.getBatchIntervalMs();
}
@Override
public Object key(SyslogConnection syslogConnection) {
return syslogConnection.getSource();
}
@Override
public SyslogMessageLogDTO aggregate(SyslogMessageLogDTO oldLog, SyslogConnection connection) {
if (oldLog == null) {
oldLog = new SyslogMessageLogDTO(systemLocation, systemId, connection.getSource());
}
SyslogMessageDTO messageDTO = new SyslogMessageDTO(connection.getBuffer());
oldLog.getMessages().add(messageDTO);
return oldLog;
}
};
}
use of org.opennms.netmgt.syslogd.api.SyslogMessageDTO in project opennms by OpenNMS.
the class SyslogSinkModule method toMessageLog.
/**
* Used for testing.
*/
public SyslogMessageLogDTO toMessageLog(SyslogConnection... connections) {
final String systemId = distPollerDao.whoami().getId();
final String systemLocation = distPollerDao.whoami().getLocation();
if (connections.length < 1) {
throw new IllegalArgumentException("One or more connection are required.");
}
final SyslogMessageLogDTO messageLog = new SyslogMessageLogDTO(systemLocation, systemId, connections[0].getSource());
for (SyslogConnection connection : connections) {
final SyslogMessageDTO messageDTO = new SyslogMessageDTO(connection.getBuffer());
messageLog.getMessages().add(messageDTO);
}
return messageLog;
}
Aggregations