~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/rpl_mi.h

  • Committer: Monty Taylor
  • Date: 2008-09-16 00:00:48 UTC
  • mto: This revision was merged to the branch mainline in revision 391.
  • Revision ID: monty@inaugust.com-20080916000048-3rvrv3gv9l0ad3gs
Fixed copyright headers in drizzled/

Show diffs side-by-side

added added

removed removed

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