3434import com .google .common .annotations .VisibleForTesting ;
3535import com .google .common .collect .ImmutableMap ;
3636import com .google .common .collect .ImmutableSet ;
37- import dev .failsafe .Failsafe ;
38- import dev .failsafe .RetryPolicy ;
3937import java .io .Closeable ;
4038import java .io .UncheckedIOException ;
4139import java .net .URI ;
@@ -375,7 +373,10 @@ public LocalDistributor add(Node node) {
375373 return this ;
376374 }
377375
378- updateNodeStatus (initialNodeStatus , healthCheck );
376+ updateNodeAvailability (
377+ initialNodeStatus .getExternalUri (),
378+ initialNodeStatus .getNodeId (),
379+ initialNodeStatus .getAvailability ());
379380
380381 LOG .info (
381382 String .format (
@@ -387,30 +388,6 @@ public LocalDistributor add(Node node) {
387388 return this ;
388389 }
389390
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-
414391 private Runnable runNodeHealthChecks () {
415392 return () -> {
416393 ImmutableMap <NodeId , Runnable > nodeHealthChecks ;
0 commit comments