Commit 13f17825 authored by Leo Gordon's avatar Leo Gordon
Browse files

computational part of sync() moved into...

computational part of sync() moved into AnalysisStats::recalculate_from_job_counts and can be run separately
parent ef154944
......@@ -36,6 +36,8 @@
package Bio::EnsEMBL::Hive::AnalysisStats;
use strict;
use List::Util 'sum';
use POSIX;
use Bio::EnsEMBL::Hive::Utils ('throw');
use Bio::EnsEMBL::Hive::Analysis;
......@@ -371,4 +373,30 @@ sub determine_status {
}
sub recalculate_from_job_counts {
my ($self, $job_counts) = @_;
# only update job_counts if given the hash:
if($job_counts) {
$self->semaphored_job_count( $job_counts->{'SEMAPHORED'} || 0 );
$self->ready_job_count( $job_counts->{'READY'} || 0 );
$self->failed_job_count( $job_counts->{'FAILED'} || 0 );
$self->done_job_count( $job_counts->{'DONE'} + $job_counts->{'PASSED_ON'} || 0 ); # done here or potentially done elsewhere
$self->total_job_count( sum( values %$job_counts ) || 0 );
}
# compute the number of total required workers for this analysis (taking into account the jobs that are already running)
my $analysis = $self->analysis();
my $scheduling_allowed = ( !defined( $self->hive_capacity ) or $self->hive_capacity )
&& ( !defined( $analysis->analysis_capacity ) or $analysis->analysis_capacity );
my $required_workers = $scheduling_allowed
&& POSIX::ceil( $self->ready_job_count() / $self->get_or_estimate_batch_size() );
$self->num_required_workers( $required_workers );
$self->check_blocking_control_rules();
$self->determine_status();
}
1;
......@@ -66,9 +66,7 @@
package Bio::EnsEMBL::Hive::Queen;
use strict;
use POSIX;
use File::Path 'make_path';
use List::Util 'sum';
use Bio::EnsEMBL::Hive::Utils ('destringify', 'dir_revhash'); # NB: needed by invisible code
use Bio::EnsEMBL::Hive::AnalysisJob;
......@@ -594,30 +592,9 @@ sub synchronize_AnalysisStats {
$analysisStats->refresh(); ## Need to get the new hive_capacity for dynamic analyses
unless($self->db->hive_use_triggers()) {
my $job_counts = $self->db->hive_use_triggers() ? undef : $self->db->get_AnalysisJobAdaptor->fetch_job_counts_hashed_by_status( $analysisStats->analysis_id );
my $job_counts = $self->db->get_AnalysisJobAdaptor->fetch_job_counts_hashed_by_status( $analysisStats->analysis_id );
$analysisStats->semaphored_job_count( $job_counts->{'SEMAPHORED'} || 0 );
$analysisStats->ready_job_count( $job_counts->{'READY'} || 0 );
$analysisStats->failed_job_count( $job_counts->{'FAILED'} || 0 );
$analysisStats->done_job_count( $job_counts->{'DONE'} + $job_counts->{'PASSED_ON'} || 0 ); # done here or potentially done elsewhere
$analysisStats->total_job_count( sum( values %$job_counts ) || 0 );
} # unless($self->db->hive_use_triggers())
# compute the number of total required workers for this analysis (taking into account the jobs that are already running)
my $analysis = $analysisStats->analysis();
my $scheduling_allowed = ( !defined( $analysisStats->hive_capacity ) or $analysisStats->hive_capacity )
&& ( !defined( $analysis->analysis_capacity ) or $analysis->analysis_capacity );
my $required_workers = $scheduling_allowed
&& POSIX::ceil( $analysisStats->ready_job_count() / $analysisStats->get_or_estimate_batch_size() );
$analysisStats->num_required_workers( $required_workers );
$analysisStats->check_blocking_control_rules();
$analysisStats->determine_status();
$analysisStats->recalculate_from_job_counts( $job_counts );
# $analysisStats->sync_lock(0); ## do we perhaps need it here?
$analysisStats->update; #update and release sync_lock
......
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