MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rpl_info_factory.h
1 /* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 
16 #ifndef RPL_INFO_FACTORY_H
17 #define RPL_INFO_FACTORY_H
18 
19 #ifdef HAVE_REPLICATION
20 
21 #include "table.h"
22 #include "rpl_info.h"
23 #include "rpl_mi.h"
24 #include "rpl_rli.h"
25 #include "rpl_rli_pdb.h"
26 #include "rpl_info_file.h"
27 #include "rpl_info_table.h"
28 #include "rpl_info_dummy.h"
29 #include "rpl_info_handler.h"
30 
31 extern ulong opt_mi_repository_id;
32 extern ulong opt_rli_repository_id;
33 
34 class Rpl_info_factory
35 {
36 public:
37  static bool create_coordinators(uint mi_option, Master_info **mi,
38  uint rli_option, Relay_log_info **rli);
39  static Master_info *create_mi(uint rli_option);
40  static bool change_mi_repository(Master_info *mi, const uint mi_option,
41  const char **msg);
42  static Relay_log_info *create_rli(uint rli_option, bool is_slave_recovery);
43  static bool change_rli_repository(Relay_log_info *rli, const uint rli_option,
44  const char **msg);
45  static Slave_worker *create_worker(uint rli_option, uint worker_id,
46  Relay_log_info *rli,
47  bool is_gaps_collecting_phase);
48  static bool reset_workers(Relay_log_info *rli);
49 private:
50  typedef struct
51  {
52  uint n_fields;
53  char name[FN_REFLEN];
54  char pattern[FN_REFLEN];
55  bool name_indexed; // whether file name should include instance number
56  } struct_file_data;
57 
58  typedef struct
59  {
60  uint n_fields;
61  const char* schema;
62  const char* name;
63  } struct_table_data;
64 
65  static struct_table_data rli_table_data;
66  static struct_file_data rli_file_data;
67  static struct_table_data mi_table_data;
68  static struct_file_data mi_file_data;
69  static struct_table_data worker_table_data;
70  static struct_file_data worker_file_data;
71 
72  static void init_repository_metadata();
73  static bool decide_repository(Rpl_info *info,
74  uint option,
75  Rpl_info_handler **handler_src,
76  Rpl_info_handler **handler_dest,
77  const char **msg);
78  static bool init_repositories(const struct_table_data table_data,
79  const struct_file_data file_data,
80  uint option,
81  uint instance,
82  Rpl_info_handler **handler_src,
83  Rpl_info_handler **handler_dest,
84  const char **msg);
85 
86  static enum_return_check check_src_repository(Rpl_info *info,
87  uint option,
88  Rpl_info_handler **handler_src);
89  static bool check_error_repository(Rpl_info *info,
90  Rpl_info_handler *handler_src,
91  Rpl_info_handler *handler_dst,
92  enum_return_check err_src,
93  enum_return_check err_dst,
94  const char **msg);
95  static bool init_repositories(Rpl_info *info,
96  Rpl_info_handler **handler_src,
97  Rpl_info_handler **handler_dst,
98  const char **msg);
99  static bool scan_repositories(uint* found_instances,
100  uint* found_rep_option,
101  const struct_table_data table_data,
102  const struct_file_data file_data, const char **msg);
103 };
104 
105 #endif
106 
107 #endif