You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
3.7 KiB

  1. /*
  2. Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
  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. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  13. */
  14. #ifndef RPL_MI_H
  15. #define RPL_MI_H
  16. #ifdef HAVE_REPLICATION
  17. #include "rpl_rli.h"
  18. #include "rpl_reporting.h"
  19. /*****************************************************************************
  20. Replication IO Thread
  21. Master_info contains:
  22. - information about how to connect to a master
  23. - current master log name
  24. - current master log offset
  25. - misc control variables
  26. Master_info is initialized once from the master.info file if such
  27. exists. Otherwise, data members corresponding to master.info fields
  28. are initialized with defaults specified by master-* options. The
  29. initialization is done through init_master_info() call.
  30. The format of master.info file:
  31. log_name
  32. log_pos
  33. master_host
  34. master_user
  35. master_pass
  36. master_port
  37. master_connect_retry
  38. To write out the contents of master.info file to disk ( needed every
  39. time we read and queue data from the master ), a call to
  40. flush_master_info() is required.
  41. To clean up, call end_master_info()
  42. *****************************************************************************/
  43. class Master_info : public Slave_reporting_capability
  44. {
  45. public:
  46. Master_info();
  47. ~Master_info();
  48. /* the variables below are needed because we can change masters on the fly */
  49. char master_log_name[FN_REFLEN];
  50. char host[HOSTNAME_LENGTH+1];
  51. char user[USERNAME_LENGTH+1];
  52. char password[MAX_PASSWORD_LENGTH+1];
  53. my_bool ssl; // enables use of SSL connection if true
  54. char ssl_ca[FN_REFLEN], ssl_capath[FN_REFLEN], ssl_cert[FN_REFLEN];
  55. char ssl_cipher[FN_REFLEN], ssl_key[FN_REFLEN];
  56. my_bool ssl_verify_server_cert;
  57. my_off_t master_log_pos;
  58. File fd; // we keep the file open, so we need to remember the file pointer
  59. IO_CACHE file;
  60. pthread_mutex_t data_lock,run_lock;
  61. pthread_cond_t data_cond,start_cond,stop_cond;
  62. THD *io_thd;
  63. MYSQL* mysql;
  64. uint32 file_id; /* for 3.23 load data infile */
  65. Relay_log_info rli;
  66. uint port;
  67. uint connect_retry;
  68. #ifndef DBUG_OFF
  69. int events_till_disconnect;
  70. #endif
  71. bool inited;
  72. volatile bool abort_slave;
  73. volatile uint slave_running;
  74. volatile ulong slave_run_id;
  75. /*
  76. The difference in seconds between the clock of the master and the clock of
  77. the slave (second - first). It must be signed as it may be <0 or >0.
  78. clock_diff_with_master is computed when the I/O thread starts; for this the
  79. I/O thread does a SELECT UNIX_TIMESTAMP() on the master.
  80. "how late the slave is compared to the master" is computed like this:
  81. clock_of_slave - last_timestamp_executed_by_SQL_thread - clock_diff_with_master
  82. */
  83. long clock_diff_with_master;
  84. };
  85. void init_master_info_with_options(Master_info* mi);
  86. int init_master_info(Master_info* mi, const char* master_info_fname,
  87. const char* slave_info_fname,
  88. bool abort_if_no_master_info_file,
  89. int thread_mask);
  90. void end_master_info(Master_info* mi);
  91. int flush_master_info(Master_info* mi,
  92. bool flush_relay_log_cache,
  93. bool need_lock_relay_log);
  94. #endif /* HAVE_REPLICATION */
  95. #endif /* RPL_MI_H */