MySQL 8.0.40
Source Code Documentation
Gcs_xcom_communication Class Reference

#include <gcs_xcom_communication_interface.h>

Inheritance diagram for Gcs_xcom_communication:
[legend]

Public Member Functions

 Gcs_xcom_communication (Gcs_xcom_statistics_updater *stats, Gcs_xcom_proxy *proxy, Gcs_xcom_view_change_control_interface *view_control, Gcs_xcom_engine *gcs_engine, Gcs_group_identifier const &group_id, std::unique_ptr< Network_provider_management_interface > comms_mgmt)
 Gcs_xcom_communication_interface constructor. More...
 
 ~Gcs_xcom_communication () override
 
enum_gcs_error send_message (const Gcs_message &message_to_send) override
 Implementation of the public send_message method defined in Gcs_xcom_communication. More...
 
int add_event_listener (const Gcs_communication_event_listener &event_listener) override
 Registers an implementation of a Gcs_communication_event_listener that will receive Communication Events. More...
 
void remove_event_listener (int event_listener_handle) override
 Removes a previously registered event listener. More...
 
enum_gcs_error do_send_message (const Gcs_message &message_to_send, unsigned long long *message_length, Cargo_type cargo) override
 Sends a message that is internal to the binding implementation. More...
 
std::map< int, const Gcs_communication_event_listener & > * get_event_listeners ()
 
Gcs_message_pipelineget_msg_pipeline () override
 
void buffer_incoming_packet (Gcs_packet &&packet, std::unique_ptr< Gcs_xcom_nodes > &&xcom_nodes) override
 Buffer packets when a view is not installed yet and the state exchange phase is being executed. More...
 
void deliver_buffered_packets () override
 The state exchange phase has been executed and the view has been installed so this is used to send any buffered packet to upper layers. More...
 
void cleanup_buffered_packets () override
 
size_t number_buffered_packets () override
 Return the number of buffered packets. More...
 
void update_members_information (const Gcs_member_identifier &me, const Gcs_xcom_nodes &members) override
 Notify the pipeline about the new XCom membership when a state exchange begins. More...
 
bool recover_packets (Gcs_xcom_synode_set const &synodes) override
 Attempts to recover the missing packets that are required for a node to join the group successfully. More...
 
Gcs_messageconvert_packet_to_message (Gcs_packet &&packet, std::unique_ptr< Gcs_xcom_nodes > &&xcom_nodes) override
 Converts the packet into a message that can be delivered to the upper layer. More...
 
void process_user_data_packet (Gcs_packet &&packet, std::unique_ptr< Gcs_xcom_nodes > &&xcom_nodes) override
 The purpose of this method is to be called when in Gcs_xcom_interface callback method xcom_receive_data is invoked. More...
 
Gcs_protocol_version get_protocol_version () const override
 Retrieves the current GCS protocol version in use. More...
 
std::pair< bool, std::future< void > > set_protocol_version (Gcs_protocol_version new_version) override
 Modifies the GCS protocol version in use. More...
 
Gcs_protocol_version get_maximum_supported_protocol_version () const override
 Get the maximum protocol version currently supported by the group. More...
 
void set_maximum_supported_protocol_version (Gcs_protocol_version version)
 
void set_communication_protocol (enum_transport_protocol protocol) override
 Sets the communication protocol to use. More...
 
enum_transport_protocol get_incoming_connections_protocol () override
 Get the incoming connections protocol which is currently active. More...
 
- Public Member Functions inherited from Gcs_xcom_communication_interface
 ~Gcs_xcom_communication_interface () override=default
 
- Public Member Functions inherited from Gcs_communication_interface
virtual ~Gcs_communication_interface ()=default
 

Private Types

enum class  packet_recovery_result {
  OK , PACKETS_UNRECOVERABLE , NO_MEMORY , PIPELINE_ERROR ,
  PIPELINE_UNEXPECTED_OUTPUT , PACKET_UNEXPECTED_CARGO , ERROR
}
 Error code for the packet recovery proceess. More...
 

