MySQL 8.4.2
Source Code Documentation
Plugin_gcs_message Class Referenceabstract

This is the base GCS plugin message. More...

#include <gcs_plugin_messages.h>

Inheritance diagram for Plugin_gcs_message:
[legend]

Public Types

enum  enum_cargo_type {
  CT_UNKNOWN = 0 , CT_CERTIFICATION_MESSAGE = 1 , CT_TRANSACTION_MESSAGE = 2 , CT_RECOVERY_MESSAGE = 3 ,
  CT_MEMBER_INFO_MESSAGE = 4 , CT_MEMBER_INFO_MANAGER_MESSAGE = 5 , CT_PIPELINE_STATS_MEMBER_MESSAGE = 6 , CT_SINGLE_PRIMARY_MESSAGE = 7 ,
  CT_GROUP_ACTION_MESSAGE = 8 , CT_GROUP_VALIDATION_MESSAGE = 9 , CT_SYNC_BEFORE_EXECUTION_MESSAGE = 10 , CT_TRANSACTION_WITH_GUARANTEE_MESSAGE = 11 ,
  CT_TRANSACTION_PREPARED_MESSAGE = 12 , CT_MESSAGE_SERVICE_MESSAGE = 13 , CT_RECOVERY_METADATA_MESSAGE = 14 , CT_MAX = 15
}
 The different cargo type codes. More...
 

Public Member Functions

virtual ~Plugin_gcs_message ()=default
 
int get_version ()
 
unsigned short get_header_length ()
 
enum_cargo_type get_cargo_type () const
 
unsigned long long get_msg_length ()
 
void encode (std::vector< unsigned char > *buffer) const
 Encodes the contents of this instance into the buffer. More...
 
void decode (const unsigned char *buffer, size_t length)
 Decodes the contents of the buffer and sets the field values according to the values decoded. More...
 

Static Public Member Functions

static enum_cargo_type get_cargo_type (const unsigned char *buffer)
 Return the cargo type of a given message buffer, without decode the complete message. More...
 
static void get_first_payload_item_raw_data (const unsigned char *buffer, const unsigned char **payload_item_data, size_t *payload_item_length)
 Return the raw data of the first payload item of a given message buffer, without decode the complete message. More...
 
static bool get_payload_item_type_raw_data (const unsigned char *buffer, const unsigned char *end, uint16 payload_item_type, const unsigned char **payload_item_data, unsigned long long *payload_item_length)
 Return the raw data of the payload item of a given payload type of a given message buffer. More...
 

Static Public Attributes

static const int PLUGIN_GCS_MESSAGE_VERSION = 1
 The protocol version number. More...
 
static const unsigned int WIRE_VERSION_SIZE = 4
 The protocol version number. More...
 
static const unsigned int WIRE_HD_LEN_SIZE = 2
 The on-the-wire size of the header length field. More...
 
static const unsigned int WIRE_MSG_LEN_SIZE = 8
 The on-the-wire size of the message size field. More...
 
static const unsigned int WIRE_CARGO_TYPE_SIZE = 2
 The on-the-wire size of the cargo type field. More...
 
static const unsigned int WIRE_FIXED_HEADER_SIZE
 The on-the-wire size of the fixed header. More...
 
static const unsigned int WIRE_PAYLOAD_ITEM_TYPE_SIZE = 2
 The on-the-wire size of the each payload item type field. More...
 
static const unsigned int WIRE_PAYLOAD_ITEM_LEN_SIZE = 8
 The on-the-wire size of the each payload item size field. More...
 
static const unsigned int WIRE_PAYLOAD_ITEM_HEADER_SIZE
 The on-the-wire size of the payload item header. More...
 

Protected Member Functions

 Plugin_gcs_message (enum_cargo_type cargo_type)
 Plugin_gcs_message constructor. More...
 
void encode_header (std::vector< unsigned char > *buffer) const
 Encodes the header of this instance into the buffer. More...
 
