MySQL 9.1.0
Source Code Documentation
|
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>
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_metadata > | get_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_packet > | revert (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_packet > | revert_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 |
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.
|
strong |
|
inlineexplicit |
|
inlineexplicit |
|
virtualdefault |
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.
[in] | packet | The packet upon which the transformation should be applied |
{true,_} | If there was an error applying the transformation |
{false,P} | If the transformation was successful, and produced the set of transformed packets P |
|
protectedpure virtual |
Implements the logic of this stage's transformation to the packet, and returns a set of one, or more, transformed packets.
[in] | packet | The packet upon which the transformation should be applied |
{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.
|
protected |
Decode the fixed part of the associated dynamic header information from the header buffer.
header | Pointer to the header buffer | |
[out] | header_length | Pointer to the length of the header information |
[out] | old_payload_length | Pointer to the length of previous stage payload |
|
protected |
Encode the fixed part of the associated dynamic header information into the header buffer.
header | Pointer to the header buffer. |
header_length | Length of the header information. |
old_payload_length | Length of previous stage payload. |
|
inlinevirtual |
Reimplemented in Gcs_message_stage_split_v2.
|
pure virtual |
Return the unique 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.
|
pure virtual |
Implemented in Gcs_message_stage_lz4, and Gcs_message_stage_split_v2.
|
inline |
Return whether the message stage is enabled or not.
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.
[in] | packet | The packet upon which the transformation should be reverted |
{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 |
|
protectedpure virtual |
Implements the logic to revert this stage's transformation to the packet, and returns one, or none, transformed packet.
[in] | packet | The packet upon which the transformation should be reverted |
{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.
|
inline |
Enable or disable the message stage.
is_enabled | Whether the message stage is enabled or disabled. |
|
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.
original_payload_size | The size of the packet to which the transformation should be applied. |
Implemented in Gcs_message_stage_lz4, and Gcs_message_stage_split_v2.
|
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.
packet | The packet upon which the transformation should be applied |
Implemented in Gcs_message_stage_lz4, and Gcs_message_stage_split_v2.
|
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.
Reimplemented in Gcs_message_stage_split_v2.
|
private |