Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Scripting Failover Scenario

by kennethk (Monsignor)
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.


Comment on Re: Scripting Failover Scenario
Select or Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1076318]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2014-09-18 08:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (109 votes), past polls