Commit d9f375a 1 parent ad2bbbb commit d9f375a Copy full SHA for d9f375a
File tree 3 files changed +20
-3
lines changed
servicetalk-loadbalancer-experimental/src
main/java/io/servicetalk/loadbalancer
test/java/io/servicetalk/loadbalancer
3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -456,10 +456,13 @@ public int score() {
456
456
@ Override
457
457
public String toString () {
458
458
final ConnState connState = this .connState ;
459
- return "Host{" +
459
+ String stateString = connState .isUnhealthy () ? State .UNHEALTHY + "(" + connState .healthCheck + ")" :
460
+ connState .state .toString ();
461
+ return "DefaultHost{" +
460
462
"lbDescription=" + lbDescription +
461
463
", address=" + address +
462
- ", state=" + connState .state +
464
+ ", state=" + stateString +
465
+ ", healthIndicator=" + healthIndicator +
463
466
", #connections=" + connState .connections .size () +
464
467
'}' ;
465
468
}
@@ -514,7 +517,7 @@ public void schedule(final Throwable originalCause) {
514
517
515
518
@ Override
516
519
public String toString () {
517
- return "UNHEALTHY (" + lastError + ')' ;
520
+ return "HealthCheck (" + lastError + ')' ;
518
521
}
519
522
}
520
523
Original file line number Diff line number Diff line change @@ -257,6 +257,16 @@ public final void cancel() {
257
257
sequentialExecutor .execute (this ::sequentialCancel );
258
258
}
259
259
260
+ @ Override
261
+ public String toString () {
262
+ return "XdsHealthIndicator{" +
263
+ ", consecutive5xx=" + consecutive5xx .get () +
264
+ ", successes=" + successes .get () +
265
+ ", failures=" + failures .get () +
266
+ ", evictedUntilNanos=" + evictedUntilNanos +
267
+ '}' ;
268
+ }
269
+
260
270
void sequentialCancel () {
261
271
assert sequentialExecutor .isCurrentThreadDraining ();
262
272
if (cancelled ) {
Original file line number Diff line number Diff line change 35
35
import static io .servicetalk .loadbalancer .HealthCheckConfig .DEFAULT_HEALTH_CHECK_FAILED_CONNECTIONS_THRESHOLD ;
36
36
import static io .servicetalk .loadbalancer .UnhealthyHostConnectionFactory .UNHEALTHY_HOST_EXCEPTION ;
37
37
import static org .hamcrest .MatcherAssert .assertThat ;
38
+ import static org .hamcrest .Matchers .containsString ;
38
39
import static org .hamcrest .Matchers .is ;
39
40
import static org .junit .jupiter .api .Assertions .assertEquals ;
40
41
import static org .junit .jupiter .api .Assertions .assertThrows ;
@@ -182,6 +183,9 @@ void hostStatus() throws Exception {
182
183
assertThrows (ExecutionException .class ,
183
184
() -> host .newConnection (any (), false , null ).toFuture ().get ());
184
185
}
186
+ assertThat (host .toString (), containsString ("UNHEALTHY" ));
187
+ assertThat (host .toString (), containsString ("DeliberateException" ));
188
+
185
189
verify (mockHostObserver , times (1 )).onHostMarkedUnhealthy (UNHEALTHY_HOST_EXCEPTION );
186
190
assertThat (host .isHealthy (), is (false ));
187
191
assertThat (host .canMakeNewConnections (), is (true ));
You can’t perform that action at this time.
0 commit comments