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