ensembl-hive  2.8.1
ChangeMySQLEngine_conf.pm
Go to the documentation of this file.
1 =head1 LICENSE
2 
3 See the NOTICE file distributed with this work for additional information
4 regarding copyright ownership.
5 
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 
18 =cut
19 
20 
21 =pod
22 
23 =head1 NAME
24 
26 
27 =head1 SYNOPSIS
28 
29  init_pipeline.pl Bio::EnsEMBL::Hive::Examples::Factories::PipeConfig::ChangeMySQLEngine_conf -pipeline_url db://hive@database/to_track_jobs -target_db db://to/turn_into_innodb -target_engine InnoDB
30 
31 =head1 DESCRIPTION
32 
33 A pipeline to change MySQL engine for all tables in a given database
34 
35 =head1 CONTACT
36 
37 Please email comments or questions to the public Ensembl
38 developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
39 
40 Questions may also be sent to the Ensembl help desk at
41 <http://www.ensembl.org/Help/Contact>.
42 
43 =cut
44 
45 package Bio::EnsEMBL::Hive::Examples::Factories::PipeConfig::ChangeMySQLEngine_conf;
46 
47 use strict;
48 use warnings;
49 
50 use base ('Bio::EnsEMBL::Hive::PipeConfig::HiveGeneric_conf');
51 use Bio::EnsEMBL::Hive::PipeConfig::HiveGeneric_conf; # Allow this particular config to use conditional dataflow and INPUT_PLUS
52 
53 =head2 default_options
54 
55  Description : Implements default_options() interface method of Bio::EnsEMBL::Hive::PipeConfig::HiveGeneric_conf that is used to initialize default options.
56  In addition to the standard things it defines four options:
57  o('concurrent_jobs') defines how many tables can be worked on in parallel
58 
59 =cut
60 
61 sub default_options {
62  my ($self) = @_;
63  return {
64  %{$self->SUPER::default_options(@_)},
65 
66  'concurrent_jobs' => 2, # how many tables can be worked on in parallel (too many will slow the process down)
67  };
68 }
69 
70 =head2 pipeline_analyses
71 
72  Description : Implements pipeline_analyses() interface method of Bio::EnsEMBL::Hive::PipeConfig::HiveGeneric_conf that defines the structure of the pipeline: analyses, jobs, rules, etc.
73  Here it defines two analyses:
74 
75  * 'generate_job_list' generates a list of tables to be copied from master_db
76 
77  * 'change_engine' changes table's engine into the target engine
78 
79 =cut
80 
81 sub pipeline_analyses {
82  my ($self) = @_;
83  return [
84  { -logic_name => 'generate_job_list',
85  -module => 'Bio::EnsEMBL::Hive::RunnableDB::JobFactory',
86  -parameters => {
87  'db_conn' => '#target_db#',
88  'inputquery' => "SELECT table_name, engine FROM information_schema.TABLES WHERE Engine != '#target_engine#' AND table_schema=DATABASE();",
89  },
90  -input_ids => [
91  {
92  'target_db' => $self->o('target_db'),
93  'target_engine' => $self->o('target_engine'),
94  }
95  ],
96 
97  -flow_into => { 2 => { 'change_engine' => INPUT_PLUS() } },
98  },
99 
100  { -logic_name => 'change_engine',
101  -module => 'Bio::EnsEMBL::Hive::RunnableDB::SqlCmd',
102  -parameters => {
103  'db_conn' => '#target_db#',
104  'sql' => "ALTER TABLE #table_name# ENGINE='#target_engine#'",
105  },
106  -hive_capacity => $self->o('concurrent_jobs'), # allow several workers to perform identical tasks in parallel
107  },
108  ];
109 }
110 
111 1;
112 
Bio::EnsEMBL::Hive::Examples::Factories::PipeConfig::ChangeMySQLEngine_conf
Definition: ChangeMySQLEngine_conf.pm:14
Bio::EnsEMBL::Hive::PipeConfig::HiveGeneric_conf
Definition: HiveGeneric_conf.pm:54
Bio
Definition: AltAlleleGroup.pm:4