MySQL 8.3.0
Source Code Documentation
group_action_message.h
Go to the documentation of this file.
1/* Copyright (c) 2018, 2023, 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 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 GROUP_ACTION_MESSAGE_INCLUDED
24#define GROUP_ACTION_MESSAGE_INCLUDED
25
26#include <string>
27
28#include "my_inttypes.h"
31
33 public:
35 // This type should not be used anywhere.
37 // Length of the payload item: 2 bytes
39 // Length of the payload item: 2 bytes
41 // Length of the payload item: 4 bytes
43 // The uuid field
45 // The GCS protocol field: 2 bytes
47 // The running_transactions_timeout field: 4 bytes
49 // The action initiator information: 4 bytes
51 // Length of the payload item: 8 bytes
53 // No valid type codes can appear after this one.
54 PIT_MAX = 9
55 };
56
57 /** Enum for the types of message / actions */
59 // This type should not be used
61 // Change to multi primary
63 // Elect/Change mode to primary member
65 // Change GCS protocol version
67 // The end of the enum
69 };
70 /** Enum for the phase of the action in the message */
72 ACTION_UNKNOWN_PHASE = 0, // This type should not be used
73 ACTION_START_PHASE = 1, // Start a new action
74 ACTION_END_PHASE = 2, // The action was ended
75 ACTION_ABORT_PHASE = 3, // The action was aborted
76 ACTION_PHASE_END = 4, // The enum end
77 };
78
79 /** Enum to identify initiator and action. */
81 // This type should not be used
82 ACTION_INITIATOR_UNKNOWN = 0, // to match with ACTION_UNKNOWN_MESSAGE
83 // Change to multi primary
85 // Change primary
87 // Change to single primary
89 // Change to single primary with UUID
91 // Change GCS protocol version
93 // The end of the enum
95 };
96
97 /**
98 Message constructor
99 */
101
102 /**
103 Message constructor
104
105 @param[in] type the action message type
106 */
108
109 /**
110 Message constructor for ACTION_PRIMARY_ELECTION_MESSAGE action type
111
112 @param[in] primary_uuid the primary uuid to elect
113 @param[in] transaction_monitor_timeout_arg The number of seconds to wait
114 before setting the kill flag for the transactions that did not reach commit
115 stage
116 */
117 Group_action_message(std::string &primary_uuid,
118 int32 &transaction_monitor_timeout_arg);
119
120 /**
121 Message constructor for ACTION_SET_COMMUNICATION_PROTOCOL_MESSAGE action
122 type
123
124 @param[in] gcs_protocol the GCS protocol to change to
125 */
127
128 /**
129 Message destructor
130 */
132
133 /**
134 Message constructor for raw data
135
136 @param[in] buf raw data
137 @param[in] len raw length
138 */
139 Group_action_message(const uchar *buf, size_t len);
140
141 /** Returns this group action message type */
143 return group_action_type;
144 }
145
146 /** Returns this group action message phase */
148 return group_action_phase;
149 }
150
152 group_action_phase = phase;
153 }
154
155 /**
156 Set the return value for this message
157 @param return_value_arg the value to set
158 */
159 void set_return_value(int return_value_arg) {
160 return_value = return_value_arg;
161 }
162
163 /**
164 Set the action initiator.
165 @param initiator Identifier for Group action initiator
166 */
168 m_action_initiator = initiator;
169 }
170
171 /**
172 @return Identifier for Group action initiator
173 */
175 return m_action_initiator;
176 }
177
178 /**
179 @return The return value associated to this message.
180 */
182
183 /**
184 Check what is the action that this message encodes from a buffer
185 @param buf the raw data buffer
186 @return If the message is a primary election action or other
187 */
189
190 /**
191 Returns this group action primary to be elected uuid.
192
193 @return the primary to be elected uuid, which can be empty
194 */
195 const std::string &get_primary_to_elect_uuid();
196
197 /**
198 Returns the GCS protocol this group action wants the group to change to.
199
200 @return the GCS protocol version
201 */
203
204 /**
205 Returns the running_transactions_timeout.
206
207 @return the running_transactions_timeout value
208 */
210
211 /**
212 Return the time at which the message contained in the buffer was sent.
213 @see Metrics_handler::get_current_time()
214
215 @param[in] buffer the buffer to decode from.
216 @param[in] length the buffer length
217
218 @return the time on which the message was sent.
219 */
220 static uint64_t get_sent_timestamp(const unsigned char *buffer,
221 size_t length);
222
223 protected:
224 /**
225 Encodes the message contents for transmission.
226
227 @param[out] buffer the message buffer to be written
228 */
229 void encode_payload(std::vector<unsigned char> *buffer) const override;
230
231 /**
232 Message decoding method
233
234 @param[in] buffer the received data
235 @param[in] end the end of the buffer.
236 */
237 void decode_payload(const unsigned char *buffer,
238 const unsigned char *end) override;
239
240 private:
241 /** The action type for this message */
243
244 /** If it is a start, stop or other message */
246
247 /** Is there any return value associated to this action */
249
250 /* Option Values */
251
252 /** The uuid for election, can be empty if not defined */
254
255 /** The GCS protocol version to change to */
257 /**
258 The number of seconds to wait before setting the kill flag for the
259 transactions that did not reach commit stage.
260 */
262 /** Group action identifier */
264};
265
266#endif /* GROUP_ACTION_MESSAGE_INCLUDED */
Definition: group_action_message.h:32
enum_action_initiator_and_action m_action_initiator
Group action identifier.
Definition: group_action_message.h:263
enum_action_message_phase group_action_phase
If it is a start, stop or other message.
Definition: group_action_message.h:245
int32 get_transaction_monitor_timeout()
Returns the running_transactions_timeout.
Definition: group_action_message.cc:197
enum_action_message_phase
Enum for the phase of the action in the message.
Definition: group_action_message.h:71
@ ACTION_PHASE_END
Definition: group_action_message.h:76
@ ACTION_ABORT_PHASE
Definition: group_action_message.h:75
@ ACTION_UNKNOWN_PHASE
Definition: group_action_message.h:72
@ ACTION_END_PHASE
Definition: group_action_message.h:74
@ ACTION_START_PHASE
Definition: group_action_message.h:73
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:261
int32 return_value
Is there any return value associated to this action.
Definition: group_action_message.h:248
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:191
void set_action_initiator(const enum_action_initiator_and_action initiator)
Set the action initiator.
Definition: group_action_message.h:167
void set_return_value(int return_value_arg)
Set the return value for this message.
Definition: group_action_message.h:159
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:186
void encode_payload(std::vector< unsigned char > *buffer) const override
Encodes the message contents for transmission.
Definition: group_action_message.cc:132
enum_action_message_phase get_group_action_message_phase()
Returns this group action message phase.
Definition: group_action_message.h:147
static uint64_t get_sent_timestamp(const unsigned char *buffer, size_t length)
Return the time at which the message contained in the buffer was sent.
Definition: group_action_message.cc:201
int32 get_return_value()
Definition: group_action_message.h:181
enum_action_message_type get_group_action_message_type()
Returns this group action message type.
Definition: group_action_message.h:142
Gcs_protocol_version gcs_protocol
The GCS protocol version to change to.
Definition: group_action_message.h:256
const enum_action_initiator_and_action & get_action_initiator()
Definition: group_action_message.h:174
enum_action_initiator_and_action
Enum to identify initiator and action.
Definition: group_action_message.h:80
@ ACTION_INITIATOR_UNKNOWN
Definition: group_action_message.h:82
@ ACTION_UDF_SWITCH_TO_SINGLE_PRIMARY_MODE
Definition: group_action_message.h:88
@ ACTION_UDF_SWITCH_TO_MULTI_PRIMARY_MODE
Definition: group_action_message.h:84
@ ACTION_UDF_SET_PRIMARY
Definition: group_action_message.h:86
@ ACTION_INITIATOR_END
Definition: group_action_message.h:94
@ ACTION_UDF_SWITCH_TO_SINGLE_PRIMARY_MODE_UUID
Definition: group_action_message.h:90
@ ACTION_UDF_COMMUNICATION_PROTOCOL_MESSAGE
Definition: group_action_message.h:92
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:173
~Group_action_message() override
Message destructor.
void set_group_action_message_phase(enum_action_message_phase phase)
Definition: group_action_message.h:151
enum_action_message_type
Enum for the types of message / actions.
Definition: group_action_message.h:58
@ ACTION_SET_COMMUNICATION_PROTOCOL_MESSAGE
Definition: group_action_message.h:66
@ ACTION_UNKNOWN_MESSAGE
Definition: group_action_message.h:60
@ ACTION_PRIMARY_ELECTION_MESSAGE
Definition: group_action_message.h:64
@ ACTION_MULTI_PRIMARY_MESSAGE
Definition: group_action_message.h:62
@ ACTION_MESSAGE_END
Definition: group_action_message.h:68
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:34
@ PIT_ACTION_TYPE
Definition: group_action_message.h:38
@ PIT_ACTION_TRANSACTION_MONITOR_TIMEOUT
Definition: group_action_message.h:48
@ PIT_MAX
Definition: group_action_message.h:54
@ PIT_ACTION_PHASE
Definition: group_action_message.h:40
@ PIT_UNKNOWN
Definition: group_action_message.h:36
@ PIT_SENT_TIMESTAMP
Definition: group_action_message.h:52
@ PIT_ACTION_SET_COMMUNICATION_PROTOCOL_VERSION
Definition: group_action_message.h:46
@ PIT_ACTION_PRIMARY_ELECTION_UUID
Definition: group_action_message.h:44
@ PIT_ACTION_INITIATOR
Definition: group_action_message.h:50
@ PIT_ACTION_RETURN_VALUE
Definition: group_action_message.h:42
std::string primary_election_uuid
The uuid for election, can be empty if not defined.
Definition: group_action_message.h:253
enum_action_message_type group_action_type
The action type for this message.
Definition: group_action_message.h:242
This is the base GCS plugin message.
Definition: gcs_plugin_messages.h:63
Gcs_protocol_version
The GCS protocol versions.
Definition: gcs_types.h:127
Some integer typedefs for easier portability.
unsigned char uchar
Definition: my_inttypes.h:51
int32_t int32
Definition: my_inttypes.h:65
Definition: buf0block_hint.cc:29
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:75
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:417
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:191
required string type
Definition: replication_group_member_actions.proto:33