My Project
rpl_info.h
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_H
00017 #define RPL_INFO_H
00018 
00019 #include "sql_priv.h"
00020 #include "sql_class.h"
00021 #include "rpl_info_handler.h"
00022 #include "rpl_reporting.h"
00023 
00024 class Rpl_info : public Slave_reporting_capability
00025 {
00026 public:
00027   virtual ~Rpl_info();
00028 
00029   /*
00030     standard lock acquisition order to avoid deadlocks:
00031     run_lock, data_lock, relay_log.LOCK_log, relay_log.LOCK_index
00032     run_lock, sleep_lock
00033   */
00034   mysql_mutex_t data_lock, run_lock, sleep_lock;
00035   /*
00036     start_cond is broadcast when SQL thread is started
00037     stop_cond  - when stopped
00038     data_cond  - when data protected by data_lock changes
00039     sleep_cond - when killed
00040   */
00041   mysql_cond_t data_cond, start_cond, stop_cond, sleep_cond;
00042 
00043 #ifdef HAVE_PSI_INTERFACE
00044   PSI_mutex_key *key_info_run_lock, *key_info_data_lock, *key_info_sleep_lock;
00045 
00046   PSI_mutex_key *key_info_data_cond, *key_info_start_cond, *key_info_stop_cond,
00047                 *key_info_sleep_cond;
00048 #endif
00049 
00050   THD *info_thd;
00051 
00052   bool inited;
00053   volatile bool abort_slave;
00054   volatile uint slave_running;
00055   volatile ulong slave_run_id;
00056 
00057 #ifndef DBUG_OFF
00058   int events_until_exit;
00059 #endif
00060 
00066   void set_rpl_info_handler(Rpl_info_handler * param_handler)
00067   {
00068     handler= param_handler;
00069   }
00070 
00076   Rpl_info_handler *get_rpl_info_handler()
00077   {
00078     return (handler);
00079   }
00080 
00081   enum_return_check check_info()
00082   {
00083     return (handler->check_info());
00084   }
00085 
00086   int remove_info()
00087   {
00088     return (handler->remove_info());
00089   }
00090 
00091   int clean_info()
00092   {
00093     return (handler->clean_info());
00094   }
00095 
00096   bool is_transactional()
00097   {
00098     return (handler->is_transactional());
00099   }
00100 
00101   bool update_is_transactional()
00102   {
00103     return (handler->update_is_transactional());
00104   }
00105 
00106   char *get_description_info()
00107   {
00108     return (handler->get_description_info());
00109   }
00110 
00111   bool copy_info(Rpl_info_handler *from, Rpl_info_handler *to)
00112   {
00113     if (read_info(from) || write_info(to))
00114       return(TRUE);
00115 
00116     return(FALSE);
00117   }
00118 
00119   uint get_internal_id()
00120   {
00121     return internal_id;
00122   }
00123 
00124 protected:
00128   Rpl_info_handler *handler;
00129 
00136   uint internal_id;
00137 
00138   Rpl_info(const char* type
00139 #ifdef HAVE_PSI_INTERFACE
00140            ,PSI_mutex_key *param_key_info_run_lock,
00141            PSI_mutex_key *param_key_info_data_lock,
00142            PSI_mutex_key *param_key_info_sleep_lock,
00143            PSI_mutex_key *param_key_info_data_cond,
00144            PSI_mutex_key *param_key_info_start_cond,
00145            PSI_mutex_key *param_key_info_stop_cond,
00146            PSI_mutex_key *param_key_info_sleep_cond
00147 #endif
00148            ,uint param_id
00149           );
00150 
00151 private:
00152   virtual bool read_info(Rpl_info_handler *from)= 0;
00153   virtual bool write_info(Rpl_info_handler *to)= 0;
00154 
00155   Rpl_info(const Rpl_info& info);
00156   Rpl_info& operator=(const Rpl_info& info);
00157 };
00158 #endif /* RPL_INFO_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines