Commit 38864f47 authored by Leo Gordon's avatar Leo Gordon
Browse files

new 'hive_meta' table to keep hive_sql_schema_version (=number of patches),...

new 'hive_meta' table to keep hive_sql_schema_version (=number of patches), hive_pipeline_name and hive_use_triggers
parent 84a73a22
......@@ -71,7 +71,7 @@ sub hive_use_triggers { # getter only, not setter
my $self = shift @_;
unless( defined($self->{'_hive_use_triggers'}) ) {
my ($hive_use_triggers) = @{ $self->get_MetaContainer->list_value_by_key( 'hive_use_triggers' ) };
my $hive_use_triggers = $self->get_MetaAdaptor->fetch_by_meta_key( 'hive_use_triggers' );
$self->{'_hive_use_triggers'} = $hive_use_triggers || 0;
}
return $self->{'_hive_use_triggers'};
......@@ -82,23 +82,24 @@ sub get_available_adaptors {
my %pairs = (
# Core adaptors extended with Hive stuff:
'MetaContainer' => 'Bio::EnsEMBL::Hive::DBSQL::MetaContainer',
'MetaContainer' => 'Bio::EnsEMBL::Hive::DBSQL::MetaContainer',
# "new" Hive adaptors (sharing the same fetching/storing code inherited from the BaseAdaptor class) :
'AnalysisCtrlRule' => 'Bio::EnsEMBL::Hive::DBSQL::AnalysisCtrlRuleAdaptor',
'DataflowRule' => 'Bio::EnsEMBL::Hive::DBSQL::DataflowRuleAdaptor',
'ResourceDescription' => 'Bio::EnsEMBL::Hive::DBSQL::ResourceDescriptionAdaptor',
'ResourceClass' => 'Bio::EnsEMBL::Hive::DBSQL::ResourceClassAdaptor',
'LogMessage' => 'Bio::EnsEMBL::Hive::DBSQL::LogMessageAdaptor',
'NakedTable' => 'Bio::EnsEMBL::Hive::DBSQL::NakedTableAdaptor',
'Analysis' => 'Bio::EnsEMBL::Hive::DBSQL::AnalysisAdaptor',
'Queen' => 'Bio::EnsEMBL::Hive::Queen',
'AnalysisData' => 'Bio::EnsEMBL::Hive::DBSQL::AnalysisDataAdaptor',
'AnalysisCtrlRule' => 'Bio::EnsEMBL::Hive::DBSQL::AnalysisCtrlRuleAdaptor',
'DataflowRule' => 'Bio::EnsEMBL::Hive::DBSQL::DataflowRuleAdaptor',
'ResourceDescription' => 'Bio::EnsEMBL::Hive::DBSQL::ResourceDescriptionAdaptor',
'ResourceClass' => 'Bio::EnsEMBL::Hive::DBSQL::ResourceClassAdaptor',
'LogMessage' => 'Bio::EnsEMBL::Hive::DBSQL::LogMessageAdaptor',
'NakedTable' => 'Bio::EnsEMBL::Hive::DBSQL::NakedTableAdaptor',
'Analysis' => 'Bio::EnsEMBL::Hive::DBSQL::AnalysisAdaptor',
'Queen' => 'Bio::EnsEMBL::Hive::Queen',
'AnalysisData' => 'Bio::EnsEMBL::Hive::DBSQL::AnalysisDataAdaptor',
'Accumulator' => 'Bio::EnsEMBL::Hive::DBSQL::AccumulatorAdaptor',
'Meta' => 'Bio::EnsEMBL::Hive::DBSQL::MetaAdaptor',
# "old" Hive adaptors (having their own fetching/storing code) :
'AnalysisJob' => 'Bio::EnsEMBL::Hive::DBSQL::AnalysisJobAdaptor',
'AnalysisStats' => 'Bio::EnsEMBL::Hive::DBSQL::AnalysisStatsAdaptor',
'Accumulator' => 'Bio::EnsEMBL::Hive::DBSQL::AccumulatorAdaptor',
'AnalysisJob' => 'Bio::EnsEMBL::Hive::DBSQL::AnalysisJobAdaptor',
'AnalysisStats' => 'Bio::EnsEMBL::Hive::DBSQL::AnalysisStatsAdaptor',
);
return \%pairs;
}
......
=pod
=head1 NAME
Bio::EnsEMBL::Hive::DBSQL::MetaAdaptor
=head1 SYNOPSIS
$dba->get_MetaAdaptor->store( \@rows );
=head1 DESCRIPTION
This is currently an "objectless" adaptor for storing and fetching metadata
=head1 CONTACT
Please contact ehive-users@ebi.ac.uk mailing list with questions/suggestions.
=cut
package Bio::EnsEMBL::Hive::DBSQL::MetaAdaptor;
use strict;
use base ('Bio::EnsEMBL::Hive::DBSQL::NakedTableAdaptor');
sub default_table_name {
return 'hive_meta';
}
sub store_pair {
my ($self, $meta_key, $meta_value) = @_;
return $self->store( { 'meta_key' => $meta_key, 'meta_value' => $meta_value } );
}
1;
......@@ -150,7 +150,6 @@ sub pipeline_create_commands {
sub pipeline_wide_parameters {
my ($self) = @_;
return {
'pipeline_name' => $self->o('pipeline_name'), # name the pipeline to differentiate the submitted processes
};
}
......@@ -205,6 +204,14 @@ sub beekeeper_extra_cmdline_options {
# ---------------------------------[now comes the interfacing stuff - feel free to call but not to modify]--------------------
sub hive_meta_table {
my ($self) = @_;
return {
'hive_pipeline_name' => $self->o('pipeline_name'),
};
}
sub pre_options {
my $self = shift @_;
......@@ -326,7 +333,7 @@ sub process_options {
$self->{'_extra_options'} = $self->load_cmdline_options( $self->pre_options() );
$self->root()->{'pipeline_db'}{'-driver'} = $self->{'_extra_options'}{'hive_driver'} || 'mysql';
$self->use_cases( [ 'pipeline_create_commands', 'pipeline_wide_parameters', 'resource_classes', 'pipeline_analyses', 'beekeeper_extra_cmdline_options', 'pipeline_url' ] );
$self->use_cases( [ 'pipeline_create_commands', 'pipeline_wide_parameters', 'resource_classes', 'pipeline_analyses', 'beekeeper_extra_cmdline_options', 'pipeline_url', 'hive_meta_table' ] );
return $self->SUPER::process_options();
}
......@@ -359,7 +366,14 @@ sub run {
my $resource_class_adaptor = $hive_dba->get_ResourceClassAdaptor;
unless($job_topup) {
my $meta_container = $hive_dba->get_MetaContainer;
my $meta_adaptor = $hive_dba->get_MetaAdaptor; # the new adaptor for 'hive_meta' table
warn "Loading hive_meta table ...\n";
my $hive_meta_table = $self->hive_meta_table;
while( my($meta_key, $meta_value) = each %$hive_meta_table ) {
$meta_adaptor->store_pair( $meta_key, $meta_value );
}
my $meta_container = $hive_dba->get_MetaContainer; # adaptor over core's 'meta' table for compatibility with core API
warn "Loading pipeline-wide parameters ...\n";
my $pipeline_wide_parameters = $self->pipeline_wide_parameters;
......
......@@ -143,10 +143,7 @@ sub main {
my $queen = $self->{'dba'}->get_Queen;
my $pipeline_name = destringify(
$self->{'dba'}->get_MetaContainer->list_value_by_key("pipeline_name")->[0]
|| $self->{'dba'}->get_MetaContainer->list_value_by_key("name")->[0]
);
my $pipeline_name = $self->{'dba'}->get_MetaAdaptor->fetch_by_meta_key( 'hive_pipeline_name' );
unless($pipeline_name) {
print STDERR "+---------------------------------------------------------------------+\n";
......
-- create a new, hive-specific table for meta data and start using it for hive_sql_schema_version tracking:
CREATE TABLE hive_meta (
meta_key VARCHAR(80) NOT NULL PRIMARY KEY,
meta_value TEXT
) COLLATE=latin1_swedish_ci ENGINE=MyISAM;
-- INSERT the 'hive_sql_schema_version' for the first time, then keep UPDATE'ing
INSERT INTO hive_meta (meta_key, meta_value) VALUES ('hive_sql_schema_version', '49');
-- move 'hive_use_triggers' into hive_meta:
INSERT IGNORE INTO hive_meta (meta_key, meta_value) SELECT 'hive_use_triggers', COALESCE(MIN(REPLACE(meta_value, '"', '')), 0) FROM meta WHERE meta_key='hive_use_triggers';
-- move 'pipeline_name' into hive_meta and rename it into 'hive_pipeline_name':
INSERT IGNORE INTO hive_meta (meta_key, meta_value) SELECT 'hive_pipeline_name', REPLACE(meta_value,'"','') FROM meta WHERE meta_key='pipeline_name' or meta_key='name';
......@@ -356,6 +356,25 @@ CREATE TABLE analysis_data (
) COLLATE=latin1_swedish_ci ENGINE=InnoDB;
/**
@table hive_meta
@colour #000000
@desc This table keeps several important hive-specific pipeline-wide key-value pairs
such as hive_sql_schema_version, hive_use_triggers and hive_pipeline_name.
@column meta_key the KEY of KEY-VALUE pairs (primary key)
@column meta_value the VALUE of KEY-VALUE pairs
*/
CREATE TABLE hive_meta (
meta_key VARCHAR(80) NOT NULL PRIMARY KEY,
meta_value TEXT
) COLLATE=latin1_swedish_ci ENGINE=MyISAM;
/**
@table meta
......@@ -366,8 +385,7 @@ CREATE TABLE analysis_data (
if we are dealing with core-hive hybrid that is created in the wrong order.
At the moment meta table is used
(1) for compatibility with the Core API ('schema_version'),
(2) to keep some Hive-specific meta-information ('pipeline_name') and
(3) to keep pipeline-wide parameters.
(2) to keep pipeline-wide parameters.
@column meta_id auto-incrementing primary key, not really used per se
@column species_id always 1, kept for compatibility with the Core API
......@@ -571,6 +589,9 @@ CREATE TABLE monitor (
) COLLATE=latin1_swedish_ci ENGINE=InnoDB;
-- Auto add schema version to database (should be overridden by Compara's table.sql)
-- Auto add core schema_version to core meta table - for compatibility with core API. Could be overridden by Compara's table.sql
INSERT IGNORE INTO meta (species_id, meta_key, meta_value) VALUES (NULL, 'schema_version', '72');
-- Auto add hive_sql_schema_version to hive_meta table
INSERT INTO hive_meta (meta_key, meta_value) VALUES ('hive_sql_schema_version', '49');
......@@ -359,6 +359,25 @@ CREATE TABLE analysis_data (
CREATE INDEX ON analysis_data (data);
/**
@table hive_meta
@colour #000000
@desc This table keeps several important hive-specific pipeline-wide key-value pairs
such as hive_sql_schema_version, hive_use_triggers and hive_pipeline_name.
@column meta_key the KEY of KEY-VALUE pairs (primary key)
@column meta_value the VALUE of KEY-VALUE pairs
*/
CREATE TABLE hive_meta (
meta_key VARCHAR(80) NOT NULL PRIMARY KEY,
meta_value TEXT
);
/**
@table meta
......@@ -369,8 +388,7 @@ CREATE INDEX ON analysis_data (data);
if we are dealing with core-hive hybrid that is created in the wrong order.
At the moment meta table is used
(1) for compatibility with the Core API ('schema_version'),
(2) to keep some Hive-specific meta-information ('pipeline_name') and
(3) to keep pipeline-wide parameters.
(2) to keep pipeline-wide parameters.
@column meta_id auto-incrementing primary key, not really used per se
@column species_id always 1, kept for compatibility with the Core API
......@@ -573,6 +591,9 @@ CREATE TABLE monitor (
);
-- Auto add schema version to database (should be overridden by Compara's table.sql)
-- Auto add core schema_version to core meta table - for compatibility with core API. Could be overridden by Compara's table.sql
INSERT INTO meta (species_id, meta_key, meta_value) VALUES (NULL, 'schema_version', '72');
-- Auto add hive_sql_schema_version to hive_meta table
INSERT INTO hive_meta (meta_key, meta_value) VALUES ('hive_sql_schema_version', '49');
......@@ -350,6 +350,25 @@ CREATE TABLE analysis_data (
CREATE INDEX analysis_data_idx ON analysis_data (data);
/**
@table hive_meta
@colour #000000
@desc This table keeps several important hive-specific pipeline-wide key-value pairs
such as hive_sql_schema_version, hive_use_triggers and hive_pipeline_name.
@column meta_key the KEY of KEY-VALUE pairs (primary key)
@column meta_value the VALUE of KEY-VALUE pairs
*/
CREATE TABLE hive_meta (
meta_key VARCHAR(80) NOT NULL PRIMARY KEY,
meta_value TEXT
);
/**
@table meta
......@@ -360,8 +379,7 @@ CREATE INDEX analysis_data_idx ON analysis_data (data);
if we are dealing with core-hive hybrid that is created in the wrong order.
At the moment meta table is used
(1) for compatibility with the Core API ('schema_version'),
(2) to keep some Hive-specific meta-information ('pipeline_name') and
(3) to keep pipeline-wide parameters.
(2) to keep pipeline-wide parameters.
@column meta_id auto-incrementing primary key, not really used per se
@column species_id always 1, kept for compatibility with the Core API
......@@ -559,6 +577,9 @@ CREATE TABLE monitor (
);
-- Auto add schema version to database (should be overridden by Compara's table.sql)
-- Auto add core schema_version to core meta table - for compatibility with core API. Could be overridden by Compara's table.sql
INSERT OR IGNORE INTO meta (species_id, meta_key, meta_value) VALUES (NULL, 'schema_version', '72');
-- Auto add hive_sql_schema_version to hive_meta table
INSERT INTO hive_meta (meta_key, meta_value) VALUES ('hive_sql_schema_version', '49');
......@@ -61,5 +61,5 @@ FOR EACH ROW
AND NEW.status = 'DEAD';
# inform the runtime part of the system that triggers are in place:
INSERT INTO meta (meta_key, meta_value) VALUES ('hive_use_triggers', '1');
-- inform the runtime part of the system that triggers are in place:
INSERT INTO hive_meta (meta_key, meta_value) VALUES ('hive_use_triggers', '1');
......@@ -65,4 +65,4 @@ END;
-- inform the runtime part of the system that triggers are in place:
INSERT INTO meta (meta_key, meta_value) VALUES ('hive_use_triggers', '1');
INSERT INTO hive_meta (meta_key, meta_value) VALUES ('hive_use_triggers', '1');
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