MySQL 9.1.0
Source Code Documentation
group_service_message.h
Go to the documentation of this file.
1/* Copyright (c) 2019, 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_SERVICE_MESSAGE_H
25#define GROUP_SERVICE_MESSAGE_H
26
27#include <string>
28#include <vector>
29
33
35 public:
37 // This type should not be used anywhere.
39
40 // Length of the payload item: variable
42
43 // Length of the payload item: variable
45
46 // Length of the payload item: 8 bytes
48
49 // No valid type codes can appear after this one.
50 // message was sent.
51 PIT_MAX = 4
52 };
53
54 /**
55 Group service message constructor.
56 */
58
59 /**
60 Group service message constructor for raw data.
61
62 @param[in] buf raw data
63 @param[in] len raw length
64 */
65 Group_service_message(const uchar *buf, size_t len);
66
67 /**
68 Group service message destructor
69 */
71
72 /**
73 Set data to message that will be transmitted to group members.
74 Memory ownership belongs to the message creator.
75
76 @param[in] data where the data will be read
77 @param[in] data_length the length of the data to write
78
79 @return returns false if succeeds, otherwise true is returned.
80 */
81 bool set_data(const uchar *data, const size_t data_length);
82
83 /**
84 Return data on message
85
86 @return content of the message
87 */
88 const uchar *get_data();
89
90 /**
91 Return the length of the data on message
92
93 @return length of the content of the message
94 */
95 size_t get_data_length();
96
97 /**
98 Set the tag that identifies the message
99
100 @param[in] tag tag name identify message
101
102 @return returns false if succeeds, otherwise tag is invalid and true
103 shall returned
104 */
105 bool set_tag(const char *tag);
106
107 /**
108 Return the tag that identifies the message
109
110 @return const string that identifies content of message
111 */
112 const std::string &get_tag() { return m_tag; }
113
114 /**
115 Return the length of the tag that identifies the message
116
117 @return length of the string that identifies content of message
118 */
119 size_t get_tag_length() { return m_tag.length(); }
120
121 /**
122 Return the time at which the message contained in the buffer was sent.
123 @see Metrics_handler::get_current_time()
124
125 @param[in] buffer the buffer to decode from.
126 @param[in] length the buffer length
127
128 @return the time on which the message was sent.
129 */
130 static uint64_t get_sent_timestamp(const unsigned char *buffer,
131 size_t length);
132
133 protected:
134 /**
135 Encodes the group service message contents for transmission.
136
137 @param[out] buffer the message buffer to be written
138 */
139 void encode_payload(std::vector<unsigned char> *buffer) const override;
140
141 /**
142 Group service message decoding method
143
144 @param[in] buffer the received data
145 */
146 void decode_payload(const unsigned char *buffer,
147 const unsigned char *) override;
148
149 private:
150 /**The message identifier*/
151 std::string m_tag;
152 /**The message data*/
153 std::vector<uchar, Malloc_allocator<uchar>> m_data;
154 /**
155 A pointer to the message data, memory ownership belongs to the
156 message creator.
157 */
158 const unsigned char *m_data_pointer;
160};
161
162#endif /* GROUP_SERVICE_MESSAGE_H */
Definition: group_service_message.h:34
const std::string & get_tag()
Return the tag that identifies the message.
Definition: group_service_message.h:112
bool set_tag(const char *tag)
Set the tag that identifies the message.
Definition: group_service_message.cc:115
const unsigned char * m_data_pointer
A pointer to the message data, memory ownership belongs to the message creator.
Definition: group_service_message.h:158
size_t m_data_pointer_length
Definition: group_service_message.h:159
std::string m_tag
The message identifier.
Definition: group_service_message.h:151
enum_payload_item_type
Definition: group_service_message.h:36
@ PIT_MAX
Definition: group_service_message.h:51
@ PIT_DATA
Definition: group_service_message.h:44
@ PIT_SENT_TIMESTAMP
Definition: group_service_message.h:47
@ PIT_UNKNOWN
Definition: group_service_message.h:38
@ PIT_TAG
Definition: group_service_message.h:41
void encode_payload(std::vector< unsigned char > *buffer) const override
Encodes the group service message contents for transmission.
Definition: group_service_message.cc:77
~Group_service_message() override
Group service message destructor.
std::vector< uchar, Malloc_allocator< uchar > > m_data
The message data.
Definition: group_service_message.h:153
size_t get_tag_length()
Return the length of the tag that identifies the message.
Definition: group_service_message.h:119
bool set_data(const uchar *data, const size_t data_length)
Set data to message that will be transmitted to group members.
Definition: group_service_message.cc:47
Group_service_message()
Group service message constructor.
Definition: group_service_message.cc:29
size_t get_data_length()
Return the length of the data on message.
Definition: group_service_message.cc:67
void decode_payload(const unsigned char *buffer, const unsigned char *) override
Group service message decoding method.
Definition: group_service_message.cc:98
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_service_message.cc:125
const uchar * get_data()
Return data on message.
Definition: group_service_message.cc:57
This is the base GCS plugin message.
Definition: gcs_plugin_messages.h:64
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