Skip to content

Commit a980fb5

Browse files
committed
Refactor routing logic to better handle failures
Separate out different parts of the logic into different classes: * When to update the view of the cluster, and the maintenance of the set of servers in the cluster: - LoadBalancer * The ability to retrieve a list of servers with roles (ClusterComposition) from a server: - ClusterComposition.Provider * Round Robin cycling through a set of addresses (maintaining the order/position on addition/removal of members in the set): - RoundRobinAddressSet The new logic distinguishes being unable to connect to the routing servers and maintains the server in the list in this case, under the assumption that the server is only temporarily unavailable. The attempt to contact routing servers only fail after a number of failed attempts with an exponential back off in between. These changes introduce event based testing for some of the components, this makes it easier to test for the behaviour of units, rather than asserting on their state, while the explicitness of it makes it easier to follow than using mocks.
1 parent 60acb8a commit a980fb5

25 files changed

+3716
-1208
lines changed

driver/src/main/java/org/neo4j/driver/internal/ClusterView.java

Lines changed: 0 additions & 175 deletions
This file was deleted.

driver/src/main/java/org/neo4j/driver/internal/NetworkSession.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ public StatementResult run( String statementText, Value statementParameters )
113113
public StatementResult run( Statement statement )
114114
{
115115
ensureConnectionIsValidBeforeRunningSession();
116+
return run( connection, statement );
117+
}
118+
119+
public static StatementResult run( Connection connection, Statement statement )
120+
{
116121
InternalStatementResult cursor = new InternalStatementResult( connection, null, statement );
117122
connection.run( statement.text(), statement.parameters().asMap( Values.ofValue() ),
118123
cursor.runResponseCollector() );

0 commit comments

Comments
 (0)