NodePredicate support on ConnectionSettings #2619
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
You can now set
NodePredicate(Func<Node, bool> filter)
onConnectionSettings
.This allows you to control which nodes are considered targets in the
RequestPipeline
for normal Elasticsearch API calls. Sniffing in theRequestPipeline
does not take this predicate into account allowing you to seed yourSniffingConnectionPool
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 outmaster 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).