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