Commit 68bf9ff4 authored by Jessica Severin's avatar Jessica Severin
Browse files

added beekeeper tag to aid in tracking dead workers

parent 9196a58a
......@@ -81,7 +81,9 @@ our @ISA = qw(Bio::EnsEMBL::DBSQL::BaseAdaptor);
=cut
sub create_new_worker {
my ($self,$analysis_id) = @_;
my $self = shift;
my $analysis_id = shift;
my $beekeeper = shift;
my $analStatsDBA = $self->_analysisStatsAdaptor;
return undef unless($analStatsDBA);
......@@ -101,10 +103,12 @@ sub create_new_worker {
my $host = hostname;
my $ppid = getppid;
$beekeeper = '' unless($beekeeper);
my $sql = "INSERT INTO hive SET born=now(), last_check_in=now()".
",process_id='$ppid' ".
",analysis_id='$analysis_id' ".
",beekeeper='$beekeeper' ".
",host='$host'";
my $sth = $self->prepare($sql);
......@@ -410,6 +414,7 @@ sub _columns {
return qw (h.hive_id
h.analysis_id
h.beekeeper
h.host
h.process_id
h.work_done
......@@ -433,6 +438,7 @@ sub _objs_from_sth {
$worker->init;
$worker->hive_id($column{'hive_id'});
$worker->beekeeper($column{'beekeeper'});
$worker->host($column{'host'});
$worker->process_id($column{'process_id'});
$worker->work_done($column{'work_done'});
......
......@@ -87,6 +87,11 @@ sub db {
$self->{'_db'} = shift if(@_);
return $self->{'_db'};
}
sub beekeeper {
my $self = shift;
$self->{'_beekeeper'} = shift if(@_);
return $self->{'_beekeeper'};
}
=head2 analysis
Arg [1] : (optional) Bio::EnsEMBL::Analysis $value
......
......@@ -7,6 +7,7 @@ use Bio::EnsEMBL::Compara::DBSQL::DBAdaptor;
use Bio::EnsEMBL::Hive::Worker;
use Bio::EnsEMBL::Hive::Queen;
use Bio::EnsEMBL::Hive::URLFactory;
use Sys::Hostname;
# ok this is a hack, but I'm going to pretend I've got an object here
# by creating a blessed hash ref and passing it around like an object
......@@ -44,6 +45,7 @@ my $DBA;
if($url) {
$DBA = Bio::EnsEMBL::Hive::URLFactory->fetch($url);
die("Unable to connect to $url\n") unless($DBA);
} else {
if($host) { $self->{'db_conf'}->{'-host'} = $host; }
if($port) { $self->{'db_conf'}->{'-port'} = $port; }
......@@ -63,9 +65,11 @@ if($url) {
# connect to database specified
$DBA = new Bio::EnsEMBL::Compara::DBSQL::DBAdaptor(%{$self->{'db_conf'}});
}
print("$DBA\n");
$self->{'queen'} = new Bio::EnsEMBL::Hive::Queen($DBA);
check_for_dead_workers($self, $self->{'queen'});
run_beekeeper($self);
Bio::EnsEMBL::Hive::URLFactory->cleanup;
......@@ -120,12 +124,6 @@ sub run_beekeeper
my $self = shift;
my $queen = $self->{'queen'};
my $overdueWorkers = $queen->fetch_overdue_workers(3600); #overdue by 1hr
print(scalar(@{$overdueWorkers}), " overdue workers\n");
foreach my $worker (@{$overdueWorkers}) {
printf("%10d %20s analysis_id=%d\n", $worker->hive_id,$worker->host, $worker->analysis->dbID);
$queen->register_worker_death($worker);
}
$queen->update_analysis_stats();
my($analysis_id, $count) = $queen->next_clutch();
......@@ -137,4 +135,26 @@ sub run_beekeeper
}
sub check_for_dead_workers {
my $self = shift;
my $queen = shift;
my $host = hostname;
my $overdueWorkers = $queen->fetch_overdue_workers(3600); #overdue by 1hr
print(scalar(@{$overdueWorkers}), " overdue workers\n");
foreach my $worker (@{$overdueWorkers}) {
if(($worker->beekeeper eq 'local') and ($worker->host eq $host)) {
my $cmd = "ps -p ". $worker->process_id;
my $check = qx/$cmd/;
print("check : $check\n");
printf("%10d %20s analysis_id=%d\n", $worker->hive_id,$worker->host, $worker->analysis->dbID);
#$queen->register_worker_death($worker);
}
}
}
......@@ -14,6 +14,7 @@
CREATE TABLE hive (
hive_id int(10) NOT NULL auto_increment,
analysis_id int(10) NOT NULL,
beekeeper varchar(80) DEAFULT '' NOT NULL,
host varchar(40) DEFAULT '' NOT NULL,
process_id int(10) NOT NULL,
work_done int(11) DEFAULT '0' NOT NULL,
......
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