Skip to content

Commit

Permalink
mxmirror: Remove dead code (timeslots)
Browse files Browse the repository at this point in the history
  • Loading branch information
donald committed May 13, 2019
1 parent be28b3e commit 61acaca
Showing 1 changed file with 1 addition and 73 deletions.
74 changes: 1 addition & 73 deletions mxmirror/mxmirror
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ my $hostip = inet_ntoa(scalar gethostbyname($fullhostname));

my $jbodmap = read_jbodmap($JBODMAP);
my $mirrors = read_mirrormap($MIRRORMAP);
#my $timeslots = CalcTimeslots($mirrors);
my $timeslots;

#print Dumper GroupMirrors($mirrors);

Expand Down Expand Up @@ -306,10 +304,6 @@ sub check_a {

}

#print Dumper $timeslots;
#exit;


#print Dumper $mirrors;

my $result = GetOptions(
Expand Down Expand Up @@ -370,7 +364,7 @@ if(defined $opt{sourcehosts}) {
}

if(defined $opt{all}) {
exit print_and_exec_all($mirrors, $timeslots);
exit print_and_exec_all($mirrors);
}


Expand Down Expand Up @@ -434,7 +428,6 @@ exit($err);

sub print_and_exec_all {
my $list = shift;
my $ts = shift;

my $default_fmt = "SRCHOST:SRCPATH DSTHOST:DSTPATH ARGS";
my $fmt = (defined $opt{format})?$opt{format}:$default_fmt;
Expand Down Expand Up @@ -464,7 +457,6 @@ sub print_and_exec_all {

foreach my $h (@hosts) {
my %vars = (
# TIME => $ts->{hosts}->{$h}->{time_str}
);
foreach(@{$list->{$h}}) {

Expand Down Expand Up @@ -1022,67 +1014,3 @@ sub ParseTime {
warn "ParseTime invalid time '$s'";
return [0,0];
}



sub CalcTimeslots {
my $list = shift;

my @hosts = sort keys %{$list};

my $ts = {};
my $t1 = ParseTime($CONFIG{START});
my $t2 = ParseTime($CONFIG{END});
my $step = ParseTime($CONFIG{STEP});

my $dt = DeltaTime($t1, $t2);

my $s = TimeToSeconds($step);
my $dspan = SecondsToTime($s/2);

$ts->{nslots} = int(TimeToSeconds($dt) / $s)+1;
$ts->{start} = $t1;
$ts->{end} = $t2;
$ts->{step} = $step;
$ts->{slots} = [];
$ts->{hosts} = {};

my $this = $ts->{start};

my $i = 0;
while($i++ < $ts->{nslots}) {
my $slot = {};

$slot->{time} = $this;
$slot->{timespan}->[0] = SubDeltaTime($this, $dspan);
$slot->{timespan}->[1] = AddDeltaTime($this, $dspan);
$slot->{time_str} = FormatTime($this);

push @{$ts->{slots}}, $slot;

$this = AddDeltaTime($this, $step);
}


$i = 0;

foreach my $host (@hosts) {
my $slot = $ts->{slots}->[$i++ % $ts->{nslots}];

foreach(@{$list->{$host}}) {
$_->{timeslot} = $slot;
}
}

return $ts;
}



# read jbod map

#eval $(cat /etc/amd/amd.jbod | sed -ne 's,^.*/amd/\(.*\)/X/\(X....\).*$,\2=\1,p')




0 comments on commit 61acaca

Please sign in to comment.