Skip to content

Commit 940233e

Browse files
committed
Delete ConfigBuilder.withRoutingFailureLimit and ConfigBuilder.withRoutingRetryDelay
1 parent 33447f5 commit 940233e

File tree

6 files changed

+31
-152
lines changed

6 files changed

+31
-152
lines changed

driver/clirr-ignored-differences.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,16 @@
6767
<method>void reset()</method>
6868
</difference>
6969

70+
<difference>
71+
<className>org/neo4j/driver/Config$ConfigBuilder</className>
72+
<differenceType>7002</differenceType>
73+
<method>org.neo4j.driver.Config$ConfigBuilder withRoutingFailureLimit(int)</method>
74+
</difference>
75+
76+
<difference>
77+
<className>org/neo4j/driver/Config$ConfigBuilder</className>
78+
<differenceType>7002</differenceType>
79+
<method>org.neo4j.driver.Config$ConfigBuilder withRoutingRetryDelay(long, java.util.concurrent.TimeUnit)</method>
80+
</difference>
81+
7082
</differences>

driver/src/main/java/org/neo4j/driver/Config.java

Lines changed: 1 addition & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ public class Config implements Serializable
8383

8484
private final SecuritySettings securitySettings;
8585

86-
private final int routingFailureLimit;
87-
private final long routingRetryDelayMillis;
8886
private final long fetchSize;
8987
private final long routingTablePurgeDelayMillis;
9088

@@ -109,8 +107,6 @@ private Config( ConfigBuilder builder )
109107

110108
this.securitySettings = builder.securitySettingsBuilder.build();
111109

112-
this.routingFailureLimit = builder.routingFailureLimit;
113-
this.routingRetryDelayMillis = builder.routingRetryDelayMillis;
114110
this.connectionTimeoutMillis = builder.connectionTimeoutMillis;
115111
this.routingTablePurgeDelayMillis = builder.routingTablePurgeDelayMillis;
116112
this.retrySettings = builder.retrySettings;
@@ -233,7 +229,7 @@ SecuritySettings securitySettings()
233229

234230
RoutingSettings routingSettings()
235231
{
236-
return new RoutingSettings( routingFailureLimit, routingRetryDelayMillis, routingTablePurgeDelayMillis );
232+
return new RoutingSettings( routingTablePurgeDelayMillis );
237233
}
238234

239235
RetrySettings retrySettings()
@@ -280,8 +276,6 @@ public static class ConfigBuilder
280276
private long connectionAcquisitionTimeoutMillis = PoolSettings.DEFAULT_CONNECTION_ACQUISITION_TIMEOUT;
281277
private String userAgent = format( "neo4j-java/%s", driverVersion() );
282278
private final SecuritySettings.SecuritySettingsBuilder securitySettingsBuilder = new SecuritySettings.SecuritySettingsBuilder();
283-
private int routingFailureLimit = RoutingSettings.DEFAULT.maxRoutingFailures();
284-
private long routingRetryDelayMillis = RoutingSettings.DEFAULT.retryTimeoutDelay();
285279
private long routingTablePurgeDelayMillis = RoutingSettings.DEFAULT.routingTablePurgeDelayMs();
286280
private int connectionTimeoutMillis = (int) TimeUnit.SECONDS.toMillis( 30 );
287281
private RetrySettings retrySettings = RetrySettings.DEFAULT;
@@ -487,86 +481,6 @@ public ConfigBuilder withTrustStrategy( TrustStrategy trustStrategy )
487481
return this;
488482
}
489483

