MySQL 8.4.2
Source Code Documentation
GRClusterMetadata Class Reference

#include <cluster_metadata_gr.h>

Inheritance diagram for GRClusterMetadata:
[legend]

Public Member Functions

 GRClusterMetadata (const metadata_cache::MetadataCacheMySQLSessionConfig &session_config, const mysqlrouter::SSLOptions &ssl_options, const bool use_cluster_notifications=false)
 Constructor. More...
 
 GRClusterMetadata (const GRClusterMetadata &)=delete
 
GRClusterMetadataoperator= (const GRClusterMetadata &)=delete
 
 ~GRClusterMetadata () override
 Destructor. More...
 
stdx::expected< metadata_cache::ClusterTopology, std::error_code > fetch_cluster_topology (const std::atomic< bool > &terminated, mysqlrouter::TargetCluster &target_cluster, const unsigned router_id, const metadata_cache::metadata_servers_list_t &metadata_servers, bool needs_writable_node, const std::string &clusterset_id, bool whole_topology, std::size_t &instance_id) override
 Returns cluster defined in the metadata given set of the metadata servers (cluster members) More...
 
void setup_notifications_listener (const metadata_cache::ClusterTopology &cluster_topology, const GRNotificationListener::NotificationClb &callback) override
 Initializes the notifications listener thread (if a given cluster type supports it) More...
 
void shutdown_notifications_listener () override
 Deinitializes the notifications listener thread. More...
 
mysqlrouter::ClusterType get_cluster_type () override
 Returns cluster type this object is suppsed to handle. More...
 
auth_credentials_t fetch_auth_credentials (const metadata_cache::metadata_server_t &md_server, const mysqlrouter::TargetCluster &target_cluster) override
 Get authentication data of the rest users from the metadata. More...
 

Protected Member Functions

metadata_cache::ClusterTopology fetch_instances_from_metadata_server (const mysqlrouter::TargetCluster &target_cluster, const std::string &cluster_type_specific_id)
 Queries the metadata server for the list of instances that belong to the desired cluster. More...
 
void update_cluster_status_from_gr (const bool unreachable_quorum_allowed_traffic, metadata_cache::ManagedCluster &cluster)
 Query the GR performance_schema tables for live information about a cluster. More...
 
GRClusterStatus check_cluster_status_in_gr (std::vector< metadata_cache::ManagedInstance * > &instances, const std::map< std::string, GroupReplicationMember > &member_status, bool &metadata_gr_discrepancy) const noexcept
 
void reset_metadata_backend (const mysqlrouter::ClusterType type)
 

Protected Attributes

std::unique_ptr< GRMetadataBackendmetadata_backend_
 

Private Member Functions

void update_backend (const mysqlrouter::MetadataSchemaVersion &version, unsigned int router_id)
 

Private Attributes

std::unique_ptr< GRNotificationListenergr_notifications_listener_
 

Friends

class GRMetadataBackend
 
class GRClusterSetMetadataBackend
 

Additional Inherited Members

Constructor & Destructor Documentation

◆ GRClusterMetadata() [1/2]

GRClusterMetadata::GRClusterMetadata ( const metadata_cache::MetadataCacheMySQLSessionConfig session_config,
const mysqlrouter::SSLOptions ssl_options,
const bool  use_cluster_notifications = false 
)

Constructor.

Parameters
session_configMetadata MySQL session configuration
ssl_optionsSSL related options to use for MySQL connections
use_cluster_notificationsFlag indicating if the metadata cache should use cluster notifications as an additional trigger for metadata refresh

◆ GRClusterMetadata() [2/2]

GRClusterMetadata::GRClusterMetadata ( const GRClusterMetadata )
explicitdelete

◆ ~GRClusterMetadata()

GRClusterMetadata::~GRClusterMetadata ( )
overridedefault

Destructor.

Disconnect and release the connection to the metadata node.

Member Function Documentation

◆ check_cluster_status_in_gr()

GRClusterStatus GRClusterMetadata::check_cluster_status_in_gr ( std::vector< metadata_cache::ManagedInstance * > &  instances,
const std::map< std::string, GroupReplicationMember > &  member_status,
bool &  metadata_gr_discrepancy 
) const
protectednoexcept

◆ fetch_auth_credentials()

GRClusterMetadata::auth_credentials_t GRClusterMetadata::fetch_auth_credentials ( const metadata_cache::metadata_server_t md_server,
const mysqlrouter::TargetCluster target_cluster 
)
overridevirtual

