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

it may be expensive to acquire the meadow_name, so try to do it only once and cache afterwards

parent 73f1512d
No related branches found
No related tags found
No related merge requests found
......@@ -44,12 +44,28 @@ sub new {
my $self = bless {}, $class;
$self->config( $config );
$self->context( [ 'Meadow', $self->type, $self->name ] );
$self->context( [ 'Meadow', $self->type, $self->cached_name ] );
return $self;
}
sub cached_name {
my ($self) = @_;
my $name;
unless( ref($self) and $name = $self->{'_name'} ) {
if($name = $self->name() and ref($self) ) {
$self->{'_name'} = $name;
}
}
return $name;
}
sub type { # should return 'LOCAL' or 'LSF'
my $class = shift @_;
......@@ -62,7 +78,7 @@ sub type { # should return 'LOCAL' or 'LSF'
sub signature {
my $self = shift @_;
return $self->type.'/'.$self->name;
return $self->type.'/'.$self->cached_name;
}
......@@ -95,7 +111,7 @@ sub generate_job_name {
sub responsible_for_worker {
my ($self, $worker) = @_;
return ($worker->meadow_type eq $self->type) && ($worker->meadow_name eq $self->name);
return ($worker->meadow_type eq $self->type) && ($worker->meadow_name eq $self->cached_name);
}
......
......@@ -61,7 +61,7 @@ sub new {
# make sure modules are loaded and available ones are checked prior to setting the current one
foreach my $meadow_class (@{ find_submodules( $self->meadow_class_path ) }) {
eval "require $meadow_class";
if($meadow_class->name) {
if( $meadow_class->name ) {
my $meadow_object = $meadow_class->new( $config );
$meadow_object->pipeline_name( $pipeline_name ) if($pipeline_name);
......@@ -121,7 +121,7 @@ sub find_available_meadow_responsible_for_worker {
my ($self, $worker) = @_;
if( my $meadow = $self->available_meadow_hash->{$worker->meadow_type} ) {
if($meadow->name eq $worker->meadow_name) {
if($meadow->cached_name eq $worker->meadow_name) {
return $meadow;
}
}
......@@ -137,7 +137,7 @@ sub whereami {
eval {
$pid = $meadow->get_current_worker_process_id();
$meadow_type = $meadow->type();
$meadow_name = $meadow->name();
$meadow_name = $meadow->cached_name();
};
unless($@) {
last;
......
......@@ -65,7 +65,7 @@ sub main {
warn "Taking the resource_usage data from the source ( $source_line ), assuming Meadow ".$meadow->signature."\n";
if(my $report_entries = $meadow->parse_report_source_line( $source_line ) ) {
$queen->store_resource_usage( $report_entries, $meadow_2_pid_wid->{$meadow->type}{$meadow->name} );
$queen->store_resource_usage( $report_entries, $meadow_2_pid_wid->{$meadow->type}{$meadow->cached_name} );
}
} else {
......@@ -77,9 +77,9 @@ sub main {
warn "\nFinding out the time interval when the pipeline was run on Meadow ".$meadow->signature."\n";
if(my $our_interval = $meadow_2_interval->{ $meadow->type }{ $meadow->name } ) {
if(my $our_interval = $meadow_2_interval->{ $meadow->type }{ $meadow->cached_name } ) {
if(my $report_entries = $meadow->get_report_entries_for_time_interval( $our_interval->{'min_born'}, $our_interval->{'max_died'}, $username ) ) {
$queen->store_resource_usage( $report_entries, $meadow_2_pid_wid->{$meadow->type}{$meadow->name} );
$queen->store_resource_usage( $report_entries, $meadow_2_pid_wid->{$meadow->type}{$meadow->cached_name} );
}
} else {
warn "\tNothing new to store for Meadow ".$meadow->signature."\n";
......
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