Commit 54927cb4 authored by Jessica Severin's avatar Jessica Severin
Browse files

changed Queen->create_new_worker method to use rearrange formating.

Also added functionality so that runWorker can be run without
specification of an analysis.  The create_new_worker method now will
query for a 'needed worker' analysis from the AnalysisStats adaptor when
the analysis_id is undef.  This simplifies the API interface between the
Queen and the beekeepers.  Now the beekeeper only needs to receive a count
of workers.  The workers can still be run with explicit analyses for
testing or situations where one wants to manually control the processing.
Now one can simply do
bsub -JW[1-100] runWorker -url mysql://ensadmin:<pass>@ecs2:3361/compara_hive_jess_23
to create 100 workers which will become whatever analysis that needs to be done.
parent b2bcfd6f
......@@ -63,6 +63,9 @@ use Bio::EnsEMBL::DBSQL::BaseAdaptor;
use Sys::Hostname;
use Bio::EnsEMBL::Hive::DBSQL::AnalysisCtrlRuleAdaptor;
use Bio::EnsEMBL::Utils::Argument qw(rearrange);
use Bio::EnsEMBL::Utils::Exception qw(throw warning);
our @ISA = qw(Bio::EnsEMBL::DBSQL::BaseAdaptor);
#
......@@ -82,12 +85,20 @@ our @ISA = qw(Bio::EnsEMBL::DBSQL::BaseAdaptor);
=cut
sub create_new_worker {
my $self = shift;
my $analysis_id = shift;
my $beekeeper = shift;
my ($self, @args) = @_;
my ($analysis_id, $beekeeper) =
rearrange([qw(analysis_id beekeeper )], @args);
my $analStatsDBA = $self->db->get_AnalysisStatsAdaptor;
return undef unless($analStatsDBA);
unless($analysis_id) {
my ($anal_stats) = @{$analStatsDBA->fetch_by_needed_workers(1)};
return undef unless($anal_stats);
$analysis_id = $anal_stats->analysis_id;
$analStatsDBA->decrement_needed_workers($analysis_id);
}
my $analysisStats = $analStatsDBA->fetch_by_analysis_id($analysis_id);
return undef unless($analysisStats);
......@@ -252,6 +263,20 @@ sub adjust_stats_for_living_workers {
}
sub get_hive_current_load {
my $self = shift;
my $sql = "SELECT sum(1/analysis_stats.hive_capacity) FROM hive, analysis_stats ".
"WHERE hive.analysis_id=analysis_stats.analysis_id and cause_of_death =''";
my $sth = $self->prepare($sql);
$sth->execute();
(my $load)=$sth->fetchrow_array();
$sth->finish;
$load=0 unless($load);
print("current hive load = $load\n");
return $load;
}
sub next_clutch {
my $self = shift;
......@@ -310,7 +335,7 @@ sub print_hive_status
my $self = shift;
my $allStats = $self->db->get_AnalysisStatsAdaptor->fetch_all();
foreach my $analysis_stats (@{$allStats}) {
$analysis_stats->print_stats;
}
......
......@@ -22,6 +22,8 @@ $self->{'analysis_id'} = undef;
$self->{'logic_name'} = undef;
$self->{'outdir'} = undef;
$self->{'beekeeper'} = undef;
$self->{'process_id'} = undef;
my $conf_file;
my ($help, $host, $user, $pass, $dbname, $port, $adaptor, $url);
......@@ -41,6 +43,7 @@ GetOptions('help' => \$help,
'lifespan=i' => \$self->{'lifespan'},
'outdir=s' => \$self->{'outdir'},
'bk=s' => \$self->{'beekeeper'},
'pid=s' => \$self->{'process_id'},
);
$self->{'analysis_id'} = shift if(@_);
......@@ -67,13 +70,9 @@ if($url) {
usage();
}
unless(defined($self->{'analysis_id'})) {
print "\nERROR : must specify analysis_id of worker\n\n";
usage();
}
# connect to database specified
$DBA = new Bio::EnsEMBL::Hive::DBSQL::DBAdaptor(%{$self->{'db_conf'}});
$url = $DBA->url();
}
my $queen = $DBA->get_Queen();
......@@ -83,8 +82,14 @@ if($self->{'logic_name'}) {
$self->{'analysis_id'} = $analysis->dbID if($analysis);
}
my $worker = $queen->create_new_worker($self->{'analysis_id'}, $self->{'beekeeper'});
die("couldn't create worker for analysis_id ".$self->{'analysis_id'}."\n") unless($worker);
my $worker = $queen->create_new_worker(
-analysis_id => $self->{'analysis_id'},
-beekeeper => $self->{'beekeeper'}
);
unless($worker) {
Bio::EnsEMBL::Hive::URLFactory->cleanup;
die("couldn't create worker\n");
}
if(defined($self->{'outdir'})) { $worker->output_dir($self->{'outdir'}); }
else {
......
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