Skip to content

Commit

Permalink
add rebalance commands to mogadm
Browse files Browse the repository at this point in the history
the "set this policy string" thing is pretty damn near unusable at this time,
and should be improved.

git-svn-id: http://code.sixapart.com/svn/mogilefs/trunk@1481 f67b2e87-0811-0410-a7e0-dd94e48410d6
  • Loading branch information
dormando committed Sep 19, 2010
1 parent eb60e1d commit 8f48de4
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Add rebalance commands

2.17 -- 2010-08-13

* Add 'domains' argument to mogstats for faster queries on basic by-domain
Expand Down
92 changes: 92 additions & 0 deletions mogadm
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,33 @@ my $usage = {
},
},
},
rebalance => {
des => "Control file rebalancing operations.",
subcmd => {
start => {
des => 'Start a rebalance job',
},
stop => {
des => 'Stop a rebalance job',
},
status => {
des => 'Show status of current rebalance job',
},
settings => {
des => 'Display rebalance settings',
},
test => {
des => 'Show what devices the current policy would match',
},
policy => {
des => 'Add or adjust the current policy',
args => '[opts]',
opts => {
'--options=s' => "Policy string (see docs/wiki for details)",
},
},
},
},
fsck => {
des => "Control a background filesystem check operation.",
subcmd => {
Expand Down Expand Up @@ -938,6 +965,69 @@ sub cmd_slave_delete {
}
}

sub cmd_rebalance_start {
my $mogadm = mogadm();
my $res = $mogadm->rebalance_start || fail($mogadm->errstr);
ok("rebalance started");
}

sub cmd_rebalance_stop {
my $mogadm = mogadm();
my $res = $mogadm->rebalance_stop || fail($mogadm->errstr);
ok("rebalance stopped");
}

# TODO: Make output prettier? Put hostname next to device name, print device
# info?
sub cmd_rebalance_test {
my $mogadm = mogadm();
my $res = $mogadm->rebalance_test || fail($mogadm->errstr);
print "Tested rebalance policy...\n";
my $s = $mogadm->server_settings;
print "Policy: ", $s->{rebal_policy}, "\n\n";
print "Source devices:\n";
for my $dev (split /,/, $res->{sdevs}) {
print " - ", $dev, "\n";
}
print "Destination devices:\n";
for my $dev (split /,/, $res->{ddevs}) {
print " - ", $dev, "\n";
}
}

sub cmd_rebalance_status {
my $mogadm = mogadm();

my $res = $mogadm->rebalance_status or fail ($mogadm->errstr);
print "Rebalance status:\n";
for my $o (split /\s+/, $res->{state}) {
my ($k, $v) = split /=/, $o;
printf("%25s = %-s\n", $k, $v);
}
}

sub cmd_rebalance_policy {
my $mogadm = mogadm();
my $args = shift;

my $res = $mogadm->rebalance_set_policy(policy => $args->{options})
or fail($mogadm->errstr);

ok("changed policy setting");
}

sub cmd_rebalance_settings {
my $mogadm = mogadm();

my $ss = $mogadm->server_settings
or fail("can't get settings");
foreach my $k (sort keys %$ss) {
next unless ($k =~ '^rebal_');
next if ($k eq 'rebal_state');
printf("%25s = %-s\n", $k, $ss->{$k});
}
}

sub cmd_fsck_start {
my $mogadm = mogadm();
my $res = $mogadm->fsck_start || fail($mogadm->errstr);
Expand Down Expand Up @@ -1070,6 +1160,8 @@ sub cmd_settings_list {
my $ss = $mogadm->server_settings
or fail("can't get settings");
foreach my $k (sort keys %$ss) {
# Don't list noisy "setting"
next if ($k =~ '^rebal');
printf("%25s = %-s\n", $k, $ss->{$k});
}
}
Expand Down

0 comments on commit 8f48de4

Please sign in to comment.