MySQL 8.4.2
Source Code Documentation
Gcs_message_data Class Reference

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 ucharget_header () const
 
uint32_t get_header_length () const
 
const ucharget_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_dataoperator= (Gcs_message_data const &)
 

Private Attributes

ucharm_header
 
ucharm_header_slider
 
uint32_t m_header_len
 
uint32_t m_header_capacity
 
ucharm_payload
 
ucharm_payload_slider
 
uint64_t m_payload_len
 
uint64_t m_payload_capacity
 
ucharm_buffer
 
uint64_t m_buffer_len
 
bool m_owner
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Gcs_message_data() [1/4]

Gcs_message_data::Gcs_message_data ( )

Gcs_message_data implementation.

◆ Gcs_message_data() [2/4]

Gcs_message_data::Gcs_message_data ( const uint32_t  header_capacity,
const uint64_t  payload_capacity 
)
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.

Parameters
header_capacityDetermines the header's size.
payload_capacityDetermines the payload's size.

◆ Gcs_message_data() [3/4]

Gcs_message_data::Gcs_message_data ( const uint64_t  data_len)
explicit

Constructor of Gcs_message_data which pre-allocates space to store a message received from a remote peer.

Parameters
data_lenData's length.

◆ ~Gcs_message_data()

Gcs_message_data::~Gcs_message_data ( )
virtual

◆ Gcs_message_data() [4/4]

Gcs_message_data::Gcs_message_data ( Gcs_message_data const &  )
private

Member Function Documentation

◆ append_to_header()

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.

Parameters
[in]to_appendthe data to append
[in]to_append_lenthe length of the data to append
Returns
true on error, false otherwise.

◆ append_to_payload()

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.

Parameters
[in]to_appendthe data to append
[in]to_append_lenthe length of the data to append
Returns
true on error, false otherwise.

◆ decode()

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.

Parameters
[in]dataData received via network
[in]data_lenData length received via network
Returns
true on error, false otherwise.

◆ encode() [1/2]

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:


| header len | payload len | header | payload |

Parameters
[in,out]bufferVariable that will hold a pointer to the buffer
[in,out]buffer_lenVariable that will hold the buffer's size.
Returns
true on error, false otherwise.

◆ encode() [2/2]

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.

Parameters
[in,out]bufferBuffer to store the encoded data in the message.
[in,out]buffer_lenThe 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.
Returns
true on error, false otherwise.

◆ get_encode_header_size()

uint64_t Gcs_message_data::get_encode_header_size ( ) const
Returns
the size of the encoded header when put on the wire.

◆ get_encode_payload_size()

uint64_t Gcs_message_data::get_encode_payload_size ( ) const
Returns
the size of the encoded payload when put on the wire.

◆ get_encode_size()

uint64_t Gcs_message_data::get_encode_size ( ) const
virtual
Returns
the size of the encoded data when put on the wire.

◆ get_header()

const uchar * Gcs_message_data::get_header ( ) const
Returns
the message header in little endian format

◆ get_header_length()

uint32_t Gcs_message_data::get_header_length ( ) const
Returns
the message header length

◆ get_payload()

const uchar * Gcs_message_data::get_payload ( ) const
Returns
the message payload in little endian format

◆ get_payload_length()

uint64_t Gcs_message_data::get_payload_length ( ) const
Returns
the message payload_length

◆ operator=()

Gcs_message_data & Gcs_message_data::operator= ( Gcs_message_data const &  )
private

◆ release_ownership()

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).

◆ report_allocate_memory()

bool Gcs_message_data::report_allocate_memory ( size_t  size)
private

On memory allocation this function is called, so that memory consumption can be tracked.

Parameters
[in]sizememory size to be allocated
Returns
true on error, false otherwise.

◆ report_deallocate_memory()

void Gcs_message_data::report_deallocate_memory ( size_t  size)
private

On memory free this function is called to reduce count of allocated memory.

Parameters
[in]sizememory size to be allocated

Member Data Documentation

◆ m_buffer

uchar* Gcs_message_data::m_buffer
private

◆ m_buffer_len

uint64_t Gcs_message_data::m_buffer_len
private

◆ m_header

uchar* Gcs_message_data::m_header
private

◆ m_header_capacity

uint32_t Gcs_message_data::m_header_capacity
private

◆ m_header_len

uint32_t Gcs_message_data::m_header_len
private

◆ m_header_slider

uchar* Gcs_message_data::m_header_slider
private

◆ m_owner

bool Gcs_message_data::m_owner
private

◆ m_payload

uchar* Gcs_message_data::m_payload
private

◆ m_payload_capacity

uint64_t Gcs_message_data::m_payload_capacity
private

◆ m_payload_len

uint64_t Gcs_message_data::m_payload_len
private

◆ m_payload_slider

uchar* Gcs_message_data::m_payload_slider
private

The documentation for this class was generated from the following files: