MySQL  8.0.17
Source Code Documentation
rpl_info_factory.h
Go to the documentation of this file.
1 /* Copyright (c) 2010, 2018, 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, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef RPL_INFO_FACTORY_H
24 #define RPL_INFO_FACTORY_H
25 
26 #include <sys/types.h>
27 #include <string>
28 #include <vector>
29 
30 #include "my_io.h"
31 #include "sql/rpl_info_handler.h" // enum_return_check
32 
33 class Master_info;
34 class Multisource_info;
35 class Relay_log_info;
36 class Rpl_info;
37 class Slave_worker;
38 
41 
43  public:
44  static bool create_slave_info_objects(uint mi_option, uint rli_option,
45  int thread_mask,
46  Multisource_info *pchannel_map);
47 
48  /**
49  Establish the relation between the channel's replication filters and
50  the channel's Relay_log_info, and copy global replication filters to
51  the channel's replication filters if needed.
52 
53  @param rli Pointer to Relay_log_info.
54  @param channel_name The channel name.
55 
56  @retval false No error
57  @retval true Failure
58  */
60  const char *channel_name);
61 
62  static Master_info *create_mi_and_rli_objects(uint mi_option, uint rli_option,
63  const char *channel,
64  bool convert_repo,
66 
67  static Master_info *create_mi(uint rli_option, const char *channel,
68  bool conver_repo);
69  static bool change_mi_repository(Master_info *mi, const uint mi_option,
70  const char **msg);
71  static Relay_log_info *create_rli(uint rli_option, bool is_slave_recovery,
72  const char *channel, bool convert_repo);
73  static bool change_rli_repository(Relay_log_info *rli, const uint rli_option,
74  const char **msg);
75  static Slave_worker *create_worker(uint rli_option, uint worker_id,
76  Relay_log_info *rli,
77  bool is_gaps_collecting_phase);
78  static bool reset_workers(Relay_log_info *rli);
79 
80  private:
81  typedef struct {
83  char name[FN_REFLEN];
84  char pattern[FN_REFLEN];
85  bool name_indexed; // whether file name should include instance number
87 
88  typedef struct {
90  const char *schema;
91  const char *name;
95 
102 
103  static void init_repository_metadata();
104  static bool decide_repository(Rpl_info *info, uint option,
105  Rpl_info_handler **handler_src,
106  Rpl_info_handler **handler_dest,
107  const char **msg);
108  static bool init_repositories(const struct_table_data &table_data,
109  const struct_file_data &file_data, uint option,
110  Rpl_info_handler **handler_src,
111  Rpl_info_handler **handler_dest,
112  const char **msg);
113 
115  Rpl_info_handler **handler_src);
116  static bool check_error_repository(Rpl_info_handler *handler_src,
117  Rpl_info_handler *handler_dst,
118  enum_return_check err_src,
119  enum_return_check err_dst,
120  const char **msg);
121  static bool init_repositories(Rpl_info *info, Rpl_info_handler **handler_src,
122  Rpl_info_handler **handler_dst,
123  const char **msg);
124  static bool scan_repositories(uint *found_instances, uint *found_rep_option,
125  const struct_table_data &table_data,
126  const struct_file_data &file_data,
127  const char **msg);
129  std::vector<std::string> &channel_list, uint mi_instances,
130  uint mi_repository, const char *default_channel,
131  bool *default_channel_created_previously);
132 
133  static bool load_channel_names_from_table(
134  std::vector<std::string> &channel_list, const char *default_channel,
135  bool *default_channel_created_previously);
136 };
137 
138 #endif
static bool create_slave_info_objects(uint mi_option, uint rli_option, int thread_mask, Multisource_info *pchannel_map)
This function should be called from init_slave() only.
Definition: rpl_info_factory.cc:1058
uint n_fields
Definition: rpl_info_factory.h:82
static struct_file_data mi_file_data
Definition: rpl_info_factory.h:99
static enum_return_check check_src_repository(Rpl_info *info, uint option, Rpl_info_handler **handler_src)
This method is called by the decide_repository() and is used to check if the source repository exits...
Definition: rpl_info_factory.cc:688
static Master_info * create_mi_and_rli_objects(uint mi_option, uint rli_option, const char *channel, bool convert_repo, Multisource_info *channel_map)
Create Master_info and Relay_log_info objects for a new channel.
Definition: rpl_info_factory.cc:1190
const string name("\ame\)
Definition: rpl_info_handler.h:55
static struct_table_data worker_table_data
Definition: rpl_info_factory.h:100
static bool change_mi_repository(Master_info *mi, const uint mi_option, const char **msg)
Allows to change the master info repository after startup.
Definition: rpl_info_factory.cc:160
Definition: rpl_info_factory.h:88
static Master_info * create_mi(uint rli_option, const char *channel, bool conver_repo)
Creates a Master info repository whose type is defined as a parameter.
Definition: rpl_info_factory.cc:90
static bool init_repositories(const struct_table_data &table_data, const struct_file_data &file_data, uint option, Rpl_info_handler **handler_src, Rpl_info_handler **handler_dest, const char **msg)
Creates repositories that will be associated to either the Master_info or Relay_log_info.
Definition: rpl_info_factory.cc:825
Definition: rpl_info_factory.h:42
static struct_table_data rli_table_data
Definition: rpl_info_factory.h:96
const uint * pk_field_indexes
Definition: rpl_info_factory.h:93
Definition: rpl_info.h:42
ulong opt_rli_repository_id
Definition: sys_vars.cc:1502
uint n_fields
Definition: rpl_info_factory.h:89
structure to define some default "config_option" option settings
Definition: innodb_config.h:180
Definition: rpl_info_factory.h:81
static struct_file_data rli_file_data
Definition: rpl_info_factory.h:97
Definition: rpl_rli.h:164
ulong opt_mi_repository_id
Definition: sys_vars.cc:1493
static bool configure_channel_replication_filters(Relay_log_info *rli, const char *channel_name)
Establish the relation between the channel&#39;s replication filters and the channel&#39;s Relay_log_info...
Definition: rpl_info_factory.cc:924
static bool change_rli_repository(Relay_log_info *rli, const uint rli_option, const char **msg)
Allows to change the relay log info repository after startup.
Definition: rpl_info_factory.cc:322
unsigned int uint
Definition: uca-dump.cc:29
#define FN_REFLEN
Definition: my_io.h:82
char msg[1024]
Definition: test_sql_9_sessions.cc:282
Multisource_info channel_map
Definition: rpl_msr.cc:411
Class to store all the Master_info objects of a slave to access them in the replication code base or ...
Definition: rpl_msr.h:110
static bool decide_repository(Rpl_info *info, uint option, Rpl_info_handler **handler_src, Rpl_info_handler **handler_dest, const char **msg)
Decides during startup what repository will be used based on the following decision table: ...
Definition: rpl_info_factory.cc:572
static bool check_error_repository(Rpl_info_handler *handler_src, Rpl_info_handler *handler_dst, enum_return_check err_src, enum_return_check err_dst, const char **msg)
This method is called by the decide_repository() and is used print out information on errors...
Definition: rpl_info_factory.cc:748
static bool scan_repositories(uint *found_instances, uint *found_rep_option, const struct_table_data &table_data, const struct_file_data &file_data, const char **msg)
Definition: rpl_info_factory.cc:876
Definition: rpl_mi.h:85
enum_return_check
Definition: rpl_info_handler.h:49
Definition: rpl_rli_pdb.h:515
Common #defines and includes for file and socket I/O.
static void init_repository_metadata()
Initializes startup information on diferent repositories.
Definition: rpl_info_factory.cc:501
static struct_table_data mi_table_data
Definition: rpl_info_factory.h:98
bool name_indexed
Definition: rpl_info_factory.h:85
static Relay_log_info * create_rli(uint rli_option, bool is_slave_recovery, const char *channel, bool convert_repo)
Creates a Relay log info repository whose type is defined as a parameter.
Definition: rpl_info_factory.cc:204
Log info(cout, "NOTE")
const char * schema
Definition: rpl_info_factory.h:90
static bool load_channel_names_from_repository(std::vector< std::string > &channel_list, uint mi_instances, uint mi_repository, const char *default_channel, bool *default_channel_created_previously)
Make a list of all the channels if existed on the previos slave run.
Definition: rpl_info_factory.cc:1246
const char * name
Definition: rpl_info_factory.h:91
unsigned long ulong
Definition: my_inttypes.h:48
static bool reset_workers(Relay_log_info *rli)
Delete all info from Worker info tables to render them useless in future MTS recovery, and indicate that in Coordinator info table.
Definition: rpl_info_factory.cc:355
uint n_pk_fields
Definition: rpl_info_factory.h:92
static bool load_channel_names_from_table(std::vector< std::string > &channel_list, const char *default_channel, bool *default_channel_created_previously)
In a multisourced slave, during init_slave(), the repositories are read to initialize the slave info ...
Definition: rpl_info_factory.cc:1300
static struct_file_data worker_file_data
Definition: rpl_info_factory.h:101
static Slave_worker * create_worker(uint rli_option, uint worker_id, Relay_log_info *rli, bool is_gaps_collecting_phase)
Creates a Slave worker repository whose type is defined as a parameter.
Definition: rpl_info_factory.cc:405