@@ -84,15 +84,15 @@ private enum State {
84
84
@ Nullable
85
85
private final HealthIndicator healthIndicator ;
86
86
private final ConnectionPoolStrategy <C > connectionPoolStrategy ;
87
- private final LoadBalancerObserver .HostObserver < Addr > hostObserver ;
87
+ private final LoadBalancerObserver .HostObserver hostObserver ;
88
88
private final ConnectionFactory <Addr , ? extends C > connectionFactory ;
89
89
private final ListenableAsyncCloseable closeable ;
90
90
private volatile ConnState connState = new ConnState (emptyList (), State .ACTIVE , 0 , null );
91
91
92
92
DefaultHost (final String lbDescription , final Addr address ,
93
93
final ConnectionPoolStrategy <C > connectionPoolStrategy ,
94
94
final ConnectionFactory <Addr , ? extends C > connectionFactory ,
95
- final HostObserver < Addr > hostObserver , final @ Nullable HealthCheckConfig healthCheckConfig ,
95
+ final HostObserver hostObserver , final @ Nullable HealthCheckConfig healthCheckConfig ,
96
96
final @ Nullable HealthIndicator healthIndicator ) {
97
97
this .lbDescription = requireNonNull (lbDescription , "lbDescription" );
98
98
this .address = requireNonNull (address , "address" );
@@ -104,7 +104,6 @@ private enum State {
104
104
this .healthCheckConfig = healthCheckConfig ;
105
105
this .hostObserver = requireNonNull (hostObserver , "hostObserver" );
106
106
this .closeable = toAsyncCloseable (this ::doClose );
107
- hostObserver .onHostCreated (address );
108
107
}
109
108
110
109
@ Override
@@ -124,7 +123,7 @@ public boolean markActiveIfNotClosed() {
124
123
return oldConnState ;
125
124
});
126
125
if (oldState .state == State .EXPIRED ) {
127
- hostObserver .onExpiredHostRevived (address , oldState .connections .size ());
126
+ hostObserver .onExpiredHostRevived (oldState .connections .size ());
128
127
}
129
128
return oldState .state != State .CLOSED ;
130
129
}
@@ -161,7 +160,7 @@ public boolean markExpired() {
161
160
Object nextState = oldState .connections .isEmpty () ? State .CLOSED : State .EXPIRED ;
162
161
if (connStateUpdater .compareAndSet (this , oldState , oldState .toExpired ())) {
163
162
cancelIfHealthCheck (oldState );
164
- hostObserver .onHostMarkedExpired (address , oldState .connections .size ());
163
+ hostObserver .onHostMarkedExpired (oldState .connections .size ());
165
164
if (nextState == State .CLOSED ) {
166
165
// Trigger the callback to remove the host from usedHosts array.
167
166
this .closeAsync ().subscribe ();
@@ -261,7 +260,7 @@ private void markHealthy(final HealthCheck originalHealthCheckState) {
261
260
}
262
261
// Only if the previous state was a healthcheck should we notify the observer.
263
262
if (oldState .isUnhealthy ()) {
264
- hostObserver .onHostRevived (address );
263
+ hostObserver .onHostRevived ();
265
264
}
266
265
}
267
266
@@ -292,7 +291,7 @@ private void onConnectionError(Throwable cause) {
292
291
"{} time(s) in a row. Error counting threshold reached, marking this host as " +
293
292
"UNHEALTHY for the selection algorithm and triggering background health-checking." ,
294
293
lbDescription , address , healthCheckConfig .failedThreshold , cause );
295
- hostObserver .onHostMarkedUnhealthy (address , cause );
294
+ hostObserver .onHostMarkedUnhealthy (cause );
296
295
nextState .healthCheck .schedule (cause );
297
296
}
298
297
break ;
@@ -336,7 +335,7 @@ private boolean addConnection(final C connection, final @Nullable HealthCheck cu
336
335
cancelIfHealthCheck (previous );
337
336
}
338
337
// If we transitioned from unhealth to healthy we need to let the observer know.
339
- hostObserver .onHostRevived (address );
338
+ hostObserver .onHostRevived ();
340
339
}
341
340
break ;
342
341
}
@@ -373,7 +372,7 @@ private boolean addConnection(final C connection, final @Nullable HealthCheck cu
373
372
// in the next iteration.
374
373
&& connStateUpdater .compareAndSet (this , currentConnState , nextState .toClosed ())) {
375
374
closeAsync ().subscribe ();
376
- hostObserver .onExpiredHostRemoved (address , nextState .connections .size ());
375
+ hostObserver .onExpiredHostRemoved (nextState .connections .size ());
377
376
break ;
378
377
}
379
378
} else {
@@ -426,9 +425,9 @@ private Completable doClose(final boolean graceful) {
426
425
LOGGER .debug ("{}: closing {} connection(s) {}gracefully to the closed address: {}." ,
427
426
lbDescription , oldState .connections .size (), graceful ? "" : "un" , address );
428
427
if (oldState .state == State .ACTIVE ) {
429
- hostObserver .onActiveHostRemoved (address , oldState .connections .size ());
428
+ hostObserver .onActiveHostRemoved (oldState .connections .size ());
430
429
} else if (oldState .state == State .EXPIRED ) {
431
- hostObserver .onExpiredHostRemoved (address , oldState .connections .size ());
430
+ hostObserver .onExpiredHostRemoved (oldState .connections .size ());
432
431
}
433
432
final List <C > connections = oldState .connections ;
434
433
return (connections .isEmpty () ? completed () :
0 commit comments