~drizzle-trunk/drizzle/development

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