Skip to content

Commit

Permalink
Transport Client: Add client.transport.ignore_cluster_name to ignor…
Browse files Browse the repository at this point in the history
…e the cluster name validation, defaults to `false`, closes elastic#1910.
  • Loading branch information
kimchy committed May 3, 2012
1 parent 133dddf commit ac0a01d
Showing 1 changed file with 5 additions and 2 deletions.
Expand Up @@ -81,6 +81,8 @@ public class TransportClientNodesService extends AbstractComponent {

private final AtomicInteger randomNodeGenerator = new AtomicInteger();

private final boolean ignoreClusterName;

private volatile boolean closed;

@Inject
Expand All @@ -93,6 +95,7 @@ public TransportClientNodesService(Settings settings, ClusterName clusterName,

this.nodesSamplerInterval = componentSettings.getAsTime("nodes_sampler_interval", timeValueSeconds(5));
this.pingTimeout = componentSettings.getAsTime("ping_timeout", timeValueSeconds(5)).millis();
this.ignoreClusterName = componentSettings.getAsBoolean("ignore_cluster_name", false);

if (logger.isDebugEnabled()) {
logger.debug("node_sampler_interval[" + nodesSamplerInterval + "]");
Expand Down Expand Up @@ -315,7 +318,7 @@ public NodesInfoResponse newInstance() {
return new NodesInfoResponse();
}
}).txGet();
if (!clusterName.equals(nodeInfo.clusterName())) {
if (!ignoreClusterName && !clusterName.equals(nodeInfo.clusterName())) {
logger.warn("node {} not part of the cluster {}, ignoring...", node, clusterName);
} else {
newNodes.add(node);
Expand Down Expand Up @@ -418,7 +421,7 @@ public void handleException(TransportException e) {

HashSet<DiscoveryNode> newNodes = new HashSet<DiscoveryNode>();
for (ClusterStateResponse clusterStateResponse : clusterStateResponses) {
if (!clusterName.equals(clusterStateResponse.clusterName())) {
if (!ignoreClusterName && !clusterName.equals(clusterStateResponse.clusterName())) {
logger.warn("node {} not part of the cluster {}, ignoring...", clusterStateResponse.state().nodes().localNode(), clusterName);
}
for (DiscoveryNode node : clusterStateResponse.state().nodes().dataNodes().values()) {
Expand Down

0 comments on commit ac0a01d

Please sign in to comment.