better logging when receiving a ping response that does not match, print who we got it from

This commit is contained in:
kimchy 2011-07-15 20:22:34 +03:00
parent 2dd6075171
commit 2594828d48
2 changed files with 25 additions and 14 deletions

View File

@ -25,7 +25,14 @@ import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.common.component.AbstractLifecycleComponent; 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.network.NetworkService;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue; 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.ZenPing;
import org.elasticsearch.discovery.zen.ping.ZenPingException; import org.elasticsearch.discovery.zen.ping.ZenPingException;
import org.elasticsearch.threadpool.ThreadPool; 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.io.IOException;
import java.net.DatagramPacket; import java.net.DatagramPacket;
@ -181,11 +192,11 @@ public class MulticastZenPing extends AbstractLifecycleComponent<ZenPing> implem
final AtomicReference<PingResponse[]> response = new AtomicReference<PingResponse[]>(); final AtomicReference<PingResponse[]> response = new AtomicReference<PingResponse[]>();
final CountDownLatch latch = new CountDownLatch(1); final CountDownLatch latch = new CountDownLatch(1);
ping(new PingListener() { ping(new PingListener() {
@Override public void onPing(PingResponse[] pings) { @Override public void onPing(PingResponse[] pings) {
response.set(pings); response.set(pings);
latch.countDown(); latch.countDown();
} }
}, timeout); }, timeout);
try { try {
latch.await(); latch.await();
return response.get(); return response.get();
@ -262,7 +273,7 @@ public class MulticastZenPing extends AbstractLifecycleComponent<ZenPing> implem
} }
ConcurrentMap<DiscoveryNode, PingResponse> responses = receivedResponses.get(request.id); ConcurrentMap<DiscoveryNode, PingResponse> responses = receivedResponses.get(request.id);
if (responses == null) { 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 { } else {
responses.put(request.pingResponse.target(), request.pingResponse); responses.put(request.pingResponse.target(), request.pingResponse);
} }

View File

@ -147,11 +147,11 @@ public class UnicastZenPing extends AbstractLifecycleComponent<ZenPing> implemen
final AtomicReference<PingResponse[]> response = new AtomicReference<PingResponse[]>(); final AtomicReference<PingResponse[]> response = new AtomicReference<PingResponse[]>();
final CountDownLatch latch = new CountDownLatch(1); final CountDownLatch latch = new CountDownLatch(1);
ping(new PingListener() { ping(new PingListener() {
@Override public void onPing(PingResponse[] pings) { @Override public void onPing(PingResponse[] pings) {
response.set(pings); response.set(pings);
latch.countDown(); latch.countDown();
} }
}, timeout); }, timeout);
try { try {
latch.await(); latch.await();
return response.get(); return response.get();
@ -263,7 +263,7 @@ public class UnicastZenPing extends AbstractLifecycleComponent<ZenPing> implemen
} }
ConcurrentMap<DiscoveryNode, PingResponse> responses = receivedResponses.get(response.id); ConcurrentMap<DiscoveryNode, PingResponse> responses = receivedResponses.get(response.id);
if (responses == null) { 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 { } else {
responses.put(pingResponse.target(), pingResponse); responses.put(pingResponse.target(), pingResponse);
} }