MySQL 8.4.2
Source Code Documentation
group_validation_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_VALIDATION_MESSAGE_INCLUDED
25#define GROUP_VALIDATION_MESSAGE_INCLUDED
26
27#include "my_inttypes.h"
29
30/** The base message for group validation messages */
32 public:
33 /** Enum for message payload */
35 PIT_UNKNOWN = 0, // Not used
36 PIT_VALIDATION_TYPE = 1, // The validation type, length: 2 bytes
37 PIT_VALIDATION_CHANNEL = 2, // The member has channel flag, length: 1 bytes
38 PIT_MEMBER_WEIGHT = 3, // The member weight, length: 2 bytes
39 PIT_SENT_TIMESTAMP = 4, // Length: 8 bytes
40 PIT_MAX // No valid type codes can appear after this one
41 };
42
43 /** Enum for the types of validation action **/
46 ELECTION_VALIDATION_MESSAGE = 1, // Member info for elections
47 GROUP_VALIDATION_MESSAGE_END = 2 // Enum end value
48 };
49
50 /**
51 Class constructor
52 @param has_channels This member has running slave channels?
53 @param member_weight_arg The election weight of this member
54 */
55 Group_validation_message(bool has_channels, uint member_weight_arg);
56
57 /**
58 Message constructor for raw data
59
60 @param[in] buf raw data
61 @param[in] len raw length
62 */
63 Group_validation_message(const uchar *buf, size_t len);
64
65 /** Class destructor */
67
68 /**
69 Does the member has running channels
70 @return true if yes, false otherwise
71 */
72 bool has_slave_channels() const;
73
74 /**
75 The election weight of this member
76 @return The member weight
77 */
78 uint get_member_weight() const;
79
80 /**
81 Return the time at which the message contained in the buffer was sent.
82 @see Metrics_handler::get_current_time()
83
84 @param[in] buffer the buffer to decode from.
85 @param[in] length the buffer length
86
87 @return the time on which the message was sent.
88 */
89 static uint64_t get_sent_timestamp(const unsigned char *buffer,
90 size_t length);
91
92 protected:
93 /**
94 Encodes the message contents for transmission.
95
96 @param[out] buffer the message buffer to be written
97 */
98 void encode_payload(std::vector<unsigned char> *buffer) const override;
99
100 /**
101 Message decoding method
102
103 @param[in] buffer the received data
104 */
105 void decode_payload(const unsigned char *buffer,
106 const unsigned char *) override;
107
108 private:
109 /**The message type*/
111
112 /** Does the member has channels? */
114
115 /** The member election weight */
117};
118
119#endif /* GROUP_VALIDATION_MESSAGE_INCLUDED */
The base message for group validation messages.
Definition: group_validation_message.h:31
uint member_weight
The member election weight.
Definition: group_validation_message.h:116
bool has_slave_channels() const
Does the member has running channels.
Definition: group_validation_message.cc:42
enum_payload_item_type
Enum for message payload.
Definition: group_validation_message.h:34
@ PIT_VALIDATION_CHANNEL
Definition: group_validation_message.h:37
@ PIT_VALIDATION_TYPE
Definition: group_validation_message.h:36
@ PIT_SENT_TIMESTAMP
Definition: group_validation_message.h:39
@ PIT_MAX
Definition: group_validation_message.h:40
@ PIT_UNKNOWN
Definition: group_validation_message.h:35
@ PIT_MEMBER_WEIGHT
Definition: group_validation_message.h:38
Group_validation_message(bool has_channels, uint member_weight_arg)
Class constructor.
Definition: group_validation_message.cc:28
enum_validation_message_type group_validation_message_type
The message type.
Definition: group_validation_message.h:110
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_validation_message.cc:90
void decode_payload(const unsigned char *buffer, const unsigned char *) override
Message decoding method.
Definition: group_validation_message.cc:50
void encode_payload(std::vector< unsigned char > *buffer) const override
Encodes the message contents for transmission.
Definition: group_validation_message.cc:71
uint get_member_weight() const
The election weight of this member.
Definition: group_validation_message.cc:46
~Group_validation_message() override
Class destructor.
enum_validation_message_type
Enum for the types of validation action.
Definition: group_validation_message.h:44
@ GROUP_VALIDATION_MESSAGE_END
Definition: group_validation_message.h:47
@ GROUP_VALIDATION_UNKNOWN_MESSAGE
Definition: group_validation_message.h:45
@ ELECTION_VALIDATION_MESSAGE
Definition: group_validation_message.h:46
bool has_channels
Does the member has channels?
Definition: group_validation_message.h:113
This is the base GCS plugin message.
Definition: gcs_plugin_messages.h:64
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