Private Member Functions

void notify_received_message (std::unique_ptr< Gcs_message > &&message)
 Notify upper layers that a message has been received. More...
 
void deliver_user_data_packet (Gcs_packet &&packet, std::unique_ptr< Gcs_xcom_nodes > &&xcom_nodes)
 Delivers the packet to the upper layer. More...
 
std::vector< Gcs_xcom_node_informationpossible_packet_recovery_donors () const
 
packet_recovery_result recover_packets_from_donor (Gcs_xcom_node_information const &donor, Gcs_xcom_synode_set const &synodes, synode_app_data_array &recovered_data)
 Attempts to recover the packets delivered in synodes from donor. More...
 
packet_recovery_result process_recovered_packets (synode_app_data_array const &recovered_data)
 Processes all the recovered packets. More...
 
packet_recovery_result process_recovered_packet (synode_app_data const &recovered_data)
 Processes a single recovered packet. More...
 
void log_packet_recovery_failure (packet_recovery_result const &error_code, Gcs_xcom_node_information const &donor) const
 Logs the packet recovery failure. More...
 
 Gcs_xcom_communication (const Gcs_xcom_communication &)
 
Gcs_xcom_communicationoperator= (const Gcs_xcom_communication &)
 

Private Attributes

std::map< int, const Gcs_communication_event_listener & > event_listeners
 
Gcs_xcom_statistics_updaterstats
 
Gcs_xcom_proxym_xcom_proxy
 
Gcs_xcom_view_change_control_interfacem_view_control
 
Gcs_message_pipeline m_msg_pipeline
 The pipeline of stages a message has to go through before it is delivered to the application or sent to the network. More...
 
std::vector< std::pair< Gcs_packet, std::unique_ptr< Gcs_xcom_nodes > > > m_buffered_packets
 Buffer that is used to store packets while the node is about to install a view and is running the state exchange phase. More...
 
Gcs_xcom_nodes m_xcom_nodes
 Most recent XCom membership known. More...
 
unsigned int m_gid_hash
 Hash of the group. More...
 
Gcs_xcom_communication_protocol_changer m_protocol_changer
 Protocol changer. More...
 
std::unique_ptr< Network_provider_management_interfacem_comms_mgmt_interface
 

Member Enumeration Documentation

◆ packet_recovery_result

Error code for the packet recovery proceess.

Enumerator
OK 
PACKETS_UNRECOVERABLE 
NO_MEMORY 
PIPELINE_ERROR 
PIPELINE_UNEXPECTED_OUTPUT 
PACKET_UNEXPECTED_CARGO 
ERROR 

Constructor & Destructor Documentation

◆ Gcs_xcom_communication() [1/2]

Gcs_xcom_communication::Gcs_xcom_communication ( Gcs_xcom_statistics_updater stats,
Gcs_xcom_proxy proxy,
Gcs_xcom_view_change_control_interface view_control,
Gcs_xcom_engine gcs_engine,
Gcs_group_identifier const &  group_id,
std::unique_ptr< Network_provider_management_interface comms_mgmt 
)
explicit

Gcs_xcom_communication_interface constructor.

Parameters
[in]statsa reference to the statistics interface
[in]proxya reference to an implementation of Gcs_xcom_communication_proxy
[in]view_controla reference to a gcs_xcom_view_change_control_interface implementation
[in]gcs_enginePointer to gcs engine
[in]group_idreference to the group identifier
[in]comms_mgmtan unique_ptr to a Network_provider_management_interface

◆ ~Gcs_xcom_communication()

Gcs_xcom_communication::~Gcs_xcom_communication ( )
overridedefault

◆ Gcs_xcom_communication() [2/2]

Gcs_xcom_communication::Gcs_xcom_communication ( const Gcs_xcom_communication )
private

Member Function Documentation

◆ add_event_listener()

int Gcs_xcom_communication::add_event_listener ( const Gcs_communication_event_listener event_listener)
overridevirtual