490-
/**
491-
* Specify how many times the client should attempt to reconnect to the routing servers before declaring the
492-
* cluster unavailable.
493-
* <p>
494-
* The routing servers are tried in order. If connecting any of them fails, they are all retried after
495-
* {@linkplain #withRoutingRetryDelay a delay}. This process of retrying all servers is then repeated for the
496-
* number of times specified here before considering the cluster unavailable.
497-
* <p>
498-
* The default value of this parameter is {@code 1}, which means that the the driver will not re-attempt to
499-
* connect to the cluster when connecting has failed to each individual server in the list of routers. This
500-
* default value is sensible under this assumption that if the attempt to connect fails for all servers, then
501-
* the entire cluster is down, or the client is disconnected from the network, and retrying to connect will
502-
* not bring it back up, in which case it is better to report the failure sooner.
503-
*
504-
* @param routingFailureLimit
505-
* the number of times to retry each server in the list of routing servers
506-
* @return this builder
507-
* @deprecated in 1.2 because driver memorizes seed URI used during construction and falls back to it at
508-
* runtime when all other known router servers failed to respond. Driver is also able to perform DNS lookup
509-
* for the seed URI during rediscovery. This means updates of cluster members will be picked up if they are
510-
* reflected in a DNS record. This configuration allowed driver to retry rediscovery procedure and postpone
511-
* failure. Currently there exists a better way of doing retries via
512-
* {@link Session#readTransaction(TransactionWork)} and {@link Session#writeTransaction(TransactionWork)}.
513-
* <b>Method will be removed in the next major release.</b>
514-
*/
515-
@Deprecated
516-
public ConfigBuilder withRoutingFailureLimit( int routingFailureLimit )
517-
{
518-
if ( routingFailureLimit < 1 )
519-
{
520-
throw new IllegalArgumentException(
521-
"The failure limit may not be smaller than 1, but was: " + routingFailureLimit );
522-
}
523-
this.routingFailureLimit = routingFailureLimit;
524-
return this;
525-
}
526-
527-
/**
528-
* Specify how long to wait before retrying to connect to a routing server.
529-
* <p>
530-
* When connecting to all routing servers fail, connecting will be retried after the delay specified here.
531-
* The delay is measured from when the first attempt to connect was made, so that the delay time specifies a
532-
* retry interval.
533-
* <p>
534-
* For each {@linkplain #withRoutingFailureLimit retry attempt} the delay time will be doubled. The time
535-
* specified here is the base time, i.e. the time to wait before the first retry. If that attempt (on all
536-
* servers) also fails, the delay before the next retry will be double the time specified here, and the next
537-
* attempt after that will be double that, et.c. So if, for example, the delay specified here is
538-
* {@code 5 SECONDS}, then after attempting to connect to each server fails reconnecting will be attempted
539-
* 5 seconds after the first connection attempt to the first server. If that attempt also fails to connect to
540-
* all servers, the next attempt will start 10 seconds after the second attempt started.
541-
* <p>
542-
* The default value of this parameter is {@code 5 SECONDS}.
543-
*
544-
* @param delay
545-
* the amount of time between attempts to reconnect to the same server
546-
* @param unit
547-
* the unit in which the duration is given
548-
* @return this builder
549-
* @deprecated in 1.2 because driver memorizes seed URI used during construction and falls back to it at
550-
* runtime when all other known router servers failed to respond. Driver is also able to perform DNS lookup
551-
* for the seed URI during rediscovery. This means updates of cluster members will be picked up if they are
552-
* reflected in a DNS record. This configuration allowed driver to retry rediscovery procedure and postpone
553-
* failure. Currently there exists a better way of doing retries via
554-
* {@link Session#readTransaction(TransactionWork)} and {@link Session#writeTransaction(TransactionWork)}.
555-
* <b>Method will be removed in the next major release.</b>
556-
*/
557-
@Deprecated
558-
public ConfigBuilder withRoutingRetryDelay( long delay, TimeUnit unit )
559-
{
560-
long routingRetryDelayMillis = unit.toMillis( delay );
561-
if ( routingRetryDelayMillis < 0 )
562-
{
563-
throw new IllegalArgumentException( String.format(
564-
"The retry delay may not be smaller than 0, but was %d %s.", delay, unit ) );
565-
}
566-
this.routingRetryDelayMillis = routingRetryDelayMillis;
567-
return this;
568-
}
569-
570484
/**
571485
* Specify how long to wait before purging stale routing tables.
572486
* <p>

driver/src/main/java/org/neo4j/driver/internal/cluster/RediscoveryImpl.java

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
*/
1919
package org.neo4j.driver.internal.cluster;
2020

21-
import io.netty.util.concurrent.EventExecutorGroup;
22-
2321
import java.net.UnknownHostException;
2422
import java.util.Collection;
2523
import java.util.HashSet;
@@ -29,7 +27,6 @@
2927
import java.util.concurrent.CompletableFuture;
3028
import java.util.concurrent.CompletionException;
3129
import java.util.concurrent.CompletionStage;
32-
import java.util.concurrent.TimeUnit;
3330

3431
import org.neo4j.driver.Bookmark;
3532
import org.neo4j.driver.Logger;
@@ -67,22 +64,18 @@ public class RediscoveryImpl implements Rediscovery
6764
private static final String INVALID_BOOKMARK_MIXTURE_CODE = "Neo.ClientError.Transaction.InvalidBookmarkMixture";
6865

