MySQL 8.0.40
Source Code Documentation
Gcs_message_stage Class Referenceabstract

This is a stage in the pipeline that processes messages when they are put through the send and receive code paths. More...

#include <gcs_message_stages.h>

Inheritance diagram for Gcs_message_stage:
[legend]

Public Types

enum class  stage_status : unsigned int { apply , skip , abort }
 

Public Member Functions

virtual stage_status skip_apply (uint64_t const &original_payload_size) const =0
 Check if the apply operation which affects outgoing packets should be executed (i.e. More...
 
virtual std::unique_ptr< Gcs_stage_metadataget_stage_header ()=0
 
 Gcs_message_stage ()
 
 Gcs_message_stage (bool enabled)
 
virtual ~Gcs_message_stage ()=default
 
virtual Stage_code get_stage_code () const =0
 Return the unique stage code. More...
 
std::pair< bool, std::vector< Gcs_packet > > apply (Gcs_packet &&packet)
 Apply some transformation to the outgoing packet, and return a set of one, or more, transformed packets. More...
 
std::pair< Gcs_pipeline_incoming_result, Gcs_packetrevert (Gcs_packet &&packet)
 Revert some transformation from the incoming packet, and return one, or none, transformed packet. More...
 
bool is_enabled () const
 Return whether the message stage is enabled or not. More...
 
virtual bool update_members_information (const Gcs_member_identifier &, const Gcs_xcom_nodes &)
 Update the list of members in the group as this may be required by some stages in the communication pipeline. More...
 
virtual Gcs_xcom_synode_set get_snapshot () const
 
void set_enabled (bool is_enabled)
 Enable or disable the message stage. More...
 

Protected Member Functions

virtual stage_status skip_revert (const Gcs_packet &packet) const =0
 Check if the revert operation which affects incoming packets should be executed (i.e. More...
 
virtual std::pair< bool, std::vector< Gcs_packet > > apply_transformation (Gcs_packet &&packet)=0
 Implements the logic of this stage's transformation to the packet, and returns a set of one, or more, transformed packets. More...
 
virtual std::pair< Gcs_pipeline_incoming_result, Gcs_packetrevert_transformation (Gcs_packet &&packet)=0
 Implements the logic to revert this stage's transformation to the packet, and returns one, or none, transformed packet. More...
 
void encode (unsigned char *header, unsigned short header_length, unsigned long long old_payload_length)
 Encode the fixed part of the associated dynamic header information into the header buffer. More...
 
void decode (const unsigned char *header, unsigned short *header_length, unsigned long long *old_payload_length)
 Decode the fixed part of the associated dynamic header information from the header buffer. More...
 

Private Attributes

bool m_is_enabled
 

Detailed Description

This is a stage in the pipeline that processes messages when they are put through the send and receive code paths.

A stage may apply a transformation to the payload of the message that it is handling. If it does morph the message, it will append a stage header to the message and change the payload accordingly. On the receiving side the GCS receiver thread will revert the transformation before delivering the message to the application.

An example of a stage is the LZ4 stage that compresses the payload.

Developers willing to create a new stage have to inherit from this class and implement six virtual methods that are self-explanatory. Note, however, that the current semantics assume that each new stage added to the pipeline will allocate a new buffer and copy the payload, which may be transformed or not, to it.

This copy assumption makes it easier to create a simple infra-structure to add new stages. Currently, this does not represent a performance bottleneck but we may revisit this design if it becomes a problem. Note that a quick, but maybe not so simple way to overcome this limitation, is through the redefinition of the apply and revert methods.

Member Enumeration Documentation

◆ stage_status

enum class Gcs_message_stage::stage_status : unsigned int
strong
Enumerator
apply 
skip 
abort 

Constructor & Destructor Documentation

◆ Gcs_message_stage() [1/2]

Gcs_message_stage::Gcs_message_stage ( )
inlineexplicit

◆ Gcs_message_stage() [2/2]

Gcs_message_stage::Gcs_message_stage ( bool  enabled)
inlineexplicit

◆ ~Gcs_message_stage()

virtual Gcs_message_stage::~Gcs_message_stage ( )
virtualdefault

Member Function Documentation

◆ apply()

std::pair< bool, std::vector< Gcs_packet > > Gcs_message_stage::apply ( Gcs_packet &&  packet)

Apply some transformation to the outgoing packet, and return a set of one, or more, transformed packets.

Parameters
[in]packetThe packet upon which the transformation should be applied
Return values
{true,_}If there was an error applying the transformation
{false,P}If the transformation was successful, and produced the set of transformed packets P

◆ apply_transformation()

virtual std::pair< bool, std::vector< Gcs_packet > > Gcs_message_stage::apply_transformation ( Gcs_packet &&  packet)
protectedpure virtual

Implements the logic of this stage's transformation to the packet, and returns a set of one, or more, transformed packets.

Parameters
[in]packetThe packet upon which the transformation should be applied
Return values
{true,_}If there was an error applying the transformation
{false,P}If the transformation was successful, and produced the set of transformed packets P

Implemented in Gcs_message_stage_lz4, and Gcs_message_stage_split_v2.

◆ decode()

void Gcs_message_stage::decode ( const unsigned char *  header,
unsigned short *  header_length,
unsigned long long *  old_payload_length 
)
protected

Decode the fixed part of the associated dynamic header information from the header buffer.

Parameters
headerPointer to the header buffer
[out]header_lengthPointer to the length of the header information
[out]old_payload_lengthPointer to the length of previous stage payload

◆ encode()

void Gcs_message_stage::encode ( unsigned char *  header,
unsigned short  header_length,
unsigned long long  old_payload_length 
)
protected

Encode the fixed part of the associated dynamic header information into the header buffer.

Parameters
headerPointer to the header buffer.
header_lengthLength of the header information.
old_payload_lengthLength of previous stage payload.

◆ get_snapshot()

virtual Gcs_xcom_synode_set Gcs_message_stage::get_snapshot ( ) const
inlinevirtual

Reimplemented in Gcs_message_stage_split_v2.

◆ get_stage_code()

virtual Stage_code Gcs_message_stage::get_stage_code ( ) const
pure virtual

Return the unique stage code.

Returns
the stage code.

Implemented in Gcs_message_stage_lz4, Gcs_message_stage_lz4_v2, Gcs_message_stage_lz4_v3, Gcs_message_stage_split_v2, and Gcs_message_stage_split_v3.

◆ get_stage_header()

virtual std::unique_ptr< Gcs_stage_metadata > Gcs_message_stage::get_stage_header ( )
pure virtual

◆ is_enabled()

bool Gcs_message_stage::is_enabled ( ) const
inline

Return whether the message stage is enabled or not.

◆ revert()

std::pair< Gcs_pipeline_incoming_result, Gcs_packet > Gcs_message_stage::revert ( Gcs_packet &&  packet)

Revert some transformation from the incoming packet, and return one, or none, transformed packet.

Parameters
[in]packetThe packet upon which the transformation should be reverted
Return values
{ERROR,_}If there was an error reverting the transformation
{OK_NO_PACKET,NP}If the transformation was reverted, but produced no packet
{OK_PACKET,P}If the transformation was reverted, and produced the packet P

◆ revert_transformation()

virtual std::pair< Gcs_pipeline_incoming_result, Gcs_packet > Gcs_message_stage::revert_transformation ( Gcs_packet &&  packet)
protectedpure virtual

Implements the logic to revert this stage's transformation to the packet, and returns one, or none, transformed packet.

Parameters
[in]packetThe packet upon which the transformation should be reverted
Return values
{ERROR,_}If there was an error reverting the transformation
{OK_NO_PACKET,NP}If the transformation was reverted, but produced no packet
{OK_PACKET,P}If the transformation was reverted, and produced the packet P

Implemented in Gcs_message_stage_lz4, and Gcs_message_stage_split_v2.

◆ set_enabled()

void Gcs_message_stage::set_enabled ( bool  is_enabled)
inline

Enable or disable the message stage.

Parameters
is_enabledWhether the message stage is enabled or disabled.

◆ skip_apply()

virtual stage_status Gcs_message_stage::skip_apply ( uint64_t const &  original_payload_size) const
pure virtual

Check if the apply operation which affects outgoing packets should be executed (i.e.

applied), skipped or aborted.

If the outcome is code apply or code skip, the stage will process or skip the message, respectively. However, if the outcome is code abort, the message will be discarded and an error will be reported thus stopping the pipeline execution.

For example, if a packet's length is less than a pre-defined threshold the packet is not compressed.

Parameters
original_payload_sizeThe size of the packet to which the transformation should be applied.
Returns
a status specifying whether the transformation should be executed, skipped or aborted

Implemented in Gcs_message_stage_lz4, and Gcs_message_stage_split_v2.

◆ skip_revert()

virtual stage_status Gcs_message_stage::skip_revert ( const Gcs_packet packet) const
protectedpure virtual

Check if the revert operation which affects incoming packets should be executed (i.e.

applied), skipped or aborted.

If the outcome is code apply or code skip, the stage will process or skip the message, respectively. However, if the outcome is code abort, the message will be discarded and an error will be reported thus stopping the pipeline execution.

For example, if the packet length is greater than the maximum allowed compressed information an error is returned.

Parameters
packetThe packet upon which the transformation should be applied
Returns
a status specifying whether the transformation should be executed, skipped or aborted

Implemented in Gcs_message_stage_lz4, and Gcs_message_stage_split_v2.

◆ update_members_information()

virtual bool Gcs_message_stage::update_members_information ( const Gcs_member_identifier ,
const Gcs_xcom_nodes  
)
inlinevirtual

Update the list of members in the group as this may be required by some stages in the communication pipeline.

By default though, the call is simply ignored.

Returns
If there is an error, true is returned. Otherwise, false is returned.

Reimplemented in Gcs_message_stage_split_v2.

Member Data Documentation

◆ m_is_enabled

bool Gcs_message_stage::m_is_enabled
private

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