Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ static final class EndpointState {
private final long probeIntervalSeconds;
private final Duration idleEvictionDuration;
private final Clock clock;
private final boolean enableBackgroundProbing;
private final String defaultEndpointAddress;

private ScheduledFuture<?> evictionFuture;
Expand Down Expand Up @@ -161,10 +162,26 @@ private PendingActiveAddressUpdate(Set<String> activeAddresses, long generation)
long probeIntervalSeconds,
Duration idleEvictionDuration,
Clock clock) {
this(
endpointCache,
probeIntervalSeconds,
idleEvictionDuration,
clock,
/* enableBackgroundProbing= */ true);
}

@VisibleForTesting
EndpointLifecycleManager(
ChannelEndpointCache endpointCache,
long probeIntervalSeconds,
Duration idleEvictionDuration,
Clock clock,
boolean enableBackgroundProbing) {
this.endpointCache = endpointCache;
this.probeIntervalSeconds = probeIntervalSeconds;
this.idleEvictionDuration = idleEvictionDuration;
this.clock = clock;
this.enableBackgroundProbing = enableBackgroundProbing;
this.defaultEndpointAddress = endpointCache.defaultChannel().getAddress();
this.activeAddressUpdateExecutor =
Executors.newSingleThreadExecutor(
Expand Down Expand Up @@ -439,6 +456,9 @@ private void createAndStartProbing(String address) {

/** Starts periodic probing for an endpoint. */
private void startProbing(String address) {
if (!enableBackgroundProbing) {
return;
}
EndpointState state = endpoints.get(address);
if (state == null || isShutdown.get()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,11 @@ public void transientFailureOscillationWithConnectingStillEvictsEndpoint() throw
KeyRangeCacheTest.FakeEndpointCache cache = new KeyRangeCacheTest.FakeEndpointCache();
manager =
new EndpointLifecycleManager(
cache, /* probeIntervalSeconds= */ 60, Duration.ofMinutes(30), Clock.systemUTC());
cache,
/* probeIntervalSeconds= */ 60,
Duration.ofMinutes(30),
Clock.systemUTC(),
/* enableBackgroundProbing= */ false);

registerAddresses(manager, "server1");
awaitCondition(
Expand Down Expand Up @@ -310,7 +314,11 @@ public void readyResetsTransientFailureCounterAfterRecovery() throws Exception {
KeyRangeCacheTest.FakeEndpointCache cache = new KeyRangeCacheTest.FakeEndpointCache();
manager =
new EndpointLifecycleManager(
cache, /* probeIntervalSeconds= */ 60, Duration.ofMinutes(30), Clock.systemUTC());
cache,
/* probeIntervalSeconds= */ 60,
Duration.ofMinutes(30),
Clock.systemUTC(),
/* enableBackgroundProbing= */ false);

registerAddresses(manager, "server1");
awaitCondition(
Expand Down
Loading