MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
semisync_slave.h
1 /* Copyright (c) 2006 MySQL AB, 2009 Sun Microsystems, Inc.
2  Use is subject to license terms.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16 
17 
18 #ifndef SEMISYNC_SLAVE_H
19 #define SEMISYNC_SLAVE_H
20 
21 #include "semisync.h"
22 
27  :public ReplSemiSyncBase {
28 public:
30  :slave_enabled_(false)
31  {}
32  ~ReplSemiSyncSlave() {}
33 
34  void setTraceLevel(unsigned long trace_level) {
35  trace_level_ = trace_level;
36  }
37 
38  /* Initialize this class after MySQL parameters are initialized. this
39  * function should be called once at bootstrap time.
40  */
41  int initObject();
42 
43  bool getSlaveEnabled() {
44  return slave_enabled_;
45  }
46  void setSlaveEnabled(bool enabled) {
47  slave_enabled_ = enabled;
48  }
49 
50  /* A slave reads the semi-sync packet header and separate the metadata
51  * from the payload data.
52  *
53  * Input:
54  * header - (IN) packet header pointer
55  * total_len - (IN) total packet length: metadata + payload
56  * need_reply - (IN) whether the master is waiting for the reply
57  * payload - (IN) payload: the replication event
58  * payload_len - (IN) payload length
59  *
60  * Return:
61  * 0: success; non-zero: error
62  */
63  int slaveReadSyncHeader(const char *header, unsigned long total_len, bool *need_reply,
64  const char **payload, unsigned long *payload_len);
65 
66  /* A slave replies to the master indicating its replication process. It
67  * indicates that the slave has received all events before the specified
68  * binlog position.
69  *
70  * Input:
71  * mysql - (IN) the mysql network connection
72  * binlog_filename - (IN) the reply point's binlog file name
73  * binlog_filepos - (IN) the reply point's binlog file offset
74  *
75  * Return:
76  * 0: success; non-zero: error
77  */
78  int slaveReply(MYSQL *mysql, const char *binlog_filename,
79  my_off_t binlog_filepos);
80 
81  int slaveStart(Binlog_relay_IO_param *param);
82  int slaveStop(Binlog_relay_IO_param *param);
83 
84 private:
85  /* True when initObject has been called */
86  bool init_done_;
87  bool slave_enabled_; /* semi-sycn is enabled on the slave */
88  MYSQL *mysql_reply; /* connection to send reply */
89 };
90 
91 
92 /* System and status variables for the slave component */
93 extern char rpl_semi_sync_slave_enabled;
94 extern unsigned long rpl_semi_sync_slave_trace_level;
95 extern char rpl_semi_sync_slave_status;
96 
97 #endif /* SEMISYNC_SLAVE_H */