-
Notifications
You must be signed in to change notification settings - Fork 70
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
Routing driver #115
Routing driver #115
Conversation
Created ClusterConnectionPool as pool of existing connection pools
Added RoutingDriver for `bolt+routing` scheme. Added the basic logic of `CheckServers` TODO: Discovery, multithread support, error handling
Added a load balancer who has the full control of a cluster view and a cluster connection pool Added discovery manager who takes a connection and perform discovery to save the new cluster status for creating a new cluster view What is missing now: timeout, error handling, remove connection when session/tx throw connection errors
a988244
to
d06a6ab
Compare
d06a6ab
to
d143b54
Compare
Built a `MockedMessagingClient` to verify messages sent via driver and to simulate messages from the server for tests
Added tests to verify error handlers are added correctly Fixed the bug where the error handlers are added after client.start and init.
fd97a8b
to
898dea3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhenlineo changes look good to me
{ | ||
private const int MinRouterCount = 1; | ||
private readonly ConcurrentRoundRobinSet<Uri> _routers = new ConcurrentRoundRobinSet<Uri>(); | ||
private readonly ConcurrentRoundRobinSet<Uri> _detachedRouters = new ConcurrentRoundRobinSet<Uri>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uris are only added to this set, otherwise it is never used. We need to decide if _detachedRouters
is needed.
|
||
public static bool IsClusterError(this Neo4jException error) | ||
{ | ||
return error.Code.Equals("Neo.ClientError.Cluster.NotALeader") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to have constants or helper methods for these strings Neo.ClientError.Cluster.NotALeader
and Neo.ClientError.General.ForbiddenOnReadOnlyDatabase
. They are used here in Neo4jErrorExtensions
and in RoundRobinLoadBalancer
.
|
||
if (uri.Port == -1) | ||
{ | ||
var builder = new UriBuilder(uri.Scheme, uri.Host, 7687); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe let's introduce a constant for 7687
Created
ClusterConnectionPool
as pool of existing connection pools.Added new scheme
bolt+routing
for creating a newRoutingDriver
for routing queries to a cluster.RoutingDriver
holds aLoadbalancer
which is responsible for supplying an usable connection during the creation of a specific read/write session.Loadbalancer
holds aClusterView
which describes the client's current understanding of the servers in the cluster and aClusterConnectionPool
that maintains a dictionary of {server, connection pool}.ClusterView
might become unavailable and get (temporarily or permanently) removed. TheClusterConnectionPool
could choose to either still keep the connection pool of a unavailable server or remove it totally too. However it is illegal to have servers that are known toClusterView
but have no connection pool entry inClusterConnectionPool
.ClusterView
load balance the connections to the servers using aConcurrentRoundRobinSet
.Added error handling callback in
SocketConnection
.SocketConnection
toPooledConnection
Loadbalancer
is done via a error handling event callback inSocketConnection
passed byLoadBalancer
.TODO:
Feature: Retry rediscovery?
ITs