* Send given metrics to the Graphite server.
*/
@Override
public void write(Iterable<QueryResult> results) {
logger.debug("Export to '{}' results {}", graphiteServerHostAndPort, results);
SocketWriter socketWriter = null;
try {
socketWriter = socketWriterPool.borrowObject(graphiteServerHostAndPort);
for (QueryResult result : results) {
String msg = metricPathPrefix + result.getName() + " " + result.getValue() + " " + result.getEpoch(TimeUnit.SECONDS) + "\n";
logger.debug("Export '{}'", msg);
socketWriter.write(msg);
}
socketWriter.flush();
socketWriterPool.returnObject(graphiteServerHostAndPort, socketWriter);
} catch (Exception e) {
logger.warn("Failure to send result to graphite server '{}' with {}", graphiteServerHostAndPort, socketWriter, e);
if (socketWriter != null) {
try {