ensembl-hive  2.6
Beekeeper.pm
Go to the documentation of this file.
1 =pod
2 
3 =head1 NAME
4 
6 
7 =head1 DESCRIPTION
8 
9  A light-weight object to record a Beekeeper instance.
10 
11  This object does not perform any of tasks beekeeper do (submitting jobs, etc),
12  its purpose is merely to record the fact that a beekeeper has been run, and
13  update its status.
14 
15 =head1 LICENSE
16 
17  Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
18  Copyright [2016-2024] EMBL-European Bioinformatics Institute
19 
20  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
21  You may obtain a copy of the License at
22 
23  http://www.apache.org/licenses/LICENSE-2.0
24 
25  Unless required by applicable law or agreed to in writing, software distributed under the License
26  is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27  See the License for the specific language governing permissions and limitations under the License.
28 
29 =head1 CONTACT
30 
31  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
32 
33 =cut
34 
35 
36 package Bio::EnsEMBL::Hive::Beekeeper;
37 
38 use strict;
39 use warnings;
40 
41 use base ( 'Bio::EnsEMBL::Hive::Storable' ); # To enable dbID() and adaptor()
42 
43 
44 =head2 new_from_Valley
45 
46  Example : my $new_from_Valley = Bio::EnsEMBL::Hive::Beekeeper->new_from_Valley($valley);
47  Description : A specific constructor that sets all the fields according to the given Valley.
49  Exceptions : none
50  Caller : general
51  Status : Stable
52 
53 =cut
54 
55 sub new_from_Valley {
56  my ($class, $valley, @args) = @_;
57 
58  my ($meadow, $pid, $meadow_host, $meadow_user) = $valley->whereami;
59  unless($meadow->can('deregister_local_process')) {
60  die "beekeeper.pl detected it has been itself submitted to '".$meadow->type."/".$meadow->cached_name."', but this mode of operation is not supported.\n"
61  ."Please just run beekeeper.pl on a farm head node, preferably from under a 'screen' session.\n";
62  }
63  $meadow->deregister_local_process();
64 
65  return $class->SUPER::new(
66  'meadow' => $meadow_host,
67  'meadow_host' => $meadow_host,
68  'meadow_user' => $meadow_user,
69  'process_id' => $pid,
70  @args,
71  );
72 }
73 
74 
75 # --------------------------------- Getter / Setters ---------------------------------------
76 
77 sub meadow_host {
78  my $self = shift;
79  $self->{'_meadow_host'} = shift if(@_);
80  return $self->{'_meadow_host'};
81 }
82 
83 sub meadow_user {
84  my $self = shift;
85  $self->{'_meadow_user'} = shift if(@_);
86  return $self->{'_meadow_user'};
87 }
88 
89 sub process_id {
90  my $self = shift;
91  $self->{'_process_id'} = shift if(@_);
92  return $self->{'_process_id'};
93 }
94 
95 sub is_blocked {
96  my $self = shift;
97  $self->{'_is_blocked'} = shift if(@_);
98  return $self->{'_is_blocked'};
99 }
100 
101 sub cause_of_death {
102  my $self = shift;
103  $self->{'_cause_of_death'} = shift if(@_);
104  return $self->{'_cause_of_death'};
105 }
106 
107 sub sleep_minutes {
108  my $self = shift;
109  $self->{'_sleep_minutes'} = shift if(@_);
110  return $self->{'_sleep_minutes'};
111 }
112 
113 sub analyses_pattern {
114  my $self = shift;
115  $self->{'_analyses_pattern'} = shift if(@_);
116  return $self->{'_analyses_pattern'};
117 }
118 
119 sub loop_limit {
120  my $self = shift;
121  $self->{'_loop_limit'} = shift if(@_);
122  return $self->{'_loop_limit'};
123 }
124 
125 sub loop_until {
126  my $self = shift;
127  $self->{'_loop_until'} = shift if(@_);
128  return $self->{'_loop_until'};
129 }
130 
131 sub options {
132  my $self = shift;
133  $self->{'_options'} = shift if(@_);
134  return $self->{'_options'};
135 }
136 
137 sub meadow_signatures {
138  my $self = shift;
139  $self->{'_meadow_signatures'} = shift if(@_);
140  return $self->{'_meadow_signatures'};
141 }
142 
143 
144 # --------------------------------- Convenient methods ---------------------------------------
145 
146 sub meadow {
147  my $self = shift;
148  $self->{'_meadow'} = shift if(@_);
149  return $self->{'_meadow'};
150 }
151 
152 
153 =head2 set_cause_of_death
154 
155  Example : $beekeeper->set_cause_of_death('LOOP_LIMIT');
156  Description : Set the "cause of death" of this beekeeper in the object and in the database.
157  Returntype : none
158  Exceptions : none
159  Caller : general
160  Status : Stable
161 
162 =cut
163 
164 sub set_cause_of_death {
165  my ($self, $cause_of_death) = @_;
166 
167  $self->cause_of_death( $cause_of_death );
168  $self->adaptor->update_cause_of_death($self) if $self->adaptor;
169 }
170 
171 
172 =head2 check_if_blocked
173 
174  Example : my $check_if_blocked = $beekeeper->check_if_blocked();
175  Description : Updates the object with the freshest value of is_blocked coming from the database
176  for this beekeeper, and return the new value.
177  Returntype : Boolean
178  Exceptions : none
179  Caller : general
180  Status : Stable
181 
182 =cut
183 
184 sub check_if_blocked {
185  my ($self) = @_;
186  $self->adaptor->reload_beekeeper_is_blocked($self) if $self->adaptor;
187  return $self->is_blocked;
188 }
189 
190 
191 =head2 toString
192 
193  Example : print $beekeeper->toString();
194  Description : Produces a string summary of properties of this beekeeper.
195  Returntype : String
196  Exceptions : none
197  Caller : general
198  Status : Stable
199 
200 =cut
201 
202 sub toString {
203  my ( $self ) = @_;
204 
205  return join( ', ',
206  'process=' . $self->meadow_user() . '@' . $self->meadow_host() . '#' . $self->process_id(),
207  "options='" . $self->options() . "'",
208  );
209 }
210 
211 
212 1;
213 
Bio::EnsEMBL::Hive::Beekeeper::new_from_Valley
public Bio::EnsEMBL::Hive::Beekeeper new_from_Valley()
Bio::EnsEMBL::Hive::Version
Definition: Version.pm:19
Bio::EnsEMBL::Hive::Beekeeper
Definition: Beekeeper.pm:13
run
public run()
Bio::EnsEMBL::Hive
Definition: Hive.pm:38
Bio::EnsEMBL::Hive::Valley
Definition: Valley.pm:16
Bio::EnsEMBL::Hive::Beekeeper::set_cause_of_death
public void set_cause_of_death()