Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid repeat connections in pings every round #21812

Closed
wants to merge 3 commits into from
Closed

avoid repeat connections in pings every round #21812

wants to merge 3 commits into from

Conversation

chengpohi
Copy link
Contributor

This PR is trying to fix: #21739 by Option 1.

@bleskes Could you review this?

Copy link
Contributor

@bleskes bleskes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx @chengpohi ! I left some comments. It would also be great to have a test that the unicast host provider is only called once per pinging round. Also it would be good to have a test that pinging picks up on nodes that it discovered - i.e., if you A & C ping B , A starts pinging C as well (it got it through B). See UnicastZenPingTests for examples and where this should go.

final UnicastPingRequest pingRequest = new UnicastPingRequest();
pingRequest.id = sendPingsHandler.id();
pingRequest.timeout = timeout;
DiscoveryNodes discoNodes = contextProvider.nodes();

pingRequest.pingResponse = createPingResponse(discoNodes);

HashSet<DiscoveryNode> nodesToPingSet = new HashSet<>();
for (PingResponse temporalResponse : temporalResponses) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part has to stay here - we want to extend our pinging as we learn of new nodes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, I mv back this. Thanks

@@ -292,6 +292,7 @@ public void clearTemporalResponses() {
*/
@Override
public void ping(final PingListener listener, final TimeValue duration) {
final List<DiscoveryNode> sortedNodesToPing = buildNodesToPing();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we unify the resolvedDiscoveryNodes logic with the buildNodesToPing ? They are similar in the sense that they don't change during a ping cycle.

Copy link
Contributor Author

@chengpohi chengpohi Nov 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @bleskes, I have updated this base on your suggestion, Could you review again? I am using Tuple for keeping resolvedDiscoveryNodes and nodesToPingSet, since we need to sort nodesToPingSet to elect the master node.

…h sendPings, and add unihostprovider test, pick up discovered node test
Copy link
Contributor

@bleskes bleskes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx @chengpohi . I left some more comments

@@ -518,6 +503,33 @@ public void run() {
}
}

private Tuple<List<DiscoveryNode>, HashSet<DiscoveryNode>> buildNodesToPing() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we typically don't like using tuple return values. In this case I think we can just return a HashSet.


final List<DiscoveryNode> resolvedDiscoveryNodes;
try {
resolvedDiscoveryNodes = resolveDiscoveryNodes(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add the return value of resolveDiscoveryNodes to the HashSet being built

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @bleskes , if we add resolveDiscoveryNodes, we can't guarantee configured hosts first ping, Does it make sense?

verify(unicastHostsProviderA, times(1)).buildDynamicNodes();
}

public void testShouldPingDiscoveredNodes() throws IOException, InterruptedException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we call this testDiscoveryOfNoneConfiguredNodes and add a comment: test that nodes discover each other if they ping a common host ?

This doesn't test what I intended - i.e., test that a node pings nodes that have pinged it while it was pinging. That is however non trivial to test and I don't want to delay your change for setting this test up.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks your feedback, I will take time to see how to this test, if I have any progress on this, I will create a new PR for this. :)

@clintongormley clintongormley added :Distributed Coordination/Discovery-Plugins Anything related to our integration plugins with EC2, GCP and Azure >bug labels Nov 28, 2016
…dNodes to testDiscoveryOfNoneConfiguredNodes
@jasontedor
Copy link
Member

Thanks for picking this up @chengpohi but this has now been superseded by #22277.

@jasontedor jasontedor closed this Dec 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Distributed Coordination/Discovery-Plugins Anything related to our integration plugins with EC2, GCP and Azure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FileBasedDiscovery causes connections on every ping round
4 participants