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