void decode_header (const unsigned char **slider)
 Decodes the header of the buffer into this instance. More...
 
virtual void encode_payload (std::vector< unsigned char > *buffer) const =0
 Encodes the contents of this instance payload into the buffer. More...
 
virtual void decode_payload (const unsigned char *buffer, const unsigned char *end)=0
 Decodes the contents of the buffer and sets the payload field values according to the values decoded. More...
 
void encode_payload_item_type_and_length (std::vector< unsigned char > *buffer, uint16 payload_item_type, unsigned long long payload_item_length) const
 Encodes the given payload item type and length into the buffer. More...
 
void encode_payload_item_char (std::vector< unsigned char > *buffer, uint16 type, unsigned char value) const
 Encodes the given payload item (type, length and value) into the buffer as a char (1 byte). More...
 
void encode_payload_item_int2 (std::vector< unsigned char > *buffer, uint16 type, uint16 value) const
 Encodes the given payload item (type, length and value) into the buffer as a 2 bytes integer. More...
 
void decode_payload_item_int2 (const unsigned char **buffer, uint16 *type, uint16 *value)
 Decodes the given payload item (type, length and value) from the buffer as a 2 bytes integer. More...
 
void encode_payload_item_int4 (std::vector< unsigned char > *buffer, uint16 type, uint32 value) const
 Encodes the given payload item (type, length and value) into the buffer as a 4 bytes integer. More...
 
void decode_payload_item_int4 (const unsigned char **buffer, uint16 *type, uint32 *value)
 Decodes the given payload item (type, length and value) from the buffer as a 4 bytes integer. More...
 
void encode_payload_item_int8 (std::vector< unsigned char > *buffer, uint16 type, ulonglong value) const
 Encodes the given payload item (type, length and value) into the buffer as a 8 bytes integer. More...
 
void encode_payload_item_string (std::vector< unsigned char > *buffer, uint16 type, const char *value, unsigned long long length) const
 Encodes the given payload item (type, length and value) into the buffer as a char array (variable size). More...
 
void decode_payload_item_string (const unsigned char **buffer, uint16 *type, std::string *value, unsigned long long *length)
 Decodes the given payload item (type, length and value) from the buffer as a char array (variable size). More...
 
void encode_payload_item_bytes (std::vector< unsigned char > *buffer, uint16 type, const unsigned char *value, unsigned long long length) const
 Encodes the given payload item (type, length and value) into the buffer as a byte buffer (variable size). More...
 
void decode_payload_item_bytes (const unsigned char **buffer, uint16 *type, unsigned char *value, unsigned long long *length)
 Decodes the given payload item (type, length and value) from the buffer as a byte buffer (variable size). More...
 

Static Protected Member Functions

static int64_t get_sent_timestamp (const unsigned char *buffer, size_t length, const uint16 timestamp_payload_item_type)
 Return the time at which the message contained in the buffer was sent. More...
 
static void decode_payload_item_type_and_length (const unsigned char **buffer, uint16 *payload_item_type, unsigned long long *payload_item_length)
 Decodes the given payload item type and length from the buffer. More...
 
static void decode_payload_item_char (const unsigned char **buffer, uint16 *type, unsigned char *value)
 Decodes the given payload item (type, length and value) from the buffer as a char (1 byte). More...
 
static void decode_payload_item_int8 (const unsigned char **buffer, uint16 *type, uint64 *value)
 Decodes the given payload item (type, length and value) from the buffer as a 8 bytes integer. More...
 

Private Attributes

int m_version
 This header instance protocol version. More...
 
unsigned short m_fixed_header_len
 This header instance length. More...
 
unsigned long long m_msg_len
 This is the message length field. More...
 
enum_cargo_type m_cargo_type
 The cargo type code. More...
 

Detailed Description

This is the base GCS plugin message.

It is composed by a fixed header and 1 or more payload items.

The on-the-wire layout looks like this:

+--------------------------------—+ | fixed header | payload | +--------------------------------—+

The on-the-wire representation of the message is:

