… | |
… | |
205 | sub snd(@) { |
205 | sub snd(@) { |
206 | my ($nodeid, $portid) = split /#/, shift, 2; |
206 | my ($nodeid, $portid) = split /#/, shift, 2; |
207 | |
207 | |
208 | warn "SND $nodeid <- " . eval { JSON::XS->new->encode (\@_) } . "\n" if TRACE && @_;#d# |
208 | warn "SND $nodeid <- " . eval { JSON::XS->new->encode (\@_) } . "\n" if TRACE && @_;#d# |
209 | |
209 | |
|
|
210 | defined $nodeid #d#UGLY |
|
|
211 | or Carp::croak "'undef' is not a valid node ID/port ID"; |
|
|
212 | |
210 | ($NODE{$nodeid} || add_node $nodeid) |
213 | ($NODE{$nodeid} || add_node $nodeid) |
211 | ->{send} (["$portid", @_]); |
214 | ->{send} (["$portid", @_]); |
212 | } |
215 | } |
213 | |
216 | |
214 | =item $is_local = port_is_local $port |
217 | =item $is_local = port_is_local $port |
… | |
… | |
238 | # on $NODE, we artificially delay... (for spawn) |
241 | # on $NODE, we artificially delay... (for spawn) |
239 | # this is very ugly - maybe we should simply delay ALL messages, |
242 | # this is very ugly - maybe we should simply delay ALL messages, |
240 | # to avoid deep recursion issues. but that's so... slow... |
243 | # to avoid deep recursion issues. but that's so... slow... |
241 | $AnyEvent::MP::Node::Self::DELAY = 1 |
244 | $AnyEvent::MP::Node::Self::DELAY = 1 |
242 | if $nodeid ne $NODE; |
245 | if $nodeid ne $NODE; |
|
|
246 | |
|
|
247 | defined $nodeid #d#UGLY |
|
|
248 | or Carp::croak "'undef' is not a valid node ID/port ID"; |
243 | |
249 | |
244 | ($NODE{$nodeid} || add_node $nodeid)->send (["", @_]); |
250 | ($NODE{$nodeid} || add_node $nodeid)->send (["", @_]); |
245 | } |
251 | } |
246 | |
252 | |
247 | =item snd_on $node, @msg |
253 | =item snd_on $node, @msg |
… | |
… | |
469 | Returns the node IDs of all nodes currently known to this node, including |
475 | Returns the node IDs of all nodes currently known to this node, including |
470 | itself and nodes not currently connected. |
476 | itself and nodes not currently connected. |
471 | |
477 | |
472 | =cut |
478 | =cut |
473 | |
479 | |
474 | sub known_nodes { |
480 | sub known_nodes() { |
475 | map $_->{id}, values %NODE |
481 | map $_->{id}, values %NODE |
476 | } |
482 | } |
477 | |
483 | |
478 | =item up_nodes |
484 | =item up_nodes |
479 | |
485 | |
480 | Return the node IDs of all nodes that are currently connected (excluding |
486 | Return the node IDs of all nodes that are currently connected (excluding |
481 | the node itself). |
487 | the node itself). |
482 | |
488 | |
483 | =cut |
489 | =cut |
484 | |
490 | |
485 | sub up_nodes { |
491 | sub up_nodes() { |
486 | map $_->{id}, grep $_->{transport}, values %NODE |
492 | map $_->{id}, grep $_->{transport}, values %NODE |
487 | } |
493 | } |
488 | |
494 | |
489 | =item $guard = mon_nodes $callback->($nodeid, $is_up, @reason) |
495 | =item $guard = mon_nodes $callback->($nodeid, $is_up, @reason) |
490 | |
496 | |