@@ -280,8 +280,7 @@ private void handleStatusChange(HealthStatusChangeEvent eventArgs) {
280
280
clusterWithHealthChange .setHealthStatus (newStatus );
281
281
282
282
if (newStatus .isHealthy ()) {
283
- if (clusterWithHealthChange .isFailbackSupported () && clusterWithHealthChange .isFailbackCandidate ()
284
- && activeCluster != clusterWithHealthChange ) {
283
+ if (clusterWithHealthChange .isFailbackSupported () && activeCluster != clusterWithHealthChange ) {
285
284
// lets check if weighted switching is possible
286
285
Map .Entry <Endpoint , Cluster > failbackCluster = findWeightedHealthyClusterToIterate ();
287
286
if (failbackCluster == clusterWithHealthChange
@@ -307,9 +306,6 @@ public Endpoint iterateActiveCluster() {
307
306
Cluster cluster = clusterToIterate .getValue ();
308
307
boolean changed = setActiveCluster (cluster , false );
309
308
if (!changed ) return null ;
310
- if (cluster .isFailbackSupported ()) {
311
- cluster .setFailbackCandidate (false );
312
- }
313
309
return clusterToIterate .getKey ();
314
310
}
315
311
@@ -471,9 +467,7 @@ public static class Cluster {
471
467
// it starts its life with the assumption of being healthy
472
468
private HealthStatus healthStatus = HealthStatus .HEALTHY ;
473
469
private MultiClusterClientConfig multiClusterClientConfig ;
474
- // it starts its life as a failback candidate,
475
- // this changes under the condition that cluster failover to another and failback is not supported by client
476
- private boolean failbackCandidate = true ;
470
+ private boolean disabled = false ;
477
471
478
472
public Cluster (ConnectionPool connectionPool , Retry retry , CircuitBreaker circuitBreaker , float weight ,
479
473
MultiClusterClientConfig multiClusterClientConfig ) {
@@ -520,26 +514,19 @@ public boolean isCBForcedOpen() {
520
514
}
521
515
522
516
public boolean isHealthy () {
523
- return healthStatus .isHealthy () && !isCBForcedOpen ();
517
+ return healthStatus .isHealthy () && !isCBForcedOpen () && ! disabled ;
524
518
}
525
519
526
- /**
527
- * Whether this cluster is a failback candidate Cluster starts its life as a failback candidate, this changes
528
- * under the condition that cluster failover to another and failback is not supported by client
529
- */
530
- public boolean isFailbackCandidate () {
531
- return failbackCandidate ;
520
+ public boolean retryOnFailover () {
521
+ return multiClusterClientConfig .isRetryOnFailover ();
532
522
}
533
523
534
- /**
535
- * Sets this cluster as a failback candidate
536
- */
537
- public void setFailbackCandidate (boolean failbackCandidate ) {
538
- this .failbackCandidate = failbackCandidate ;
524
+ public boolean isDisabled () {
525
+ return disabled ;
539
526
}
540
527
541
- public boolean retryOnFailover ( ) {
542
- return multiClusterClientConfig . isRetryOnFailover () ;
528
+ public void setDisabled ( boolean disabled ) {
529
+ this . disabled = disabled ;
543
530
}
544
531
545
532
/**
@@ -553,8 +540,7 @@ public boolean isFailbackSupported() {
553
540
public String toString () {
554
541
return circuitBreaker .getName () + "{" + "connectionPool=" + connectionPool + ", retry=" + retry
555
542
+ ", circuitBreaker=" + circuitBreaker + ", weight=" + weight + ", healthStatus=" + healthStatus
556
- + ", multiClusterClientConfig=" + multiClusterClientConfig + ", failbackCandidate=" + failbackCandidate
557
- + '}' ;
543
+ + ", multiClusterClientConfig=" + multiClusterClientConfig + '}' ;
558
544
}
559
545
}
560
546
0 commit comments