28
28
29
29
import java .time .Duration ;
30
30
import java .util .Collection ;
31
- import java .util .Collections ;
32
31
import java .util .concurrent .LinkedBlockingQueue ;
33
32
import java .util .concurrent .ThreadPoolExecutor ;
34
33
import javax .annotation .Nullable ;
@@ -58,17 +57,14 @@ public final class RoundRobinLoadBalancerFactory<ResolvedAddress, C extends Load
58
57
59
58
private final String id ;
60
59
private final int linearSearchSpace ;
61
- private final boolean useNewRoundRobin ;
62
60
@ Nullable
63
61
private final HealthCheckConfig healthCheckConfig ;
64
62
65
63
private RoundRobinLoadBalancerFactory (final String id ,
66
64
final int linearSearchSpace ,
67
- final boolean useNewRoundRobin ,
68
65
@ Nullable final HealthCheckConfig healthCheckConfig ) {
69
66
this .id = id ;
70
67
this .linearSearchSpace = linearSearchSpace ;
71
- this .useNewRoundRobin = useNewRoundRobin ;
72
68
this .healthCheckConfig = healthCheckConfig ;
73
69
}
74
70
@@ -78,30 +74,10 @@ public <T extends C> LoadBalancer<T> newLoadBalancer(
78
74
final String targetResource ,
79
75
final Publisher <? extends Collection <? extends ServiceDiscovererEvent <ResolvedAddress >>> eventPublisher ,
80
76
final ConnectionFactory <ResolvedAddress , T > connectionFactory ) {
81
- return useNewRoundRobin ? useNewRoundRobinLoadBalancer (targetResource , eventPublisher , connectionFactory )
82
- : new RoundRobinLoadBalancer <>(id , targetResource , eventPublisher , connectionFactory ,
77
+ return new RoundRobinLoadBalancer <>(id , targetResource , eventPublisher , connectionFactory ,
83
78
linearSearchSpace , healthCheckConfig );
84
79
}
85
80
86
- @ Override
87
- public LoadBalancer <C > newLoadBalancer (
88
- final Publisher <? extends Collection <? extends ServiceDiscovererEvent <ResolvedAddress >>> eventPublisher ,
89
- final ConnectionFactory <ResolvedAddress , C > connectionFactory ,
90
- final String targetResource ) {
91
- return useNewRoundRobin ? useNewRoundRobinLoadBalancer (targetResource , eventPublisher , connectionFactory )
92
- : new RoundRobinLoadBalancer <>(id , targetResource , eventPublisher , connectionFactory ,
93
- linearSearchSpace , healthCheckConfig );
94
- }
95
-
96
- private <T extends C > LoadBalancer <T > useNewRoundRobinLoadBalancer (
97
- final String targetResource ,
98
- final Publisher <? extends Collection <? extends ServiceDiscovererEvent <ResolvedAddress >>> eventPublisher ,
99
- final ConnectionFactory <ResolvedAddress , T > connectionFactory ) {
100
- return new DefaultLoadBalancer <>(id , targetResource , eventPublisher ,
101
- new RoundRobinSelector <>(Collections .emptyList (), targetResource , false ), connectionFactory ,
102
- linearSearchSpace , NoopLoadBalancerObserver .instance (), healthCheckConfig , null );
103
- }
104
-
105
81
@ Override
106
82
public ExecutionStrategy requiredOffloads () {
107
83
// We do not block
@@ -121,7 +97,6 @@ public static final class Builder<ResolvedAddress, C extends LoadBalancedConnect
121
97
implements RoundRobinLoadBalancerBuilder <ResolvedAddress , C > {
122
98
private final String id ;
123
99
private int linearSearchSpace = 16 ;
124
- private boolean useNewRoundRobin ;
125
100
@ Nullable
126
101
private Executor backgroundExecutor ;
127
102
private Duration healthCheckInterval = DEFAULT_HEALTH_CHECK_INTERVAL ;
@@ -153,13 +128,6 @@ public RoundRobinLoadBalancerFactory.Builder<ResolvedAddress, C> linearSearchSpa
153
128
return this ;
154
129
}
155
130
156
- // In the future we may elevate this to the RoundRobinLoadBalancerBuilder interface or pick another
157
- // route to transition to the new load balancer structure.
158
- RoundRobinLoadBalancerBuilder <ResolvedAddress , C > useNewRoundRobin (boolean useNewRoundRobin ) {
159
- this .useNewRoundRobin = useNewRoundRobin ;
160
- return this ;
161
- }
162
-
163
131
@ Override
164
132
public RoundRobinLoadBalancerFactory .Builder <ResolvedAddress , C > backgroundExecutor (
165
133
Executor backgroundExecutor ) {
@@ -217,14 +185,14 @@ public RoundRobinLoadBalancerFactory.Builder<ResolvedAddress, C> healthCheckFail
217
185
@ Override
218
186
public RoundRobinLoadBalancerFactory <ResolvedAddress , C > build () {
219
187
if (this .healthCheckFailedConnectionsThreshold < 0 ) {
220
- return new RoundRobinLoadBalancerFactory <>(id , linearSearchSpace , useNewRoundRobin , null );
188
+ return new RoundRobinLoadBalancerFactory <>(id , linearSearchSpace , null );
221
189
}
222
190
223
191
HealthCheckConfig healthCheckConfig = new HealthCheckConfig (
224
192
this .backgroundExecutor == null ? SharedExecutor .getInstance () : this .backgroundExecutor ,
225
193
healthCheckInterval , healthCheckJitter , healthCheckFailedConnectionsThreshold ,
226
194
healthCheckResubscribeInterval , healthCheckResubscribeJitter );
227
- return new RoundRobinLoadBalancerFactory <>(id , linearSearchSpace , useNewRoundRobin , healthCheckConfig );
195
+ return new RoundRobinLoadBalancerFactory <>(id , linearSearchSpace , healthCheckConfig );
228
196
}
229
197
}
230
198
0 commit comments