use of com.wavefront.ingester.GraphiteHostAnnotator in project java by wavefrontHQ.
the class PushAgent method startGraphiteListener.
protected void startGraphiteListener(String strPort, boolean withCustomFormatter) {
int port = Integer.parseInt(strPort);
if (prefix != null && !prefix.isEmpty()) {
preprocessors.forPort(strPort).forReportPoint().addTransformer(new ReportPointAddPrefixTransformer(prefix));
}
preprocessors.forPort(strPort).forReportPoint().addFilter(new ReportPointTimestampInRangeFilter(dataBackfillCutoffHours, dataPrefillCutoffHours));
// Add a metadatahandler, to handle @SourceTag, @SourceDescription, etc.
SourceTagHandler metadataHandler = new SourceTagHandlerImpl(getSourceTagFlushTasks(port));
// Set up a custom graphite handler, with no formatter
ChannelHandler graphiteHandler = new ChannelStringHandler(new GraphiteDecoder("unknown", customSourceTags), new PointHandlerImpl(strPort, pushValidationLevel, pushBlockedSamples, getFlushTasks(strPort)), preprocessors.forPort(strPort), metadataHandler);
if (!withCustomFormatter) {
List<Function<Channel, ChannelHandler>> handler = Lists.newArrayList(1);
handler.add(input -> {
SocketChannel ch = (SocketChannel) input;
if (ch != null && ch.remoteAddress() != null) {
return new GraphiteHostAnnotator(disableRdnsLookup ? ch.remoteAddress().getAddress().getHostAddress() : reverseDnsCache.get(ch.remoteAddress().getAddress()), customSourceTags);
}
return new GraphiteHostAnnotator("unknown", customSourceTags);
});
startAsManagedThread(new StringLineIngester(handler, graphiteHandler, port).withChildChannelOptions(childChannelOptions), "listener-plaintext-wavefront-" + port);
} else {
startAsManagedThread(new StringLineIngester(graphiteHandler, port).withChildChannelOptions(childChannelOptions), "Listener-plaintext-graphite-" + port);
}
}
Aggregations