MySQL 8.0.37
Source Code Documentation
group_action_message.h
Go to the documentation of this file.
1/* Copyright (c) 2018, 2024, Oracle and/or its affiliates.
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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef GROUP_ACTION_MESSAGE_INCLUDED
25#define GROUP_ACTION_MESSAGE_INCLUDED
26
27#include <string>
28
29#include "my_inttypes.h"
32
34 public:
36 // This type should not be used anywhere.
38 // Length of the payload item: 2 bytes
40 // Length of the payload item: 2 bytes
42 // Length of the payload item: 4 bytes
44 // The uuid field
46 // The GCS protocol field: 2 bytes
48 // The running_transactions_timeout field: 4 bytes
50 // The action initiator information: 4 bytes
52 // No valid type codes can appear after this one.
53 PIT_MAX = 8
54 };
55
56 /** Enum for the types of message / actions */
58 // This type should not be used
60 // Change to multi primary
62 // Elect/Change mode to primary member
64 // Change GCS protocol version
66 // The end of the enum
68 };
69 /** Enum for the phase of the action in the message */
71 ACTION_UNKNOWN_PHASE = 0, // This type should not be used
72 ACTION_START_PHASE = 1, // Start a new action
73 ACTION_END_PHASE = 2, // The action was ended
74 ACTION_ABORT_PHASE = 3, // The action was aborted
75 ACTION_PHASE_END = 4, // The enum end
76 };
77
78 /** Enum to identify initiator and action. */
80 // This type should not be used
81 ACTION_INITIATOR_UNKNOWN = 0, // to match with ACTION_UNKNOWN_MESSAGE
82 // Change to multi primary
84 // Change primary
86 // Change to single primary
88 // Change to single primary with UUID
90 // Change GCS protocol version
92 // The end of the enum
94 };
95
96 /**
97 Message constructor
98 */
100
101 /**
102 Message constructor
103
104 @param[in] type the action message type
105 */
107
108 /**
109 Message constructor for ACTION_PRIMARY_ELECTION_MESSAGE action type
110
111 @param[in] primary_uuid the primary uuid to elect
112 @param[in] transaction_monitor_timeout_arg The number of seconds to wait
113 before setting the kill flag for the transactions that did not reach commit
114 stage
115 */
116 Group_action_message(std::string &primary_uuid,
117 int32 &transaction_monitor_timeout_arg);
118
119 /**
120 Message constructor for ACTION_SET_COMMUNICATION_PROTOCOL_MESSAGE action
121 type
122
123 @param[in] gcs_protocol the GCS protocol to change to
124 */
126
127 /**
128 Message destructor
129 */
131
132 /**
133 Message constructor for raw data
134
135 @param[in] buf raw data
136 @param[in] len raw length
137 */
138 Group_action_message(const uchar *buf, size_t len);
139
140 /** Returns this group action message type */
142 return group_action_type;
143 }
144
145 /** Returns this group action message phase */
147 return group_action_phase;
148 }
149
151 group_action_phase = phase;
152 }
153
154 /**
155 Set the return value for this message
156 @param return_value_arg the value to set
157 */
158 void set_return_value(int return_value_arg) {
159 return_value = return_value_arg;
160 }
161
162 /**
163 Set the action initiator.
164 @param initiator Identifier for Group action initiator
165 */
167 m_action_initiator = initiator;
168 }
169
170 /**
171 @return Identifier for Group action initiator
172 */
174 return m_action_initiator;
175 }
176
177 /**
178 @return The return value associated to this message.
179 */
181
182 /**
183 Check what is the action that this message encodes from a buffer
184 @param buf the raw data buffer
185 @return If the message is a primary election action or other
186 */
188
189 /**
190 Returns this group action primary to be elected uuid.
191
192 @return the primary to be elected uuid, which can be empty
193 */
194 const std::string &get_primary_to_elect_uuid();
195
196 /**
197 Returns the GCS protocol this group action wants the group to change to.
198
199 @return the GCS protocol version
200 */
202
203 /**
204 Returns the running_transactions_timeout.
205
206 @return the running_transactions_timeout value
207 */
209
210 protected:
211 /**
212 Encodes the message contents for transmission.
213
214 @param[out] buffer the message buffer to be written
215 */
216 void encode_payload(std::vector<unsigned char> *buffer) const override;
217
218 /**
219 Message decoding method
220
221 @param[in] buffer the received data
222 @param[in] end the end of the buffer.
223 */
224 void decode_payload(const unsigned char *buffer,
225 const unsigned char *end) override;
226
227 private:
228 /** The action type for this message */
230
231 /** If it is a start, stop or other message */
233
234 /** Is there any return value associated to this action */
236
237 /* Option Values */
238
239 /** The uuid for election, can be empty if not defined */
241
242 /** The GCS protocol version to change to */
244 /**
245 The number of seconds to wait before setting the kill flag for the
246 transactions that did not reach commit stage.
247 */
249 /** Group action identifier */
251};
252
253#endif /* GROUP_ACTION_MESSAGE_INCLUDED */
Definition: group_action_message.h:33
enum_action_initiator_and_action m_action_initiator
Group action identifier.
Definition: group_action_message.h:250
enum_action_message_phase group_action_phase
If it is a start, stop or other message.
Definition: group_action_message.h:232
int32 get_transaction_monitor_timeout()
Returns the running_transactions_timeout.
Definition: group_action_message.cc:195
enum_action_message_phase
Enum for the phase of the action in the message.
Definition: group_action_message.h:70
@ ACTION_PHASE_END
Definition: group_action_message.h:75
@ ACTION_ABORT_PHASE
Definition: group_action_message.h:74
@ ACTION_UNKNOWN_PHASE
Definition: group_action_message.h:71
@ ACTION_END_PHASE
Definition: group_action_message.h:73
@ ACTION_START_PHASE
Definition: group_action_message.h:72
int32 m_transaction_monitor_timeout
The number of seconds to wait before setting the kill flag for the transactions that did not reach co...
Definition: group_action_message.h:248
int32 return_value
Is there any return value associated to this action.
Definition: group_action_message.h:235
Gcs_protocol_version const & get_gcs_protocol()
Returns the GCS protocol this group action wants the group to change to.
Definition: group_action_message.cc:189
void set_action_initiator(const enum_action_initiator_and_action initiator)
Set the action initiator.
Definition: group_action_message.h:166
void set_return_value(int return_value_arg)
Set the return value for this message.
Definition: group_action_message.h:158
Group_action_message()
Message constructor.
Definition: group_action_message.cc:28
const std::string & get_primary_to_elect_uuid()
Returns this group action primary to be elected uuid.
Definition: group_action_message.cc:184
void encode_payload(std::vector< unsigned char > *buffer) const override
Encodes the message contents for transmission.
Definition: group_action_message.cc:133
enum_action_message_phase get_group_action_message_phase()
Returns this group action message phase.
Definition: group_action_message.h:146
int32 get_return_value()
Definition: group_action_message.h:180
enum_action_message_type get_group_action_message_type()
Returns this group action message type.
Definition: group_action_message.h:141
Gcs_protocol_version gcs_protocol
The GCS protocol version to change to.
Definition: group_action_message.h:243
const enum_action_initiator_and_action & get_action_initiator()
Definition: group_action_message.h:173
enum_action_initiator_and_action
Enum to identify initiator and action.
Definition: group_action_message.h:79
@ ACTION_INITIATOR_UNKNOWN
Definition: group_action_message.h:81
@ ACTION_UDF_SWITCH_TO_SINGLE_PRIMARY_MODE
Definition: group_action_message.h:87
@ ACTION_UDF_SWITCH_TO_MULTI_PRIMARY_MODE
Definition: group_action_message.h:83
@ ACTION_UDF_SET_PRIMARY
Definition: group_action_message.h:85
@ ACTION_INITIATOR_END
Definition: group_action_message.h:93
@ ACTION_UDF_SWITCH_TO_SINGLE_PRIMARY_MODE_UUID
Definition: group_action_message.h:89
@ ACTION_UDF_COMMUNICATION_PROTOCOL_MESSAGE
Definition: group_action_message.h:91
static enum_action_message_type get_action_type(const uchar *buf)
Check what is the action that this message encodes from a buffer.
Definition: group_action_message.cc:171
~Group_action_message() override
Message destructor.
void set_group_action_message_phase(enum_action_message_phase phase)
Definition: group_action_message.h:150
enum_action_message_type
Enum for the types of message / actions.
Definition: group_action_message.h:57
@ ACTION_SET_COMMUNICATION_PROTOCOL_MESSAGE
Definition: group_action_message.h:65
@ ACTION_UNKNOWN_MESSAGE
Definition: group_action_message.h:59
@ ACTION_PRIMARY_ELECTION_MESSAGE
Definition: group_action_message.h:63
@ ACTION_MULTI_PRIMARY_MESSAGE
Definition: group_action_message.h:61
@ ACTION_MESSAGE_END
Definition: group_action_message.h:67
void decode_payload(const unsigned char *buffer, const unsigned char *end) override
Message decoding method.
Definition: group_action_message.cc:73
enum_payload_item_type
Definition: group_action_message.h:35
@ PIT_ACTION_TYPE
Definition: group_action_message.h:39
@ PIT_ACTION_TRANSACTION_MONITOR_TIMEOUT
Definition: group_action_message.h:49
@ PIT_MAX
Definition: group_action_message.h:53
@ PIT_ACTION_PHASE
Definition: group_action_message.h:41
@ PIT_UNKNOWN
Definition: group_action_message.h:37
@ PIT_ACTION_SET_COMMUNICATION_PROTOCOL_VERSION
Definition: group_action_message.h:47
@ PIT_ACTION_PRIMARY_ELECTION_UUID
Definition: group_action_message.h:45
@ PIT_ACTION_INITIATOR
Definition: group_action_message.h:51
@ PIT_ACTION_RETURN_VALUE
Definition: group_action_message.h:43
std::string primary_election_uuid
The uuid for election, can be empty if not defined.
Definition: group_action_message.h:240
enum_action_message_type group_action_type
The action type for this message.
Definition: group_action_message.h:229
This is the base GCS plugin message.
Definition: gcs_plugin_messages.h:64
Gcs_protocol_version
The GCS protocol versions.
Definition: gcs_types.h:128
Some integer typedefs for easier portability.
unsigned char uchar
Definition: my_inttypes.h:52
int32_t int32
Definition: my_inttypes.h:66
Definition: buf0block_hint.cc:30
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:420
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:192
required string type
Definition: replication_group_member_actions.proto:34