@@ -93,7 +93,8 @@ public void ensureRoutingShouldUpdateRoutingTableAndPurgeConnectionPoolWhenStale
9393 when ( routingTable .update ( any ( ClusterComposition .class ) ) ).thenReturn ( set );
9494
9595 // when
96- LoadBalancer balancer = new LoadBalancer ( conns , routingTable , rediscovery , DEV_NULL_LOGGER );
96+ LoadBalancer balancer = new LoadBalancer ( conns , routingTable , rediscovery , DEV_NULL_LOGGER ,
97+ new LeastConnectedLoadBalancingStrategy ( conns ) );
9798
9899 // then
99100 assertNotNull ( balancer );
@@ -109,7 +110,8 @@ public void shouldRefreshRoutingTableOnInitialization() throws Exception
109110 // given & when
110111 final AtomicInteger refreshRoutingTableCounter = new AtomicInteger ( 0 );
111112 LoadBalancer balancer = new LoadBalancer ( mock ( ConnectionPool .class ), mock ( RoutingTable .class ),
112- mock ( Rediscovery .class ), DEV_NULL_LOGGER )
113+ mock ( Rediscovery .class ), DEV_NULL_LOGGER ,
114+ new LeastConnectedLoadBalancingStrategy ( mock ( ConnectionPool .class ) ) )
113115 {
114116 @ Override
115117 synchronized void refreshRoutingTable ()
@@ -163,7 +165,8 @@ public void shouldForgetAddressAndItsConnectionsOnServiceUnavailableWhileClosing
163165 RoutingTable routingTable = mock ( RoutingTable .class );
164166 ConnectionPool connectionPool = mock ( ConnectionPool .class );
165167 Rediscovery rediscovery = mock ( Rediscovery .class );
166- LoadBalancer loadBalancer = new LoadBalancer ( connectionPool , routingTable , rediscovery , DEV_NULL_LOGGER );
168+ LoadBalancer loadBalancer = new LoadBalancer ( connectionPool , routingTable , rediscovery , DEV_NULL_LOGGER ,
169+ new LeastConnectedLoadBalancingStrategy ( connectionPool ) );
167170 BoltServerAddress address = new BoltServerAddress ( "host" , 42 );
168171
169172 PooledConnection connection = newConnectionWithFailingSync ( address );
@@ -197,7 +200,8 @@ public void shouldForgetAddressAndItsConnectionsOnServiceUnavailableWhileClosing
197200 PooledConnection connectionWithFailingSync = newConnectionWithFailingSync ( address );
198201 when ( connectionPool .acquire ( any ( BoltServerAddress .class ) ) ).thenReturn ( connectionWithFailingSync );
199202 Rediscovery rediscovery = mock ( Rediscovery .class );
200- LoadBalancer loadBalancer = new LoadBalancer ( connectionPool , routingTable , rediscovery , DEV_NULL_LOGGER );
203+ LoadBalancer loadBalancer = new LoadBalancer ( connectionPool , routingTable , rediscovery , DEV_NULL_LOGGER ,
204+ new LeastConnectedLoadBalancingStrategy ( connectionPool ) );
201205
202206 Session session = newSession ( loadBalancer );
203207 // begin transaction to make session obtain a connection
@@ -243,7 +247,8 @@ public void shouldThrowWhenRediscoveryReturnsNoSuitableServers()
243247 when ( routingTable .readers () ).thenReturn ( new AddressSet () );
244248 when ( routingTable .writers () ).thenReturn ( new AddressSet () );
245249
246- LoadBalancer loadBalancer = new LoadBalancer ( connections , routingTable , rediscovery , DEV_NULL_LOGGER );
250+ LoadBalancer loadBalancer = new LoadBalancer ( connections , routingTable , rediscovery , DEV_NULL_LOGGER ,
251+ new LeastConnectedLoadBalancingStrategy ( connections ) );
247252
248253 try
249254 {
@@ -283,7 +288,8 @@ public void shouldSelectLeastConnectedAddress()
283288
284289 Rediscovery rediscovery = mock ( Rediscovery .class );
285290
286- LoadBalancer loadBalancer = new LoadBalancer ( connectionPool , routingTable , rediscovery , DEV_NULL_LOGGER );
291+ LoadBalancer loadBalancer = new LoadBalancer ( connectionPool , routingTable , rediscovery , DEV_NULL_LOGGER ,
292+ new LeastConnectedLoadBalancingStrategy ( connectionPool ) );
287293
288294 Set <BoltServerAddress > seenAddresses = new HashSet <>();
289295 for ( int i = 0 ; i < 10 ; i ++ )
@@ -309,7 +315,8 @@ public void shouldRoundRobinWhenNoActiveConnections()
309315
310316 Rediscovery rediscovery = mock ( Rediscovery .class );
311317
312- LoadBalancer loadBalancer = new LoadBalancer ( connectionPool , routingTable , rediscovery , DEV_NULL_LOGGER );
318+ LoadBalancer loadBalancer = new LoadBalancer ( connectionPool , routingTable , rediscovery , DEV_NULL_LOGGER ,
319+ new LeastConnectedLoadBalancingStrategy ( connectionPool ) );
313320
314321 Set <BoltServerAddress > seenAddresses = new HashSet <>();
315322 for ( int i = 0 ; i < 10 ; i ++ )
@@ -330,7 +337,8 @@ private void testRediscoveryWhenStale( AccessMode mode )
330337 RoutingTable routingTable = newStaleRoutingTableMock ( mode );
331338 Rediscovery rediscovery = newRediscoveryMock ();
332339
333- LoadBalancer loadBalancer = new LoadBalancer ( connections , routingTable , rediscovery , DEV_NULL_LOGGER );
340+ LoadBalancer loadBalancer = new LoadBalancer ( connections , routingTable , rediscovery , DEV_NULL_LOGGER ,
341+ new LeastConnectedLoadBalancingStrategy ( connections ) );
334342 verify ( rediscovery ).lookupClusterComposition ( routingTable , connections );
335343
336344 assertNotNull ( loadBalancer .acquireConnection ( mode ) );
@@ -346,7 +354,8 @@ private void testNoRediscoveryWhenNotStale( AccessMode staleMode, AccessMode not
346354 RoutingTable routingTable = newStaleRoutingTableMock ( staleMode );
347355 Rediscovery rediscovery = newRediscoveryMock ();
348356
349- LoadBalancer loadBalancer = new LoadBalancer ( connections , routingTable , rediscovery , DEV_NULL_LOGGER );
357+ LoadBalancer loadBalancer = new LoadBalancer ( connections , routingTable , rediscovery , DEV_NULL_LOGGER ,
358+ new LeastConnectedLoadBalancingStrategy ( connections ) );
350359 verify ( rediscovery ).lookupClusterComposition ( routingTable , connections );
351360
352361 assertNotNull ( loadBalancer .acquireConnection ( notStaleMode ) );
@@ -379,7 +388,8 @@ private LoadBalancer setupLoadBalancer( PooledConnection writerConn, PooledConne
379388 when ( routingTable .readers () ).thenReturn ( readerAddrs );
380389 when ( routingTable .writers () ).thenReturn ( writerAddrs );
381390
382- return new LoadBalancer ( connPool , routingTable , rediscovery , DEV_NULL_LOGGER );
391+ return new LoadBalancer ( connPool , routingTable , rediscovery , DEV_NULL_LOGGER ,
392+ new LeastConnectedLoadBalancingStrategy ( connPool ) );
383393 }
384394
385395 private static Session newSession ( LoadBalancer loadBalancer )
0 commit comments