From 1a4664d667306ff47af608e6fd14d881d10f642b Mon Sep 17 00:00:00 2001 From: Leo Gordon <lg4@ebi.ac.uk> Date: Tue, 1 Jul 2014 12:57:45 +0100 Subject: [PATCH] internal api cleanup: switched to more intuitive set_and_update_status/check_in_worker/check_in_job calls --- modules/Bio/EnsEMBL/Hive/AnalysisJob.pm | 10 ++++++---- .../Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm | 6 +++--- modules/Bio/EnsEMBL/Hive/Process.pm | 2 +- modules/Bio/EnsEMBL/Hive/Worker.pm | 16 +++++++++++++--- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/modules/Bio/EnsEMBL/Hive/AnalysisJob.pm b/modules/Bio/EnsEMBL/Hive/AnalysisJob.pm index 8096e23c4..89d49059f 100644 --- a/modules/Bio/EnsEMBL/Hive/AnalysisJob.pm +++ b/modules/Bio/EnsEMBL/Hive/AnalysisJob.pm @@ -134,12 +134,14 @@ sub semaphored_job_id { return $self->{'_semaphored_job_id'}; } - -sub update_status { +sub set_and_update_status { my ($self, $status ) = @_; + $self->status($status); - return unless($self->adaptor); - $self->adaptor->update_status($self); + + if(my $adaptor = $self->adaptor) { + $adaptor->check_in_job($self); + } } sub dataflow_rules { # if ever set will prevent the Job from fetching rules from the DB diff --git a/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm b/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm index e85f7c549..cbfcd761c 100644 --- a/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm +++ b/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm @@ -252,7 +252,7 @@ sub increase_semaphore_count_for_jobid { # used in semaphore propagation } -=head2 update_status +=head2 check_in_job Arg [1] : $analysis_id Example : @@ -263,7 +263,7 @@ sub increase_semaphore_count_for_jobid { # used in semaphore propagation =cut -sub update_status { +sub check_in_job { my ($self, $job) = @_; my $sql = "UPDATE job SET status='".$job->status."' "; @@ -527,7 +527,7 @@ sub gc_dataflow { $job->dataflow_output_id( $job->input_id() , $branch_name ); - $job->update_status('PASSED_ON'); + $job->set_and_update_status('PASSED_ON'); if(my $semaphored_job_id = $job->semaphored_job_id) { $self->decrease_semaphore_count_for_jobid( $semaphored_job_id ); # step-unblock the semaphore diff --git a/modules/Bio/EnsEMBL/Hive/Process.pm b/modules/Bio/EnsEMBL/Hive/Process.pm index 99ba89f32..3f1e53430 100644 --- a/modules/Bio/EnsEMBL/Hive/Process.pm +++ b/modules/Bio/EnsEMBL/Hive/Process.pm @@ -191,7 +191,7 @@ sub enter_status { my $job = $self->input_job(); - $job->update_status( $status ); + $job->set_and_update_status( $status ); my $status_msg = 'Job '.$job->dbID.' : '.$status; diff --git a/modules/Bio/EnsEMBL/Hive/Worker.pm b/modules/Bio/EnsEMBL/Hive/Worker.pm index 1ebbb6b25..787c036da 100644 --- a/modules/Bio/EnsEMBL/Hive/Worker.pm +++ b/modules/Bio/EnsEMBL/Hive/Worker.pm @@ -704,7 +704,7 @@ sub run_one_batch { } else { # job successfully completed: $self->more_work_done( $job_partial_timing ); $jobs_done_here++; - $job->update_status('DONE'); + $job->set_and_update_status('DONE'); if(my $semaphored_job_id = $job->semaphored_job_id) { my $dbc = $self->adaptor->db->dbc; @@ -728,6 +728,17 @@ sub run_one_batch { } +sub set_and_update_status { + my ($self, $status ) = @_; + + $self->status($status); + + if(my $adaptor = $self->adaptor) { + $adaptor->check_in_worker( $self ); + } +} + + sub enter_status { my ($self, $status, $msg) = @_; @@ -737,8 +748,7 @@ sub enter_status { $self->worker_say( $msg ); } - $self->status( $status ); - $self->adaptor->check_in_worker( $self ); + $self->set_and_update_status( $status ); } -- GitLab