MySQL  8.0.20
Source Code Documentation
single_primary_message.h
Go to the documentation of this file.
1 /* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
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, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef SINGLE_PRIMARY_MESSAGE_INCLUDED
24 #define SINGLE_PRIMARY_MESSAGE_INCLUDED
25 
26 #include <set>
27 #include <string>
28 #include <vector>
29 
30 #include "my_inttypes.h"
33 
35  public:
37  // This type should not be used anywhere.
39 
40  // Length of the payload item: 2 bytes
42 
43  // Uuid to elect: variable
45 
46  // The election mode: 2 bytes
48 
49  // No valid type codes can appear after this one.
50  PIT_MAX = 4
51  };
52 
53  /**
54  The several single primary type messages.
55  */
56  typedef enum {
57  /**This type should not be used anywhere.*/
59  /**A new primary was elected.*/
61  /**Primary did apply queue after election.*/
63  /**No more forbidden transactions on multi master remain*/
65  /**Invoke a new election*/
67  /**The primary is now ready, processed all the backlog*/
69  /**The member as set the read on the election context*/
71  /**The end of the enum.*/
74 
75  /**
76  Message constructor
77 
78  @param[in] type the single primary message type
79  */
81 
82  /**
83  Message constructor for primary election invocations
84 
85  @note this message will use type SINGLE_PRIMARY_PRIMARY_ELECTION
86 
87  @param primary_uuid The primary uuid to elect
88  @param election_mode The election mode to perform
89  */
92 
93  /**
94  Message destructor
95  */
96  virtual ~Single_primary_message();
97 
98  /**
99  Message constructor for raw data
100 
101  @param[in] buf raw data
102  @param[in] len raw length
103  */
104  Single_primary_message(const uchar *buf, size_t len);
105 
106  /** Returns this single primary message type */
109  }
110 
111  /**
112  @note This method should only be used with type
113  SINGLE_PRIMARY_PRIMARY_ELECTION
114  @return the primary uuid associated to this message
115  */
116  std::string &get_primary_uuid();
117 
118  /**
119  @note This method should only be used with type
120  SINGLE_PRIMARY_PRIMARY_ELECTION
121  @return the election mode associated to this message
122  */
124 
125  protected:
126  /**
127  Encodes the message contents for transmission.
128 
129  @param[out] buffer the message buffer to be written
130  */
131  void encode_payload(std::vector<unsigned char> *buffer) const;
132 
133  /**
134  Message decoding method
135 
136  @param[in] buffer the received data
137  @param[in] end the end of the buffer.
138  */
139  void decode_payload(const unsigned char *buffer, const unsigned char *end);
140 
141  private:
142  /**The message type*/
144 
145  /** The uuid for the primary member */
146  std::string primary_uuid;
147  /** The mode for election requests */
149 };
150 
151 #endif /* SINGLE_PRIMARY_MESSAGE_INCLUDED */
A new primary was elected.
Definition: single_primary_message.h:60
unsigned char uchar
Definition: my_inttypes.h:51
std::string & get_primary_uuid()
Definition: single_primary_message.cc:110
This type should not be used anywhere.
Definition: single_primary_message.h:58
char buffer[STRING_BUFFER]
Definition: test_sql_9_sessions.cc:57
Some integer typedefs for easier portability.
enum_primary_election_mode election_mode
The mode for election requests.
Definition: single_primary_message.h:148
This is the base GCS plugin message.
Definition: gcs_plugin_messages.h:63
enum_primary_election_mode get_election_mode()
Definition: single_primary_message.cc:115
Single_primary_message_type single_primary_message_type
The message type.
Definition: single_primary_message.h:143
The end of the enum.
Definition: single_primary_message.h:72
virtual ~Single_primary_message()
Message destructor.
Definition: single_primary_message.cc:41
Definition: single_primary_message.h:50
Single_primary_message_type
The several single primary type messages.
Definition: single_primary_message.h:56
The member as set the read on the election context.
Definition: single_primary_message.h:70
std::string primary_uuid
The uuid for the primary member.
Definition: single_primary_message.h:146
void decode_payload(const unsigned char *buffer, const unsigned char *end)
Message decoding method.
Definition: single_primary_message.cc:50
enum_primary_election_mode
Enum for election types.
Definition: primary_election_include.h:32
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:188
Definition: single_primary_message.h:44
No more forbidden transactions on multi master remain.
Definition: single_primary_message.h:64
enum_payload_item_type
Definition: single_primary_message.h:36
Single_primary_message_type get_single_primary_message_type() const
Returns this single primary message type.
Definition: single_primary_message.h:107
Invoke a new election.
Definition: single_primary_message.h:66
The primary is now ready, processed all the backlog.
Definition: single_primary_message.h:68
Definition: single_primary_message.h:47
Definition: single_primary_message.h:41
Primary did apply queue after election.
Definition: single_primary_message.h:62
void encode_payload(std::vector< unsigned char > *buffer) const
Encodes the message contents for transmission.
Definition: single_primary_message.cc:91
Definition: single_primary_message.h:38
Definition: single_primary_message.h:34
Single_primary_message(Single_primary_message_type type)
Message constructor.
Definition: single_primary_message.cc:28