rpl_mi.h 3.93 KB
Newer Older
1 2 3 4
/* Copyright (C) 2000-2003 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
unknown's avatar
unknown committed
5
   the Free Software Foundation; version 2 of the License.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

#ifndef RPL_MI_H
#define RPL_MI_H

#ifdef HAVE_REPLICATION

21
#include "rpl_rli.h"
22
#include "rpl_reporting.h"
Andrei Elkin's avatar
Andrei Elkin committed
23
#include "my_sys.h"
24 25


26 27 28 29
/*****************************************************************************

  Replication IO Thread

30
  Master_info contains:
31 32 33 34 35
    - information about how to connect to a master
    - current master log name
    - current master log offset
    - misc control variables

36
  Master_info is initialized once from the master.info file if such
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
  exists. Otherwise, data members corresponding to master.info fields
  are initialized with defaults specified by master-* options. The
  initialization is done through init_master_info() call.

  The format of master.info file:

  log_name
  log_pos
  master_host
  master_user
  master_pass
  master_port
  master_connect_retry

  To write out the contents of master.info file to disk ( needed every
  time we read and queue data from the master ), a call to
  flush_master_info() is required.

  To clean up, call end_master_info()

*****************************************************************************/

59
class Master_info : public Slave_reporting_capability
60 61
{
 public:
62 63
  Master_info();
  ~Master_info();
Andrei Elkin's avatar
Andrei Elkin committed
64
  bool shall_ignore_server_id(ulong s_id);
65 66 67 68 69 70 71 72 73

  /* the variables below are needed because we can change masters on the fly */
  char master_log_name[FN_REFLEN];
  char host[HOSTNAME_LENGTH+1];
  char user[USERNAME_LENGTH+1];
  char password[MAX_PASSWORD_LENGTH+1];
  my_bool ssl; // enables use of SSL connection if true
  char ssl_ca[FN_REFLEN], ssl_capath[FN_REFLEN], ssl_cert[FN_REFLEN];
  char ssl_cipher[FN_REFLEN], ssl_key[FN_REFLEN];
74
  my_bool ssl_verify_server_cert;
75 76 77 78 79 80 81 82 83 84

  my_off_t master_log_pos;
  File fd; // we keep the file open, so we need to remember the file pointer
  IO_CACHE file;

  pthread_mutex_t data_lock,run_lock;
  pthread_cond_t data_cond,start_cond,stop_cond;
  THD *io_thd;
  MYSQL* mysql;
  uint32 file_id;				/* for 3.23 load data infile */
85
  Relay_log_info rli;
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
  uint port;
  uint connect_retry;
#ifndef DBUG_OFF
  int events_till_disconnect;
#endif
  bool inited;
  volatile bool abort_slave;
  volatile uint slave_running;
  volatile ulong slave_run_id;
  /*
     The difference in seconds between the clock of the master and the clock of
     the slave (second - first). It must be signed as it may be <0 or >0.
     clock_diff_with_master is computed when the I/O thread starts; for this the
     I/O thread does a SELECT UNIX_TIMESTAMP() on the master.
     "how late the slave is compared to the master" is computed like this:
     clock_of_slave - last_timestamp_executed_by_SQL_thread - clock_diff_with_master

  */
  long clock_diff_with_master;
Andrei Elkin's avatar
Andrei Elkin committed
105 106 107 108
  float heartbeat_period;         // interface with CHANGE MASTER or master.info
  ulonglong received_heartbeats;  // counter of received heartbeat events
  DYNAMIC_ARRAY ignore_server_ids;
  ulong master_id;
109 110
};

111 112
void init_master_info_with_options(Master_info* mi);
int init_master_info(Master_info* mi, const char* master_info_fname,
113 114 115
		     const char* slave_info_fname,
		     bool abort_if_no_master_info_file,
		     int thread_mask);
116 117
void end_master_info(Master_info* mi);
int flush_master_info(Master_info* mi, bool flush_relay_log_cache);
Andrei Elkin's avatar
Andrei Elkin committed
118
int change_master_server_id_cmp(ulong *id1, ulong *id2);
119 120 121

#endif /* HAVE_REPLICATION */
#endif /* RPL_MI_H */