use of org.opennms.netmgt.telemetry.adapters.api.TelemetryMessage in project opennms by OpenNMS.
the class AbstractPersistingAdapter method handleMessageLog.
@Override
public void handleMessageLog(TelemetryMessageLog messageLog) {
for (TelemetryMessage message : messageLog.getMessageList()) {
final Optional<CollectionSetWithAgent> result;
try {
result = handleMessage(message, messageLog);
} catch (Exception e) {
LOG.warn("Failed to build a collection set from message: {}. Dropping.", message, e);
return;
}
if (!result.isPresent()) {
LOG.debug("No collection set was returned when processing message: {}. Dropping.", message);
return;
}
// Locate the matching package definition
final Package pkg = getPackageFor(protocol, result.get().getAgent());
if (pkg == null) {
LOG.warn("No matching package found for message: {}. Dropping.", message);
return;
}
// Build the repository from the package definition
final RrdRepository repository = new RrdRepository();
repository.setStep(pkg.getRrd().getStep());
repository.setHeartBeat(repository.getStep() * 2);
repository.setRraList(pkg.getRrd().getRras());
repository.setRrdBaseDir(new File(pkg.getRrd().getBaseDir()));
// Persist!
final CollectionSet collectionSet = result.get().getCollectionSet();
LOG.trace("Persisting collection set: {} for message: {}", collectionSet, message);
final Persister persister = persisterFactory.createPersister(EMPTY_SERVICE_PARAMETERS, repository);
collectionSet.visit(persister);
}
}
Aggregations