Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Scripting Failover Scenario

by kennethk (Abbot)
on Feb 26, 2014 at 22:16 UTC ( #1076318=note: print w/replies, xml ) Need Help??

in reply to Scripting Failover Scenario

First, it seems like this is a situation for a hash of arrays (see perllol and HASHES OF ARRAYS). So your data might look like:
my %parent = ( europe => [qw| london moscow |], asia => [qw| tokyo seoul |], africa => [qw| cario algiers |], );
though a hash of hashes might make sense depending on how you access the data.

Second, do you care about determinism/repeatability in where a city rolls over to? You could just cycle over keys, and push the cities onto the next taker:

sub fallover { my ($hash, $failure) = @_; my $list = delete($hash->{$failure}) or return; my @targets = keys %$hash; my $i = 0; while (@$list) { my $city = shift @$list; push @{$hash->{$targets[$i++]}}, $city; $i %= @targets; } }

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Replies are listed 'Best First'.
Re^2: Scripting Failover Scenario
by ahjohnson2 (Initiate) on Feb 27, 2014 at 01:53 UTC

    Thanks for the feedback. I failed to mention the failover sites are predetermined. So in a scenario, if Europe goes down, london fails to asia, and moscow fails to africa. If asia goes down, london is then isoloated (no further failover available). Tokyo would fail to Africa, and Seoul (slated to failover to europe) would also be isolated.

    The option of having the sites roll to the next available parent can't work.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1076318]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2018-06-19 05:50 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (111 votes). Check out past polls.