MySQL 8.0.39
Source Code Documentation
|
#include <gcs_xcom_control_interface.h>
Public Member Functions | |
Gcs_xcom_control (Gcs_xcom_node_address *xcom_node_address, std::vector< Gcs_xcom_node_address * > &xcom_peers, Gcs_group_identifier group_identifier, Gcs_xcom_proxy *xcom_proxy, Gcs_xcom_group_management *xcom_group_management, Gcs_xcom_engine *gcs_engine, Gcs_xcom_state_exchange_interface *state_exchange, Gcs_xcom_view_change_control_interface *view_control, bool boot, My_xp_socket_util *socket_util, std::unique_ptr< Network_provider_operations_interface > comms_operation_interface) | |
Gcs_xcom_control_interface constructor. More... | |
~Gcs_xcom_control () override | |
enum_gcs_error | join () override |
Method that causes one to join the group that this interface pertains. More... | |
enum_gcs_error | do_join (const bool retry=true) |
enum_gcs_error | retry_do_join () |
enum_gcs_error | leave () override |
Method that causes one to leave the group that this interface pertains. More... | |
enum_gcs_error | do_leave () |
void | do_leave_view () |
Sends a leave view message to informat that XCOM has already exited or is about to do so. More... | |
void | do_remove_node_from_group () |
Request other members to remove node from the group. More... | |
bool | belongs_to_group () override |
Reports if one has joined and belongs to a group. More... | |
Gcs_view * | get_current_view () override |
Returns the currently installed view. More... | |
const Gcs_member_identifier | get_local_member_identifier () const override |
Retrieves the local identifier of this member on a group. More... | |
int | add_event_listener (const Gcs_control_event_listener &event_listener) override |
Registers an implementation of a Gcs_control_event_listener that will receive Control Events. More... | |
void | remove_event_listener (int event_listener_handle) override |
Removes a previously registered event listener. More... | |
bool | xcom_receive_global_view (synode_no const config_id, synode_no message_id, Gcs_xcom_nodes *xcom_nodes, bool do_not_deliver_to_client, synode_no max_synode) |
The purpose of this method is to be called when in Gcs_xcom_interface callback method of View Changing is invoked. More... | |
bool | xcom_receive_local_view (synode_no const config_id, Gcs_xcom_nodes *xcom_nodes, synode_no max_synode) |
bool | xcom_receive_leave () |
void | process_control_message (Gcs_message *msg, Gcs_protocol_version maximum_supported_protocol_version, Gcs_protocol_version used_protocol_version) |
Process a message from the control interface and if necessary delegate it to the state exchange. More... | |
std::map< int, const Gcs_control_event_listener & > * | get_event_listeners () |
Gcs_xcom_node_address * | get_node_address () |
Return the address associated with the current node. More... | |
Gcs_xcom_node_information const & | get_node_information () const |
Gcs_xcom_proxy * | get_xcom_proxy () |
Return a pointer to the proxy object used to access XCOM. More... | |
Gcs_suspicions_manager * | get_suspicions_manager () |
void | set_boot_node (bool boot) |
void | set_node_address (Gcs_xcom_node_address *node_address) |
Set the address associated with the current node. More... | |
void | set_peer_nodes (std::vector< Gcs_xcom_node_address * > &xcom_peers) |
Inserts in m_initial_peers copies of the Gcs_xcom_node_address objects whose addresses are in the xcom_peers vector. More... | |
void | clear_peer_nodes () |
Deletes all the Gcs_xcom_node_address objects pointed by the elements of the m_initial_peers vector, clearing it at the end. More... | |
My_xp_socket_util * | get_socket_util () |
Return a pointer to a socket utility. More... | |
void | wait_for_xcom_thread () |
This member function can be used to wait until xcom thread exits. More... | |
bool | is_xcom_running () |
Whether XCOM's Thread is running or not. More... | |
void | set_join_behavior (unsigned int join_attempts, unsigned int join_sleep_time) |
enum_gcs_error | set_xcom_cache_size (uint64_t size) override |
Sets a new value for the maximum size of the XCom cache. More... | |
void | install_leave_view (Gcs_view::Gcs_view_error_code error_code) |
Notify that the current member has left the group and whether it left gracefully or not. More... | |
Public Member Functions inherited from Gcs_control_interface | |
virtual | ~Gcs_control_interface ()=default |
Static Public Attributes | |
static constexpr int | CONNECTION_ATTEMPTS = 10 |
Protected Attributes | |
bool | m_xcom_running |
bool | m_leave_view_requested |
bool | m_leave_view_delivered |
bool | m_boot |
std::vector< Gcs_xcom_node_address * > | m_initial_peers |
Gcs_xcom_view_change_control_interface * | m_view_control |
Gcs_xcom_engine * | m_gcs_engine |
Private Member Functions | |
void | init_me () |
void | build_total_members (Gcs_xcom_nodes *xcom_nodes, std::vector< Gcs_member_identifier * > &alive_members, std::vector< Gcs_member_identifier * > &failed_members) |
void | build_left_members (std::vector< Gcs_member_identifier * > &left_members, std::vector< Gcs_member_identifier * > &alive_members, std::vector< Gcs_member_identifier * > &failed_members, const std::vector< Gcs_member_identifier > *current_members) |
void | build_joined_members (std::vector< Gcs_member_identifier * > &joined_members, std::vector< Gcs_member_identifier * > &alive_members, const std::vector< Gcs_member_identifier > *current_members) |
void | build_member_suspect_nodes (std::vector< Gcs_member_identifier * > &member_suspect_nodes, std::vector< Gcs_member_identifier * > &failed_members, const std::vector< Gcs_member_identifier > *current_members) |
void | build_non_member_suspect_nodes (std::vector< Gcs_member_identifier * > &non_member_suspect_nodes, std::vector< Gcs_member_identifier * > &failed_members, const std::vector< Gcs_member_identifier > *current_members) |
bool | is_killer_node (const std::vector< Gcs_member_identifier * > &alive_members) const |
Decides if this node shall be the one to kill failed nodes. More... | |
void | build_member_list (std::set< Gcs_member_identifier * > *origin, std::vector< Gcs_member_identifier > *to_fill) |
Copies from a set to a vector of Gcs_member_identifier. More... | |
void | install_view (Gcs_xcom_view_identifier *new_view_id, const Gcs_group_identifier &group_id, std::map< Gcs_member_identifier, Xcom_member_state * > *states, std::set< Gcs_member_identifier * > *total, std::set< Gcs_member_identifier * > *left, std::set< Gcs_member_identifier * > *join, Gcs_view::Gcs_view_error_code error_code=Gcs_view::OK) |
Makes all the necessary arrangements to install a new view in the binding and in all registered client applications. More... | |
bool | is_this_node_in (std::vector< Gcs_member_identifier * > *members) |
Check whether the current member is in the received vector of members. More... | |
connection_descriptor * | get_connection_to_node (std::vector< Gcs_xcom_node_address * > *peers_list) |
Cycle through peers_list and try to open a connection to the peer, if it isn't the node itself. More... | |
bool | send_add_node_request (std::map< std::string, int > const &my_addresses) |
Attempts to send an add_node request to some initial peer from m_initial_peers . More... | |
bool | try_send_add_node_request_to_seeds (std::map< std::string, int > const &my_addresses) |
Attempts to send an add_node request to some initial peer from m_initial_peers . More... | |
std::pair< bool, connection_descriptor * > | connect_to_peer (Gcs_xcom_node_address &peer, std::map< std::string, int > const &my_addresses) |
Connects to the given peer's XCom. More... | |
void | expel_incompatible_members (std::vector< Gcs_xcom_node_information > const &incompatible_members) |
Expel the given members from XCom. More... | |
Gcs_xcom_control (const Gcs_xcom_control &) | |
Gcs_xcom_control & | operator= (const Gcs_xcom_control &) |
Private Attributes | |
Gcs_group_identifier * | m_gid |
unsigned int | m_gid_hash |
Gcs_xcom_proxy * | m_xcom_proxy |
Gcs_xcom_group_management * | m_xcom_group_management |
std::map< int, const Gcs_control_event_listener & > | event_listeners |
Gcs_xcom_node_information * | m_local_node_info |
Gcs_xcom_node_address * | m_local_node_address |
Gcs_xcom_state_exchange_interface * | m_state_exchange |
My_xp_thread_impl | m_xcom_thread |
My_xp_socket_util * | m_socket_util |
unsigned int | m_join_attempts |
unsigned int | m_join_sleep_time |
Gcs_suspicions_manager * | m_suspicions_manager |
My_xp_thread_impl | m_suspicions_processing_thread |
Gcs_sock_probe_interface * | m_sock_probe_interface |
std::unique_ptr< Network_provider_operations_interface > | m_comms_operation_interface |
|
explicit |
Gcs_xcom_control_interface constructor.
[in] | xcom_node_address | Information about the node's address |
[in] | xcom_peers | Information about the nodes that it should get in touch to enter a group |
[in] | group_identifier | Group identifier object |
[in] | xcom_proxy | Proxy implementation reference |
[in] | xcom_group_management | Group management reference |
[in] | gcs_engine | MySQL GCS engine |
[in] | state_exchange | Reference to the State Exchange algorithm implementation |
[in] | view_control | View change control interface reference |
[in] | boot | Whether the node will be used to bootstrap the group |
[in] | socket_util | Reference to a socket utility |
[in] | comms_operation_interface | an unique_ptr to a Network_provider_operations_interface |
|
override |
|
private |
|
overridevirtual |
Registers an implementation of a Gcs_control_event_listener that will receive Control Events.
See the class header for more details on implementations and usage.
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.
[in] | event_listener | a class that implements Gcs_control_event_listener |
Implements Gcs_control_interface.
|
overridevirtual |
Reports if one has joined and belongs to a group.
true | if belonging to a group |
Implements Gcs_control_interface.
|
private |
|
private |
|
private |
Copies from a set to a vector of Gcs_member_identifier.
[in] | origin | original set |
[in] | to_fill | destination vector |
|
private |
|
private |
|
private |
void Gcs_xcom_control::clear_peer_nodes | ( | ) |
Deletes all the Gcs_xcom_node_address objects pointed by the elements of the m_initial_peers vector, clearing it at the end.
|
private |
Connects to the given peer's XCom.
peer | Peer to connect to. |
my_addresses | The addresses of this node, used to filter our own address from the initial peers. |
{true,connection_descriptor*} | If we connected successfully. |
{false,_} | If we could not connect. |
enum_gcs_error Gcs_xcom_control::do_join | ( | const bool | retry = true | ) |
enum_gcs_error Gcs_xcom_control::do_leave | ( | ) |
void Gcs_xcom_control::do_leave_view | ( | ) |
Sends a leave view message to informat that XCOM has already exited or is about to do so.
void Gcs_xcom_control::do_remove_node_from_group | ( | ) |
Request other members to remove node from the group.
|
private |
Expel the given members from XCom.
incompatible_members | the members to expel |
|
private |
Cycle through peers_list and try to open a connection to the peer, if it isn't the node itself.
[in] | peers_list | list of the peers |
|
overridevirtual |
Returns the currently installed view.
pointer | to a Gcs_view object. If one has left a group, this shall be the last installed view. That view can be considered a best-effort view since, in some GCSs, the one that leaves might not have access to the exchanged information. |
NULL | if one never joined a group. |
Implements Gcs_control_interface.
map< int, const Gcs_control_event_listener & > * Gcs_xcom_control::get_event_listeners | ( | ) |
|
overridevirtual |
Retrieves the local identifier of this member on a group.
reference | to a valid Gcs_member_identifier instance |
NULL | in case of error |
Implements Gcs_control_interface.
Gcs_xcom_node_address * Gcs_xcom_control::get_node_address | ( | ) |
Return the address associated with the current node.
Gcs_xcom_node_information const & Gcs_xcom_control::get_node_information | ( | ) | const |
My_xp_socket_util * Gcs_xcom_control::get_socket_util | ( | ) |
Return a pointer to a socket utility.
Gcs_suspicions_manager * Gcs_xcom_control::get_suspicions_manager | ( | ) |
Gcs_xcom_proxy * Gcs_xcom_control::get_xcom_proxy | ( | ) |
Return a pointer to the proxy object used to access XCOM.
|
private |
void Gcs_xcom_control::install_leave_view | ( | Gcs_view::Gcs_view_error_code | error_code | ) |
Notify that the current member has left the group and whether it left gracefully or not.
[in] | error_code | that identifies whether there was any error when the view was received. |
|
private |
Makes all the necessary arrangements to install a new view in the binding and in all registered client applications.
[in] | new_view_id | new view identifier |
[in] | group_id | group id |
[in] | states | collection of states to set in the new view |
[in] | total | all the members |
[in] | left | members that left the last view |
[in] | join | members that joined from the last view |
[in] | error_code | Error code to set in the new view |
|
private |
Decides if this node shall be the one to kill failed nodes.
The algorithm is: i am the highest node id alive.
alive_members | Set of alive members. |
|
private |
Check whether the current member is in the received vector of members.
[in] | members | list of members |
bool Gcs_xcom_control::is_xcom_running | ( | ) |
Whether XCOM's Thread is running or not.
|
overridevirtual |
Method that causes one to join the group that this interface pertains.
The method is non-blocking, meaning that it shall only send the request to an underlying GCS. The final result shall come via a View Change event delivered through Gcs_control_event_listener.
GCS_OK | in case of everything goes well. Any other value of gcs_error in case of error. |
Implements Gcs_control_interface.
|
overridevirtual |
Method that causes one to leave the group that this interface pertains.
The method is non-blocking, meaning that it shall only send the request to an underlying GCS. The final result shall come via a View Change event delivered through Gcs_control_event_listener.
GCS_OK | in case of everything goes well. Any other value of gcs_error in case of error |
Implements Gcs_control_interface.
|
private |
void Gcs_xcom_control::process_control_message | ( | Gcs_message * | msg, |
Gcs_protocol_version | maximum_supported_protocol_version, | ||
Gcs_protocol_version | used_protocol_version | ||
) |
Process a message from the control interface and if necessary delegate it to the state exchange.
[in] | msg | message |
[in] | maximum_supported_protocol_version | maximum supported protocol version |
[in] | used_protocol_version | protocol version in use by control message, i.e. state exchange message |
|
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.
[in] | event_listener_handle | the handle returned when the listener was registered |
Implements Gcs_control_interface.
enum_gcs_error Gcs_xcom_control::retry_do_join | ( | ) |
|
private |
Attempts to send an add_node request to some initial peer from m_initial_peers
.
Performs up to s_connection_attempts
attempts.
my_addresses | The addresses of this node, used to filter our own address from the initial peers. |
void Gcs_xcom_control::set_boot_node | ( | bool | boot | ) |
void Gcs_xcom_control::set_join_behavior | ( | unsigned int | join_attempts, |
unsigned int | join_sleep_time | ||
) |
void Gcs_xcom_control::set_node_address | ( | Gcs_xcom_node_address * | node_address | ) |
Set the address associated with the current node.
void Gcs_xcom_control::set_peer_nodes | ( | std::vector< Gcs_xcom_node_address * > & | xcom_peers | ) |
Inserts in m_initial_peers copies of the Gcs_xcom_node_address objects whose addresses are in the xcom_peers vector.
[in] | xcom_peers | vector with peers' information |
|
overridevirtual |
Sets a new value for the maximum size of the XCom cache.
[in] | size | the new maximum size of the XCom cache |
- | GCS_OK if request was successfully scheduled in XCom, GCS_NOK otherwise. |
Implements Gcs_control_interface.
|
private |
Attempts to send an add_node request to some initial peer from m_initial_peers
.
my_addresses | The addresses of this node, used to filter our own address from the initial peers. |
void Gcs_xcom_control::wait_for_xcom_thread | ( | ) |
This member function can be used to wait until xcom thread exits.
bool Gcs_xcom_control::xcom_receive_global_view | ( | synode_no const | config_id, |
synode_no | message_id, | ||
Gcs_xcom_nodes * | xcom_nodes, | ||
bool | do_not_deliver_to_client, | ||
synode_no | max_synode | ||
) |
The purpose of this method is to be called when in Gcs_xcom_interface callback method of View Changing is invoked.
This allows, in terms of software architecture, to concentrate all the view change logic and processing in a single place. The view_change callback that is registered in Gcs_xcom_interface should be a simple pass-through.
[in] | config_id | The configuration ID that this view pertains to |
[in] | message_id | the message that conveys the View Change |
[in] | xcom_nodes | Set of nodes that participated in the consensus to deliver the message |
[in] | do_not_deliver_to_client | Whether to filter this view from being delivered to the client |
[in] | max_synode | XCom max synode |
bool Gcs_xcom_control::xcom_receive_leave | ( | ) |
bool Gcs_xcom_control::xcom_receive_local_view | ( | synode_no const | config_id, |
Gcs_xcom_nodes * | xcom_nodes, | ||
synode_no | max_synode | ||
) |
|
staticconstexpr |
|
private |
|
protected |
|
private |
|
protected |
|
private |
|
private |
|
protected |
|
private |
|
private |
|
protected |
|
protected |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
protected |
|
private |
|
private |
|
protected |
|
private |