+----------------—+--------—+-----------------------------------—+ | field | wire size | description | +===================+===========+======================================+ | version | 4 bytes | protocol version | | fixed_hdr_len | 2 bytes | length of the fixed header | | message_len | 8 bytes | length of the message | | cargo_type | 2 bytes | the cargo type in the payload | +----------------—+--------—+-----------------------------------—+ | payload_item_type | 2 bytes | the item type in the payload | | payload_item_len | 8 bytes | length of the payload item | | payload_item | X bytes | payload item | +----------------—+--------—+-----------------------------------—+

The last tree lines can occur one or more times.

Member Enumeration Documentation

◆ enum_cargo_type

The different cargo type codes.

NOTE: all type values must fit into WIRE_CARGO_TYPE_SIZE bytes storage.

Enumerator
CT_UNKNOWN 
CT_CERTIFICATION_MESSAGE 
CT_TRANSACTION_MESSAGE 
CT_RECOVERY_MESSAGE 
CT_MEMBER_INFO_MESSAGE 
CT_MEMBER_INFO_MANAGER_MESSAGE 
CT_PIPELINE_STATS_MEMBER_MESSAGE 
CT_SINGLE_PRIMARY_MESSAGE 
CT_GROUP_ACTION_MESSAGE 
CT_GROUP_VALIDATION_MESSAGE 
CT_SYNC_BEFORE_EXECUTION_MESSAGE 
CT_TRANSACTION_WITH_GUARANTEE_MESSAGE 
CT_TRANSACTION_PREPARED_MESSAGE 
CT_MESSAGE_SERVICE_MESSAGE 
CT_RECOVERY_METADATA_MESSAGE 
CT_MAX 

Constructor & Destructor Documentation

◆ ~Plugin_gcs_message()

virtual Plugin_gcs_message::~Plugin_gcs_message ( )
virtualdefault

◆ Plugin_gcs_message()

Plugin_gcs_message::Plugin_gcs_message ( enum_cargo_type  cargo_type)
explicitprotected

Plugin_gcs_message constructor.

Only to be called by derivative classes

Parameters
[in]cargo_typeMessage type to be sent

Member Function Documentation

◆ decode()

void Plugin_gcs_message::decode ( const unsigned char *  buffer,
size_t  length 
)

Decodes the contents of the buffer and sets the field values according to the values decoded.

Parameters
[in]bufferthe buffer to decode from.
[in]lengththe length of the buffer.

◆ decode_header()

void Plugin_gcs_message::decode_header ( const unsigned char **  slider)
protected

Decodes the header of the buffer into this instance.

Parameters
[out]sliderbefore call decode_header: the start of the buffer after call decode_header: the position on which the header ends on the buffer.

◆ decode_payload()

virtual void Plugin_gcs_message::decode_payload ( const unsigned char *  buffer,
const unsigned char *  end 
)
protectedpure virtual

Decodes the contents of the buffer and sets the payload field values according to the values decoded.

Parameters
[in]bufferthe buffer to decode from.
[in]endthe end of the buffer.

Implemented in Gtid_Executed_Message, Group_member_info, Group_service_message, Group_validation_message, Recovery_message, Transaction_message, Transaction_with_guarantee_message, Group_member_info_manager_message, Pipeline_stats_member_message, Group_action_message, Recovery_metadata_message, Single_primary_message, Sync_before_execution_message, and Transaction_prepared_message.

◆ decode_payload_item_bytes()

void Plugin_gcs_message::decode_payload_item_bytes ( const unsigned char **  buffer,
uint16 type,
unsigned char *  value,
unsigned long long *  length 
)
protected

Decodes the given payload item (type, length and value) from the buffer as a byte buffer (variable size).

Parameters
[in]bufferthe buffer to encode from
[out]typethe type of the payload item
[out]valuethe value of the payload item
[out]lengththe length of the payload item

◆ decode_payload_item_char()

