~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/rpl_mi.h

  • Committer: Monty Taylor
  • Date: 2008-10-07 09:36:42 UTC
  • mto: This revision was merged to the branch mainline in revision 489.
  • Revision ID: monty@inaugust.com-20081007093642-1uqwwt6z5u306cux
Split a method out into innodb_plugin_extras. Innodb is the only thing that uses it. I imagine we probably want to do something totally different with this...

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 DRIZZLED_RPL_MI_H
 
21
#define DRIZZLED_RPL_MI_H
 
22
 
 
23
#include "rpl_rli.h"
 
24
#include "rpl_reporting.h"
 
25
 
 
26
 
 
27
/*****************************************************************************
 
28
 
 
29
  Replication IO Thread
 
30
 
 
31
  Master_info contains:
 
32
    - information about how to connect to a master
 
33
    - current master log name
 
34
    - current master log offset
 
35
    - misc control variables
 
36
 
 
37
  Master_info is initialized once from the master.info file if such
 
38
  exists. Otherwise, data members corresponding to master.info fields
 
39
  are initialized with defaults specified by master-* options. The
 
40
  initialization is done through init_master_info() call.
 
41
 
 
42
  The format of master.info file:
 
43
 
 
44
  log_name
 
45
  log_pos
 
46
  master_host
 
47
  master_user
 
48
  master_pass
 
49
  master_port
 
50
  master_connect_retry
 
51
 
 
52
  To write out the contents of master.info file to disk ( needed every
 
53
  time we read and queue data from the master ), a call to
 
54
  flush_master_info() is required.
 
55
 
 
56
  To clean up, call end_master_info()
 
57
 
 
58
*****************************************************************************/
 
59
 
 
60
class Master_info : public Slave_reporting_capability
 
61
{
 
62
 public:
 
63
  Master_info();
 
64
  ~Master_info();
 
65
 
 
66
  /* the variables below are needed because we can change masters on the fly */
 
67
  char master_log_name[FN_REFLEN];
 
68
  char host[HOSTNAME_LENGTH+1];
 
69
  char user[USERNAME_LENGTH+1];
 
70
  char password[MAX_PASSWORD_LENGTH+1];
 
71
 
 
72
  my_off_t master_log_pos;
 
73
  File fd; // we keep the file open, so we need to remember the file pointer
 
74
  IO_CACHE file;
 
75
 
 
76
  pthread_mutex_t data_lock,run_lock;
 
77
  pthread_cond_t data_cond,start_cond,stop_cond;
 
78
  THD *io_thd;
 
79
  DRIZZLE *drizzle;
 
80
  uint32_t file_id;                             /* for 3.23 load data infile */
 
81
  Relay_log_info rli;
 
82
  uint32_t port;
 
83
  uint32_t connect_retry;
 
84
  float heartbeat_period;         // interface with CHANGE MASTER or master.info
 
85
  uint64_t received_heartbeats;  // counter of received heartbeat events
 
86
  int events_till_disconnect;
 
87
  bool inited;
 
88
  volatile bool abort_slave;
 
89
  volatile uint32_t slave_running;
 
90
  volatile uint32_t slave_run_id;
 
91
  /*
 
92
     The difference in seconds between the clock of the master and the clock of
 
93
     the slave (second - first). It must be signed as it may be <0 or >0.
 
94
     clock_diff_with_master is computed when the I/O thread starts; for this the
 
95
     I/O thread does a SELECT UNIX_TIMESTAMP() on the master.
 
96
     "how late the slave is compared to the master" is computed like this:
 
97
     clock_of_slave - last_timestamp_executed_by_SQL_thread - clock_diff_with_master
 
98
 
 
99
  */
 
100
  long clock_diff_with_master;
 
101
};
 
102
 
 
103
void init_master_log_pos(Master_info* mi);
 
104
int init_master_info(Master_info* mi, const char* master_info_fname,
 
105
                     const char* slave_info_fname,
 
106
                     bool abort_if_no_master_info_file,
 
107
                     int thread_mask);
 
108
void end_master_info(Master_info* mi);
 
109
int flush_master_info(Master_info* mi, bool flush_relay_log_cache);
 
110
 
 
111
#endif /* DRIZZLED_RPL_MI_H */