23#ifndef GCS_MSG_STAGES_H
24#define GCS_MSG_STAGES_H
28#include <initializer_list>
103 uint64_t
const &original_payload_size)
const = 0;
149 virtual std::pair<Gcs_pipeline_incoming_result, Gcs_packet>
187 std::pair<Gcs_pipeline_incoming_result, Gcs_packet>
revert(
225 void encode(
unsigned char *header,
unsigned short header_length,
226 unsigned long long old_payload_length);
237 void decode(
const unsigned char *header,
unsigned short *header_length,
238 unsigned long long *old_payload_length);
250 std::map<Stage_code, std::unique_ptr<Gcs_message_stage>>;
253 std::pair<const Gcs_protocol_version, Gcs_stages_list>;
452 template <
class T,
class... Args>
454 std::unique_ptr<T> stage(
new T(args...));
456 if (stage !=
nullptr) {
459 if (ptr ==
nullptr) {
461 std::make_pair(stage->get_stage_code(), std::move(stage)));
485 assert(ptr !=
nullptr);
526 assert(ptr !=
nullptr);
583 uint64_t
const &original_payload_size)
const;
599 uint64_t
const &original_payload_size,
600 std::vector<Stage_code>
const &stages_to_apply)
const;
612 Gcs_packet &&packet, std::vector<Stage_code>
const &stages)
const;
623 std::pair<bool, std::vector<Gcs_packet>>
apply_stage(
637 std::pair<Gcs_pipeline_incoming_result, Gcs_packet>
revert_stage(
It represents the identity of a group member within a certain group.
Definition: gcs_member_identifier.h:39
This class serves as data container for information flowing in the GCS ecosystem.
Definition: gcs_message.h:47
This is the pipeline that an outgoing or incoming message has to go through when being sent to or rec...
Definition: gcs_message_stages.h:364
std::pair< bool, Gcs_packet > create_packet(Cargo_type const &cargo, Gcs_protocol_version const ¤t_version, uint64_t const &original_payload_size, std::vector< Stage_code > const &stages_to_apply) const
Create a packet for a message with size original_payload_size and type cargo, that will go through th...
Definition: gcs_message_stages.cc:249
std::pair< bool, std::vector< Stage_code > > get_stages_to_apply(Gcs_protocol_version const &pipeline_version, uint64_t const &original_payload_size) const
Find out which stages should be applied to an outgoing message.
Definition: gcs_message_stages.cc:213
std::pair< Gcs_pipeline_incoming_result, Gcs_packet > process_incoming(Gcs_packet &&packet) const
This member function SHALL be called by the receiver thread to process the packet through the stages ...
Definition: gcs_message_stages.cc:338
virtual ~Gcs_message_pipeline()=default
const Gcs_stages_list * retrieve_pipeline(Gcs_protocol_version pipeline_version) const
Retrieve the stages associated with a pipeline version.
Definition: gcs_message_stages.cc:415
bool contains_pipeline(Gcs_protocol_version pipeline_version) const
Check whether a pipeline version is registered or not.
Definition: gcs_message_stages.h:512
Gcs_message_stage & get_stage(Stage_code code) const
Definition: gcs_message_stages.h:483
Gcs_message_pipeline(Gcs_message_pipeline &&p)=delete
Gcs_message_pipeline & operator=(Gcs_message_pipeline &&p)=delete
void update_members_information(const Gcs_member_identifier &me, const Gcs_xcom_nodes &xcom_nodes) const
Update the list of members in the group as this may be required by some stages in the communication p...
Definition: gcs_message_stages.cc:390
Gcs_map_type_handler m_handlers
The registered stages.
Definition: gcs_message_stages.h:371
Gcs_message_pipeline()
Definition: gcs_message_stages.h:386
std::pair< Gcs_pipeline_incoming_result, Gcs_packet > revert_stage(Gcs_packet &&packet, Stage_code const &stage_code) const
Revert the given stage to the given incoming packet.
Definition: gcs_message_stages.cc:370
const Gcs_stages_list & get_pipeline(Gcs_protocol_version pipeline_version) const
Definition: gcs_message_stages.h:523
Gcs_protocol_version get_version() const
Return the pipeline version in use.
Definition: gcs_message_stages.cc:491
std::pair< bool, std::vector< Gcs_packet > > process_outgoing(Gcs_message_data const &msg_data, Cargo_type cargo) const
This member function SHALL be called by the message sender.
Definition: gcs_message_stages.cc:116
bool contains_stage(Stage_code code) const
Check whether a stage is registered or not.
Definition: gcs_message_stages.h:472
void cleanup()
Clean all data structures and objects created.
Definition: gcs_message_stages.cc:495
Gcs_map_version_stages m_pipelines
This is the pre-assembled outgoing pipelines for the different versions that are currently supported,...
Definition: gcs_message_stages.h:378
std::pair< bool, std::vector< Gcs_packet > > apply_stage(std::vector< Gcs_packet > &&packets, Gcs_message_stage &stage) const
Apply the given stage to the given outgoing packet.
Definition: gcs_message_stages.cc:311
Gcs_message_stage * retrieve_stage(const Gcs_packet &p) const
This member function SHALL retrieve the current stage type code of a packet.
Gcs_message_stage * retrieve_stage(Stage_code stage_code) const
This member function SHALL retrieve the associated stage if there is any, otherwise a null pointer is...
Definition: gcs_message_stages.cc:408
void register_stage(Args... args)
Register a stage to be used by the pipeline.
Definition: gcs_message_stages.h:453
std::atomic< Gcs_protocol_version > m_pipeline_version
The pipeline version in use.
Definition: gcs_message_stages.h:383
Gcs_message_pipeline(Gcs_message_pipeline &p)=delete
Gcs_xcom_synode_set get_snapshot() const
Definition: gcs_message_stages.cc:397
bool set_version(Gcs_protocol_version pipeline_version)
Set the pipeline version in use.
Definition: gcs_message_stages.cc:483
std::pair< bool, std::vector< Gcs_packet > > apply_stages(Gcs_packet &&packet, std::vector< Stage_code > const &stages) const
Apply the given stages to the given outgoing packet.
Definition: gcs_message_stages.cc:287
Gcs_message_pipeline & operator=(const Gcs_message_pipeline &p)=delete
bool register_pipeline(std::initializer_list< Gcs_pair_version_stages > stages)
Register the stages per version that form the different pipelines.
Definition: gcs_message_stages.cc:422
This is a stage in the pipeline that processes messages when they are put through the send and receiv...
Definition: gcs_message_stages.h:81
virtual Gcs_xcom_synode_set get_snapshot() const
Definition: gcs_message_stages.h:207
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.
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,...
bool m_is_enabled
Definition: gcs_message_stages.h:241
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,...
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,...
Definition: gcs_message_stages.cc:47
virtual Stage_code get_stage_code() const =0
Return the unique stage code.
Gcs_message_stage()
Definition: gcs_message_stages.h:153
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....
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.
virtual std::unique_ptr< Gcs_stage_metadata > get_stage_header()=0
void set_enabled(bool is_enabled)
Enable or disable the message stage.
Definition: gcs_message_stages.h:214
virtual stage_status skip_revert(const Gcs_packet &packet) const =0
Check if the revert operation which affects incoming packets should be executed (i....
bool is_enabled() const
Return whether the message stage is enabled or not.
Definition: gcs_message_stages.h:193
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 p...
Definition: gcs_message_stages.h:202
stage_status
Definition: gcs_message_stages.h:83
Gcs_message_stage(bool enabled)
Definition: gcs_message_stages.h:155
virtual ~Gcs_message_stage()=default
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.
Definition: gcs_message_stages.cc:75
This class is an abstraction for the packet concept.
Definition: gcs_internal_message.h:57
This class contains information on the configuration, i.e set of nodes or simply site definition.
Definition: gcs_xcom_group_member_information.h:390
const char * p
Definition: ctype-mb.cc:1234
std::map< Gcs_protocol_version, Gcs_stages_list > Gcs_map_version_stages
Definition: gcs_message_stages.h:251
std::pair< const Gcs_protocol_version, Gcs_stages_list > Gcs_pair_version_stages
Definition: gcs_message_stages.h:253
std::vector< Stage_code > Gcs_stages_list
Definitions of structures that store the possible message stages and their handlers.
Definition: gcs_message_stages.h:248
std::map< Stage_code, std::unique_ptr< Gcs_message_stage > > Gcs_map_type_handler
Definition: gcs_message_stages.h:250
Gcs_pipeline_incoming_result
Error code for the pipeline's processing of incoming packets.
Definition: gcs_message_stages.h:44
@ OK_NO_PACKET
Successful, but produces no packet.
@ OK_PACKET
Successful, and returned a packet.
Gcs_protocol_version
The GCS protocol versions.
Definition: gcs_types.h:127
std::unordered_set< Gcs_xcom_synode > Gcs_xcom_synode_set
Definition: gcs_xcom_synode.h:83
required bool enabled
Definition: replication_group_member_actions.proto:32