Skip to content

Commit

Permalink
nuke old drain/rebalance code.
Browse files Browse the repository at this point in the history
the old drain "status" will stick around to mean "don't allow new files on
this device" - which we sorely needed anyway.

git-svn-id: http://code.sixapart.com/svn/mogilefs/trunk@1489 f67b2e87-0811-0410-a7e0-dd94e48410d6
  • Loading branch information
dormando committed Sep 19, 2010
1 parent d1207f2 commit 0be2f97
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 245 deletions.
4 changes: 0 additions & 4 deletions MANIFEST
Expand Up @@ -62,10 +62,6 @@ lib/MogileFS/HTTPFile.pm
lib/MogileFS/IOStatWatcher.pm
lib/MogileFS/Overview.pm
lib/MogileFS/ProcManager.pm
lib/MogileFS/RebalancePolicy.pm
lib/MogileFS/RebalancePolicy/DrainDevices.pm
lib/MogileFS/RebalancePolicy/PercentFree.pm
lib/MogileFS/RebalancePolicy/Random.pm
lib/MogileFS/ReplicationPolicy.pm
lib/MogileFS/ReplicationPolicy/MultipleHosts.pm
lib/MogileFS/ReplicationPolicy/Union.pm
Expand Down
34 changes: 0 additions & 34 deletions lib/MogileFS/RebalancePolicy.pm

This file was deleted.

63 changes: 0 additions & 63 deletions lib/MogileFS/RebalancePolicy/DrainDevices.pm

This file was deleted.

65 changes: 0 additions & 65 deletions lib/MogileFS/RebalancePolicy/PercentFree.pm

This file was deleted.

27 changes: 0 additions & 27 deletions lib/MogileFS/RebalancePolicy/Random.pm

This file was deleted.

52 changes: 0 additions & 52 deletions lib/MogileFS/Worker/Replicate.pm
Expand Up @@ -5,8 +5,6 @@ use strict;
use base 'MogileFS::Worker';
use fields (
'fidtodo', # hashref { fid => 1 }
'peerrepl', # hashref { fid => time() } # when peer started replicating
'rebal_pol_obj', # rebalancer policy object
);

use List::Util ();
Expand All @@ -27,7 +25,6 @@ sub new {
my $self = fields::new($class);
$self->SUPER::new($psock);
$self->{fidtodo} = {};
$self->{peerrepl} = {};
return $self;
}

Expand Down Expand Up @@ -216,55 +213,6 @@ sub replicate_using_torepl_table {
return 1;
}

sub rebalance_devices {
my $self = shift;
my $sto = Mgd::get_store();
return 0 unless $sto->server_setting('enable_rebalance');
my $pol = $self->rebalance_policy_obj or return 0;
unless ($self->run_rebalance_policy_a_bit($pol)) {
error("disabling rebalancing due to lack of work");
MogileFS::Config->set_server_setting("enable_rebalance", 0);
}
}

sub drain_devices {
my $self = shift;
my $pol = MogileFS::RebalancePolicy::DrainDevices->instance;
my $rv = $self->run_rebalance_policy_a_bit($pol);
#error("[$$] drained = $rv\n") if $rv;
}

# returns number of files rebalanced.
sub run_rebalance_policy_a_bit {
my ($self, $pol) = @_;
my $stop_at = time() + 5; # Run for up to 5 seconds, then return.
my $n = 0;
my %avoid_devids = map { $_->id => 1 } $pol->dest_devs_to_avoid;
while (my $dfid = $pol->devfid_to_rebalance) {
$self->rebalance_devfid($dfid, avoid_devids => \%avoid_devids);
$n++;
last if time() >= $stop_at;
}
return $n;
}

sub rebalance_policy_obj {
my $self = shift;
my $rclass = Mgd::get_store()->server_setting('rebalance_policy') ||
"MogileFS::RebalancePolicy::PercentFree";

# return old one, if it's still of the same type.
if ($self->{'rebal_pol_obj'} && ref($self->{'rebal_pol_obj'}) eq $rclass) {
return $self->{'rebal_pol_obj'};
}

return error("Bogus rebalance_policy setting") unless $rclass =~ /^[\w:\-]+$/;
return error("Failed to load $rclass: $@") unless eval "use $rclass; 1;";
my $pol = eval { $rclass->new };
return error("Failed to instantiate rebalance policy: $@") unless $pol;
return $self->{'rebal_pol_obj'} = $pol;
}

# Return 1 on success, 0 on failure.
sub rebalance_devfid {
my ($self, $devfid, $opts) = @_;
Expand Down

0 comments on commit 0be2f97

Please sign in to comment.