Skip to content

Commit

Permalink
Java client nodes using multicast discovery connect to one another, c…
Browse files Browse the repository at this point in the history
…loses elastic#1135.
  • Loading branch information
kimchy committed Jul 20, 2011
1 parent 60bf324 commit 0b0053c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ public DiscoveryNode(String nodeName, String nodeId, TransportAddress address, M
this.address = address;
}

/**
* Should this node form a connection to the provided node.
*/
public boolean shouldConnectTo(DiscoveryNode otherNode) {
if (clientNode() && otherNode.clientNode()) {
return false;
}
return true;
}

/**
* The address that the node can be communicated with.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,6 @@ private class ReconnectToNodes implements Runnable {
}

private boolean nodeRequiresConnection(DiscoveryNode node) {
if (localNode().clientNode()) {
if (node.clientNode()) {
return false;
}
}
return true;
return localNode().shouldConnectTo(node);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,16 @@ public void stop() {
continue;
}
if (!clusterName.equals(MulticastZenPing.this.clusterName)) {
// not our cluster, ignore it...
if (logger.isTraceEnabled()) {
logger.trace("[{}] received ping_request from [{}], but wrong cluster_name [{}], expected [{}], ignoring", id, requestingNode, clusterName, MulticastZenPing.this.clusterName);
}
continue;
}
// don't connect between two client nodes, no need for that...
if (!discoveryNodes.localNode().shouldConnectTo(requestingNode)) {
if (logger.isTraceEnabled()) {
logger.trace("[{}] received ping_request from [{}], both are client nodes, ignoring", id, requestingNode, clusterName);
}
continue;
}
final MulticastPingResponse multicastPingResponse = new MulticastPingResponse();
Expand Down

0 comments on commit 0b0053c

Please sign in to comment.