MySQL 8.0.40
Source Code Documentation
|
This class serves as data container for information flowing in the GCS ecosystem. More...
#include <gcs_message.h>
Public Member Functions | |
Gcs_message_data () | |
Gcs_message_data implementation. More... | |
Gcs_message_data (const uint32_t header_capacity, const uint64_t payload_capacity) | |
Constructor of Gcs_message_data which pre-allocates space to store the header and payload and should be used when creating messages to send information to remote peers. More... | |
Gcs_message_data (const uint64_t data_len) | |
Constructor of Gcs_message_data which pre-allocates space to store a message received from a remote peer. More... | |
virtual | ~Gcs_message_data () |
bool | append_to_header (const uchar *to_append, uint32_t to_append_len) |
Appends data to the header of the message. More... | |
bool | append_to_payload (const uchar *to_append, uint64_t to_append_len) |
Appends data to the payload of the message. More... | |
void | release_ownership () |
Release the buffer's ownership which means that this object will not be responsible for deallocating its internal buffer. More... | |
bool | encode (uchar **buffer, uint64_t *buffer_len) const |
Encodes the header and payload into an internal buffer. More... | |
bool | encode (uchar *buffer, uint64_t *buffer_len) const |
Encodes the header and payload into a buffer provided by the caller. More... | |
bool | decode (const uchar *data, uint64_t data_len) |
Decodes data received via GCS and that belongs to a message. More... | |
const uchar * | get_header () const |
uint32_t | get_header_length () const |
const uchar * | get_payload () const |
uint64_t | get_payload_length () const |
virtual uint64_t | get_encode_size () const |
uint64_t | get_encode_payload_size () const |
uint64_t | get_encode_header_size () const |
Private Member Functions | |
bool | report_allocate_memory (size_t size) |
On memory allocation this function is called, so that memory consumption can be tracked. More... | |
void | report_deallocate_memory (size_t size) |
On memory free this function is called to reduce count of allocated memory. More... | |
Gcs_message_data (Gcs_message_data const &) | |
Gcs_message_data & | operator= (Gcs_message_data const &) |
Private Attributes | |
uchar * | m_header |
uchar * | m_header_slider |
uint32_t | m_header_len |
uint32_t | m_header_capacity |
uchar * | m_payload |
uchar * | m_payload_slider |
uint64_t | m_payload_len |
uint64_t | m_payload_capacity |
uchar * | m_buffer |
uint64_t | m_buffer_len |
bool | m_owner |
This class serves as data container for information flowing in the GCS ecosystem.
It has been isolated in order to be used in place where a full-blown Gcs_message does not make sense.
For a full usage example, check the Gcs_message documentation.
Gcs_message_data::Gcs_message_data | ( | ) |
Gcs_message_data implementation.
|
explicit |
Constructor of Gcs_message_data which pre-allocates space to store the header and payload and should be used when creating messages to send information to remote peers.
header_capacity | Determines the header's size. |
payload_capacity | Determines the payload's size. |
|
explicit |
Constructor of Gcs_message_data which pre-allocates space to store a message received from a remote peer.
data_len | Data's length. |
|
virtual |
|
private |
bool Gcs_message_data::append_to_header | ( | const uchar * | to_append, |
uint32_t | to_append_len | ||
) |
Appends data to the header of the message.
The data MUST have been previously encoded in little endian format.
If the data to be appended exceeds the pre-allocated buffer capacity an error is returned.
[in] | to_append | the data to append |
[in] | to_append_len | the length of the data to append |
bool Gcs_message_data::append_to_payload | ( | const uchar * | to_append, |
uint64_t | to_append_len | ||
) |
Appends data to the payload of the message.
The data MUST have been previously encoded in little endian format.
If the data to be appended exceeds the pre-allocated buffer capacity an error is returned.
[in] | to_append | the data to append |
[in] | to_append_len | the length of the data to append |
bool Gcs_message_data::decode | ( | const uchar * | data, |
uint64_t | data_len | ||
) |
Decodes data received via GCS and that belongs to a message.
After decoding, all the fields will be filled. The data MUST be in little endian format.
If the buffer is not large enough to store the encoded data or is a NULL pointer, an error is returned.
[in] | data | Data received via network |
[in] | data_len | Data length received via network |
bool Gcs_message_data::encode | ( | uchar ** | buffer, |
uint64_t * | buffer_len | ||
) | const |
Encodes the header and payload into an internal buffer.
If NULL pointer is provided or the data was not already appended to the buffer, an error is returned.
The meta data is formatted in little endian format, and is structured on the wire as depicted below:
[in,out] | buffer | Variable that will hold a pointer to the buffer |
[in,out] | buffer_len | Variable that will hold the buffer's size. |
bool Gcs_message_data::encode | ( | uchar * | buffer, |
uint64_t * | buffer_len | ||
) | const |
Encodes the header and payload into a buffer provided by the caller.
If the buffer is not large enough to store the encoded data or is a NULL pointer, an error is returned.
[in,out] | buffer | Buffer to store the encoded data in the message. |
[in,out] | buffer_len | The length of the buffer where the data is to be stored. It contains the length of the data dumped into the buffer once the function succeeds. |
uint64_t Gcs_message_data::get_encode_header_size | ( | ) | const |
uint64_t Gcs_message_data::get_encode_payload_size | ( | ) | const |
|
virtual |
const uchar * Gcs_message_data::get_header | ( | ) | const |
uint32_t Gcs_message_data::get_header_length | ( | ) | const |
const uchar * Gcs_message_data::get_payload | ( | ) | const |
uint64_t Gcs_message_data::get_payload_length | ( | ) | const |
|
private |
void Gcs_message_data::release_ownership | ( | ) |
Release the buffer's ownership which means that this object will not be responsible for deallocating its internal buffer.
The caller should do so.
This method should be used along with the following method: encode(**buffer, *buffer_len).
|
private |
On memory allocation this function is called, so that memory consumption can be tracked.
[in] | size | memory size to be allocated |
|
private |
On memory free this function is called to reduce count of allocated memory.
[in] | size | memory size to be allocated |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |