Commit 5c88e337 authored by Leo Gordon's avatar Leo Gordon
Browse files

support selective balancing of semaphores funneling into a specific analysis

parent 45f4153e
......@@ -697,13 +697,18 @@ sub reset_jobs_for_analysis_id {
=cut
sub balance_semaphores {
my ($self) = @_;
my ($self, $filter_analysis) = @_;
my $analysis_id = $filter_analysis && $filter_analysis->dbID();
my $find_sql = qq{
SELECT funnel.job_id, funnel.semaphore_count was, COALESCE(SUM(fan.status!='DONE'),0) should
FROM job funnel
LEFT JOIN job fan ON (funnel.job_id=fan.semaphored_job_id)
WHERE funnel.status='SEMAPHORED'
WHERE }
.($analysis_id ? "funnel.analysis_id=$analysis_id AND " : '')
.qq{
funnel.status='SEMAPHORED'
GROUP BY funnel.job_id
HAVING was<>should OR should=0
};
......
......@@ -201,11 +201,6 @@ sub main {
$self->{'dba'}->get_Queen->synchronize_AnalysisStats($reset_analysis->stats);
}
if($all_dead) { $queen->register_all_workers_dead(); }
if($check_for_dead) { $queen->check_for_dead_workers($valley, 1); }
if($balance_semaphores) { $self->{'dba'}->get_AnalysisJobAdaptor->balance_semaphores(); }
if ($kill_worker_id) {
my $kill_worker = $queen->fetch_by_dbID($kill_worker_id);
......@@ -236,6 +231,10 @@ sub main {
? $self->{'dba'}->get_AnalysisAdaptor->fetch_by_dbID( $self->{'dba'}->get_AnalysisJobAdaptor->fetch_by_dbID( $run_job_id )->analysis_id )
: $self->{'dba'}->get_AnalysisAdaptor->fetch_by_logic_name($self->{'logic_name'});
if($all_dead) { $queen->register_all_workers_dead(); }
if($check_for_dead) { $queen->check_for_dead_workers($valley, 1); }
if($balance_semaphores) { $self->{'dba'}->get_AnalysisJobAdaptor->balance_semaphores( $analysis ); }
if ($max_loops) { # positive $max_loop means limited, negative means unlimited
run_autonomously($self, $max_loops, $keep_alive, $queen, $valley, $analysis, $run_job_id, $force);
......
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