Registers an implementation of a Gcs_communication_event_listener that will receive Communication Events.

Note that a binding implementation shall not offer the possibility of changing listeners while the system is up and running. In that sense, listeners must be added to it only when booting up the system.

Parameters
[in]event_listenera class that implements Gcs_communication_event_listener
Returns
an handle representing the registration of this object to be used in remove_event_listener

Implements Gcs_communication_interface.

◆ buffer_incoming_packet()

void Gcs_xcom_communication::buffer_incoming_packet ( Gcs_packet &&  packet,
std::unique_ptr< Gcs_xcom_nodes > &&  xcom_nodes 
)
overridevirtual

Buffer packets when a view is not installed yet and the state exchange phase is being executed.

Note that this method must be executed by the same thread that processes global view messages and data message in order to avoid any concurrency issue.

Parameters
packetPacket to buffer.
xcom_nodesMembership at the time the packet was received

Implements Gcs_xcom_communication_interface.

◆ cleanup_buffered_packets()

void Gcs_xcom_communication::cleanup_buffered_packets ( )
overridevirtual

◆ convert_packet_to_message()

Gcs_message * Gcs_xcom_communication::convert_packet_to_message ( Gcs_packet &&  packet,
std::unique_ptr< Gcs_xcom_nodes > &&  xcom_nodes 
)
overridevirtual

Converts the packet into a message that can be delivered to the upper layer.

Parameters
packetThe packet to convert
xcom_nodesThe membership at the time the packet was delivered
Return values
Gcs_message*if successful
nullptrif unsuccessful

Implements Gcs_xcom_communication_interface.

◆ deliver_buffered_packets()

void Gcs_xcom_communication::deliver_buffered_packets ( )
overridevirtual

The state exchange phase has been executed and the view has been installed so this is used to send any buffered packet to upper layers.

Note that this method must be executed by the same thread that processes global view messages and data message in order to avoid any concurrency issue.

Implements Gcs_xcom_communication_interface.

◆ deliver_user_data_packet()

void Gcs_xcom_communication::deliver_user_data_packet ( Gcs_packet &&  packet,
std::unique_ptr< Gcs_xcom_nodes > &&  xcom_nodes 
)
private

Delivers the packet to the upper layer.

◆ do_send_message()

enum_gcs_error Gcs_xcom_communication::do_send_message ( const Gcs_message message_to_send,
unsigned long long *  message_length,
Cargo_type  cargo 
)
overridevirtual

Sends a message that is internal to the binding implementation.

This message will not be subject to the same restrictions of send_message. As such, it will not observe view safety nor will count for the statistics of messages sent.

Parameters
[in]message_to_sendthe message to send
[out]message_lengththe length of message which was send if GCS_OK, unspecified otherwise
[in]cargointernal message header cargo type
Returns
the xcom broadcast message error
Return values
GCS_OKmessage is transmitted successfully
GCS_NOKerror occurred while transmitting message
GCS_MESSAGE_TOO_BIGmessage is bigger then xcom can handle

Implements Gcs_xcom_communication_interface.

◆ get_event_listeners()

std::map< int, const Gcs_communication_event_listener & > * Gcs_xcom_communication::get_event_listeners ( )

◆ get_incoming_connections_protocol()

enum_transport_protocol Gcs_xcom_communication::get_incoming_connections_protocol ( )
overridevirtual

Get the incoming connections protocol which is currently active.

Returns
GcsRunningProtocol

Implements Gcs_communication_interface.

◆ get_maximum_supported_protocol_version()

Gcs_protocol_version Gcs_xcom_communication::get_maximum_supported_protocol_version ( ) const
overridevirtual

Get the maximum protocol version currently supported by the group.

Returns
the maximum protocol version currently supported by the group

Implements Gcs_communication_interface.

◆ get_msg_pipeline()

Gcs_message_pipeline & Gcs_xcom_communication::get_msg_pipeline ( )
inlineoverridevirtual