6966
private final BoltServerAddress initialRouter;
70-
private final RoutingSettings settings;
7167
private final Logger log;
7268
private final ClusterCompositionProvider provider;
7369
private final ServerAddressResolver resolver;
74-
private final EventExecutorGroup eventExecutorGroup;
7570
private final DomainNameResolver domainNameResolver;
7671

77-
public RediscoveryImpl( BoltServerAddress initialRouter, RoutingSettings settings, ClusterCompositionProvider provider,
78-
EventExecutorGroup eventExecutorGroup, ServerAddressResolver resolver, Logging logging, DomainNameResolver domainNameResolver )
72+
public RediscoveryImpl( BoltServerAddress initialRouter, ClusterCompositionProvider provider, ServerAddressResolver resolver, Logging logging,
73+
DomainNameResolver domainNameResolver )
7974
{
8075
this.initialRouter = initialRouter;
81-
this.settings = settings;
8276
this.log = logging.getLog( getClass() );
8377
this.provider = provider;
8478
this.resolver = resolver;
85-
this.eventExecutorGroup = eventExecutorGroup;
8679
this.domainNameResolver = requireNonNull( domainNameResolver );
8780
}
8881

@@ -101,13 +94,12 @@ public CompletionStage<ClusterCompositionLookupResult> lookupClusterComposition(
10194
CompletableFuture<ClusterCompositionLookupResult> result = new CompletableFuture<>();
10295
// if we failed discovery, we will chain all errors into this one.
10396
ServiceUnavailableException baseError = new ServiceUnavailableException( String.format( NO_ROUTERS_AVAILABLE, routingTable.database().description() ) );
104-
lookupClusterComposition( routingTable, connectionPool, 0, 0, result, bookmark, impersonatedUser, baseError );
97+
lookupClusterComposition( routingTable, connectionPool, result, bookmark, impersonatedUser, baseError );
10598
return result;
10699
}
107100

108-
private void lookupClusterComposition( RoutingTable routingTable, ConnectionPool pool, int failures, long previousDelay,
109-
CompletableFuture<ClusterCompositionLookupResult> result, Bookmark bookmark, String impersonatedUser,
110-
Throwable baseError )
101+
private void lookupClusterComposition( RoutingTable routingTable, ConnectionPool pool, CompletableFuture<ClusterCompositionLookupResult> result,
102+
Bookmark bookmark, String impersonatedUser, Throwable baseError )
111103
{
112104
lookup( routingTable, pool, bookmark, impersonatedUser, baseError )
113105
.whenComplete(
@@ -124,22 +116,7 @@ else if ( compositionLookupResult != null )
124116
}
125117
else
126118
{
127-
int newFailures = failures + 1;
128-
if ( newFailures >= settings.maxRoutingFailures() )
129-
{
130-
// now we throw our saved error out
131-
result.completeExceptionally( baseError );
132-
}
133-
else
134-
{
135-
long nextDelay = Math.max( settings.retryTimeoutDelay(), previousDelay * 2 );
136-
log.info( "Unable to fetch new routing table, will try again in " + nextDelay + "ms" );
137-
eventExecutorGroup.next().schedule(
138-
() -> lookupClusterComposition( routingTable, pool, newFailures, nextDelay, result, bookmark, impersonatedUser,
139-
baseError ),
140-
nextDelay, TimeUnit.MILLISECONDS
141-
);
142-
}
119+
result.completeExceptionally( baseError );
143120
}
144121
} );
145122
}

