24#ifndef GCS_XCOM_STATE_EXCHANGE_INCLUDED
25#define GCS_XCOM_STATE_EXCHANGE_INCLUDED
44#include "plugin/group_replication/libmysqlgcs/xdr_gen/xcom_vp.h"
120 synode_no configuration_id,
123 const uchar *data, uint64_t data_size);
197 bool decode(
const uchar *data, uint64_t data_size);
419 synode_no configuration_id, std::vector<Gcs_member_identifier *> &
total,
420 std::vector<Gcs_member_identifier *> &left,
421 std::vector<Gcs_member_identifier *> &joined,
422 std::vector<std::unique_ptr<Gcs_message_data>> &exchangeable_data,
423 Gcs_view *current_view, std::string *group,
453 virtual std::vector<Gcs_xcom_node_information>
481 virtual std::set<Gcs_member_identifier *> *
get_left() = 0;
487 virtual std::set<Gcs_member_identifier *> *
get_total() = 0;
499 virtual std::map<Gcs_member_identifier, Xcom_member_state *>
525 void init()
override;
527 void reset()
override;
534 synode_no configuration_id, std::vector<Gcs_member_identifier *> &
total,
535 std::vector<Gcs_member_identifier *> &left,
536 std::vector<Gcs_member_identifier *> &joined,
537 std::vector<std::unique_ptr<Gcs_message_data>> &exchangeable_data,
538 Gcs_view *current_view, std::string *group,
560 std::set<Gcs_member_identifier *> *
get_total()
override {
606 std::vector<std::unique_ptr<Gcs_message_data>> &exchangeable_data);
622 std::set<Gcs_member_identifier *> &pset);
This interface represents all the communication facilities that a binding implementation should provi...
Definition: gcs_communication_interface.h:90
It represents the identity of a group member within a certain group.
Definition: gcs_member_identifier.h:40
This represents the membership view that a member has from a group.
Definition: gcs_view.h:55
This class contains information on the configuration, i.e set of nodes or simply site definition.
Definition: gcs_xcom_group_member_information.h:391
Definition: gcs_xcom_state_exchange.h:370
virtual std::map< Gcs_member_identifier, Xcom_member_state * > * get_member_states()=0
virtual std::string * get_group()=0
virtual std::vector< Gcs_xcom_node_information > compute_incompatible_members()=0
Compute the set of incompatible members after the state exchange has finished.
virtual void init()=0
Accomplishes all necessary initialization steps.
virtual bool process_recovery_state()=0
Recovers any missing packets required for the member to join the group.
virtual std::set< Gcs_member_identifier * > * get_total()=0
virtual void end()=0
If messages were buffered during its processing, they are delivered to upper layers and internal stru...
virtual Gcs_xcom_view_identifier * get_new_view_id()=0
Retrieves the new view identifier after a State Exchange.
virtual std::set< Gcs_member_identifier * > * get_left()=0
virtual std::set< Gcs_member_identifier * > * get_joined()=0
virtual ~Gcs_xcom_state_exchange_interface()=default
virtual void reset()=0
If messages were buffered during its processing, they are discarded and internal structures needed ar...
virtual void reset_with_flush()=0
Has the same behavior as the reset but additionally flushes buffered messages.
virtual void compute_maximum_supported_protocol_version()=0
Computes the maximum protocol version supported by the group.
virtual bool state_exchange(synode_no configuration_id, std::vector< Gcs_member_identifier * > &total, std::vector< Gcs_member_identifier * > &left, std::vector< Gcs_member_identifier * > &joined, std::vector< std::unique_ptr< Gcs_message_data > > &exchangeable_data, Gcs_view *current_view, std::string *group, const Gcs_member_identifier &local_info, const Gcs_xcom_nodes &xcom_nodes)=0
Signals the module to start a State Exchange.
virtual bool process_member_state(Xcom_member_state *ms_info, const Gcs_member_identifier &p_id, Gcs_protocol_version maximum_supported_protocol_version, Gcs_protocol_version used_protocol_version)=0
Processes a member state message on an ongoing State Exchange round.
Implementation of the gcs_xcom_state_exchange_interface.
Definition: gcs_xcom_state_exchange.h:511
void init() override
Accomplishes all necessary initialization steps.
Definition: gcs_xcom_state_exchange.cc:334
std::map< Gcs_member_identifier, uint > m_awaited_vector
Definition: gcs_xcom_state_exchange.h:668
void update_communication_channel(const Gcs_xcom_nodes &xcom_nodes)
Update the communication system with information on membership.
Definition: gcs_xcom_state_exchange.cc:656
std::pair< bool, Gcs_protocol_version > members_announce_same_version() const
Checks whether all the existing group members, myself excluded, announce the same protocol version.
Definition: gcs_xcom_state_exchange.cc:754
std::string * get_group() override
Definition: gcs_xcom_state_exchange.h:569
void compute_maximum_supported_protocol_version() override
Computes the maximum protocol version supported by the group.
Definition: gcs_xcom_state_exchange.cc:941
Gcs_member_identifier m_local_information
Definition: gcs_xcom_state_exchange.h:688
std::string * m_group_name
Definition: gcs_xcom_state_exchange.h:685
std::set< Gcs_member_identifier * > * get_joined() override
Definition: gcs_xcom_state_exchange.h:554
Gcs_xcom_view_identifier * get_new_view_id() override
Retrieves the new view identifier after a State Exchange.
Definition: gcs_xcom_state_exchange.cc:1030
Gcs_communication_interface * m_broadcaster
Definition: gcs_xcom_state_exchange.h:666
std::map< Gcs_member_identifier, Xcom_member_state * > * get_member_states() override
Definition: gcs_xcom_state_exchange.h:564
bool is_joining()
Computes if the local member is joining.
Definition: gcs_xcom_state_exchange.cc:494
std::map< Gcs_member_identifier, Gcs_protocol_version > m_member_versions
Definition: gcs_xcom_state_exchange.h:679
Gcs_xcom_nodes m_ms_xcom_nodes
Definition: gcs_xcom_state_exchange.h:696
enum_gcs_error broadcast_state(const Gcs_xcom_view_identifier &proposed_view, std::vector< std::unique_ptr< Gcs_message_data > > &exchangeable_data)
Broadcasts the local state to all nodes in the Cluster.
Definition: gcs_xcom_state_exchange.cc:517
bool process_member_state(Xcom_member_state *ms_info, const Gcs_member_identifier &p_id, Gcs_protocol_version maximum_supported_protocol_version, Gcs_protocol_version used_protocol_version) override
Processes a member state message on an ongoing State Exchange round.
Definition: gcs_xcom_state_exchange.cc:665
std::vector< Gcs_xcom_node_information > compute_incompatible_members() override
Compute the set of incompatible members after the state exchange has finished.
Definition: gcs_xcom_state_exchange.cc:721
std::set< Gcs_member_identifier * > * get_left() override
Definition: gcs_xcom_state_exchange.h:558
void fill_member_set(std::vector< Gcs_member_identifier * > &in, std::set< Gcs_member_identifier * > &pset)
Converts xcom data to a set of internal representation.
Definition: gcs_xcom_state_exchange.cc:1010
bool incompatible_with_group() const
Checks whether this server is incompatible with the group.
Definition: gcs_xcom_state_exchange.cc:788
void update_awaited_vector()
Updates the structure that waits for State Exchanges.
Definition: gcs_xcom_state_exchange.cc:637
bool state_exchange(synode_no configuration_id, std::vector< Gcs_member_identifier * > &total, std::vector< Gcs_member_identifier * > &left, std::vector< Gcs_member_identifier * > &joined, std::vector< std::unique_ptr< Gcs_message_data > > &exchangeable_data, Gcs_view *current_view, std::string *group, const Gcs_member_identifier &local_info, const Gcs_xcom_nodes &xcom_nodes) override
Signals the module to start a State Exchange.
Definition: gcs_xcom_state_exchange.cc:409
bool is_leaving()
Computes if the local member is leaving.
Definition: gcs_xcom_state_exchange.cc:506
std::map< Gcs_member_identifier, uint > m_recover_vector
Definition: gcs_xcom_state_exchange.h:670
void reset_with_flush() override
Has the same behavior as the reset but additionally flushes buffered messages.
Definition: gcs_xcom_state_exchange.cc:336
std::set< Gcs_member_identifier * > m_ms_total
Definition: gcs_xcom_state_exchange.h:673
std::set< Gcs_member_identifier * > m_ms_left
Definition: gcs_xcom_state_exchange.h:673
bool snapshot_is_enough(Gcs_xcom_synode_set const &snapshot_to_recover) const
Auxiliary method that checks whether snapshot_to_recover contains all the synodes required.
void save_member_state(Xcom_member_state *ms_info, const Gcs_member_identifier &p_id, Gcs_protocol_version maximum_supported_protocol_version, Gcs_protocol_version used_protocol_version)
Stores the member's state and protocol version.
Definition: gcs_xcom_state_exchange.cc:1016
~Gcs_xcom_state_exchange() override
Definition: gcs_xcom_state_exchange.cc:325
std::map< Gcs_member_identifier, Xcom_member_state * > m_member_states
Definition: gcs_xcom_state_exchange.h:676
std::vector< synode_no > cached_ids
Definition: gcs_xcom_state_exchange.h:693
std::map< Gcs_member_identifier, Gcs_protocol_version > m_member_max_versions
Definition: gcs_xcom_state_exchange.h:682
void reset() override
If messages were buffered during its processing, they are discarded and internal structures needed ar...
Definition: gcs_xcom_state_exchange.cc:361
std::vector< Gcs_xcom_node_information > compute_incompatible_joiners()
Computes the set of incompatible nodes that are trying to join the group.
Definition: gcs_xcom_state_exchange.cc:885
std::set< Gcs_member_identifier * > m_ms_joined
Definition: gcs_xcom_state_exchange.h:673
Gcs_xcom_state_exchange(Gcs_xcom_state_exchange const &)
synode_no m_configuration_id
Definition: gcs_xcom_state_exchange.h:691
Gcs_xcom_state_exchange(Gcs_communication_interface *comm)
State Exchange constructor.
Definition: gcs_xcom_state_exchange.cc:309
void end() override
If messages were buffered during its processing, they are delivered to upper layers and internal stru...
Definition: gcs_xcom_state_exchange.cc:400
bool process_recovery_state() override
Recovers any missing packets required for the member to join the group.
Definition: gcs_xcom_state_exchange.cc:963
Gcs_xcom_state_exchange & operator=(Gcs_xcom_state_exchange const &)
std::set< Gcs_member_identifier * > * get_total() override
Definition: gcs_xcom_state_exchange.h:560
Definition: gcs_xcom_state_exchange.h:716
virtual void end_view_exchange()=0
virtual void end_leave()=0
virtual bool is_joining()=0
virtual bool belongs_to_group()=0
virtual void set_current_view(Gcs_view *current_view)=0
virtual bool is_leaving()=0
virtual bool start_leave()=0
virtual void set_unsafe_current_view(Gcs_view *current_view)=0
virtual bool is_finalized()=0
virtual void set_belongs_to_group(bool belong)=0
virtual Gcs_view * get_current_view()=0
virtual bool is_view_changing()=0
virtual ~Gcs_xcom_view_change_control_interface()=default
virtual void wait_for_view_change_end()=0
virtual void end_join()=0
virtual bool start_join()=0
virtual Gcs_view * get_unsafe_current_view()=0
virtual void finalize()=0
virtual void start_view_exchange()=0
Definition: gcs_xcom_state_exchange.h:754
void end_join() override
Definition: gcs_xcom_state_exchange.cc:1214
bool start_join() override
Definition: gcs_xcom_state_exchange.cc:1203
bool is_finalized() override
Definition: gcs_xcom_state_exchange.cc:1232
bool m_view_changing
Definition: gcs_xcom_state_exchange.h:783
My_xp_mutex_impl m_current_view_mutex
Definition: gcs_xcom_state_exchange.h:800
Gcs_view * get_current_view() override
Definition: gcs_xcom_state_exchange.cc:1123
void end_view_exchange() override
Definition: gcs_xcom_state_exchange.cc:1151
My_xp_cond_impl m_wait_for_view_cond
Definition: gcs_xcom_state_exchange.h:787
Gcs_xcom_view_change_control(Gcs_xcom_view_change_control const &)
~Gcs_xcom_view_change_control() override
Definition: gcs_xcom_state_exchange.cc:1102
bool is_view_changing() override
Definition: gcs_xcom_state_exchange.cc:1158
bool is_joining() override
Definition: gcs_xcom_state_exchange.cc:1220
void finalize() override
Definition: gcs_xcom_state_exchange.cc:1230
bool is_leaving() override
Definition: gcs_xcom_state_exchange.cc:1193
void start_view_exchange() override
Definition: gcs_xcom_state_exchange.cc:1145
void wait_for_view_change_end() override
Definition: gcs_xcom_state_exchange.cc:1167
Gcs_xcom_view_change_control & operator=(Gcs_xcom_view_change_control const &)
bool belongs_to_group() override
Definition: gcs_xcom_state_exchange.cc:1137
void set_belongs_to_group(bool belong) override
Definition: gcs_xcom_state_exchange.cc:1141
void set_current_view(Gcs_view *current_view) override
Definition: gcs_xcom_state_exchange.cc:1109
bool start_leave() override
Definition: gcs_xcom_state_exchange.cc:1176
bool m_joining
Definition: gcs_xcom_state_exchange.h:785
My_xp_mutex_impl m_joining_leaving_mutex
Definition: gcs_xcom_state_exchange.h:789
void end_leave() override
Definition: gcs_xcom_state_exchange.cc:1187
Gcs_xcom_view_change_control()
Definition: gcs_xcom_state_exchange.cc:1079
bool m_belongs_to_group
Definition: gcs_xcom_state_exchange.h:805
std::atomic< bool > m_finalized
Definition: gcs_xcom_state_exchange.h:809
Gcs_view * m_current_view
Definition: gcs_xcom_state_exchange.h:794
My_xp_mutex_impl m_wait_for_view_mutex
Definition: gcs_xcom_state_exchange.h:788
Gcs_view * get_unsafe_current_view() override
Definition: gcs_xcom_state_exchange.cc:1133
bool m_leaving
Definition: gcs_xcom_state_exchange.h:784
void set_unsafe_current_view(Gcs_view *current_view) override
Definition: gcs_xcom_state_exchange.cc:1117
Definition: gcs_xcom_view_identifier.h:33
Definition: my_xp_cond.h:136
Definition: my_xp_mutex.h:123
Class that conveys the state to be exchanged between members, which is not provided by XCom.
Definition: gcs_xcom_state_exchange.h:105
Xcom_member_state & operator=(Xcom_member_state const &)=delete
Xcom_member_state(Xcom_member_state const &)=delete
Gcs_xcom_view_identifier * m_view_id
Definition: gcs_xcom_state_exchange.h:263
synode_no m_configuration_id
Definition: gcs_xcom_state_exchange.h:269
const Gcs_xcom_synode_set & get_snapshot() const
Definition: gcs_xcom_state_exchange.h:245
Gcs_protocol_version m_version
GCS communication version number in use.
Definition: gcs_xcom_state_exchange.h:294
static constexpr uint64_t get_encode_snapshot_elem_size()
Definition: gcs_xcom_state_exchange.h:255
Gcs_xcom_view_identifier * get_view_id()
Definition: gcs_xcom_state_exchange.h:225
uint64_t get_encode_payload_size() const
Definition: gcs_xcom_state_exchange.cc:74
static constexpr uint64_t get_encode_header_size()
Definition: gcs_xcom_state_exchange.h:209
bool decode_header(const uchar *buffer, uint64_t buffer_len)
Decodes the Member State's header that was sent through the network.
Definition: gcs_xcom_state_exchange.cc:206
uchar * m_data
Definition: gcs_xcom_state_exchange.h:274
static constexpr auto WIRE_XCOM_SNAPSHOT_NR_ELEMS_SIZE
Definition: gcs_xcom_state_exchange.h:253
static constexpr auto WIRE_XCOM_VARIABLE_VIEW_ID_SIZE
Definition: gcs_xcom_state_exchange.h:248
static constexpr auto WIRE_XCOM_VIEW_ID_SIZE
Definition: gcs_xcom_state_exchange.h:249
static constexpr auto WIRE_XCOM_GROUP_ID_SIZE
Definition: gcs_xcom_state_exchange.h:250
uint64_t get_data_size() const
Definition: gcs_xcom_state_exchange.h:243
uint64_t m_data_size
Definition: gcs_xcom_state_exchange.h:279
bool encode_header(uchar *buffer, uint64_t *buffer_len) const
Encodes the Member State's header to be sent through the newtwork.
Definition: gcs_xcom_state_exchange.cc:92
bool encode_snapshot(uchar *buffer, uint64_t *buffer_len) const
Encodes the Member State's snapshot to be sent through the network.
Definition: gcs_xcom_state_exchange.cc:159
static constexpr auto WIRE_XCOM_NODE_ID_SIZE
Definition: gcs_xcom_state_exchange.h:252
~Xcom_member_state()
Member state destructor.
Definition: gcs_xcom_state_exchange.cc:69
static constexpr auto WIRE_XCOM_MSG_ID_SIZE
Definition: gcs_xcom_state_exchange.h:251
bool decode(const uchar *data, uint64_t data_size)
Decodes Member State that was sent through the network.
Definition: gcs_xcom_state_exchange.cc:281
Xcom_member_state(const Gcs_xcom_view_identifier &view_id, synode_no configuration_id, Gcs_protocol_version version, const Gcs_xcom_synode_set &snapshot, const uchar *data, uint64_t data_size)
Xcom_member_state constructor.
Definition: gcs_xcom_state_exchange.cc:38
bool decode_snapshot(const uchar *buffer, uint64_t buffer_len)
Decodes the Member State's snapshot that was sent through the network.
Definition: gcs_xcom_state_exchange.cc:239
synode_no get_configuration_id() const
Definition: gcs_xcom_state_exchange.h:231
Gcs_xcom_synode_set m_snapshot
Recovery information which is currently a list of the XCom synods of the fragments that are in buffer...
Definition: gcs_xcom_state_exchange.h:289
const uchar * get_data() const
Definition: gcs_xcom_state_exchange.h:237
uint64_t get_encode_snapshot_size() const
Definition: gcs_xcom_state_exchange.cc:78
enum_gcs_error
This enumeration describes errors which can occur during group communication operations.
Definition: gcs_types.h:41
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
unsigned char uchar
Definition: my_inttypes.h:52
Type total(const Shards< COUNT > &shards) noexcept
Get the total value of all shards.
Definition: ut0counter.h:333
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2876
required uint64 version
Definition: replication_group_member_actions.proto:41