… | |
… | |
358 | } |
358 | } |
359 | |
359 | |
360 | ############################################################################# |
360 | ############################################################################# |
361 | # node monitoring and info |
361 | # node monitoring and info |
362 | |
362 | |
363 | sub _uniq_nodes { |
|
|
364 | my %node; |
|
|
365 | |
|
|
366 | @node{values %NODE} = values %NODE; |
|
|
367 | |
|
|
368 | values %node; |
|
|
369 | } |
|
|
370 | |
|
|
371 | sub _public_nodes { |
|
|
372 | &_uniq_nodes |
|
|
373 | } |
|
|
374 | |
|
|
375 | =item node_is_known $nodeid |
363 | =item node_is_known $nodeid |
376 | |
364 | |
377 | Returns true iff the given node is currently known to the system. |
365 | Returns true iff the given node is currently known to the system. |
378 | |
366 | |
379 | =cut |
367 | =cut |
… | |
… | |
397 | ? 1 : 0 |
385 | ? 1 : 0 |
398 | } |
386 | } |
399 | |
387 | |
400 | =item known_nodes |
388 | =item known_nodes |
401 | |
389 | |
402 | Returns the node IDs of all public nodes connected to this node, including |
390 | Returns the node IDs of all nodes currently known to this node, including |
403 | itself. |
391 | itself and nodes not currently connected. |
404 | |
392 | |
405 | =cut |
393 | =cut |
406 | |
394 | |
407 | sub known_nodes { |
395 | sub known_nodes { |
408 | map $_->{id}, _public_nodes |
396 | map $_->{id}, values %NODE |
409 | } |
397 | } |
410 | |
398 | |
411 | =item up_nodes |
399 | =item up_nodes |
412 | |
400 | |
413 | Return the node IDs of all public nodes that are currently connected |
401 | Return the node IDs of all nodes that are currently connected (excluding |
414 | (excluding the node itself). |
402 | the node itself). |
415 | |
403 | |
416 | =cut |
404 | =cut |
417 | |
405 | |
418 | sub up_nodes { |
406 | sub up_nodes { |
419 | map $_->{id}, grep $_->{transport}, _public_nodes |
407 | map $_->{id}, grep $_->{transport}, values %NODE |
420 | } |
408 | } |
421 | |
409 | |
422 | =item $guard = mon_nodes $callback->($nodeid, $is_up, @reason) |
410 | =item $guard = mon_nodes $callback->($nodeid, $is_up, @reason) |
423 | |
411 | |
424 | Registers a callback that is called each time a node goes up (connection |
412 | Registers a callback that is called each time a node goes up (connection |