@@ -76,7 +76,7 @@ public final Driver newInstance( URI uri, AuthToken authToken, RoutingSettings r
76
76
SecurityPlan securityPlan = createSecurityPlan ( address , config );
77
77
ConnectionPool connectionPool = createConnectionPool ( authToken , securityPlan , config );
78
78
79
- Bootstrap bootstrap = BootstrapFactory . newBootstrap ();
79
+ Bootstrap bootstrap = createBootstrap ();
80
80
EventLoopGroup eventLoopGroup = bootstrap .config ().group ();
81
81
RetryLogic retryLogic = createRetryLogic ( retrySettings , eventLoopGroup , config .logging () );
82
82
@@ -85,8 +85,8 @@ public final Driver newInstance( URI uri, AuthToken authToken, RoutingSettings r
85
85
86
86
try
87
87
{
88
- return createDriver ( uri , address , connectionPool , config , newRoutingSettings , securityPlan , retryLogic ,
89
- asyncConnectionPool );
88
+ return createDriver ( uri , address , connectionPool , asyncConnectionPool , config , newRoutingSettings ,
89
+ securityPlan , retryLogic );
90
90
}
91
91
catch ( Throwable driverError )
92
92
{
@@ -121,8 +121,8 @@ private AsyncConnectionPool createAsyncConnectionPool( AuthToken authToken, Secu
121
121
}
122
122
123
123
private Driver createDriver ( URI uri , BoltServerAddress address , ConnectionPool connectionPool ,
124
- Config config , RoutingSettings routingSettings , SecurityPlan securityPlan , RetryLogic retryLogic ,
125
- AsyncConnectionPool asyncConnectionPool )
124
+ AsyncConnectionPool asyncConnectionPool , Config config , RoutingSettings routingSettings ,
125
+ SecurityPlan securityPlan , RetryLogic retryLogic )
126
126
{
127
127
String scheme = uri .getScheme ().toLowerCase ();
128
128
switch ( scheme )
@@ -131,7 +131,8 @@ private Driver createDriver( URI uri, BoltServerAddress address, ConnectionPool
131
131
assertNoRoutingContext ( uri , routingSettings );
132
132
return createDirectDriver ( address , connectionPool , config , securityPlan , retryLogic , asyncConnectionPool );
133
133
case BOLT_ROUTING_URI_SCHEME :
134
- return createRoutingDriver ( address , connectionPool , config , routingSettings , securityPlan , retryLogic );
134
+ return createRoutingDriver ( address , connectionPool , asyncConnectionPool , config , routingSettings ,
135
+ securityPlan , retryLogic );
135
136
default :
136
137
throw new ClientException ( format ( "Unsupported URI scheme: %s" , scheme ) );
137
138
}
@@ -158,13 +159,15 @@ protected Driver createDirectDriver( BoltServerAddress address, ConnectionPool c
158
159
* <b>This method is protected only for testing</b>
159
160
*/
160
161
protected Driver createRoutingDriver ( BoltServerAddress address , ConnectionPool connectionPool ,
161
- Config config , RoutingSettings routingSettings , SecurityPlan securityPlan , RetryLogic retryLogic )
162
+ AsyncConnectionPool asyncConnectionPool , Config config , RoutingSettings routingSettings ,
163
+ SecurityPlan securityPlan , RetryLogic retryLogic )
162
164
{
163
165
if ( !securityPlan .isRoutingCompatible () )
164
166
{
165
167
throw new IllegalArgumentException ( "The chosen security plan is not compatible with a routing driver" );
166
168
}
167
- ConnectionProvider connectionProvider = createLoadBalancer ( address , connectionPool , config , routingSettings );
169
+ ConnectionProvider connectionProvider = createLoadBalancer ( address , connectionPool , asyncConnectionPool ,
170
+ config , routingSettings );
168
171
SessionFactory sessionFactory = createSessionFactory ( connectionProvider , retryLogic , config );
169
172
return createDriver ( config , securityPlan , sessionFactory );
170
173
}
@@ -184,21 +187,22 @@ protected InternalDriver createDriver( Config config, SecurityPlan securityPlan,
184
187
* <p>
185
188
* <b>This method is protected only for testing</b>
186
189
*/
187
- protected LoadBalancer createLoadBalancer ( BoltServerAddress address , ConnectionPool connectionPool , Config config ,
188
- RoutingSettings routingSettings )
190
+ protected LoadBalancer createLoadBalancer ( BoltServerAddress address , ConnectionPool connectionPool ,
191
+ AsyncConnectionPool asyncConnectionPool , Config config , RoutingSettings routingSettings )
189
192
{
190
- return new LoadBalancer ( address , routingSettings , connectionPool , createClock (), config . logging (),
191
- createLoadBalancingStrategy ( config , connectionPool ) );
193
+ return new LoadBalancer ( address , routingSettings , connectionPool , asyncConnectionPool , createClock (),
194
+ config . logging (), createLoadBalancingStrategy ( config , connectionPool , asyncConnectionPool ) );
192
195
}
193
196
194
- private static LoadBalancingStrategy createLoadBalancingStrategy ( Config config , ConnectionPool connectionPool )
197
+ private static LoadBalancingStrategy createLoadBalancingStrategy ( Config config , ConnectionPool connectionPool ,
198
+ AsyncConnectionPool asyncConnectionPool )
195
199
{
196
200
switch ( config .loadBalancingStrategy () )
197
201
{
198
202
case ROUND_ROBIN :
199
203
return new RoundRobinLoadBalancingStrategy ( config .logging () );
200
204
case LEAST_CONNECTED :
201
- return new LeastConnectedLoadBalancingStrategy ( connectionPool , config .logging () );
205
+ return new LeastConnectedLoadBalancingStrategy ( connectionPool , asyncConnectionPool , config .logging () );
202
206
default :
203
207
throw new IllegalArgumentException ( "Unknown load balancing strategy: " + config .loadBalancingStrategy () );
204
208
}
@@ -253,7 +257,7 @@ protected SessionFactory createSessionFactory( ConnectionProvider connectionProv
253
257
}
254
258
255
259
/**
256
- * Creates new {@link RetryLogic > }.
260
+ * Creates new {@link RetryLogic}.
257
261
* <p>
258
262
* <b>This method is protected only for testing</b>
259
263
*/
@@ -263,6 +267,16 @@ protected RetryLogic createRetryLogic( RetrySettings settings, EventExecutorGrou
263
267
return new ExponentialBackoffRetryLogic ( settings , eventExecutorGroup , createClock (), logging );
264
268
}
265
269
270
+ /**
271
+ * Creates new {@link Bootstrap}.
272
+ * <p>
273
+ * <b>This method is protected only for testing</b>
274
+ */
275
+ protected Bootstrap createBootstrap ()
276
+ {
277
+ return BootstrapFactory .newBootstrap ();
278
+ }
279
+
266
280
private static SecurityPlan createSecurityPlan ( BoltServerAddress address , Config config )
267
281
{
268
282
try
0 commit comments