MySQL 8.4.0
Source Code Documentation
Primary_election_validation_handler Class Reference

#include <primary_election_validation_handler.h>

Inheritance diagram for Primary_election_validation_handler:
[legend]

Public Types

enum  enum_primary_validation_result { VALID_PRIMARY = 0 , INVALID_PRIMARY = 1 , CURRENT_PRIMARY = 2 , GROUP_SOLO_PRIMARY = 3 }
 Enum for the end results of validation. More...
 

Public Member Functions

 Primary_election_validation_handler ()
 Constructor. More...
 
 ~Primary_election_validation_handler () override
 Destructor. More...
 
bool initialize_validation_structures ()
 Initialize the group member structures and registers an observer. More...
 
void terminates_validation_structures ()
 Cleans the membership info, and pending notifications. More...
 
bool prepare_election ()
 Shares information among members about weights and channels in all members. More...
 
enum_primary_validation_result validate_election (std::string &uuid, std::string &valid_uuid, std::string &error_msg)
 Validate group for election. More...
 
enum_primary_validation_result validate_primary_uuid (std::string &uuid)
 Check that the UUID is valid and present in the group. More...
 
enum_primary_validation_result validate_primary_version (std::string &uuid, std::string &error_msg)
 Check that the group members have valid versions. More...
 
void abort_validation_process ()
 Interrupt the validation process in case of an abort. More...
 
- Public Member Functions inherited from Group_event_observer
virtual ~Group_event_observer ()=0
 

Private Member Functions

enum_primary_validation_result validate_group_slave_channels (std::string &uuid)
 Check which members have slave channels. 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
 Executed after primary election. 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...
 

Private Attributes

bool validation_process_aborted
 Was the validation process aborted. More...
 
uint number_of_responses
 The number of members that sent info or left. More...
 
std::map< const std::string, Election_member_info * > group_members_info
 The information about the group members <address,member> More...
 
mysql_mutex_t notification_lock
 The lock for notifications. More...
 
mysql_cond_t notification_cond
 The condition for notifications. More...
 

Member Enumeration Documentation

◆ enum_primary_validation_result

Enum for the end results of validation.

Enumerator
VALID_PRIMARY 
INVALID_PRIMARY 
CURRENT_PRIMARY 
GROUP_SOLO_PRIMARY 

Constructor & Destructor Documentation

◆ Primary_election_validation_handler()

Primary_election_validation_handler::Primary_election_validation_handler ( )

Constructor.

◆ ~Primary_election_validation_handler()

Primary_election_validation_handler::~Primary_election_validation_handler ( )
override

Destructor.

Member Function Documentation

◆ abort_validation_process()

void Primary_election_validation_handler::abort_validation_process ( )

Interrupt the validation process in case of an abort.

◆ after_primary_election()

int Primary_election_validation_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 
)
overrideprivatevirtual

Executed after primary election.

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

Implements Group_event_observer.

◆ after_view_change()

int Primary_election_validation_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 
)
overrideprivatevirtual

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 Primary_election_validation_handler::before_message_handling ( const Plugin_gcs_message message,
const std::string &  message_origin,
bool *  skip_message 
)
overrideprivatevirtual

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.

◆ initialize_validation_structures()

bool Primary_election_validation_handler::initialize_validation_structures ( )

Initialize the group member structures and registers an observer.

Note
this method should be called in a GCS logical moment
Returns
true if some error happened, false otherwise

◆ prepare_election()

bool Primary_election_validation_handler::prepare_election ( )

Shares information among members about weights and channels in all members.

◆ terminates_validation_structures()

void Primary_election_validation_handler::terminates_validation_structures ( )

Cleans the membership info, and pending notifications.

Deregister the observer for group events.

◆ validate_election()

Primary_election_validation_handler::enum_primary_validation_result Primary_election_validation_handler::validate_election ( std::string &  uuid,
std::string &  valid_uuid,
std::string &  error_msg 
)

Validate group for election.

Parameters
[in]uuidmember to validate
[out]valid_uuidthe only member valid for election
[out]error_msgthe error message outputted by validation
Returns
if the primary is valid or what is the solo valid primary
Return values
VALID_PRIMARYif valid
INVALID_PRIMARYif not valid
CURRENT_PRIMARYif it is already the primary
GROUP_SOLO_PRIMARYonly one member is valid

◆ validate_group_slave_channels()

Primary_election_validation_handler::enum_primary_validation_result Primary_election_validation_handler::validate_group_slave_channels ( std::string &  uuid)
private

Check which members have slave channels.

◆ validate_primary_uuid()

Primary_election_validation_handler::enum_primary_validation_result Primary_election_validation_handler::validate_primary_uuid ( std::string &  uuid)

Check that the UUID is valid and present in the group.

Parameters
uuidmember to validate
Return values
INVALID_PRIMARYif not present in the group anymore
CURRENT_PRIMARYif the uuid provided is already the primary
VALID_PRIMARYif the uuid is valid in the group

◆ validate_primary_version()

Primary_election_validation_handler::enum_primary_validation_result Primary_election_validation_handler::validate_primary_version ( std::string &  uuid,
std::string &  error_msg 
)

Check that the group members have valid versions.

  1. All support appointed elections
  2. The appointed member is from the lowest version present in the group
Parameters
[in]uuidmember to validate
[out]error_msgthe error message outputted by validation

Member Data Documentation

◆ group_members_info

std::map<const std::string, Election_member_info *> Primary_election_validation_handler::group_members_info
private

The information about the group members <address,member>

◆ notification_cond

mysql_cond_t Primary_election_validation_handler::notification_cond
private

The condition for notifications.

◆ notification_lock

mysql_mutex_t Primary_election_validation_handler::notification_lock
private

The lock for notifications.

◆ number_of_responses

uint Primary_election_validation_handler::number_of_responses
private

The number of members that sent info or left.

◆ validation_process_aborted

bool Primary_election_validation_handler::validation_process_aborted
private

Was the validation process aborted.


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