My Project
|
00001 /* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; version 2 of the License. 00006 00007 This program is distributed in the hope that it will be useful, 00008 but WITHOUT ANY WARRANTY; without even the implied warranty of 00009 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00010 GNU General Public License for more details. 00011 00012 You should have received a copy of the GNU General Public License 00013 along with this program; if not, write to the Free Software 00014 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 00015 00016 #ifndef RPL_INFO_FACTORY_H 00017 #define RPL_INFO_FACTORY_H 00018 00019 #ifdef HAVE_REPLICATION 00020 00021 #include "table.h" 00022 #include "rpl_info.h" 00023 #include "rpl_mi.h" 00024 #include "rpl_rli.h" 00025 #include "rpl_rli_pdb.h" 00026 #include "rpl_info_file.h" 00027 #include "rpl_info_table.h" 00028 #include "rpl_info_dummy.h" 00029 #include "rpl_info_handler.h" 00030 00031 extern ulong opt_mi_repository_id; 00032 extern ulong opt_rli_repository_id; 00033 00034 class Rpl_info_factory 00035 { 00036 public: 00037 static bool create_coordinators(uint mi_option, Master_info **mi, 00038 uint rli_option, Relay_log_info **rli); 00039 static Master_info *create_mi(uint rli_option); 00040 static bool change_mi_repository(Master_info *mi, const uint mi_option, 00041 const char **msg); 00042 static Relay_log_info *create_rli(uint rli_option, bool is_slave_recovery); 00043 static bool change_rli_repository(Relay_log_info *rli, const uint rli_option, 00044 const char **msg); 00045 static Slave_worker *create_worker(uint rli_option, uint worker_id, 00046 Relay_log_info *rli, 00047 bool is_gaps_collecting_phase); 00048 static bool reset_workers(Relay_log_info *rli); 00049 private: 00050 typedef struct 00051 { 00052 uint n_fields; 00053 char name[FN_REFLEN]; 00054 char pattern[FN_REFLEN]; 00055 bool name_indexed; // whether file name should include instance number 00056 } struct_file_data; 00057 00058 typedef struct 00059 { 00060 uint n_fields; 00061 const char* schema; 00062 const char* name; 00063 } struct_table_data; 00064 00065 static struct_table_data rli_table_data; 00066 static struct_file_data rli_file_data; 00067 static struct_table_data mi_table_data; 00068 static struct_file_data mi_file_data; 00069 static struct_table_data worker_table_data; 00070 static struct_file_data worker_file_data; 00071 00072 static void init_repository_metadata(); 00073 static bool decide_repository(Rpl_info *info, 00074 uint option, 00075 Rpl_info_handler **handler_src, 00076 Rpl_info_handler **handler_dest, 00077 const char **msg); 00078 static bool init_repositories(const struct_table_data table_data, 00079 const struct_file_data file_data, 00080 uint option, 00081 uint instance, 00082 Rpl_info_handler **handler_src, 00083 Rpl_info_handler **handler_dest, 00084 const char **msg); 00085 00086 static enum_return_check check_src_repository(Rpl_info *info, 00087 uint option, 00088 Rpl_info_handler **handler_src); 00089 static bool check_error_repository(Rpl_info *info, 00090 Rpl_info_handler *handler_src, 00091 Rpl_info_handler *handler_dst, 00092 enum_return_check err_src, 00093 enum_return_check err_dst, 00094 const char **msg); 00095 static bool init_repositories(Rpl_info *info, 00096 Rpl_info_handler **handler_src, 00097 Rpl_info_handler **handler_dst, 00098 const char **msg); 00099 static bool scan_repositories(uint* found_instances, 00100 uint* found_rep_option, 00101 const struct_table_data table_data, 00102 const struct_file_data file_data, const char **msg); 00103 }; 00104 00105 #endif 00106 00107 #endif