| 1 | /* Copyright (C) 2007 Google Inc. |
| 2 | Copyright (C) 2008 MySQL AB |
| 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_H |
| 19 | #define SEMISYNC_H |
| 20 | |
| 21 | #include "mysqld.h" |
| 22 | #include "log_event.h" |
| 23 | #include "replication.h" |
| 24 | |
| 25 | /** |
| 26 | This class is used to trace function calls and other process |
| 27 | information |
| 28 | */ |
| 29 | class Trace { |
| 30 | public: |
| 31 | static const unsigned long k_trace_function; |
| 32 | static const unsigned long k_trace_general; |
| 33 | static const unsigned long k_trace_detail; |
| 34 | static const unsigned long k_trace_net_wait; |
| 35 | |
| 36 | unsigned long m_trace_level; /* the level for tracing */ |
| 37 | |
| 38 | Trace() |
| 39 | :m_trace_level(0L) |
| 40 | {} |
| 41 | Trace(unsigned long trace_level) |
| 42 | :m_trace_level(trace_level) |
| 43 | {} |
| 44 | }; |
| 45 | |
| 46 | /** |
| 47 | Base class for semi-sync master and slave classes |
| 48 | */ |
| 49 | class Repl_semi_sync_base |
| 50 | :public Trace { |
| 51 | public: |
| 52 | static const unsigned char [2]; /* three byte packet header */ |
| 53 | |
| 54 | /* Constants in network packet header. */ |
| 55 | static const unsigned char k_packet_magic_num; |
| 56 | static const unsigned char k_packet_flag_sync; |
| 57 | }; |
| 58 | |
| 59 | /* The layout of a semisync slave reply packet: |
| 60 | 1 byte for the magic num |
| 61 | 8 bytes for the binlog positon |
| 62 | n bytes for the binlog filename, terminated with a '\0' |
| 63 | */ |
| 64 | #define REPLY_MAGIC_NUM_LEN 1 |
| 65 | #define REPLY_BINLOG_POS_LEN 8 |
| 66 | #define REPLY_BINLOG_NAME_LEN (FN_REFLEN + 1) |
| 67 | #define REPLY_MAGIC_NUM_OFFSET 0 |
| 68 | #define REPLY_BINLOG_POS_OFFSET (REPLY_MAGIC_NUM_OFFSET + REPLY_MAGIC_NUM_LEN) |
| 69 | #define REPLY_BINLOG_NAME_OFFSET (REPLY_BINLOG_POS_OFFSET + REPLY_BINLOG_POS_LEN) |
| 70 | #define REPLY_MESSAGE_MAX_LENGTH \ |
| 71 | (REPLY_MAGIC_NUM_LEN + REPLY_BINLOG_POS_LEN + REPLY_BINLOG_NAME_LEN) |
| 72 | |
| 73 | #endif /* SEMISYNC_H */ |
| 74 | |