MySQL 9.1.0
Source Code Documentation
single_primary_message.h
Go to the documentation of this file.
1/* Copyright (c) 2016, 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 SINGLE_PRIMARY_MESSAGE_INCLUDED
25#define SINGLE_PRIMARY_MESSAGE_INCLUDED
26
27#include <set>
28#include <string>
29#include <vector>
30
31#include "my_inttypes.h"
34
36 public:
38 // This type should not be used anywhere.
40
41 // Length of the payload item: 2 bytes
43
44 // Uuid to elect: variable
46
47 // The election mode: 2 bytes
49
50 // Length of the payload item: 8 bytes
52
53 // No valid type codes can appear after this one.
54 PIT_MAX = 5
55 };
56
57 /**
58 The several single primary type messages.
59 */
60 typedef enum {
61 /**This type should not be used anywhere.*/
63 /**A new primary was elected.*/
65 /**Primary did apply queue after election.*/
67 /**No more forbidden transactions on multi master remain*/
69 /**Invoke a new election*/
71 /**The primary is now ready, processed all the backlog*/
73 /**The member as set the read on the election context*/
75 /**The end of the enum.*/
78
79 /**
80 Message constructor
81
82 @param[in] type the single primary message type
83 */
85
86 /**
87 Message constructor for primary election invocations
88
89 @note this message will use type SINGLE_PRIMARY_PRIMARY_ELECTION
90
91 @param primary_uuid The primary uuid to elect
92 @param election_mode The election mode to perform
93 */
96
97 /**
98 Message destructor
99 */
101
102 /**
103 Message constructor for raw data
104
105 @param[in] buf raw data
106 @param[in] len raw length
107 */
108 Single_primary_message(const uchar *buf, size_t len);
109
110 /** Returns this single primary message type */
113 }
114
115 /**
116 @note This method should only be used with type
117 SINGLE_PRIMARY_PRIMARY_ELECTION
118 @return the primary uuid associated to this message
119 */
120 std::string &get_primary_uuid();
121
122 /**
123 @note This method should only be used with type
124 SINGLE_PRIMARY_PRIMARY_ELECTION
125 @return the election mode associated to this message
126 */
128
129 /**
130 Return the time at which the message contained in the buffer was sent.
131 @see Metrics_handler::get_current_time()
132
133 @param[in] buffer the buffer to decode from.
134 @param[in] length the buffer length
135
136 @return the time on which the message was sent.
137 */
138 static uint64_t get_sent_timestamp(const unsigned char *buffer,
139 size_t length);
140
141 protected:
142 /**
143 Encodes the message contents for transmission.
144
145 @param[out] buffer the message buffer to be written
146 */
147 void encode_payload(std::vector<unsigned char> *buffer) const override;
148
149 /**
150 Message decoding method
151
152 @param[in] buffer the received data
153 @param[in] end the end of the buffer.
154 */
155 void decode_payload(const unsigned char *buffer,
156 const unsigned char *end) override;
157
158 private:
159 /**The message type*/
161
162 /** The uuid for the primary member */
163 std::string primary_uuid;
164 /** The mode for election requests */
166};
167
168#endif /* SINGLE_PRIMARY_MESSAGE_INCLUDED */
This is the base GCS plugin message.
Definition: gcs_plugin_messages.h:64
Definition: single_primary_message.h:35
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: single_primary_message.cc:126
enum_primary_election_mode get_election_mode()
Definition: single_primary_message.cc:121
enum_primary_election_mode election_mode
The mode for election requests.
Definition: single_primary_message.h:165
Single_primary_message(Single_primary_message_type type)
Message constructor.
Definition: single_primary_message.cc:30
Single_primary_message_type
The several single primary type messages.
Definition: single_primary_message.h:60
@ SINGLE_PRIMARY_QUEUE_APPLIED_MESSAGE
Primary did apply queue after election.
Definition: single_primary_message.h:66
@ SINGLE_PRIMARY_READ_MODE_SET
The member as set the read on the election context.
Definition: single_primary_message.h:74
@ SINGLE_PRIMARY_PRIMARY_READY
The primary is now ready, processed all the backlog.
Definition: single_primary_message.h:72
@ SINGLE_PRIMARY_UNKNOWN
This type should not be used anywhere.
Definition: single_primary_message.h:62
@ SINGLE_PRIMARY_MESSAGE_TYPE_END
The end of the enum.
Definition: single_primary_message.h:76
@ SINGLE_PRIMARY_PRIMARY_ELECTION
Invoke a new election.
Definition: single_primary_message.h:70
@ SINGLE_PRIMARY_NO_RESTRICTED_TRANSACTIONS
No more forbidden transactions on multi master remain.
Definition: single_primary_message.h:68
@ SINGLE_PRIMARY_NEW_PRIMARY_MESSAGE
A new primary was elected.
Definition: single_primary_message.h:64
enum_payload_item_type
Definition: single_primary_message.h:37
@ PIT_SINGLE_PRIMARY_SERVER_UUID
Definition: single_primary_message.h:45
@ PIT_UNKNOWN
Definition: single_primary_message.h:39
@ PIT_SINGLE_PRIMARY_MESSAGE_TYPE
Definition: single_primary_message.h:42
@ PIT_SINGLE_PRIMARY_ELECTION_MODE
Definition: single_primary_message.h:48
@ PIT_SENT_TIMESTAMP
Definition: single_primary_message.h:51
@ PIT_MAX
Definition: single_primary_message.h:54
Single_primary_message_type get_single_primary_message_type() const
Returns this single primary message type.
Definition: single_primary_message.h:111
void decode_payload(const unsigned char *buffer, const unsigned char *end) override
Message decoding method.
Definition: single_primary_message.cc:52
~Single_primary_message() override
Message destructor.
std::string primary_uuid
The uuid for the primary member.
Definition: single_primary_message.h:163
std::string & get_primary_uuid()
Definition: single_primary_message.cc:116
Single_primary_message_type single_primary_message_type
The message type.
Definition: single_primary_message.h:160
void encode_payload(std::vector< unsigned char > *buffer) const override
Encodes the message contents for transmission.
Definition: single_primary_message.cc:94
Some integer typedefs for easier portability.
unsigned char uchar
Definition: my_inttypes.h:52
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
enum_primary_election_mode
Enum for election types.
Definition: primary_election_include.h:33
required string type
Definition: replication_group_member_actions.proto:34