From 19e30a2880d14236f70386f125846ef850a52e40 Mon Sep 17 00:00:00 2001 From: dormando Date: Fri, 2 Apr 2010 00:37:34 +0000 Subject: [PATCH] Support modifying class replpolicy strings. git-svn-id: http://code.sixapart.com/svn/mogilefs/trunk@1430 f67b2e87-0811-0410-a7e0-dd94e48410d6 --- Changes | 4 ++++ Makefile.PL | 2 +- mogadm | 32 ++++++++++++++++++++++---------- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/Changes b/Changes index fd8076d..aa41f11 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,7 @@ + * Add --replpolicy option for configuring a replication policy string. + Used in MogileFS::Network policies, etc. + (dormando) + * Updates to mogstats (dormando, Barry Abrahamson) 2.15 -- 2009-12-05 diff --git a/Makefile.PL b/Makefile.PL index 3032a19..1b68c2c 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -12,6 +12,6 @@ WriteMakefile( PREREQ_PM => { 'LWP::Simple' => 0, 'Compress::Zlib' => 0, - 'MogileFS::Client' => '1.10', + 'MogileFS::Client' => '1.11', }, ); diff --git a/mogadm b/mogadm index c706604..eba282a 100755 --- a/mogadm +++ b/mogadm @@ -158,6 +158,7 @@ my $usage = { "" => "Domain to add class to.", "" => "Name of class to add.", "--mindevcount=i" => "Minimum number of replicas.", + "--replpolicy=s" => "Replication policy string.", }, }, modify => { @@ -167,6 +168,7 @@ my $usage = { "" => "Domain to add class to.", "" => "Name of class to add.", "--mindevcount=i" => "Minimum number of replicas.", + "--replpolicy=s" => "Replication policy string.", }, }, delete => { @@ -631,13 +633,14 @@ sub cmd_domain_list { # actually lists domains and classes my $domains = domains() or fail_text('no_domains'); - # now iterate - printf " %-20s %-20s \%s\n", "domain", "class", "mindevcount"; - printf "%-20s %-20s \%s\n", '-' x 20, '-' x 20, '-' x 13; + printf " %-20s %-20s %-12s %-12s\n", "domain", "class", "mindevcount", "replpolicy"; + printf "%-20s %-20s %-12s %-12s\n", '-' x 20, '-' x 20, '-' x 13, '-' x 12; foreach my $domain (sort keys %$domains) { foreach my $class (sort keys %{$domains->{$domain}}) { - printf " %-20s %-20s %d\n", $domain, $class, $domains->{$domain}->{$class} || 0; + my $dom = $domains->{$domain}->{$class}; + printf " %-20s %-20s %-8d %-13s\n", $domain, $class, + $dom->{mindevcount} || 0, $dom->{replpolicy} || ''; } print "\n"; } @@ -694,17 +697,18 @@ sub cmd_class_add { my $domains = domains() or fail_text('no_domains'); - my $domain = $args->{domain}; - my $class = $args->{class}; + my $domain = delete $args->{domain}; + my $class = delete $args->{class}; cmd_help_die() unless $domain && $class; fail('Domain not found.') unless $domains->{$domain}; fail('Class already exists.') if $domains->{$domain}->{$class}; $args->{mindevcount} ||= 2; + $args->{replpolicy} ||= ''; my $mogadm = mogadm(); - $mogadm->create_class($domain, $class, $args->{mindevcount}); + $mogadm->create_class($domain, $class, $args); if ($mogadm->err) { fail('Error creating class: ' . $mogadm->errstr); } @@ -717,17 +721,18 @@ sub cmd_class_modify { my $domains = domains() or fail_text('no_domains'); - my $domain = $args->{domain}; - my $class = $args->{class}; + my $domain = delete $args->{domain}; + my $class = delete $args->{class}; cmd_help_die() unless $domain && $class; fail('Domain not found.') unless $domains->{$domain}; fail('Class does not exist.') unless $domains->{$domain}->{$class}; $args->{mindevcount} ||= 2; + $args->{replpolicy} ||= ''; my $mogadm = mogadm(); - $mogadm->update_class($domain, $class, $args->{mindevcount}); + $mogadm->update_class($domain, $class, $args); if ($mogadm->err) { fail('Error updating class: ' . $mogadm->errstr); } @@ -1531,6 +1536,11 @@ integer. Number of devices the files in this class should be replicated across. Can be set to anything >= 1. +=item B<--replpolicy=EvalueE> + +Stringified replication policy. ie "MultipleHosts(3)" is equivalent to a +--mindevcount=3. See documentation or plugins on alternative policies. + =back =head1 FSCK OPTIONS @@ -1577,7 +1587,9 @@ Class manipulation $ mogadm class list $ mogadm class add first.domain my.class $ mogadm class add first.domain my.class --mindevcount=3 + $ mogadm class add first.domain my.class --replpolicy="MultipleHosts(3)" $ mogadm class modify first.domain my.class --mindevcount=2 + $ mogadm class modify first.domain my.class --replpolicy="MultipleHosts(3)" $ mogadm class delete first.domain my.class Check the status of your entire MogileFS system: