Commit 16997244 authored by Leo Gordon's avatar Leo Gordon
Browse files

moved meadow identification code to Valley.pm

parent 0cab5341
......@@ -4,42 +4,23 @@
package Bio::EnsEMBL::Hive::Meadow;
use Sys::Hostname;
use Bio::EnsEMBL::Hive::Meadow::LSF;
use Bio::EnsEMBL::Hive::Meadow::LOCAL;
use strict;
use warnings;
sub new {
my $class = shift @_;
unless($class=~/::/) {
$class = 'Bio::EnsEMBL::Hive::Meadow'.$class;
}
return bless { @_ }, $class;
}
sub guess_current_type_pid_exechost {
my $self = shift @_;
my ($type, $pid);
eval {
$pid = Bio::EnsEMBL::Hive::Meadow::LSF->get_current_worker_process_id();
$type = 'LSF';
};
if($@) {
$pid = Bio::EnsEMBL::Hive::Meadow::LOCAL->get_current_worker_process_id();
$type = 'LOCAL';
}
sub type { # should return 'LOCAL' or 'LSF'
my $class = shift @_;
my $exechost = hostname();
$class = ref($class) if(ref($class));
return ($type, $pid, $exechost);
}
sub type { # should return 'LOCAL' or 'LSF'
return (reverse split(/::/, ref(shift @_)))[0];
return (reverse split(/::/, $class ))[0];
}
sub pipeline_name { # if set, provides a filter for job-related queries
......
......@@ -23,6 +23,7 @@ package Bio::EnsEMBL::Hive::Valley;
use strict;
use warnings;
use Sys::Hostname;
use Bio::EnsEMBL::Utils::Argument; # import 'rearrange()'
use Bio::EnsEMBL::Hive::Utils ('find_submodules');
......@@ -96,5 +97,28 @@ sub current_meadow_class {
}
sub guess_current_type_pid_exechost {
my $self = shift @_;
my ($type, $pid);
foreach my $meadow_class (@{ $self->get_available_meadow_classes_list }) {
eval {
$pid = $meadow_class->get_current_worker_process_id();
$type = $meadow_class->type();
};
unless($@) {
last;
}
}
unless($pid) {
die "Could not determine the Meadow, please investigate";
}
my $exechost = hostname();
return ($type, $pid, $exechost);
}
1;
......@@ -7,7 +7,7 @@ use Bio::EnsEMBL::Hive::Utils ('script_usage');
use Bio::EnsEMBL::Registry;
use Bio::EnsEMBL::Hive::DBSQL::DBAdaptor;
use Bio::EnsEMBL::Hive::Queen;
use Bio::EnsEMBL::Hive::Meadow;
use Bio::EnsEMBL::Hive::Valley;
Bio::EnsEMBL::Registry->no_version_check(1);
......@@ -89,7 +89,7 @@ unless($DBA and $DBA->isa("Bio::EnsEMBL::Hive::DBSQL::DBAdaptor")) {
my $queen = $DBA->get_Queen();
my ($meadow_type, $process_id, $exec_host) = Bio::EnsEMBL::Hive::Meadow->guess_current_type_pid_exechost();
my ($meadow_type, $process_id, $exec_host) = Bio::EnsEMBL::Hive::Valley->new()->guess_current_type_pid_exechost();
print "runWorker(-MeadowType => $meadow_type, -ProcessId => $process_id, -ExecHost => $exec_host)\n";
......
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