34
34
import com .google .common .annotations .VisibleForTesting ;
35
35
import com .google .common .collect .ImmutableMap ;
36
36
import com .google .common .collect .ImmutableSet ;
37
- import dev .failsafe .Failsafe ;
38
- import dev .failsafe .RetryPolicy ;
39
37
import java .io .Closeable ;
40
38
import java .io .UncheckedIOException ;
41
39
import java .net .URI ;
@@ -375,7 +373,10 @@ public LocalDistributor add(Node node) {
375
373
return this ;
376
374
}
377
375
378
- updateNodeStatus (initialNodeStatus , healthCheck );
376
+ updateNodeAvailability (
377
+ initialNodeStatus .getExternalUri (),
378
+ initialNodeStatus .getNodeId (),
379
+ initialNodeStatus .getAvailability ());
379
380
380
381
LOG .info (
381
382
String .format (
@@ -387,30 +388,6 @@ public LocalDistributor add(Node node) {
387
388
return this ;
388
389
}
389
390
390
- private void updateNodeStatus (NodeStatus status , Runnable healthCheck ) {
391
- // Setting the Node as available if the initial call to status was successful.
392
- // Otherwise, retry to have it available as soon as possible.
393
- if (status .getAvailability () == UP ) {
394
- updateNodeAvailability (status .getExternalUri (), status .getNodeId (), status .getAvailability ());
395
- } else {
396
- // Running the health check right after the Node registers itself. We retry the
397
- // execution because the Node might on a complex network topology. For example,
398
- // Kubernetes pods with IPs that take a while before they are reachable.
399
- RetryPolicy <Object > initialHealthCheckPolicy =
400
- RetryPolicy .builder ()
401
- .withMaxAttempts (-1 )
402
- .withMaxDuration (Duration .ofSeconds (90 ))
403
- .withDelay (Duration .ofSeconds (15 ))
404
- .abortIf (result -> true )
405
- .build ();
406
-
407
- LOG .log (getDebugLogLevel (), "Running health check for Node " + status .getExternalUri ());
408
- ExecutorService executor = Executors .newSingleThreadExecutor ();
409
- executor .submit (() -> Failsafe .with (initialHealthCheckPolicy ).run (healthCheck ::run ));
410
- executor .shutdown ();
411
- }
412
- }
413
-
414
391
private Runnable runNodeHealthChecks () {
415
392
return () -> {
416
393
ImmutableMap <NodeId , Runnable > nodeHealthChecks ;
0 commit comments