Commit 014208ff authored by Brandon Walts's avatar Brandon Walts
Browse files

Merge branch 'version/2.1' into version/2.2

parents 6275af27 37bd34e0
......@@ -167,6 +167,19 @@ sub parse_report_source_line {
return;
}
=head2 get_report_entries_for_process_ids
Title : get_report_entries_for_process_ids
Function: A higher-level method that gets process_ids as input and
returns a structure like parse_report_source_line.
=cut
sub get_report_entries_for_process_ids {
my ($self, @process_ids) = @_;
warn "\t".ref($self)." does not support resource usage logs\n";
return;
}
sub get_report_entries_for_time_interval {
my $self = shift @_;
......
......@@ -280,14 +280,16 @@ sub get_report_entries_for_process_ids {
my %combined_report_entries = ();
while (my $pid_batch = join(' ', map { "'$_'" } splice(@_, 0, 20))) { # can't fit too many pids on one shell cmdline
my $cmd = "bacct -l $pid_batch |";
unless ($self->config_get('AccountingDisabled')) {
while (my $pid_batch = join(' ', map { "'$_'" } splice(@_, 0, 20))) { # can't fit too many pids on one shell cmdline
my $cmd = "bacct -l $pid_batch |";
# warn "LSF::get_report_entries_for_process_ids() running cmd:\n\t$cmd\n";
# warn "LSF::get_report_entries_for_process_ids() running cmd:\n\t$cmd\n";
my $batch_of_report_entries = $self->parse_report_source_line( $cmd );
my $batch_of_report_entries = $self->parse_report_source_line( $cmd );
%combined_report_entries = (%combined_report_entries, %$batch_of_report_entries);
%combined_report_entries = (%combined_report_entries, %$batch_of_report_entries);
}
}
return \%combined_report_entries;
......@@ -297,17 +299,21 @@ sub get_report_entries_for_process_ids {
sub get_report_entries_for_time_interval {
my ($self, $from_time, $to_time, $username) = @_;
my $from_timepiece = Time::Piece->strptime($from_time, '%Y-%m-%d %H:%M:%S');
$from_time = $from_timepiece->strftime('%Y/%m/%d/%H:%M');
my $batch_of_report_entries = {};
unless ($self->config_get('AccountingDisabled')) {
my $from_timepiece = Time::Piece->strptime($from_time, '%Y-%m-%d %H:%M:%S');
$from_time = $from_timepiece->strftime('%Y/%m/%d/%H:%M');
my $to_timepiece = Time::Piece->strptime($to_time, '%Y-%m-%d %H:%M:%S') + 2*ONE_MINUTE;
$to_time = $to_timepiece->strftime('%Y/%m/%d/%H:%M');
my $to_timepiece = Time::Piece->strptime($to_time, '%Y-%m-%d %H:%M:%S') + 2*ONE_MINUTE;
$to_time = $to_timepiece->strftime('%Y/%m/%d/%H:%M');
my $cmd = "bacct -l -C $from_time,$to_time ".($username ? "-u $username" : '') . ' |';
my $cmd = "bacct -l -C $from_time,$to_time ".($username ? "-u $username" : '') . ' |';
# warn "LSF::get_report_entries_for_time_interval() running cmd:\n\t$cmd\n";
my $batch_of_report_entries = $self->parse_report_source_line( $cmd );
$batch_of_report_entries = $self->parse_report_source_line( $cmd );
}
return $batch_of_report_entries;
}
......
......@@ -362,17 +362,16 @@ sub check_for_dead_workers { # scans the whole Valley for lost Workers (but i
if(my $lost_this_meadow = scalar(keys %$pid_to_lost_worker) ) {
warn "GarbageCollector:\tDiscovered $lost_this_meadow lost $meadow_type Workers\n";
my $report_entries = {};
my $report_entries;
if($this_meadow->can('find_out_causes')) {
die "Your Meadow::$meadow_type driver now has to support get_report_entries_for_process_ids() method instead of find_out_causes(). Please update it.\n";
} elsif($this_meadow->can('get_report_entries_for_process_ids')) {
$report_entries = $this_meadow->get_report_entries_for_process_ids( keys %$pid_to_lost_worker );
my $lost_with_known_cod = scalar( grep { $_->{'cause_of_death'} } values %$report_entries);
warn "GarbageCollector:\tFound why $lost_with_known_cod of $meadow_type Workers died\n";
} else {
warn "GarbageCollector:\t$meadow_type meadow does not support post-mortem examination\n";
if ($report_entries = $this_meadow->get_report_entries_for_process_ids( keys %$pid_to_lost_worker )) {
my $lost_with_known_cod = scalar( grep { $_->{'cause_of_death'} } values %$report_entries);
warn "GarbageCollector:\tFound why $lost_with_known_cod of $meadow_type Workers died\n";
}
}
warn "GarbageCollector:\tReleasing the jobs\n";
......
......@@ -21,7 +21,7 @@ use warnings;
use Cwd;
use File::Basename;
use Test::More tests => 18;
use Test::More;
use Test::Exception;
use Bio::EnsEMBL::Hive::Utils::Config;
......@@ -183,17 +183,32 @@ my $expected_bacct = {
},
};
unless ($lsf_meadow->config_get('AccountingDisabled')) {
lives_and( sub {
local $ENV{EHIVE_EXPECTED_BACCT} = '-l 34 56[7]';
my $h = $lsf_meadow->get_report_entries_for_process_ids(34, '56[7]');
is_deeply($h, $expected_bacct, 'Got bacct output');
}, 'Can call bacct on process_ids');
lives_and( sub {
local $ENV{EHIVE_EXPECTED_BACCT} = '-l -C 2015/10/11/12:23,2015/12/12/23:58 -u kb3';
my $h = $lsf_meadow->get_report_entries_for_time_interval('2015-10-11 12:23:45', '2015-12-12 23:56:59', 'kb3');
is_deeply($h, $expected_bacct, 'Got bacct output');
}, 'Can call bacct on a date range');
}
$lsf_meadow->config_set("AccountingDisabled", 1);
lives_and( sub {
local $ENV{EHIVE_EXPECTED_BACCT} = '-l 34 56[7]';
my $h = $lsf_meadow->get_report_entries_for_process_ids(34, '56[7]');
is_deeply($h, $expected_bacct, 'Got bacct output');
}, 'Can call bacct on process_ids');
is_deeply($h, {}, 'No bacct output when accounting disabled');
}, 'Suppressed bacct when AccountingDisabled when checking process_ids');
lives_and( sub {
local $ENV{EHIVE_EXPECTED_BACCT} = '-l -C 2015/10/11/12:23,2015/12/12/23:58 -u kb3';
my $h = $lsf_meadow->get_report_entries_for_time_interval('2015-10-11 12:23:45', '2015-12-12 23:56:59', 'kb3');
is_deeply($h, $expected_bacct, 'Got bacct output');
}, 'Can call bacct on a date range');
is_deeply($h, {}, 'No bacct output when accounting disabled');
}, 'Suppressed bacct when AccountingDisabled when checking a date range');
done_testing();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment