Skip to content
Snippets Groups Projects
Commit 574ea28c authored by Leo Gordon's avatar Leo Gordon
Browse files

moving code that stores resource usage into Queen::store_resource_usage and calling it from there

parent 8ad9df2a
No related branches found
No related tags found
No related merge requests found
......@@ -416,6 +416,11 @@ sub check_for_dead_workers { # scans the whole Valley for lost Workers (but i
$worker->cause_of_death( $report_entries->{$process_id}{'cause_of_death'} );
$self->register_worker_death( $worker );
}
if( %$report_entries ) { # use the opportunity to also store resource usage of the buried workers:
my $processid_2_workerid = { map { $_ => $pid_to_lost_worker->{$_}->dbID } keys %$pid_to_lost_worker };
$self->store_resource_usage( $report_entries, $processid_2_workerid );
}
}
}
......@@ -752,4 +757,25 @@ sub register_all_workers_dead {
}
sub store_resource_usage {
my ($self, $report_entries, $processid_2_workerid) = @_;
my $sql_replace = 'REPLACE INTO worker_resource_usage (worker_id, exit_status, mem_megs, swap_megs, pending_sec, cpu_sec, lifespan_sec, exception_status) VALUES (?, ?, ?, ?, ?, ?, ?, ?)';
my $sth_replace = $self->prepare( $sql_replace );
my @not_ours = ();
while( my ($process_id, $report_entry) = each %$report_entries ) {
if( my $worker_id = $processid_2_workerid->{$process_id} ) {
$sth_replace->execute( $worker_id, @$report_entry{'exit_status', 'mem_megs', 'swap_megs', 'pending_sec', 'cpu_sec', 'lifespan_sec', 'exception_status'} ); # slicing hashref
} else {
push @not_ours, $process_id;
#warn "\tDiscarding process_id=$process_id as probably not ours because it could not be mapped to a Worker\n";
}
}
$sth_replace->finish();
}
1;
......@@ -111,20 +111,11 @@ sub main {
my $report_entries = Bio::EnsEMBL::Hive::Meadow::LSF::parse_report_source_line( $bacct_source_line );
my $processid_2_workerid = $hive_dba->get_WorkerAdaptor()->fetch_by_meadow_type_AND_meadow_name_HASHED_FROM_process_id_TO_worker_id( 'LSF', $this_lsf_farm );
my $queen = $hive_dba->get_Queen;
my $sth_replace = $dbc->prepare( 'REPLACE INTO worker_resource_usage (worker_id, exit_status, mem_megs, swap_megs, pending_sec, cpu_sec, lifespan_sec, exception_status) VALUES (?, ?, ?, ?, ?, ?, ?, ?)' );
my $processid_2_workerid = $queen->fetch_by_meadow_type_AND_meadow_name_HASHED_FROM_process_id_TO_worker_id( 'LSF', $this_lsf_farm );
while( my ($process_id, $report_entry) = each %$report_entries ) {
if( my $worker_id = $processid_2_workerid->{$process_id} ) {
$sth_replace->execute( $worker_id, @$report_entry{'exit_status', 'mem_megs', 'swap_megs', 'pending_sec', 'cpu_sec', 'lifespan_sec', 'exception_status'} ); # slicing hashref
} else {
warn "\tDiscarding process_id=$process_id as probably not ours because it could not be mapped to a Worker\n";
}
}
$sth_replace->finish();
warn "\nReport has been loaded into pipeline's 'worker_resource_usage' table. Enjoy.\n";
$queen->store_resource_usage( $report_entries, $processid_2_workerid );
}
__DATA__
......
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