MySQL 9.1.0
Source Code Documentation
Consensus_leaders_handler Class Reference

Deals with the orchestration necessary to set the appropriate "consensus leaders" on GCS. More...

#include <consensus_leaders_handler.h>

Inheritance diagram for Consensus_leaders_handler:
[legend]

Public Member Functions

 Consensus_leaders_handler (Group_events_observation_manager &group_events_manager)
 Register as a group event observer in group_events_manager. More...
 
 ~Consensus_leaders_handler () override
 Unregister as a group event observer from m_group_events_manager. More...
 
int after_view_change (const std::vector< Gcs_member_identifier > &joining, const std::vector< Gcs_member_identifier > &leaving, const std::vector< Gcs_member_identifier > &group, bool is_leaving, bool *skip_election, enum_primary_election_mode *election_mode, std::string &suggested_primary) override
 Executed after view install and before primary election. More...
 
int after_primary_election (std::string primary_uuid, enum_primary_election_primary_change_status primary_change_status, enum_primary_election_mode election_mode, int error) override
 Sets the newly elected primary as the single preferred "consensus leader" in GCS. More...
 
int before_message_handling (const Plugin_gcs_message &message, const std::string &message_origin, bool *skip_message) override
 Executed before the message is processed. More...
 
void set_consensus_leaders (Member_version const &communication_protocol, bool is_single_primary_mode, Group_member_info::Group_member_role role, Gcs_member_identifier const &my_gcs_id, std::function< bool()> allow_single_leader_getter)
 Set the appropriate "consensus leaders" in GCS. More...
 
void set_consensus_leaders (Member_version const &communication_protocol, bool is_single_primary_mode, Group_member_info::Group_member_role role, Gcs_member_identifier const &my_gcs_id)
 Set the appropriate "consensus leaders" in GCS. More...
 
- Public Member Functions inherited from Group_event_observer
virtual ~Group_event_observer ()=0
 

Private Member Functions

void set_as_single_consensus_leader (Gcs_member_identifier const &leader) const
 
void set_everyone_as_consensus_leader () const
 

Private Attributes

Group_events_observation_managerm_group_events_manager
 

Static Private Attributes

static Member_version const s_first_protocol_with_support_for_consensus_leaders
 

Detailed Description

Deals with the orchestration necessary to set the appropriate "consensus leaders" on GCS.

Reacts to successful primary elections by setting the newly elected primary as the single preferred "consensus leader" in GCS.

Constructor & Destructor Documentation

◆ Consensus_leaders_handler()

Consensus_leaders_handler::Consensus_leaders_handler ( Group_events_observation_manager group_events_manager)

Register as a group event observer in group_events_manager.

First member version where we have XCom's single leader.

◆ ~Consensus_leaders_handler()

Consensus_leaders_handler::~Consensus_leaders_handler ( )
override

Unregister as a group event observer from m_group_events_manager.

Member Function Documentation

◆ after_primary_election()

int Consensus_leaders_handler::after_primary_election ( std::string  primary_uuid,
enum_primary_election_primary_change_status  primary_change_status,
enum_primary_election_mode  election_mode,
int  error 
)
overridevirtual

Sets the newly elected primary as the single preferred "consensus leader" in GCS.

Parameters
primary_uuidthe elected primary
primary_change_statusif the primary changed after the election
election_modewhat was the election mode
errorif there was and error on the process
Returns
int 0 on success

Implements Group_event_observer.

◆ after_view_change()

int Consensus_leaders_handler::after_view_change ( const std::vector< Gcs_member_identifier > &  joining,
const std::vector< Gcs_member_identifier > &  leaving,
const std::vector< Gcs_member_identifier > &  group,
bool  is_leaving,
bool *  skip_election,
enum_primary_election_mode election_mode,
std::string &  suggested_primary 
)
overridevirtual

Executed after view install and before primary election.

Parameters
joiningmembers joining the group
leavingmembers leaving the group
groupmembers in the group
is_leavingis the member leaving
[out]skip_electionskip primary election on view
[out]election_modeelection mode
[out]suggested_primarywhat should be the next primary to elect

Implements Group_event_observer.

◆ before_message_handling()

int Consensus_leaders_handler::before_message_handling ( const Plugin_gcs_message message,
const std::string &  message_origin,
bool *  skip_message 
)
overridevirtual

Executed before the message is processed.

Parameters
messageThe GCS message
message_originThe member that sent this message (address)
[out]skip_messageskip message handling if true

Implements Group_event_observer.

◆ set_as_single_consensus_leader()

void Consensus_leaders_handler::set_as_single_consensus_leader ( Gcs_member_identifier const &  leader) const
private

◆ set_consensus_leaders() [1/2]

void Consensus_leaders_handler::set_consensus_leaders ( Member_version const &  communication_protocol,
bool  is_single_primary_mode,
Group_member_info::Group_member_role  role,
Gcs_member_identifier const &  my_gcs_id 
)

Set the appropriate "consensus leaders" in GCS.

The "consensus leaders" are set according to the following rules: a) communication_protocol is < 8.0.27: do nothing b) communication_protocol is >= 8.0.27: b1) primary_mode is SINGLE and my_role is PRIMARY: set myself, my_gcs_id, as the single preferred "consensus leader" b2) primary_mode is SINGLE and my_role is SECONDARY: do nothing b3) primary_mode is MULTI: set everyone as "consensus leader"

It inserts a default implementation of allow_single_leader_getter that verifies the current value of group_replication_paxos_single_leader var

◆ set_consensus_leaders() [2/2]

void Consensus_leaders_handler::set_consensus_leaders ( Member_version const &  communication_protocol,
bool  is_single_primary_mode,
Group_member_info::Group_member_role  role,
Gcs_member_identifier const &  my_gcs_id,
std::function< bool()>  allow_single_leader_getter 
)

Set the appropriate "consensus leaders" in GCS.

The "consensus leaders" are set according to the following rules: 0) If the the return result of allow_single_leader_getter lambda is false :do nothing a) communication_protocol is < 8.0.27: do nothing b) communication_protocol is >= 8.0.27: b1) primary_mode is SINGLE and my_role is PRIMARY: set myself, my_gcs_id, as the single preferred "consensus leader" b2) primary_mode is SINGLE and my_role is SECONDARY: do nothing b3) primary_mode is MULTI: set everyone as "consensus leader"

◆ set_everyone_as_consensus_leader()

void Consensus_leaders_handler::set_everyone_as_consensus_leader ( ) const
private

Member Data Documentation

◆ m_group_events_manager

Group_events_observation_manager& Consensus_leaders_handler::m_group_events_manager
private

◆ s_first_protocol_with_support_for_consensus_leaders

Member_version const Consensus_leaders_handler::s_first_protocol_with_support_for_consensus_leaders
staticprivate

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