void Plugin_gcs_message::decode_payload_item_char ( const unsigned char **  buffer,
uint16 type,
unsigned char *  value 
)
staticprotected

Decodes the given payload item (type, length and value) from the buffer as a char (1 byte).

Parameters
[in]bufferthe buffer to encode from
[out]typethe type of the payload item
[out]valuethe value of the payload item

◆ decode_payload_item_int2()

void Plugin_gcs_message::decode_payload_item_int2 ( const unsigned char **  buffer,
uint16 type,
uint16 value 
)
protected

Decodes the given payload item (type, length and value) from the buffer as a 2 bytes integer.

Parameters
[in]bufferthe buffer to encode from
[out]typethe type of the payload item
[out]valuethe value of the payload item

◆ decode_payload_item_int4()

void Plugin_gcs_message::decode_payload_item_int4 ( const unsigned char **  buffer,
uint16 type,
uint32 value 
)
protected

Decodes the given payload item (type, length and value) from the buffer as a 4 bytes integer.

Parameters
[in]bufferthe buffer to encode from
[out]typethe type of the payload item
[out]valuethe value of the payload item

◆ decode_payload_item_int8()

void Plugin_gcs_message::decode_payload_item_int8 ( const unsigned char **  buffer,
uint16 type,
uint64 value 
)
staticprotected

Decodes the given payload item (type, length and value) from the buffer as a 8 bytes integer.

Parameters
[in]bufferthe buffer to encode from
[out]typethe type of the payload item
[out]valuethe value of the payload item

◆ decode_payload_item_string()

void Plugin_gcs_message::decode_payload_item_string ( const unsigned char **  buffer,
uint16 type,
std::string *  value,
unsigned long long *  length 
)
protected

Decodes the given payload item (type, length and value) from the buffer as a char array (variable size).

Parameters
[in]bufferthe buffer to encode from
[out]typethe type of the payload item
[out]valuethe value of the payload item
[out]lengththe length of the payload item

◆ decode_payload_item_type_and_length()

void Plugin_gcs_message::decode_payload_item_type_and_length ( const unsigned char **  buffer,
uint16 payload_item_type,
unsigned long long *  payload_item_length 
)
staticprotected

Decodes the given payload item type and length from the buffer.

Parameters
[in]bufferthe buffer to encode from
[out]payload_item_typethe type of the payload item
[out]payload_item_lengththe length of the payload item

◆ encode()

void Plugin_gcs_message::encode ( std::vector< unsigned char > *  buffer) const

Encodes the contents of this instance into the buffer.

Parameters
[out]bufferthe buffer to encode to.

◆ encode_header()

void Plugin_gcs_message::encode_header ( std::vector< unsigned char > *  buffer) const
protected

Encodes the header of this instance into the buffer.

Parameters
[out]bufferthe buffer to encode to.

◆ encode_payload()

virtual void Plugin_gcs_message::encode_payload ( std::vector< unsigned char > *  buffer) const
protectedpure virtual

◆ encode_payload_item_bytes()

void Plugin_gcs_message::encode_payload_item_bytes ( std::vector< unsigned char > *  buffer,
uint16  type,
const unsigned char *  value,
unsigned long long  length 
) const
protected

Encodes the given payload item (type, length and value) into the buffer as a byte buffer (variable size).

Parameters
[out]bufferthe buffer to encode to
[in]typethe type of the payload item
[in]valuethe value of the payload item
[in]lengththe length of the payload item

◆ encode_payload_item_char()

void Plugin_gcs_message::encode_payload_item_char ( std::vector< unsigned char > *  buffer,
uint16  type,
unsigned char  value 
) const
protected

Encodes the given payload item (type, length and value) into the buffer as a char (1 byte).

Parameters
[out]bufferthe buffer to encode to
[in]typethe type of the payload item
[in]valuethe value of the payload item

◆ encode_payload_item_int2()

void Plugin_gcs_message::encode_payload_item_int2 ( std::vector< unsigned char > *  buffer,
uint16  type,
uint16  value 
) const
protected

