Skip to content

Commit 8761136

Browse files
atakavciCopilot
andauthored
[automatic failover] Implement add/remove endpoints (#4200)
* - weighted cluster seleciton - Healtstatus manager with initial listener and registration logic - pluggable health checker strategy introduced, these are draft NoOpStrategy, EchoStrategy, LagAwareStrategy, - fix failing tests impacted from weighted clusters * - add builder for ClusterConfig - add echo ot CommandObjects and UnifiedJEdis - improve StrategySupplier by accepting jedisclientconfig - adapt EchoStrategy to StrategySupplier. Now it handles the creation of connection by accepting endpoint and JedisClientConfig - make healthchecks disabled by default - drop noOpStrategy - add unit&integration tests for health check * - fix naming * clean up and mark override methods * fix link in javadoc * fix formatting * - fix double registered listeners in healtstatusmgr - clear redundant catch - replace failover options and drop failoveroptions class - remove forced_unhealthy from healthstatus - fix failback check - add disabled flag to cluster - update/fix related tests * Update src/main/java/redis/clients/jedis/mcf/EchoStrategy.java Co-authored-by: Copilot <[email protected]> * - add remove endpoints * - replace cluster disabled with failbackCandidate - replace failback enabled with failbacksupported in client - fix formatting - set defaults * - remove failback candidate - fix failing tests * - fix remove logic - fix failing tests --------- Co-authored-by: Copilot <[email protected]>
1 parent b79a9f3 commit 8761136

File tree

6 files changed

+376
-95
lines changed

6 files changed

+376
-95
lines changed

src/main/java/redis/clients/jedis/MultiClusterClientConfig.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ public static interface StrategySupplier {
147147
//////////// Failover Config ////////////
148148

149149
/** Whether to retry failed commands during failover */
150-
private boolean retryOnFailover = false;
150+
private boolean retryOnFailover;
151151

152-
/** Whether failback is enabled */
153-
private boolean failback = false;
152+
/** Whether failback is supported by client */
153+
private boolean isFailbackSupported;
154154

155155
public MultiClusterClientConfig(ClusterConfig[] clusterConfigs) {
156156
this.clusterConfigs = clusterConfigs;
@@ -220,8 +220,13 @@ public boolean isRetryOnFailover() {
220220
return retryOnFailover;
221221
}
222222

223-
public boolean isFailback() {
224-
return failback;
223+
/** Whether failback is supported by client */
224+
public boolean isFailbackSupported() {
225+
return isFailbackSupported;
226+
}
227+
228+
public static Builder builder(ClusterConfig[] clusterConfigs) {
229+
return new Builder(clusterConfigs);
225230
}
226231

227232
public static class ClusterConfig {
@@ -284,7 +289,6 @@ public static class Builder {
284289

285290
private float weight = 1.0f;
286291
private StrategySupplier healthCheckStrategySupplier = EchoStrategy.DEFAULT;
287-
private boolean healthCheckEnabled = true;
288292

289293
public Builder(HostAndPort hostAndPort, JedisClientConfig clientConfig) {
290294
this.hostAndPort = hostAndPort;
@@ -318,7 +322,6 @@ public Builder healthCheckStrategy(HealthCheckStrategy healthCheckStrategy) {
318322
}
319323

320324
public Builder healthCheckEnabled(boolean healthCheckEnabled) {
321-
this.healthCheckEnabled = healthCheckEnabled;
322325
if (!healthCheckEnabled) {
323326
this.healthCheckStrategySupplier = null;
324327
} else if (healthCheckStrategySupplier == null) {
@@ -354,7 +357,7 @@ public static class Builder {
354357
private List<Class<? extends Throwable>> fallbackExceptionList = FALLBACK_EXCEPTIONS_DEFAULT;
355358

356359
private boolean retryOnFailover = false;
357-
private boolean failback = false;
360+
private boolean isFailbackSupported = true;
358361

359362
public Builder(ClusterConfig[] clusterConfigs) {
360363

@@ -453,8 +456,8 @@ public Builder retryOnFailover(boolean retryOnFailover) {
453456
return this;
454457
}
455458

456-
public Builder failback(boolean failback) {
457-
this.failback = failback;
459+
public Builder failbackSupported(boolean supported) {
460+
this.isFailbackSupported = supported;
458461
return this;
459462
}
460463

@@ -484,7 +487,7 @@ public MultiClusterClientConfig build() {
484487
config.fallbackExceptionList = this.fallbackExceptionList;
485488

486489
config.retryOnFailover = this.retryOnFailover;
487-
config.failback = this.failback;
490+
config.isFailbackSupported = this.isFailbackSupported;
488491

489492
return config;
490493
}

0 commit comments

Comments
 (0)