24#ifndef GCS_MSG_STAGES_H
25#define GCS_MSG_STAGES_H
29#include <initializer_list>
104 uint64_t
const &original_payload_size)
const = 0;
150 virtual std::pair<Gcs_pipeline_incoming_result, Gcs_packet>
188 std::pair<Gcs_pipeline_incoming_result, Gcs_packet>
revert(
226 void encode(
unsigned char *header,
unsigned short header_length,
227 unsigned long long old_payload_length);
238 void decode(
const unsigned char *header,
unsigned short *header_length,
239 unsigned long long *old_payload_length);
251 std::map<Stage_code, std::unique_ptr<Gcs_message_stage>>;
254 std::pair<const Gcs_protocol_version, Gcs_stages_list>;
453 template <
class T,
class... Args>
455 std::unique_ptr<T> stage(
new T(args...));
457 if (stage !=
nullptr) {
460 if (ptr ==
nullptr) {
462 std::make_pair(stage->get_stage_code(), std::move(stage)));
486 assert(ptr !=
nullptr);
527 assert(ptr !=
nullptr);
584 uint64_t
const &original_payload_size)
const;
600 uint64_t
const &original_payload_size,
601 std::vector<Stage_code>
const &stages_to_apply)
const;
613 Gcs_packet &&packet, std::vector<Stage_code>
const &stages)
const;
624 std::pair<bool, std::vector<Gcs_packet>>
apply_stage(
638 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:40
This class serves as data container for information flowing in the GCS ecosystem.
Definition: gcs_message.h:48
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:365
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:250
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:214
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:339
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:416
bool contains_pipeline(Gcs_protocol_version pipeline_version) const
Check whether a pipeline version is registered or not.
Definition: gcs_message_stages.h:513
Gcs_message_stage & get_stage(Stage_code code) const
Definition: gcs_message_stages.h:484
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:391
Gcs_map_type_handler m_handlers
The registered stages.
Definition: gcs_message_stages.h:372
Gcs_message_pipeline()
Definition: gcs_message_stages.h:387
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:371
const Gcs_stages_list & get_pipeline(Gcs_protocol_version pipeline_version) const
Definition: gcs_message_stages.h:524
Gcs_protocol_version get_version() const
Return the pipeline version in use.
Definition: gcs_message_stages.cc:492
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:117
bool contains_stage(Stage_code code) const
Check whether a stage is registered or not.
Definition: gcs_message_stages.h:473
void cleanup()
Clean all data structures and objects created.
Definition: gcs_message_stages.cc:496
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:379
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:312
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:409
void register_stage(Args... args)
Register a stage to be used by the pipeline.
Definition: gcs_message_stages.h:454
std::atomic< Gcs_protocol_version > m_pipeline_version
The pipeline version in use.
Definition: gcs_message_stages.h:384
Gcs_message_pipeline(Gcs_message_pipeline &p)=delete
Gcs_xcom_synode_set get_snapshot() const
Definition: gcs_message_stages.cc:398
bool set_version(Gcs_protocol_version pipeline_version)
Set the pipeline version in use.
Definition: gcs_message_stages.cc:484
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:288
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:423
This is a stage in the pipeline that processes messages when they are put through the send and receiv...
Definition: gcs_message_stages.h:82
virtual Gcs_xcom_synode_set get_snapshot() const
Definition: gcs_message_stages.h:208
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:242
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:48
virtual Stage_code get_stage_code() const =0
Return the unique stage code.
Gcs_message_stage()
Definition: gcs_message_stages.h:154
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:215
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:194
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:203
stage_status
Definition: gcs_message_stages.h:84
Gcs_message_stage(bool enabled)
Definition: gcs_message_stages.h:156
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:76
This class is an abstraction for the packet concept.
Definition: gcs_internal_message.h:58
This class contains information on the configuration, i.e set of nodes or simply site definition.
Definition: gcs_xcom_group_member_information.h:391
const char * p
Definition: ctype-mb.cc:1225
std::map< Gcs_protocol_version, Gcs_stages_list > Gcs_map_version_stages
Definition: gcs_message_stages.h:252
std::pair< const Gcs_protocol_version, Gcs_stages_list > Gcs_pair_version_stages
Definition: gcs_message_stages.h:254
std::vector< Stage_code > Gcs_stages_list
Definitions of structures that store the possible message stages and their handlers.
Definition: gcs_message_stages.h:249
std::map< Stage_code, std::unique_ptr< Gcs_message_stage > > Gcs_map_type_handler
Definition: gcs_message_stages.h:251
Gcs_pipeline_incoming_result
Error code for the pipeline's processing of incoming packets.
Definition: gcs_message_stages.h:45
@ 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:128
std::unordered_set< Gcs_xcom_synode > Gcs_xcom_synode_set
Definition: gcs_xcom_synode.h:84
required bool enabled
Definition: replication_group_member_actions.proto:33