◆ get_protocol_version()

Gcs_protocol_version Gcs_xcom_communication::get_protocol_version ( ) const
overridevirtual

Retrieves the current GCS protocol version in use.

Implements Gcs_communication_interface.

◆ log_packet_recovery_failure()

void Gcs_xcom_communication::log_packet_recovery_failure ( packet_recovery_result const &  error_code,
Gcs_xcom_node_information const &  donor 
) const
private

Logs the packet recovery failure.

◆ notify_received_message()

void Gcs_xcom_communication::notify_received_message ( std::unique_ptr< Gcs_message > &&  message)
private

Notify upper layers that a message has been received.

◆ number_buffered_packets()

size_t Gcs_xcom_communication::number_buffered_packets ( )
overridevirtual

Return the number of buffered packets.

Note that this method must be executed by the same thread that processes global view messages and data message in order to avoid any concurrency issue.

Implements Gcs_xcom_communication_interface.

◆ operator=()

Gcs_xcom_communication & Gcs_xcom_communication::operator= ( const Gcs_xcom_communication )
private

◆ possible_packet_recovery_donors()

std::vector< Gcs_xcom_node_information > Gcs_xcom_communication::possible_packet_recovery_donors ( ) const
private
Returns
the list of possible donors from which to recover the missing packets this server requires to successfully join the group.

◆ process_recovered_packet()

Gcs_xcom_communication::packet_recovery_result Gcs_xcom_communication::process_recovered_packet ( synode_app_data const &  recovered_data)
private

Processes a single recovered packet.

◆ process_recovered_packets()

Gcs_xcom_communication::packet_recovery_result Gcs_xcom_communication::process_recovered_packets ( synode_app_data_array const &  recovered_data)
private

Processes all the recovered packets.

◆ process_user_data_packet()

void Gcs_xcom_communication::process_user_data_packet ( Gcs_packet &&  packet,
std::unique_ptr< Gcs_xcom_nodes > &&  xcom_nodes 
)
overridevirtual

The purpose of this method is to be called when in Gcs_xcom_interface callback method xcom_receive_data is invoked.

This allows, in terms of software architecture, to concentrate all the message delivery logic and processing in a single place.

The deliver_message callback that is registered in XCom (in gcs_xcom_interface.h) and that actually receives the low-level messages, is implemented as a delegator to this method.

Note that the method will be responsible for deleting the message passed as parameter and must be executed by the same thread that processes global view messages and data message in order to avoid any concurrency issue.

Implements Gcs_xcom_communication_interface.

◆ recover_packets()

bool Gcs_xcom_communication::recover_packets ( Gcs_xcom_synode_set const &  synodes)
overridevirtual

Attempts to recover the missing packets that are required for a node to join the group successfully.

For example, the missing packets may be some fragments of a message that have already been delivered by XCom to the existing members of the group. The joining node needs those fragments in order to be able to deliver the reassembled message when the final fragments are delivered by XCom.

Note that this method must be executed by the same thread that processes global view messages and data message in order to avoid any concurrency issue.

Parameters
synodesThe synodes where the required packets were decided
Returns
true If successful, false otherwise

Implements Gcs_xcom_communication_interface.

◆ recover_packets_from_donor()

Gcs_xcom_communication::packet_recovery_result Gcs_xcom_communication::recover_packets_from_donor ( Gcs_xcom_node_information const &  donor,
Gcs_xcom_synode_set const &  synodes,
synode_app_data_array &  recovered_data 
)
private

Attempts to recover the packets delivered in synodes from donor.

recovered_data is an out parameter.

◆ remove_event_listener()

void Gcs_xcom_communication::remove_event_listener ( int  event_listener_handle)
overridevirtual

Removes a previously registered event listener.

Note that a binding implementation shall not offer the possibility of changing listeners while the system is up and running. In that sense listeners must be removed from it only when shutting down the system.

Parameters
[in]event_listener_handlethe handle returned when the listener was registered

