Skip to content

NodePredicate support on ConnectionSettings #2619

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

Merged
merged 1 commit into from
Feb 17, 2017
Merged

Conversation

Mpdreamz
Copy link
Member

@Mpdreamz Mpdreamz commented Feb 16, 2017

You can now set NodePredicate(Func<Node, bool> filter) on ConnectionSettings.

This allows you to control which nodes are considered targets in the RequestPipeline for normal Elasticsearch API calls. Sniffing in the RequestPipeline does not take this predicate into account allowing you to seed your SniffingConnectionPool with master nodes and have it sniff on startup afterwhich none of the API calls will touch the master nodes.

The default predicate for any IConnectionPool that supports reseeding of nodes (SniffingConnectionPool) is to filter out master only nodes.

For those that don't SingleNode-, Static-, StickyConnectionPool et all) the default NodePredicate` returns true for all nodes, assuming the list of nodes you pass are correct from the get go.

Our Node type returns a bunch of interesting information so you could use it to sniff all the warm or cold nodes in the cluster and only talk to those for instance.

See the > tests < for more examples.

We also protect against a predicate filtering out all the nodes by throwing a new UnexpectedElasticsearchClientException() where itsDebugInformation fully explaina what just happened.

cc @bleskes @gmoskovicz and @ppf2 (whom i too easily dismissed on #1322, while sub classing SniffingConnectionPool and overriding Reseed was A solution its far from pretty).

…odes, this can also be plugged into by providing NodePredicate() on ConnectionSettings()
@gmoskovicz
Copy link
Contributor

@Mpdreamz that is amazing! Thanks for this addition!

Copy link
Contributor

@gmarz gmarz left a comment

Choose a reason for hiding this comment

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

LGTM! Love this feature @Mpdreamz 👍

@bleskes
Copy link

bleskes commented Feb 17, 2017 via email

@gmarz gmarz merged commit c8de193 into 5.x Feb 17, 2017
@gmarz gmarz deleted the feature/node-predicate-filter branch February 17, 2017 14:57
gmarz pushed a commit that referenced this pull request Feb 17, 2017
…odes, this can also be plugged into by providing NodePredicate() on ConnectionSettings() (#2619)
@gmarz
Copy link
Contributor

gmarz commented Feb 17, 2017

Merged to 5.x and ported to master

awelburn pushed a commit to Artesian/elasticsearch-net that referenced this pull request Nov 6, 2017
…odes, this can also be plugged into by providing NodePredicate() on ConnectionSettings() (elastic#2619)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants