-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Connection pooling / cluster failover support #528
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ial seed for the round robin on the GetNext() call. This allows callee's to reseed themselves and will ensure all the indivual nodes are tried when max retries equals number of known hosts
… back alive when their timeout has expired
…, transport is in charge.
…d for the first time, can be disabled in connectionconfiguration
Mpdreamz
added a commit
that referenced
this pull request
Mar 12, 2014
Connection pooling / cluster failover support
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds support for builtin cluster failover support and connection pooling.
SingleNodeConnectionPool
This is still the default when you do not specify any connectionpool.
In this example we never explicitly passed an
IConnectionPool
to use so it will default to theSingleNodeConnectionPool
which will always report the single node we passed in as alive and well. This means that the defaults for existing code is unchangedStaticConnectionPool
This adds a static pool of nodes that will be round robin'ed over when performing elasticsearch calls. Whenever a node reports a known failure (timout, 503 etcetera) it will retry on the next node in the pool and mark the failing node as dead. This means that while the node has been marked dead it will automatically be skipped for the duration it has been marked dead. When all nodes are marked dead it will simply pick one at random. You can specify the maximum amount of retries which will default to the amount of nodes you pass in minus 1.
SniffingConnectionPool
Similar to the static connection pool this will round robin over the specified nodes but will use the nodes to initially sniff the rest of the cluster to build the list of known hosts. You can make it re-sniff whenever a connection fault occurs or sniff whenever the last sniff happened too long ago.
See the unit tests here:
https://github.com/Mpdreamz/NEST/tree/feature/connection-pooling/src/Elasticsearch.Net.Tests.Unit/Connection
In particular read this tests to know why builtin support for cluster failover in NEST is an absolute must:
https://github.com/Mpdreamz/NEST/blob/feature/connection-pooling/src/Elasticsearch.Net.Tests.Unit/Connection/ConcurrencyTests.cs#L94