diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/UnicastZenPing.java b/core/src/main/java/org/elasticsearch/discovery/zen/UnicastZenPing.java index f24e7da5cf8..e2d9fca6f69 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/UnicastZenPing.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/UnicastZenPing.java @@ -584,7 +584,6 @@ public class UnicastZenPing extends AbstractComponent implements ZenPing { List pingResponses = CollectionUtils.iterableAsArrayList(temporalResponses); pingResponses.add(createPingResponse(contextProvider.nodes())); - UnicastPingResponse unicastPingResponse = new UnicastPingResponse(); unicastPingResponse.id = request.id; unicastPingResponse.pingResponses = pingResponses.toArray(new PingResponse[pingResponses.size()]); @@ -596,8 +595,11 @@ public class UnicastZenPing extends AbstractComponent implements ZenPing { @Override public void messageReceived(UnicastPingRequest request, TransportChannel channel) throws Exception { - channel.sendResponse(handlePingRequest(request)); + if (request.pingResponse.clusterName().equals(clusterName)) { + channel.sendResponse(handlePingRequest(request)); + } } + } public static class UnicastPingRequest extends TransportRequest { diff --git a/core/src/main/java/org/elasticsearch/transport/TransportService.java b/core/src/main/java/org/elasticsearch/transport/TransportService.java index 511be6fb84c..39a6f5cc41c 100644 --- a/core/src/main/java/org/elasticsearch/transport/TransportService.java +++ b/core/src/main/java/org/elasticsearch/transport/TransportService.java @@ -334,10 +334,12 @@ public class TransportService extends AbstractLifecycleComponent { if (node.equals(localNode)) { return localNode; } + logger.trace("connecting with node [{}] to perform handshake", node); transport.connectToNode(node, ConnectionProfile.LIGHT_PROFILE); try { return handshake(node, handshakeTimeout, checkClusterName); } catch (ConnectTransportException | IllegalStateException e) { + logger.trace((Supplier) () -> new ParameterizedMessage("disconnecting from node [{}] after failed handshake", node), e); transport.disconnectFromNode(node); throw e; }