use of org.openkilda.messaging.info.DatapointEntries in project open-kilda by telstra.
the class DatapointParseBolt method execute.
@Override
public void execute(Tuple tuple) {
if (ZooKeeperSpout.SPOUT_ID.equals(tuple.getSourceComponent())) {
LifecycleEvent event = (LifecycleEvent) tuple.getValueByField(FIELD_ID_LIFECYCLE_EVENT);
if (event != null && shouldHandleLifeCycleEvent(event.getSignal())) {
handleLifeCycleEvent(tuple, event);
}
collector.ack(tuple);
} else if (active) {
InfoData data = (InfoData) tuple.getValueByField(MessageKafkaTranslator.FIELD_ID_PAYLOAD);
LOGGER.debug("Processing datapoint: {}", data);
try {
List<Datapoint> datapoints;
Object payload = tuple.getValueByField(MessageKafkaTranslator.FIELD_ID_PAYLOAD);
if (payload instanceof Datapoint) {
LOGGER.debug("Processing datapoint: {}", payload);
datapoints = Collections.singletonList((Datapoint) payload);
} else if (payload instanceof DatapointEntries) {
LOGGER.debug("Processing datapoints: {}", payload);
datapoints = ((DatapointEntries) payload).getDatapointEntries();
} else {
LOGGER.error("Unhandled input tuple from {} with data {}", getClass().getName(), payload);
return;
}
for (Datapoint datapoint : datapoints) {
collector.emit(asList(datapoint.simpleHashCode(), datapoint));
}
} catch (Exception e) {
LOGGER.error("Failed process data: {}", data, e);
} finally {
collector.ack(tuple);
}
} else {
LOGGER.debug("DatapointParseBolt is inactive");
collector.ack(tuple);
}
}
use of org.openkilda.messaging.info.DatapointEntries in project open-kilda by telstra.
the class PushToStreamMeterRegistry method pushMeters.
/**
* Push the current values of registered meters to the specified stream.
*/
public void pushMeters(OutputCollector collector, String streamId) {
try {
List<Datapoint> datapoints = new ArrayList<>();
for (Meter meter : getMeters()) {
datapoints.addAll(meter.match(this::writeGauge, this::writeCounter, this::writeTimer, this::writeSummary, this::writeLongTaskTimer, this::writeTimeGauge, this::writeFunctionCounter, this::writeFunctionTimer, this::writeCustomMeter));
}
String payload = Utils.MAPPER.writeValueAsString(new DatapointEntries(datapoints));
log.debug("Pushing datapoint(s) {}", payload);
collector.emit(streamId, Collections.singletonList(payload));
} catch (Exception ex) {
log.warn("Failed to send metrics", ex);
}
}
Aggregations