ensembl-hive  2.5
Role.pm
Go to the documentation of this file.
1 =pod
2 
3 =head1 NAME
4 
6 
7 =head1 DESCRIPTION
8 
9  Role is a state of a Worker while performing jobs of a particular Analysis.
10 
11 =head1 LICENSE
12 
13  Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
14  Copyright [2016-2022] EMBL-European Bioinformatics Institute
15 
16  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
17  You may obtain a copy of the License at
18 
19  http://www.apache.org/licenses/LICENSE-2.0
20 
21  Unless required by applicable law or agreed to in writing, software distributed under the License
22  is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23  See the License for the specific language governing permissions and limitations under the License.
24 
25 =head1 CONTACT
26 
27  Please subscribe to the Hive mailing list: http://listserver.ebi.ac.uk/mailman/listinfo/ehive-users to discuss Hive-related questions or to be notified of our updates
28 
29 =head1 APPENDIX
30 
31  The rest of the documentation details each of the object methods.
32  Internal methods are usually preceded with a _
33 
34 =cut
35 
36 
37 package Bio::EnsEMBL::Hive::Role;
38 
39 use strict;
40 use warnings;
41 
42 use base ( 'Bio::EnsEMBL::Hive::Storable' );
43 
44 
45 =head1 AUTOLOADED
46 
47  worker_id / worker
48  analysis_id / analysis
49 
50 =cut
51 
52 
53 sub when_started {
54  my $self = shift;
55  $self->{'_when_started'} = shift if(@_);
56  return $self->{'_when_started'};
57 }
58 
59 
60 sub when_finished {
61  my $self = shift;
62  $self->{'_when_finished'} = shift if(@_);
63  return $self->{'_when_finished'};
64 }
65 
66 
67 sub attempted_jobs {
68  my $self = shift;
69  $self->{'_attempted_jobs'} = shift if(@_);
70  return $self->{'_attempted_jobs'} || 0;
71 }
72 
73 
74 sub done_jobs {
75  my $self = shift;
76  $self->{'_done_jobs'} = shift if(@_);
77  return $self->{'_done_jobs'} || 0;
78 }
79 
80 
81 sub register_attempt {
82  my $self = shift;
83  my $success = shift;
84 
85  $self->{'_attempted_jobs'}++;
86  $self->{'_done_jobs'} += $success;
87 
88  if( my $adaptor = $self->adaptor ) {
89  $adaptor->update_attempted_jobs_AND_done_jobs( $self );
90  }
91 }
92 
93 1;