~hezx/mysql-server/semi-sync-replication

« back to all changes in this revision

Viewing changes to semisync_slave.h

  • Committer: He Zhenxing
  • Date: 2008-10-15 03:18:28 UTC
  • Revision ID: hezx@mysql.com-20081015031828-kozqcu4tr9fl8s21
initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2006 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
15
 
 
16
 
 
17
#ifndef SEMISYNC_SLAVE_H
 
18
#define SEMISYNC_SLAVE_H
 
19
 
 
20
#include "semisync.h"
 
21
 
 
22
/**
 
23
   The extension class for the slave of semi-synchronous replication
 
24
*/
 
25
class ReplSemiSyncSlave
 
26
  :public ReplSemiSyncBase {
 
27
public:
 
28
 ReplSemiSyncSlave()
 
29
   :slave_enabled_(false)
 
30
  {}
 
31
  ~ReplSemiSyncSlave() {}
 
32
 
 
33
  void setTraceLevel(unsigned long trace_level) {
 
34
    trace_level_ = trace_level;
 
35
  }
 
36
 
 
37
  /* Initialize this class after MySQL parameters are initialized. this
 
38
   * function should be called once at bootstrap time.
 
39
   */
 
40
  int initObject();
 
41
 
 
42
  bool getSlaveEnabled() {
 
43
    return slave_enabled_;
 
44
  }
 
45
  void setSlaveEnabled(bool enabled) {
 
46
    slave_enabled_ = enabled;
 
47
  }
 
48
 
 
49
  /* A slave reads the semi-sync packet header and separate the metadata
 
50
   * from the payload data.
 
51
   * 
 
52
   * Input:
 
53
   *  header      - (IN)  packet header pointer
 
54
   *  total_len   - (IN)  total packet length: metadata + payload
 
55
   *  need_reply  - (IN)  whether the master is waiting for the reply
 
56
   *  payload     - (IN)  payload: the replication event
 
57
   *  payload_len - (IN)  payload length
 
58
   *
 
59
   * Return:
 
60
   *  0: success;  -1 or otherwise: error
 
61
   */
 
62
  int slaveReadSyncHeader(const char *header, unsigned long total_len, bool *need_reply,
 
63
                          const char **payload, unsigned long *payload_len);
 
64
 
 
65
  /* A slave replies to the master indicating its replication process.  It
 
66
   * indicates that the slave has received all events before the specified
 
67
   * binlog position.
 
68
   * 
 
69
   * Input:
 
70
   *  mysql            - (IN)  the mysql network connection
 
71
   *  binlog_filename  - (IN)  the reply point's binlog file name
 
72
   *  binlog_filepos   - (IN)  the reply point's binlog file offset
 
73
   *
 
74
   * Return:
 
75
   *  0: success;  -1 or otherwise: error
 
76
   */
 
77
/*   int slaveReply(MYSQL *mysql, const char *binlog_filename, */
 
78
/*                  my_off_t binlog_filepos); */
 
79
 
 
80
  int slaveReply(const char *log_name, my_off_t log_pos);
 
81
  
 
82
  int slaveStart(Binlog_relay_IO_param *param);
 
83
  int slaveStop(Binlog_relay_IO_param *param);
 
84
 
 
85
private:
 
86
  /* True when initObject has been called */
 
87
  bool init_done_;
 
88
  bool slave_enabled_;        /* semi-sycn is enabled on the slave */
 
89
  MYSQL *mysql;         /* connection to send reply */
 
90
};
 
91
 
 
92
 
 
93
extern bool semi_sync_need_reply;
 
94
 
 
95
extern char rpl_semi_sync_slave_enabled;
 
96
extern unsigned long rpl_semi_sync_slave_trace_level;
 
97
extern unsigned long rpl_semi_sync_slave_status;
 
98
 
 
99
#endif /* SEMISYNC_SLAVE_H */