… | |
… | |
60 | our %NODE_REQ; |
60 | our %NODE_REQ; |
61 | |
61 | |
62 | # only in global code |
62 | # only in global code |
63 | our %GLOBAL_MON; # monitors {family} |
63 | our %GLOBAL_MON; # monitors {family} |
64 | |
64 | |
65 | sub other_globals() { |
|
|
66 | grep $_ ne $NODE && node_is_up $_, keys %{ $GLOBAL_DB{"'g"} } |
|
|
67 | } |
|
|
68 | |
|
|
69 | # broadcasts a message to all other global nodes |
65 | # broadcasts a message to all other global nodes |
70 | sub g_broadcast { |
66 | sub g_broadcast { |
71 | snd $_, @_ |
67 | snd $_, @_ |
72 | for other_globals; |
68 | for grep $_ ne $NODE && node_is_up $_, keys %{ $GLOBAL_DB{"'g"} } |
73 | } |
69 | } |
74 | |
70 | |
75 | # add/replace/del inside a family in the database |
71 | # add/replace/del inside a family in the database |
76 | # @$dle must not contain any key in %$set |
72 | # @$dle must not contain any key in %$set |
77 | sub g_upd { |
73 | sub g_upd { |
… | |
… | |
219 | # switch to global mode |
215 | # switch to global mode |
220 | |
216 | |
221 | # regularly try to connect to global nodes - maybe use seeding code? |
217 | # regularly try to connect to global nodes - maybe use seeding code? |
222 | $MASTER_TIMER = AE::timer 0, $AnyEvent::MP::Kernel::CONFIG->{monitor_timeout}, sub { |
218 | $MASTER_TIMER = AE::timer 0, $AnyEvent::MP::Kernel::CONFIG->{monitor_timeout}, sub { |
223 | (add_node $_)->connect |
219 | (add_node $_)->connect |
224 | for other_globals; |
220 | for keys %{ $GLOBAL_DB{"'g"} } |
225 | }; |
221 | }; |
226 | |
222 | |
227 | # instantly connect to other global nodes when we learn of them |
223 | # instantly connect to other global nodes when we learn of them |
228 | # so we don't have to wait for the timer. |
224 | # so we don't have to wait for the timer. |
229 | #TODO |
225 | #TODO |