Implements Gcs_communication_interface.

◆ send_message()

enum_gcs_error Gcs_xcom_communication::send_message ( const Gcs_message message_to_send)
overridevirtual

Implementation of the public send_message method defined in Gcs_xcom_communication.

Besides sending a message to the group, this method does two extra things:

  • Guarantees view safety, in which no messages can be sent when a view change is occurring.
  • Registers in the statistics interface that a message was sent.
Parameters
[in]message_to_sendthe message to send
Returns
the xcom broadcast message error
Return values
GCS_OKwhen message is transmitted successfully
GCS_NOKwhen error occurred while transmitting message
GCS_MESSAGE_TOO_BIGwhen message is bigger then xcom can handle

Implements Gcs_communication_interface.

◆ set_communication_protocol()

void Gcs_xcom_communication::set_communication_protocol ( enum_transport_protocol  protocol)
overridevirtual

Sets the communication protocol to use.

Parameters
protocolthe protocol to use

Implements Gcs_communication_interface.

◆ set_maximum_supported_protocol_version()

void Gcs_xcom_communication::set_maximum_supported_protocol_version ( Gcs_protocol_version  version)

◆ set_protocol_version()

std::pair< bool, std::future< void > > Gcs_xcom_communication::set_protocol_version ( Gcs_protocol_version  new_version)
overridevirtual

Modifies the GCS protocol version in use.

The method is non-blocking. It returns a future on which the caller can wait for the action to finish.

This method has the following requirements:

  • It must be called by all group members at the same logical instant, i.e. it is part of the replicated state machine.
  • It must not be called concurrently, i.e. a new protocol change may only begin after the previous one has finished.

A GCS client must ensure the requirements are met. In the case of Group Replication, these requirements are ensured by initiating a GCS protocol change as part of a GR group action.

Parameters
new_versionThe desired GCS protocol version
Return values
{true,future}If successful
{false,_}If unsuccessful because new_version is unsupported

Implements Gcs_communication_interface.

◆ update_members_information()

void Gcs_xcom_communication::update_members_information ( const Gcs_member_identifier me,
const Gcs_xcom_nodes members 
)
overridevirtual

Notify the pipeline about the new XCom membership when a state exchange begins.

Note that this method must be executed by the same thread that processes global view messages and data message in order to avoid any concurrency issue.

Parameters
meThe identifier of this server
membersThe XCom membership

Implements Gcs_xcom_communication_interface.

Member Data Documentation

◆ event_listeners

std::map<int, const Gcs_communication_event_listener &> Gcs_xcom_communication::event_listeners
private

◆ m_buffered_packets

std::vector<std::pair<Gcs_packet, std::unique_ptr<Gcs_xcom_nodes> > > Gcs_xcom_communication::m_buffered_packets
private

Buffer that is used to store packets while the node is about to install a view and is running the state exchange phase.

◆ m_comms_mgmt_interface

std::unique_ptr<Network_provider_management_interface> Gcs_xcom_communication::m_comms_mgmt_interface
private

◆ m_gid_hash

unsigned int Gcs_xcom_communication::m_gid_hash
private

Hash of the group.

◆ m_msg_pipeline

Gcs_message_pipeline Gcs_xcom_communication::m_msg_pipeline
private

The pipeline of stages a message has to go through before it is delivered to the application or sent to the network.

◆ m_protocol_changer

Gcs_xcom_communication_protocol_changer Gcs_xcom_communication::m_protocol_changer
private

Protocol changer.

◆ m_view_control

Gcs_xcom_view_change_control_interface* Gcs_xcom_communication::m_view_control
private

◆ m_xcom_nodes

Gcs_xcom_nodes Gcs_xcom_communication::m_xcom_nodes
private

Most recent XCom membership known.

◆ m_xcom_proxy

Gcs_xcom_proxy* Gcs_xcom_communication::m_xcom_proxy
private

◆ stats

Gcs_xcom_statistics_updater* Gcs_xcom_communication::stats
private

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