… | |
… | |
217 | snd $SRCNODE->{id}, g_chg1 => $_[0], $GLOBAL_DB{$_[0]}; |
217 | snd $SRCNODE->{id}, g_chg1 => $_[0], $GLOBAL_DB{$_[0]}; |
218 | }; |
218 | }; |
219 | |
219 | |
220 | ############################################################################# |
220 | ############################################################################# |
221 | # switch to global mode |
221 | # switch to global mode |
222 | |
|
|
223 | $GLOBAL = 1; |
|
|
224 | $MASTER = $NODE; |
|
|
225 | undef $GLOBAL_SLAVE{$NODE}; # we are our own master (and slave) |
|
|
226 | |
222 | |
227 | # regularly try to connect to global nodes - maybe use seeding code? |
223 | # regularly try to connect to global nodes - maybe use seeding code? |
228 | $MASTER_TIMER = AE::timer 0, $AnyEvent::MP::Kernel::CONFIG->{monitor_timeout}, sub { |
224 | $MASTER_TIMER = AE::timer 0, $AnyEvent::MP::Kernel::CONFIG->{monitor_timeout}, sub { |
229 | (add_node $_)->connect |
225 | (add_node $_)->connect |
230 | for keys %{ $GLOBAL_DB{"'g"} }; |
226 | for keys %{ $GLOBAL_DB{"'g"} }; |
… | |
… | |
292 | g_slave_disconnect $SRCNODE->{id}; |
288 | g_slave_disconnect $SRCNODE->{id}; |
293 | $SRCNODE->{transport}{remote_greeting}{global} = 1; |
289 | $SRCNODE->{transport}{remote_greeting}{global} = 1; |
294 | g_global_connect $SRCNODE->{id}; |
290 | g_global_connect $SRCNODE->{id}; |
295 | }; |
291 | }; |
296 | |
292 | |
297 | # send the local db to themaster - outselves - to prime our global_db |
293 | # enable global mode |
298 | snd $MASTER, g_set => \%LOCAL_DB; |
294 | $GLOBAL = 1; |
|
|
295 | |
|
|
296 | # global nodes are their own masters - this |
|
|
297 | # resends global requests and sets the local database. |
|
|
298 | master_set $NODE; |
|
|
299 | |
299 | # now add us to the set of global nodes |
300 | # now add us to the set of global nodes |
300 | db_set "'g" => $NODE => undef; |
301 | db_set "'g" => $NODE => undef; |
301 | |
302 | |
302 | =back |
303 | =back |
303 | |
304 | |