driver/src/main/java/org/neo4j/driver/internal/cluster/RoutingSettings.java

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,39 +23,25 @@
2323
public class RoutingSettings
2424
{
2525
public static final long STALE_ROUTING_TABLE_PURGE_DELAY_MS = SECONDS.toMillis( 30 );
26-
public static final RoutingSettings DEFAULT = new RoutingSettings( 1, SECONDS.toMillis( 5 ), STALE_ROUTING_TABLE_PURGE_DELAY_MS );
26+
public static final RoutingSettings DEFAULT = new RoutingSettings( STALE_ROUTING_TABLE_PURGE_DELAY_MS );
2727

28-
private final int maxRoutingFailures;
29-
private final long retryTimeoutDelay;
3028
private final RoutingContext routingContext;
3129
private final long routingTablePurgeDelayMs;
3230

33-
public RoutingSettings( int maxRoutingFailures, long retryTimeoutDelay, long routingTablePurgeDelayMs )
31+
public RoutingSettings( long routingTablePurgeDelayMs )
3432
{
35-
this( maxRoutingFailures, retryTimeoutDelay, routingTablePurgeDelayMs, RoutingContext.EMPTY );
33+
this( routingTablePurgeDelayMs, RoutingContext.EMPTY );
3634
}
3735

38-
public RoutingSettings( int maxRoutingFailures, long retryTimeoutDelay, long routingTablePurgeDelayMs, RoutingContext routingContext )
36+
public RoutingSettings( long routingTablePurgeDelayMs, RoutingContext routingContext )
3937
{
40-
this.maxRoutingFailures = maxRoutingFailures;
41-
this.retryTimeoutDelay = retryTimeoutDelay;
4238
this.routingContext = routingContext;
4339
this.routingTablePurgeDelayMs = routingTablePurgeDelayMs;
4440
}
4541

4642
public RoutingSettings withRoutingContext( RoutingContext newRoutingContext )
4743
{
48-
return new RoutingSettings( maxRoutingFailures, retryTimeoutDelay, routingTablePurgeDelayMs, newRoutingContext );
49-
}
50-
51-
public int maxRoutingFailures()
52-
{
53-
return maxRoutingFailures;
54-
}
55-
56-
public long retryTimeoutDelay()
57-
{
58-
return retryTimeoutDelay;
44+
return new RoutingSettings( routingTablePurgeDelayMs, newRoutingContext );
5945
}
6046

6147
public RoutingContext routingContext()

driver/src/main/java/org/neo4j/driver/internal/cluster/loadbalancing/LoadBalancer.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public class LoadBalancer implements ConnectionProvider
6767
"Failed to obtain connection towards %s server. Known routing table is: %s";
6868
private static final String CONNECTION_ACQUISITION_ATTEMPT_FAILURE_MESSAGE =
6969
"Failed to obtain a connection towards address %s, will try other addresses if available. Complete failure is reported separately from this entry.";
70-
private static final BoltServerAddress[] BOLT_SERVER_ADDRESSES_EMPTY_ARRAY = new BoltServerAddress[0];
7170
private final ConnectionPool connectionPool;
7271
private final RoutingTableRegistry routingTables;
7372
private final LoadBalancingStrategy loadBalancingStrategy;
@@ -79,7 +78,7 @@ public LoadBalancer( BoltServerAddress initialRouter, RoutingSettings settings,
7978
EventExecutorGroup eventExecutorGroup, Clock clock, Logging logging,
8079
LoadBalancingStrategy loadBalancingStrategy, ServerAddressResolver resolver, DomainNameResolver domainNameResolver )
8180
{
82-
this( connectionPool, createRediscovery( eventExecutorGroup, initialRouter, resolver, settings, clock, logging, requireNonNull( domainNameResolver ) ),
81+
this( connectionPool, createRediscovery( initialRouter, resolver, settings, clock, logging, requireNonNull( domainNameResolver ) ),
8382
settings, loadBalancingStrategy, eventExecutorGroup, clock, logging );
8483
}
8584

@@ -272,11 +271,11 @@ private static RoutingTableRegistry createRoutingTables( ConnectionPool connecti
272271
return new RoutingTableRegistryImpl( connectionPool, rediscovery, clock, logging, settings.routingTablePurgeDelayMs() );
273272
}
274273

275-
private static Rediscovery createRediscovery( EventExecutorGroup eventExecutorGroup, BoltServerAddress initialRouter, ServerAddressResolver resolver,
274+
private static Rediscovery createRediscovery( BoltServerAddress initialRouter, ServerAddressResolver resolver,
276275
RoutingSettings settings, Clock clock, Logging logging, DomainNameResolver domainNameResolver )
277276
{
278277
ClusterCompositionProvider clusterCompositionProvider = new RoutingProcedureClusterCompositionProvider( clock, settings.routingContext() );
279-
return new RediscoveryImpl( initialRouter, settings, clusterCompositionProvider, eventExecutorGroup, resolver, logging, domainNameResolver );
278+
return new RediscoveryImpl( initialRouter, clusterCompositionProvider, resolver, logging, domainNameResolver );
280279
}
281280

282281
private static RuntimeException unknownMode( AccessMode mode )

0 commit comments

Comments
 (0)