Commit 1cf05bd9 authored by Matthieu Muffato's avatar Matthieu Muffato
Browse files

Changed the return type of whereami() to include the Meadow object

parent f205ab8e
......@@ -55,9 +55,9 @@ use base ( 'Bio::EnsEMBL::Hive::Storable' ); # To enable dbID() and adaptor()
sub new_from_Valley {
my ($class, $valley, @args) = @_;
my ($meadow_type, $meadow_name, $pid, $meadow_host, $meadow_user) = $valley->whereami;
unless($meadow_type eq 'LOCAL') {
die "beekeeper.pl detected it has been itself submitted to '$meadow_type/$meadow_name', but this mode of operation is not supported.\n"
my ($meadow, $pid, $meadow_host, $meadow_user) = $valley->whereami;
unless($meadow->type eq 'LOCAL') {
die "beekeeper.pl detected it has been itself submitted to '".$meadow->type."/".$meadow->cached_name."', but this mode of operation is not supported.\n"
."Please just run beekeeper.pl on a farm head node, preferably from under a 'screen' session.\n";
}
......
......@@ -117,8 +117,10 @@ sub create_new_worker {
= @flags{qw(-resource_class_id -resource_class_name -beekeeper_id
-no_write -debug -worker_log_dir -hive_log_dir -job_limit -life_span -no_cleanup -retry_throwing_jobs -can_respecialize)};
my ($meadow_type, $meadow_name, $process_id, $meadow_host, $meadow_user) = Bio::EnsEMBL::Hive::Valley->new()->whereami();
die "Valley is not fully defined" unless ($meadow_type && $meadow_name && $process_id && $meadow_host && $meadow_user);
my ($meadow, $process_id, $meadow_host, $meadow_user) = Bio::EnsEMBL::Hive::Valley->new()->whereami();
die "Valley is not fully defined" unless ($meadow && $process_id && $meadow_host && $meadow_user);
my $meadow_type = $meadow->type;
my $meadow_name = $meadow->cached_name;
foreach my $prev_worker_incarnation (@{ $self->fetch_all( "status!='DEAD' AND meadow_type='$meadow_type' AND meadow_name='$meadow_name' AND process_id='$process_id'" ) }) {
# so far 'RELOCATED events' has been detected on LSF 9.0 in response to sending signal #99 or #100
......
......@@ -140,25 +140,22 @@ sub find_available_meadow_responsible_for_worker {
sub whereami {
my $self = shift @_;
my ($meadow_type, $meadow_name, $pid);
my $meadow_host = hostname();
my $meadow_user = $ENV{'USER'} || getpwuid($<);
foreach my $meadow (@{ $self->get_available_meadow_list }) {
my $pid;
eval {
$pid = $meadow->get_current_worker_process_id();
$meadow_type = $meadow->type();
$meadow_name = $meadow->cached_name();
# get_current_worker_process_id() is expected to die if the pid
# cannot be determined. With the eval{} and the unless{} it will
# skip the meadow and try the next one.
$pid = $meadow->get_current_worker_process_id();
};
unless($@) {
last;
return ($meadow, $pid, $meadow_host, $meadow_user);
}
}
unless($pid) {
die "Could not determine the Meadow, please investigate";
}
my $meadow_host = hostname();
my $meadow_user = $ENV{'USER'} || getpwuid($<);
return ($meadow_type, $meadow_name, $pid, $meadow_host, $meadow_user);
die "Could not determine the Meadow, please investigate";
}
......
......@@ -76,9 +76,9 @@ my $valley = Bio::EnsEMBL::Hive::Valley->new($config, 'LOCAL', $pipeline_name);
ok($valley, 'Can build a Valley');
my ($meadow_type, $meadow_name) = $valley->whereami();
ok($meadow_type, 'Could find the neadow type');
ok($meadow_name, 'Could find the neadow name');
my ($meadow, $pid) = $valley->whereami();
ok($meadow, 'Could find the meadow');
ok($pid, 'Could find the process id');
my $available_meadows = $valley->get_available_meadow_list();
ok(scalar(@$available_meadows), 'At least a meadow could be found');
......
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