From abf64a13b0564d60d78e91ef5d3074724e493c30 Mon Sep 17 00:00:00 2001 From: Slim Date: Thu, 12 May 2016 11:32:36 -0700 Subject: [PATCH] reconnect to the graphite after transient disconnect (#2952) * reconnect to the graphite after transient disconnect * catch the socket exception and retry --- .../main/java/io/druid/emitter/graphite/GraphiteEmitter.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extensions-contrib/graphite-emitter/src/main/java/io/druid/emitter/graphite/GraphiteEmitter.java b/extensions-contrib/graphite-emitter/src/main/java/io/druid/emitter/graphite/GraphiteEmitter.java index d8c877aa046..52e892c0fea 100644 --- a/extensions-contrib/graphite-emitter/src/main/java/io/druid/emitter/graphite/GraphiteEmitter.java +++ b/extensions-contrib/graphite-emitter/src/main/java/io/druid/emitter/graphite/GraphiteEmitter.java @@ -29,6 +29,7 @@ import com.metamx.emitter.service.AlertEvent; import com.metamx.emitter.service.ServiceMetricEvent; import java.io.IOException; +import java.net.SocketException; import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; @@ -139,7 +140,6 @@ public class GraphiteEmitter implements Emitter public void run() { try { - if (!pickledGraphite.isConnected()) { log.info("trying to connect to graphite server"); pickledGraphite.connect(); @@ -168,6 +168,8 @@ public class GraphiteEmitter implements Emitter log.error(e, e.getMessage()); if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); + } else if (e instanceof SocketException){ + pickledGraphite.connect(); } } }