11 It contains all the beekeeper-management methods that are
12 called by beekeeper.pl and requir the database.
16 See the NOTICE file distributed with
this work
for additional information
17 regarding copyright ownership.
19 Licensed under the Apache License,
Version 2.0 (the
"License"); you may not use
this file except in compliance with the License.
20 You may obtain a copy of the License at
24 Unless required by applicable law or agreed to in writing, software distributed under the License
25 is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26 See the License
for the specific language governing permissions and limitations under the License.
30 Please subscribe to the
Hive mailing list: http:
35 package Bio::EnsEMBL::Hive::DBSQL::BeekeeperAdaptor;
39 use base (
'Bio::EnsEMBL::Hive::DBSQL::ObjectAdaptor');
41 # --------------------------------- ObjectAdaptor implementation ---------------------------------------
43 sub default_table_name {
49 return 'Bio::EnsEMBL::Hive::Beekeeper';
53 # --------------------------------- Beekeeper methods ---------------------------------------
55 =head2 find_live_beekeepers_in_my_meadow
58 Example : my $live_beekeepers_in_my_meadow = $bk_adaptor->find_live_beekeepers_in_my_meadow($beekeeper);
59 Description : Returns all the beekeepers registered on the same host as $ref_beekeeper that are still alive.
67 sub find_live_beekeepers_in_my_meadow {
68 my ($self, $ref_beekeeper) = @_;
70 my $filter = sprintf(
"meadow_host = '%s' AND beekeeper_id != %d AND cause_of_death IS NULL", $ref_beekeeper->meadow_host, $ref_beekeeper->dbID);
71 return $self->fetch_all($filter);
75 =head2 bury_other_beekeepers
78 Example : $bk_adaptor->bury_other_beekeepers($ref_beekeeper);
79 Description : Calls find_live_beekeepers_in_my_meadow() and buries the beekeepers that
80 are not running any more (not find with `ps`)
88 sub bury_other_beekeepers {
89 my ($self, $ref_beekeeper) = @_;
91 my $allegedly_live_beekeepers_in_my_meadow = $self->find_live_beekeepers_in_my_meadow($ref_beekeeper);
92 foreach my $beekeeper_to_check (@$allegedly_live_beekeepers_in_my_meadow) {
94 my $cmd = qq{ps -p $pid -f | fgrep beekeeper.pl};
95 my $beekeeper_entry = qx{$cmd};
97 unless ($beekeeper_entry) {
98 $beekeeper_to_check->set_cause_of_death(
'DISAPPEARED');
104 =head2 reload_beekeeper_is_blocked
107 Example : my $is_blocked = $bk_adaptor->reload_beekeeper_is_blocked($beekeeper);
108 Description : Updates the
object with the freshest value of is_blocked coming from the database
109 for this beekeeper, and
return the
new value.
117 sub reload_beekeeper_is_blocked {
118 my ($self, $beekeeper) = @_;
120 my $query =
'SELECT is_blocked FROM beekeeper WHERE beekeeper_id = ?';
122 my $sth = $self->dbc->prepare($query);
123 $sth->execute($beekeeper->dbID);
125 my ($is_blocked) = $sth->fetchrow_array();
134 =head2 block_all_alive_beekeepers
136 Example : $bk_adaptor->block_all_alive_beekeepers();
137 Description : Set is_blocked
for all beekeepers known to the
138 pipeline which haven
't died yet. Part of the "shut
139 everything down" feature - as eHive stands we cannot
140 tell other beekeepers to kill their respective active
141 workers (unless said workers happen to belong to the
142 same meadow, in which case we can essentially hijack
143 them) but at least we can prevent them from spawning
147 Caller : beekeeper.pl
152 sub block_all_alive_beekeepers {
155 my $statement = 'UPDATE beekeeper SET is_blocked = 1 WHERE cause_of_death IS NULL
';
156 my $sth = $self->dbc()->prepare( $statement );