MySQL 8.0.39
Source Code Documentation
|
#include <cluster_metadata_gr.h>
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 | |
GRClusterMetadata & | operator= (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 mysqlrouter::TargetCluster &target_cluster) override |
Get authentication data of the rest users from the metadata. More... | |
std::optional< std::chrono::seconds > | get_periodic_stats_update_frequency () noexcept override |
Public Member Functions inherited from ClusterMetadata | |
ClusterMetadata (const metadata_cache::MetadataCacheMySQLSessionConfig &session_config, const mysqlrouter::SSLOptions &ssl_options) | |
Constructor. More... | |
ClusterMetadata (const ClusterMetadata &)=delete | |
ClusterMetadata & | operator= (const ClusterMetadata &)=delete |
~ClusterMetadata () override | |
Destructor. More... | |
bool | connect_and_setup_session (const metadata_cache::metadata_server_t &metadata_server) noexcept override |
Connects with the Metadata server and sets up the session parameters. More... | |
void | disconnect () noexcept override |
Disconnects from the Metadata server. More... | |
std::shared_ptr< mysqlrouter::MySQLSession > | get_connection () override |
Gets the object representing the session to the metadata server. More... | |
bool | update_router_attributes (const metadata_cache::metadata_server_t &rw_server, const unsigned router_id, const metadata_cache::RouterAttributes &router_attributes) override |
bool | update_router_last_check_in (const metadata_cache::metadata_server_t &rw_server, const unsigned router_id) override |
std::optional< metadata_cache::metadata_server_t > | find_rw_server (const std::vector< metadata_cache::ManagedInstance > &instances) |
std::optional< metadata_cache::metadata_server_t > | find_rw_server (const std::vector< metadata_cache::ManagedCluster > &clusters) |
Public Member Functions inherited from MetaData | |
MetaData ()=default | |
MetaData (const MetaData &)=delete | |
MetaData & | operator= (const MetaData &)=delete |
virtual | ~MetaData ()=default |
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 (metadata_cache::ManagedCluster &cluster) |
Query the GR performance_schema tables for live information about a cluster. More... | |
GRClusterStatus | check_cluster_status (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 Member Functions inherited from ClusterMetadata | |
bool | do_connect (mysqlrouter::MySQLSession &connection, const metadata_cache::metadata_server_t &mi) |
Connects a MYSQL connection to the given instance. More... | |
mysqlrouter::MetadataSchemaVersion | get_and_check_metadata_schema_version (mysqlrouter::MySQLSession &session) |
Protected Attributes | |
std::unique_ptr< GRMetadataBackend > | metadata_backend_ |
Protected Attributes inherited from ClusterMetadata | |
mysql_ssl_mode | ssl_mode_ |
mysqlrouter::SSLOptions | ssl_options_ |
metadata_cache::MetadataCacheMySQLSessionConfig | session_config_ |
std::shared_ptr< mysqlrouter::MySQLSession > | metadata_connection_ |
Private Member Functions | |
void | update_backend (const mysqlrouter::MetadataSchemaVersion &version, unsigned int router_id) |
Private Attributes | |
std::unique_ptr< GRNotificationListener > | gr_notifications_listener_ |
Friends | |
class | GRMetadataBackend |
class | GRClusterSetMetadataBackend |
Additional Inherited Members | |
Public Types inherited from MetaData | |
using | JsonAllocator = rapidjson::CrtAllocator |
using | JsonDocument = rapidjson::Document |
using | auth_credentials_t = std::map< std::string, std::pair< std::string, JsonDocument > > |
GRClusterMetadata::GRClusterMetadata | ( | const metadata_cache::MetadataCacheMySQLSessionConfig & | session_config, |
const mysqlrouter::SSLOptions & | ssl_options, | ||
const bool | use_cluster_notifications = false |
||
) |
Constructor.
session_config | Metadata MySQL session configuration |
ssl_options | SSL related options to use for MySQL connections |
use_cluster_notifications | Flag indicating if the metadata cache should use cluster notifications as an additional trigger for metadata refresh |
|
explicitdelete |
|
overridedefault |
Destructor.
Disconnect and release the connection to the metadata node.
|
protectednoexcept |
|
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.
target_cluster | information about the Cluster that this information is retrieved for |
Reimplemented from ClusterMetadata.
|
overridevirtual |
Returns cluster defined in the metadata given set of the metadata servers (cluster members)
terminated | flag indicating that the process is cterminating, allowing the function to leave earlier if possible | |
[in,out] | target_cluster | object identifying the Cluster this operation refers to |
router_id | id of the router in the cluster metadata | |
metadata_servers | set of the metadata servers to use to fetch the metadata | |
needs_writable_node | flag indicating if the caller needs us to query for writable node | |
clusterset_id | UUID of the ClusterSet the Cluster belongs to (if bootstrapped as a ClusterSet) | |
whole_topology | return all usable nodes, ignore potential metadata filters or policies (like target_cluster etc.) | |
[out] | instance_id | of the server the metadata was fetched from |
metadata_cache::metadata_error |
Implements MetaData.
|
protected |
Queries the metadata server for the list of instances that belong to the desired cluster.
|
overridevirtual |
Returns cluster type this object is suppsed to handle.
Implements MetaData.
|
overridevirtualnoexcept |
Reimplemented from ClusterMetadata.
|
delete |
|
protected |
|
inlineoverridevirtual |
Initializes the notifications listener thread (if a given cluster type supports it)
cluster_topology | current topology of the monitored Cluster(s) to |
callback | callback function to get called when the GR notification was received |
Implements MetaData.
|
inlineoverridevirtual |
Deinitializes the notifications listener thread.
Implements MetaData.
|
private |
|
protected |
Query the GR performance_schema tables for live information about a cluster.
update_cluster_status() calls check_cluster_status() for some of its processing. Together, they:
The information is pulled from GR maintained performance_schema tables.
|
friend |
|
friend |
|
private |
|
protected |