Commit ba8716f1 authored by Jessica Severin's avatar Jessica Severin
Browse files

finally gave in and created a Hive::DBSQL::DBAdaptor which inherits from

Bio::EnsEMBL::DBSQL::DBAdaptor to match symetry with core,pipeline,compara
This means I can remove all 'hive' adaptors from compara now and the
URLFactory now returns by default a Hive::DBSQL::DBAdaptor.
This also means I can make my graph configuring runnableDBs really
adaptible to run on both Pipeline and Hive systems by doing
if($self->db->isa('Bio::EnsEMBL::Pipeline::DBAdaptor')) {...}
if($self->db->isa('Bio::EnsEMBL::Hive::DBAdaptor')) {...}
parent 9303bb52
#
# BioPerl module for DBSQL::Obj
#
# Cared for by Ewan Birney <birney@sanger.ac.uk>
#
# Copyright Ewan Birney
#
# You may distribute this module under the same terms as perl itself
# POD documentation - main docs before the code
=head1 NAME
Bio::EnsEMBL::Hive::DBSQL::DBAdaptor
=head1 SYNOPSIS
$db = Bio::EnsEMBL::Hive::DBSQL::DBAdaptor->new(
-user => 'root',
-dbname => 'pog',
-host => 'caldy',
-driver => 'mysql',
);
=head1 DESCRIPTION
This object represents the handle for a comparative DNA alignment database
=head1 CONTACT
Post questions the the EnsEMBL developer list: <ensembl-dev@ebi.ac.uk>
=cut
# Let the code begin...
package Bio::EnsEMBL::Hive::DBSQL::DBAdaptor;
use vars qw(@ISA);
use strict;
use Bio::EnsEMBL::DBSQL::DBConnection;
use Bio::EnsEMBL::DBSQL::DBAdaptor;
@ISA = qw( Bio::EnsEMBL::DBSQL::DBAdaptor );
sub new {
my ($class, @args) = @_;
#call superclass constructor; this may actually return a container
my $container = $class->SUPER::new(@args);
my $self;
if($container->isa('Bio::EnsEMBL::Container')) {
$self = $container->_obj;
} else {
$self = $container;
}
#we want to return the container not the contained object
return $container;
}
sub get_AnalysisAdaptor {
my $self = shift;
return $self->_get_adaptor("Bio::EnsEMBL::DBSQL::AnalysisAdaptor" );
}
sub get_Queen {
my $self = shift;
return $self->_get_adaptor("Bio::EnsEMBL::Hive::Queen" );
}
sub get_AnalysisJobAdaptor {
my $self = shift;
return $self->_get_adaptor("Bio::EnsEMBL::Hive::DBSQL::AnalysisJobAdaptor" );
}
sub get_AnalysisStatsAdaptor {
my $self = shift;
return $self->_get_adaptor("Bio::EnsEMBL::Hive::DBSQL::AnalysisStatsAdaptor" );
}
sub get_DataflowRuleAdaptor {
my $self = shift;
return $self->_get_adaptor("Bio::EnsEMBL::Hive::DBSQL::DataflowRuleAdaptor" );
}
sub get_AnalysisCtrlRuleAdaptor {
my $self = shift;
return $self->_get_adaptor("Bio::EnsEMBL::Hive::DBSQL::AnalysisCtrlRuleAdaptor" );
}
1;
...@@ -61,6 +61,7 @@ use strict; ...@@ -61,6 +61,7 @@ use strict;
use Bio::EnsEMBL::Hive::Worker; use Bio::EnsEMBL::Hive::Worker;
use Bio::EnsEMBL::DBSQL::BaseAdaptor; use Bio::EnsEMBL::DBSQL::BaseAdaptor;
use Sys::Hostname; use Sys::Hostname;
use Bio::EnsEMBL::Hive::DBSQL::AnalysisCtrlRuleAdaptor;
our @ISA = qw(Bio::EnsEMBL::DBSQL::BaseAdaptor); our @ISA = qw(Bio::EnsEMBL::DBSQL::BaseAdaptor);
...@@ -85,7 +86,7 @@ sub create_new_worker { ...@@ -85,7 +86,7 @@ sub create_new_worker {
my $analysis_id = shift; my $analysis_id = shift;
my $beekeeper = shift; my $beekeeper = shift;
my $analStatsDBA = $self->_analysisStatsAdaptor; my $analStatsDBA = $self->db->get_AnalysisStatsAdaptor;
return undef unless($analStatsDBA); return undef unless($analStatsDBA);
my $analysisStats = $analStatsDBA->fetch_by_analysis_id($analysis_id); my $analysisStats = $analStatsDBA->fetch_by_analysis_id($analysis_id);
...@@ -144,11 +145,11 @@ sub register_worker_death { ...@@ -144,11 +145,11 @@ sub register_worker_death {
$sth->finish; $sth->finish;
if($worker->cause_of_death eq "NO_WORK") { if($worker->cause_of_death eq "NO_WORK") {
$self->_analysisStatsAdaptor->update_status($worker->analysis->dbID, "ALL_CLAIMED"); $self->db->get_AnalysisStatsAdaptor->update_status($worker->analysis->dbID, "ALL_CLAIMED");
} }
if($worker->cause_of_death eq "FATALITY") { if($worker->cause_of_death eq "FATALITY") {
#print("FATAL DEATH Arrrrgggghhhhhhhh (hive_id=",$worker->hive_id,")\n"); #print("FATAL DEATH Arrrrgggghhhhhhhh (hive_id=",$worker->hive_id,")\n");
$self->_analysisJobAdaptor->reset_dead_jobs_for_worker($worker); $self->db->get_AnalysisJobAdaptor->reset_dead_jobs_for_worker($worker);
} }
} }
...@@ -185,7 +186,7 @@ sub update_analysis_stats { ...@@ -185,7 +186,7 @@ sub update_analysis_stats {
"WHERE analysis_job.analysis_id=analysis.analysis_id ". "WHERE analysis_job.analysis_id=analysis.analysis_id ".
"GROUP BY analysis_job.analysis_id, status"; "GROUP BY analysis_job.analysis_id, status";
my $statsDBA = $self->_analysisStatsAdaptor; my $statsDBA = $self->db->get_AnalysisStatsAdaptor;
my $analysisStats = undef; my $analysisStats = undef;
my $sth = $self->prepare($sql); my $sth = $self->prepare($sql);
...@@ -225,7 +226,7 @@ sub update_analysis_stats { ...@@ -225,7 +226,7 @@ sub update_analysis_stats {
sub adjust_stats_for_living_workers { sub adjust_stats_for_living_workers {
my $self = shift; my $self = shift;
my $statsDBA = $self->_analysisStatsAdaptor; my $statsDBA = $self->db->get_AnalysisStatsAdaptor;
my $sql = "SELECT analysis_id, count(*) FROM hive ". my $sql = "SELECT analysis_id, count(*) FROM hive ".
"WHERE cause_of_death='' GROUP BY analysis_id"; "WHERE cause_of_death='' GROUP BY analysis_id";
...@@ -253,7 +254,7 @@ sub adjust_stats_for_living_workers { ...@@ -253,7 +254,7 @@ sub adjust_stats_for_living_workers {
sub next_clutch { sub next_clutch {
my $self = shift; my $self = shift;
my $clutches = $self->_analysisStatsAdaptor->fetch_by_needed_workers(); my $clutches = $self->db->get_AnalysisStatsAdaptor->fetch_by_needed_workers();
return (0, 0) unless($clutches); return (0, 0) unless($clutches);
my $smallestClutch = undef; my $smallestClutch = undef;
...@@ -277,35 +278,13 @@ sub next_clutch { ...@@ -277,35 +278,13 @@ sub next_clutch {
# #
# INTERNAL METHODS # INTERNAL METHODS
# #
################### ###################
sub _analysisStatsAdaptor {
my $self = shift;
unless($self->{'analysisStatsDBA'}) {
$self->{'analysisStatsDBA'} = new Bio::EnsEMBL::Hive::DBSQL::AnalysisStatsAdaptor($self->db);
}
return $self->{'analysisStatsDBA'};
}
sub _analysisJobAdaptor {
my $self = shift;
unless($self->{'analysisJobDBA'}) {
$self->{'analysisJobDBA'} = new Bio::EnsEMBL::Hive::DBSQL::AnalysisJobAdaptor($self->db);
}
return $self->{'analysisJobDBA'};
}
sub _analysisAdaptor {
my $self = shift;
unless($self->{'analysisDBA'}) {
$self->{'analysisDBA'} = new Bio::EnsEMBL::DBSQL::AnalysisAdaptor($self->db);
}
return $self->{'analysisDBA'};
}
=head2 _fetch_by_hive_id =head2 _fetch_by_hive_id
Arg [1] : int $id Arg [1] : int $id
......
...@@ -42,7 +42,7 @@ use Bio::EnsEMBL::Hive::Extensions; ...@@ -42,7 +42,7 @@ use Bio::EnsEMBL::Hive::Extensions;
use Bio::EnsEMBL::DBSQL::AnalysisAdaptor; use Bio::EnsEMBL::DBSQL::AnalysisAdaptor;
use Bio::EnsEMBL::DBSQL::DBConnection; use Bio::EnsEMBL::DBSQL::DBConnection;
use Bio::EnsEMBL::DBSQL::DBAdaptor; use Bio::EnsEMBL::DBSQL::DBAdaptor;
use Bio::EnsEMBL::Compara::DBSQL::DBAdaptor; use Bio::EnsEMBL::Hive::DBSQL::DBAdaptor;
our @ISA = qw(Bio::EnsEMBL::Root); our @ISA = qw(Bio::EnsEMBL::Root);
...@@ -167,7 +167,7 @@ sub _get_db_connection ...@@ -167,7 +167,7 @@ sub _get_db_connection
return ($dbc,$path) if($dbc); return ($dbc,$path) if($dbc);
#print("CONNECT via user=$user\n pass=$pass\n host=$host\n port=$port\n dbname=$dbname\n path=$path\n"); #print("CONNECT via user=$user\n pass=$pass\n host=$host\n port=$port\n dbname=$dbname\n path=$path\n");
$dbc = new Bio::EnsEMBL::Compara::DBSQL::DBAdaptor( $dbc = new Bio::EnsEMBL::Hive::DBSQL::DBAdaptor(
-disconnect_when_inactive => 1, -disconnect_when_inactive => 1,
-driver => 'mysql', -driver => 'mysql',
-user => $user, -user => $user,
......
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