Get authentication data of the rest users from the metadata.

Authentication data is stored in the router_rest_accounts table. This method fetches the following information: username, password hash, privileges and name of the authentication mechanism that should be used.

Parameters
target_clusterinformation about the Cluster that this information is retrieved for
md_serveraddress of the metadata server to get the data from
Returns
authentication data of the rest users stored in the metadata

Reimplemented from ClusterMetadata.

◆ fetch_cluster_topology()

stdx::expected< metadata_cache::ClusterTopology, std::error_code > GRClusterMetadata::fetch_cluster_topology ( const std::atomic< bool > &  terminated,
mysqlrouter::TargetCluster target_cluster,
const unsigned  router_id,
const metadata_cache::metadata_servers_list_t metadata_servers,
bool  needs_writable_node,
const std::string &  clusterset_id,
bool  whole_topology,
std::size_t &  instance_id 
)
overridevirtual

Returns cluster defined in the metadata given set of the metadata servers (cluster members)

Parameters
terminatedflag indicating that the process is cterminating, allowing the function to leave earlier if possible
[in,out]target_clusterobject identifying the Cluster this operation refers to
router_idid of the router in the cluster metadata
metadata_serversset of the metadata servers to use to fetch the metadata
needs_writable_nodeflag indicating if the caller needs us to query for writable node
clusterset_idUUID of the ClusterSet the Cluster belongs to (if bootstrapped as a ClusterSet)
whole_topologyreturn all usable nodes, ignore potential metadata filters or policies (like target_cluster etc.)
[out]instance_idof the server the metadata was fetched from
Returns
object containing cluster topology information in case of success, or error code in case of failure
Exceptions
metadata_cache::metadata_error

Implements MetaData.

◆ fetch_instances_from_metadata_server()

metadata_cache::ClusterTopology GRClusterMetadata::fetch_instances_from_metadata_server ( const mysqlrouter::TargetCluster target_cluster,
const std::string &  cluster_type_specific_id 
)
protected

Queries the metadata server for the list of instances that belong to the desired cluster.

◆ get_cluster_type()

mysqlrouter::ClusterType GRClusterMetadata::get_cluster_type ( )
overridevirtual

Returns cluster type this object is suppsed to handle.

Implements MetaData.

◆ operator=()

GRClusterMetadata & GRClusterMetadata::operator= ( const GRClusterMetadata )
delete

◆ reset_metadata_backend()

void GRClusterMetadata::reset_metadata_backend ( const mysqlrouter::ClusterType  type)
protected

◆ setup_notifications_listener()

void GRClusterMetadata::setup_notifications_listener ( const metadata_cache::ClusterTopology cluster_topology,
const GRNotificationListener::NotificationClb callback 
)
inlineoverridevirtual

Initializes the notifications listener thread (if a given cluster type supports it)

Parameters
cluster_topologycurrent topology of the monitored Cluster(s) to
callbackcallback function to get called when the GR notification was received

Implements MetaData.

◆ shutdown_notifications_listener()

void GRClusterMetadata::shutdown_notifications_listener ( )
inlineoverridevirtual

Deinitializes the notifications listener thread.

Implements MetaData.

◆ update_backend()

void GRClusterMetadata::update_backend ( const mysqlrouter::MetadataSchemaVersion version,
unsigned int  router_id 
)
private

◆ update_cluster_status_from_gr()

void GRClusterMetadata::update_cluster_status_from_gr ( const bool  unreachable_quorum_allowed_traffic,
metadata_cache::ManagedCluster cluster 
)
protected

Query the GR performance_schema tables for live information about a cluster.

update_cluster_status_from_gr() calls check_cluster_status_in_gr() for some of its processing. Together, they:

  • check current topology (status) returned from a cluster node
  • update 'instances' with this state
  • get other metadata about the cluster

The information is pulled from GR maintained performance_schema tables.

Friends And Related Function Documentation

◆ GRClusterSetMetadataBackend

friend class GRClusterSetMetadataBackend
friend

◆ GRMetadataBackend

friend class GRMetadataBackend
friend

Member Data Documentation

◆ gr_notifications_listener_

std::unique_ptr<GRNotificationListener> GRClusterMetadata::gr_notifications_listener_
private

◆ metadata_backend_

std::unique_ptr<GRMetadataBackend> GRClusterMetadata::metadata_backend_
protected

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