MySQL 8.0.39
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 // No valid type codes can appear after this one.
51 PIT_MAX = 4
52 };
53
54 /**
55 The several single primary type messages.
56 */
57 typedef enum {
58 /**This type should not be used anywhere.*/
60 /**A new primary was elected.*/
62 /**Primary did apply queue after election.*/
64 /**No more forbidden transactions on multi master remain*/
66 /**Invoke a new election*/
68 /**The primary is now ready, processed all the backlog*/
70 /**The member as set the read on the election context*/
72 /**The end of the enum.*/
75
76 /**
77 Message constructor
78
79 @param[in] type the single primary message type
80 */
82
83 /**
84 Message constructor for primary election invocations
85
86 @note this message will use type SINGLE_PRIMARY_PRIMARY_ELECTION
87
88 @param primary_uuid The primary uuid to elect
89 @param election_mode The election mode to perform
90 */
93
94 /**
95 Message destructor
96 */
98
99 /**
100 Message constructor for raw data
101
102 @param[in] buf raw data
103 @param[in] len raw length
104 */
105 Single_primary_message(const uchar *buf, size_t len);
106
107 /** Returns this single primary message type */
110 }
111
112 /**
113 @note This method should only be used with type
114 SINGLE_PRIMARY_PRIMARY_ELECTION
115 @return the primary uuid associated to this message
116 */
117 std::string &get_primary_uuid();
118
119 /**
120 @note This method should only be used with type
121 SINGLE_PRIMARY_PRIMARY_ELECTION
122 @return the election mode associated to this message
123 */
125
126 protected:
127 /**
128 Encodes the message contents for transmission.
129
130 @param[out] buffer the message buffer to be written
131 */
132 void encode_payload(std::vector<unsigned char> *buffer) const override;
133
134 /**
135 Message decoding method
136
137 @param[in] buffer the received data
138 @param[in] end the end of the buffer.
139 */
140 void decode_payload(const unsigned char *buffer,
141 const unsigned char *end) override;
142
143 private:
144 /**The message type*/
146
147 /** The uuid for the primary member */
148 std::string primary_uuid;
149 /** The mode for election requests */
151};
152
153#endif /* SINGLE_PRIMARY_MESSAGE_INCLUDED */
This is the base GCS plugin message.
Definition: gcs_plugin_messages.h:64
Definition: single_primary_message.h:35
enum_primary_election_mode get_election_mode()
Definition: single_primary_message.cc:116
enum_primary_election_mode election_mode
The mode for election requests.
Definition: single_primary_message.h:150
Single_primary_message(Single_primary_message_type type)
Message constructor.
Definition: single_primary_message.cc:29
Single_primary_message_type
The several single primary type messages.
Definition: single_primary_message.h:57
@ SINGLE_PRIMARY_QUEUE_APPLIED_MESSAGE
Primary did apply queue after election.
Definition: single_primary_message.h:63
@ SINGLE_PRIMARY_READ_MODE_SET
The member as set the read on the election context.
Definition: single_primary_message.h:71
@ SINGLE_PRIMARY_PRIMARY_READY
The primary is now ready, processed all the backlog.
Definition: single_primary_message.h:69
@ SINGLE_PRIMARY_UNKNOWN
This type should not be used anywhere.
Definition: single_primary_message.h:59
@ SINGLE_PRIMARY_MESSAGE_TYPE_END
The end of the enum.
Definition: single_primary_message.h:73
@ SINGLE_PRIMARY_PRIMARY_ELECTION
Invoke a new election.
Definition: single_primary_message.h:67
@ SINGLE_PRIMARY_NO_RESTRICTED_TRANSACTIONS
No more forbidden transactions on multi master remain.
Definition: single_primary_message.h:65
@ SINGLE_PRIMARY_NEW_PRIMARY_MESSAGE
A new primary was elected.
Definition: single_primary_message.h:61
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_MAX
Definition: single_primary_message.h:51
Single_primary_message_type get_single_primary_message_type() const
Returns this single primary message type.
Definition: single_primary_message.h:108
void decode_payload(const unsigned char *buffer, const unsigned char *end) override
Message decoding method.
Definition: single_primary_message.cc:51
~Single_primary_message() override
Message destructor.
std::string primary_uuid
The uuid for the primary member.
Definition: single_primary_message.h:148
std::string & get_primary_uuid()
Definition: single_primary_message.cc:111
Single_primary_message_type single_primary_message_type
The message type.
Definition: single_primary_message.h:145
void encode_payload(std::vector< unsigned char > *buffer) const override
Encodes the message contents for transmission.
Definition: single_primary_message.cc:92
Some integer typedefs for easier portability.
unsigned char uchar
Definition: my_inttypes.h:52
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
enum_primary_election_mode
Enum for election types.
Definition: primary_election_include.h:33
required string type
Definition: replication_group_member_actions.proto:34