From 2594828d48f100e897e03ccd02a45151a6df913c Mon Sep 17 00:00:00 2001 From: kimchy Date: Fri, 15 Jul 2011 20:22:34 +0300 Subject: [PATCH] better logging when receiving a ping response that does not match, print who we got it from --- .../zen/ping/multicast/MulticastZenPing.java | 27 +++++++++++++------ .../zen/ping/unicast/UnicastZenPing.java | 12 ++++----- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/ping/multicast/MulticastZenPing.java b/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/ping/multicast/MulticastZenPing.java index 42ec103db3b..25ae2dafcf4 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/ping/multicast/MulticastZenPing.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/ping/multicast/MulticastZenPing.java @@ -25,7 +25,14 @@ import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.component.AbstractLifecycleComponent; -import org.elasticsearch.common.io.stream.*; +import org.elasticsearch.common.io.stream.BytesStreamInput; +import org.elasticsearch.common.io.stream.CachedStreamInput; +import org.elasticsearch.common.io.stream.CachedStreamOutput; +import org.elasticsearch.common.io.stream.HandlesStreamOutput; +import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.io.stream.Streamable; +import org.elasticsearch.common.io.stream.VoidStreamable; import org.elasticsearch.common.network.NetworkService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; @@ -34,7 +41,11 @@ import org.elasticsearch.discovery.zen.DiscoveryNodesProvider; import org.elasticsearch.discovery.zen.ping.ZenPing; import org.elasticsearch.discovery.zen.ping.ZenPingException; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.*; +import org.elasticsearch.transport.BaseTransportRequestHandler; +import org.elasticsearch.transport.TransportChannel; +import org.elasticsearch.transport.TransportException; +import org.elasticsearch.transport.TransportService; +import org.elasticsearch.transport.VoidTransportResponseHandler; import java.io.IOException; import java.net.DatagramPacket; @@ -181,11 +192,11 @@ public class MulticastZenPing extends AbstractLifecycleComponent implem final AtomicReference response = new AtomicReference(); final CountDownLatch latch = new CountDownLatch(1); ping(new PingListener() { - @Override public void onPing(PingResponse[] pings) { - response.set(pings); - latch.countDown(); - } - }, timeout); + @Override public void onPing(PingResponse[] pings) { + response.set(pings); + latch.countDown(); + } + }, timeout); try { latch.await(); return response.get(); @@ -262,7 +273,7 @@ public class MulticastZenPing extends AbstractLifecycleComponent implem } ConcurrentMap responses = receivedResponses.get(request.id); if (responses == null) { - logger.warn("received ping response with no matching id [{}]", request.id); + logger.warn("received ping response {} with no matching id [{}]", request.pingResponse, request.id); } else { responses.put(request.pingResponse.target(), request.pingResponse); } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java b/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java index 765656492af..c423afe0e44 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java @@ -147,11 +147,11 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen final AtomicReference response = new AtomicReference(); final CountDownLatch latch = new CountDownLatch(1); ping(new PingListener() { - @Override public void onPing(PingResponse[] pings) { - response.set(pings); - latch.countDown(); - } - }, timeout); + @Override public void onPing(PingResponse[] pings) { + response.set(pings); + latch.countDown(); + } + }, timeout); try { latch.await(); return response.get(); @@ -263,7 +263,7 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen } ConcurrentMap responses = receivedResponses.get(response.id); if (responses == null) { - logger.warn("received ping response with no matching id [{}]", response.id); + logger.warn("received ping response {} with no matching id [{}]", pingResponse, response.id); } else { responses.put(pingResponse.target(), pingResponse); }