From 545d8f35df8935ceb21497c9dca904ee52c64543 Mon Sep 17 00:00:00 2001 From: kimchy Date: Thu, 20 Jan 2011 17:28:45 +0200 Subject: [PATCH] No cluster name filtering when sniffing is not enabled, closes #637. --- .../TransportClientNodesService.java | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java index 7ade3a82d32..3d693fee58b 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java @@ -163,12 +163,30 @@ public class TransportClientNodesService extends AbstractComponent { if (!transportService.nodeConnected(node)) { try { transportService.connectToNode(node); - newNodes.add(node); } catch (Exception e) { logger.debug("Failed to connect to node " + node + ", removed from nodes list", e); + continue; } - } else { - newNodes.add(node); + } + try { + NodesInfoResponse nodeInfo = transportService.submitRequest(node, TransportActions.Admin.Cluster.Node.INFO, Requests.nodesInfoRequest("_local"), new BaseTransportResponseHandler() { + @Override public NodesInfoResponse newInstance() { + return new NodesInfoResponse(); + } + + @Override public void handleResponse(NodesInfoResponse response) { + } + + @Override public void handleException(TransportException exp) { + } + }).txGet(); + if (!clusterName.equals(nodeInfo.clusterName())) { + logger.warn("Node {} not part of the cluster {}, ignoring...", node, clusterName); + } else { + newNodes.add(node); + } + } catch (Exception e) { + logger.warn("failed to get node info for {}", e, node); } } nodes = new ImmutableList.Builder().addAll(newNodes).build();