use of org.opennms.nrtg.api.model.LightweightMeasurementSet in project opennms by OpenNMS.
the class CollectionJobListener method onMessage.
@Override
public void onMessage(Message message) {
try {
// FIXME abstraction between technology and job handling is missing
CollectionJob collectionJob = (CollectionJob) simpleMessageConverter.fromMessage(message);
collectionJob = protocolCollectorRegistry.getProtocolCollector(collectionJob.getService()).collect(collectionJob);
Date finishedTimestamp = new Date();
collectionJob.setFinishedTimestamp(finishedTimestamp);
Map<String, MeasurementSet> measurementSets = collectionJob.getMeasurementSetsByDestination();
int val = counter.incrementAndGet();
if (val % 1000 == 0) {
logger.debug("processed job #{}, {} measurement set(s)", val, measurementSets.size());
} else {
logger.trace("processed job #{}, {} measurement set(s)", val, measurementSets.size());
}
for (String destinationString : measurementSets.keySet()) {
jmsTemplate.convertAndSend(destinationString, measurementSets.get(destinationString));
logger.info("** sending msg '{}' to '{}'", measurementSets.get(destinationString), destinationString);
}
LightweightMeasurementSet errorMeasurementSet = new LightweightMeasurementSet(collectionJob.getNodeId(), collectionJob.getService(), collectionJob.getNetInterface(), collectionJob.getFinishedTimestamp());
for (String metricId : collectionJob.getAllMetrics()) {
if (collectionJob.getMetricValue(metricId) == null) {
errorMeasurementSet.addMeasurement(metricId, collectionJob.getMetricType(metricId), null, collectionJob.getOnmsLogicMetricId(metricId));
}
logger.trace("collected metric of job #{}='{}'", counter + ": " + metricId, collectionJob.getMetricValue(metricId));
}
if (errorMeasurementSet.getMeasurements().size() > 0) {
logger.warn("result set of job #{} contains {} null values", counter, errorMeasurementSet.getMeasurements().size());
jmsTemplate.convertAndSend("error", errorMeasurementSet);
logger.trace("** sending to 'error'");
}
} catch (JMSException ex) {
logger.error(ex.getMessage());
// FIXME react, don't continue
} catch (MessageConversionException ex) {
logger.error(ex.getMessage());
// FIXME react, don't continue
}
}
Aggregations