Skip to content

Commit

Permalink
Support modifying class replpolicy strings.
Browse files Browse the repository at this point in the history
git-svn-id: http://code.sixapart.com/svn/mogilefs/trunk@1430 f67b2e87-0811-0410-a7e0-dd94e48410d6
  • Loading branch information
dormando committed Apr 2, 2010
1 parent a84d1b1 commit 19e30a2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ WriteMakefile(
PREREQ_PM => {
'LWP::Simple' => 0,
'Compress::Zlib' => 0,
'MogileFS::Client' => '1.10',
'MogileFS::Client' => '1.11',
},
);
32 changes: 22 additions & 10 deletions mogadm
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ my $usage = {
"<domain>" => "Domain to add class to.",
"<class>" => "Name of class to add.",
"--mindevcount=i" => "Minimum number of replicas.",
"--replpolicy=s" => "Replication policy string.",
},
},
modify => {
Expand All @@ -167,6 +168,7 @@ my $usage = {
"<domain>" => "Domain to add class to.",
"<class>" => "Name of class to add.",
"--mindevcount=i" => "Minimum number of replicas.",
"--replpolicy=s" => "Replication policy string.",
},
},
delete => {
Expand Down Expand Up @@ -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";
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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=E<lt>valueE<gt>>
Stringified replication policy. ie "MultipleHosts(3)" is equivalent to a
--mindevcount=3. See documentation or plugins on alternative policies.
=back
=head1 FSCK OPTIONS
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 19e30a2

Please sign in to comment.