Encodes the given payload item (type, length and value) into the buffer as a 2 bytes integer.

Parameters
[out]bufferthe buffer to encode to
[in]typethe type of the payload item
[in]valuethe value of the payload item

◆ encode_payload_item_int4()

void Plugin_gcs_message::encode_payload_item_int4 ( std::vector< unsigned char > *  buffer,
uint16  type,
uint32  value 
) const
protected

Encodes the given payload item (type, length and value) into the buffer as a 4 bytes integer.

Parameters
[out]bufferthe buffer to encode to
[in]typethe type of the payload item
[in]valuethe value of the payload item

◆ encode_payload_item_int8()

void Plugin_gcs_message::encode_payload_item_int8 ( std::vector< unsigned char > *  buffer,
uint16  type,
ulonglong  value 
) const
protected

Encodes the given payload item (type, length and value) into the buffer as a 8 bytes integer.

Parameters
[out]bufferthe buffer to encode to
[in]typethe type of the payload item
[in]valuethe value of the payload item

◆ encode_payload_item_string()

void Plugin_gcs_message::encode_payload_item_string ( std::vector< unsigned char > *  buffer,
uint16  type,
const char *  value,
unsigned long long  length 
) const
protected

Encodes the given payload item (type, length and value) into the buffer as a char array (variable size).

Parameters
[out]bufferthe buffer to encode to
[in]typethe type of the payload item
[in]valuethe value of the payload item
[in]lengththe length of the payload item

◆ encode_payload_item_type_and_length()

void Plugin_gcs_message::encode_payload_item_type_and_length ( std::vector< unsigned char > *  buffer,
uint16  payload_item_type,
unsigned long long  payload_item_length 
) const
protected

Encodes the given payload item type and length into the buffer.

Parameters
[out]bufferthe buffer to encode to
[in]payload_item_typethe type of the payload item
[in]payload_item_lengththe length of the payload item

◆ get_cargo_type() [1/2]

enum_cargo_type Plugin_gcs_message::get_cargo_type ( ) const
inline
Returns
the cargo type.

◆ get_cargo_type() [2/2]

Plugin_gcs_message::enum_cargo_type Plugin_gcs_message::get_cargo_type ( const unsigned char *  buffer)
static

Return the cargo type of a given message buffer, without decode the complete message.

Parameters
[in]bufferthe buffer to decode from.
Returns
the cargo type of a given message buffer

◆ get_first_payload_item_raw_data()

void Plugin_gcs_message::get_first_payload_item_raw_data ( const unsigned char *  buffer,
const unsigned char **  payload_item_data,
size_t *  payload_item_length 
)
static

Return the raw data of the first payload item of a given message buffer, without decode the complete message.

Parameters
[out]bufferthe buffer to decode from.
[out]payload_item_datathe data.
[out]payload_item_lengththe length of the data.

◆ get_header_length()

unsigned short Plugin_gcs_message::get_header_length ( )
inline
Returns
the value of the header length field value.

◆ get_msg_length()

unsigned long long Plugin_gcs_message::get_msg_length ( )
inline
Returns
the message length field value.

◆ get_payload_item_type_raw_data()

bool Plugin_gcs_message::get_payload_item_type_raw_data ( const unsigned char *  buffer,
const unsigned char *  end,
uint16  payload_item_type,
const unsigned char **  payload_item_data,
unsigned long long *  payload_item_length 
)
static

Return the raw data of the payload item of a given payload type of a given message buffer.

Parameters
[in]bufferthe buffer to decode from.
[in]endthe end of buffer from which it decode.
[in]payload_item_typethe payload type to be searched.
[out]payload_item_datathe data for the given payload type.
[out]payload_item_lengththe length of the data for the given payload type.
Returns
the operation status
Return values
falseOK
trueError

◆ get_sent_timestamp()

int64_t Plugin_gcs_message::get_sent_timestamp ( const unsigned char *  buffer,
size_t  length,
const uint16  timestamp_payload_item_type 
)
staticprotected

