64
64
import java .util .concurrent .locks .ReadWriteLock ;
65
65
import java .util .concurrent .locks .ReentrantReadWriteLock ;
66
66
import java .util .function .Supplier ;
67
+ import java .util .logging .Level ;
67
68
import java .util .logging .Logger ;
68
69
import java .util .stream .Collectors ;
69
70
import java .util .stream .Stream ;
@@ -274,6 +275,8 @@ boolean allBucketsSameSize(Map<String, Set<Host>> hostBuckets) {
274
275
private void refresh (NodeStatus status ) {
275
276
Objects .requireNonNull (status );
276
277
278
+ LOG .fine ("Refreshing: " + status .getUri ());
279
+
277
280
// Iterate over the available nodes to find a match.
278
281
Lock writeLock = lock .writeLock ();
279
282
writeLock .lock ();
@@ -282,12 +285,13 @@ private void refresh(NodeStatus status) {
282
285
.filter (host -> host .getId ().equals (status .getNodeId ()))
283
286
.findFirst ();
284
287
285
-
286
288
if (existing .isPresent ()) {
287
289
// Modify the state
290
+ LOG .fine ("Modifying existing state" );
288
291
existing .get ().update (status );
289
292
} else {
290
293
// No match made. Add a new host.
294
+ LOG .info ("Creating a new remote node for " + status .getUri ());
291
295
Node node = new RemoteNode (
292
296
tracer ,
293
297
clientFactory ,
@@ -316,7 +320,10 @@ private LocalDistributor add(Node node, NodeStatus status) {
316
320
317
321
Host host = new Host (bus , node );
318
322
host .update (status );
323
+
324
+ LOG .fine ("Adding host: " + host .asSummary ());
319
325
hosts .add (host );
326
+
320
327
LOG .info (String .format ("Added node %s." , node .getId ()));
321
328
host .runHealthCheck ();
322
329
@@ -325,6 +332,8 @@ private LocalDistributor add(Node node, NodeStatus status) {
325
332
nodeRunnables .add (runnable );
326
333
allChecks .put (node .getId (), nodeRunnables );
327
334
hostChecker .submit (runnable , Duration .ofMinutes (5 ), Duration .ofSeconds (30 ));
335
+ } catch (Throwable t ) {
336
+ LOG .log (Level .WARNING , "Unable to process host" , t );
328
337
} finally {
329
338
writeLock .unlock ();
330
339
}
0 commit comments