Return the time at which the message contained in the buffer was sent.

See also
Metrics_handler::get_current_time()
Note
The method static uint64_t get_sent_timestamp(const unsigned char *buffer, size_t length); must be implemented on all children classes in order to allow read the sent timestamp without requiring a object creation and complete message deserialization.
Parameters
[in]bufferthe buffer to decode from.
[in]lengththe buffer length
[in]timestamp_payload_item_typethe payload item type of the timestamp.
Returns
the time on which the message was sent.

◆ get_version()

int Plugin_gcs_message::get_version ( )
inline
Returns
the value of the version field.

Member Data Documentation

◆ m_cargo_type

enum_cargo_type Plugin_gcs_message::m_cargo_type
private

The cargo type code.

◆ m_fixed_header_len

unsigned short Plugin_gcs_message::m_fixed_header_len
private

This header instance length.

◆ m_msg_len

unsigned long long Plugin_gcs_message::m_msg_len
private

This is the message length field.

◆ m_version

int Plugin_gcs_message::m_version
private

This header instance protocol version.

◆ PLUGIN_GCS_MESSAGE_VERSION

const int Plugin_gcs_message::PLUGIN_GCS_MESSAGE_VERSION = 1
static

The protocol version number.

◆ WIRE_CARGO_TYPE_SIZE

const unsigned int Plugin_gcs_message::WIRE_CARGO_TYPE_SIZE = 2
static

The on-the-wire size of the cargo type field.

◆ WIRE_FIXED_HEADER_SIZE

const unsigned int Plugin_gcs_message::WIRE_FIXED_HEADER_SIZE
static
Initial value:
=
static const unsigned int WIRE_MSG_LEN_SIZE
The on-the-wire size of the message size field.
Definition: gcs_plugin_messages.h:84
static const unsigned int WIRE_HD_LEN_SIZE
The on-the-wire size of the header length field.
Definition: gcs_plugin_messages.h:79
static const unsigned int WIRE_VERSION_SIZE
The protocol version number.
Definition: gcs_plugin_messages.h:74
static const unsigned int WIRE_CARGO_TYPE_SIZE
The on-the-wire size of the cargo type field.
Definition: gcs_plugin_messages.h:89

The on-the-wire size of the fixed header.

◆ WIRE_HD_LEN_SIZE

const unsigned int Plugin_gcs_message::WIRE_HD_LEN_SIZE = 2
static

The on-the-wire size of the header length field.

◆ WIRE_MSG_LEN_SIZE

const unsigned int Plugin_gcs_message::WIRE_MSG_LEN_SIZE = 8
static

The on-the-wire size of the message size field.

◆ WIRE_PAYLOAD_ITEM_HEADER_SIZE

const unsigned int Plugin_gcs_message::WIRE_PAYLOAD_ITEM_HEADER_SIZE
static
Initial value:
=
static const unsigned int WIRE_PAYLOAD_ITEM_LEN_SIZE
The on-the-wire size of the each payload item size field.
Definition: gcs_plugin_messages.h:104
static const unsigned int WIRE_PAYLOAD_ITEM_TYPE_SIZE
The on-the-wire size of the each payload item type field.
Definition: gcs_plugin_messages.h:99

The on-the-wire size of the payload item header.

◆ WIRE_PAYLOAD_ITEM_LEN_SIZE

const unsigned int Plugin_gcs_message::WIRE_PAYLOAD_ITEM_LEN_SIZE = 8
static

The on-the-wire size of the each payload item size field.

◆ WIRE_PAYLOAD_ITEM_TYPE_SIZE

const unsigned int Plugin_gcs_message::WIRE_PAYLOAD_ITEM_TYPE_SIZE = 2
static

The on-the-wire size of the each payload item type field.

◆ WIRE_VERSION_SIZE

const unsigned int Plugin_gcs_message::WIRE_VERSION_SIZE = 4
static

The protocol version number.


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