MySQL 8.4.2
Source Code Documentation
GRMetadataCache Class Reference

#include <metadata_cache_gr.h>

Inheritance diagram for GRMetadataCache:
[legend]

Public Member Functions

 GRMetadataCache (const unsigned router_id, const std::string &clusterset_id, const std::vector< mysql_harness::TCPAddress > &metadata_servers, std::shared_ptr< MetaData > cluster_metadata, const metadata_cache::MetadataCacheTTLConfig &ttl_config, const mysqlrouter::SSLOptions &ssl_options, const mysqlrouter::TargetCluster &target_cluster, const metadata_cache::RouterAttributes &router_attributes, size_t thread_stack_size=mysql_harness::kDefaultStackSizeInKiloBytes, bool use_gr_notifications=false)
 Initialize a connection to the MySQL Metadata server. More...
 
bool refresh (bool needs_writable_node) override
 Refreshes the cache. More...
 
mysqlrouter::ClusterType cluster_type () const noexcept override
 
- Public Member Functions inherited from MetadataCache
 MetadataCache (const unsigned router_id, const std::string &clusterset_id, const std::vector< mysql_harness::TCPAddress > &metadata_servers, std::shared_ptr< MetaData > cluster_metadata, const metadata_cache::MetadataCacheTTLConfig &ttl_config, const mysqlrouter::SSLOptions &ssl_options, const mysqlrouter::TargetCluster &target_cluster, const metadata_cache::RouterAttributes &router_attributes, size_t thread_stack_size=mysql_harness::kDefaultStackSizeInKiloBytes, bool use_cluster_notifications=false)
 Initialize a connection to the MySQL Metadata server. More...
 
 ~MetadataCache () override
 
void start ()
 Starts the Metadata Cache. More...
 
void stop () noexcept
 Stops the Metadata Cache. More...
 
metadata_cache::cluster_nodes_list_t get_cluster_nodes ()
 Returns list of managed servers in a cluster. More...
 
metadata_cache::ClusterTopology get_cluster_topology ()
 Returns object containing current Cluster Topology. More...
 
bool wait_primary_failover (const std::string &server_uuid, const std::chrono::seconds &timeout)
 Wait until cluster PRIMARY changes. More...
 
void refresh_thread ()
 refresh cluster information More...
 
void add_state_listener (metadata_cache::ClusterStateListenerInterface *listener) override
 Register observer that is notified when there is a change in the cluster nodes setup/state discovered. More...
 
void remove_state_listener (metadata_cache::ClusterStateListenerInterface *listener) override
 Unregister observer previously registered with add_state_listener() More...
 
void add_acceptor_handler_listener (metadata_cache::AcceptorUpdateHandlerInterface *listener)
 Register observer that is notified when the state of listening socket acceptors should be updated on the next metadata refresh. More...
 
void remove_acceptor_handler_listener (metadata_cache::AcceptorUpdateHandlerInterface *listener)
 Unregister observer previously registered with add_acceptor_handler_listener() More...
 
void add_md_refresh_listener (metadata_cache::MetadataRefreshListenerInterface *listener)
 Register observer that is notified on each metadata refresh event. More...
 
void remove_md_refresh_listener (metadata_cache::MetadataRefreshListenerInterface *listener)
 Unregister observer previously registered with add_md_refresh_listener() More...
 
metadata_cache::MetadataCacheAPIBase::RefreshStatus refresh_status ()
 
std::chrono::milliseconds ttl () const
 
mysqlrouter::TargetCluster target_cluster () const
 
std::vector< mysql_harness::TCPAddressmetadata_servers ()
 
void enable_fetch_auth_metadata ()
 
void force_cache_update ()
 
void check_auth_metadata_timers () const
 
std::pair< bool, MetaData::auth_credentials_t::mapped_type > get_rest_user_auth_data (const std::string &user)
 
void handle_sockets_acceptors_on_md_refresh ()
 Toggle socket acceptors state update on next metadata refresh. More...
 
bool fetch_whole_topology () const
 
void fetch_whole_topology (bool val)
 

Private Member Functions

void log_cluster_details () const
 

Additional Inherited Members

- Static Public Member Functions inherited from MetadataCache
static void * run_thread (void *context)
 run refresh thread More...
 
- Protected Member Functions inherited from MetadataCache
void on_refresh_failed (bool terminated, bool md_servers_reachable=false)
 
void on_refresh_succeeded (const metadata_cache::metadata_server_t &metadata_server)
 
void on_instances_changed (const bool md_servers_reachable, const metadata_cache::ClusterTopology &cluster_topology, uint64_t view_id=0)
 
void on_handle_sockets_acceptors ()
 Called when the listening sockets acceptors state should be updated but replicaset instances has not changed (in that case socket acceptors would be handled when calling on_instances_changed). More...
 
void on_md_refresh (const bool cluster_nodes_changed, const metadata_cache::ClusterTopology &cluster_topology)
 Called on each metadata refresh. More...
 
void on_refresh_requested ()
 
void on_refresh_completed ()
 
bool update_auth_cache ()
 
void update_router_attributes ()
 
void update_router_last_check_in ()
 
bool needs_initial_attributes_update ()
 
bool needs_last_check_in_update ()
 
- Protected Attributes inherited from MetadataCache
metadata_cache::ClusterTopology cluster_topology_
 
mysqlrouter::TargetCluster target_cluster_
 
const std::string clusterset_id_
 
metadata_cache::metadata_servers_list_t metadata_servers_
 
metadata_cache::MetadataCacheTTLConfig ttl_config_
 
mysqlrouter::SSLOptions ssl_options_
 
unsigned router_id_
 
Monitor< RestAuthDatarest_auth_ {{}}
 
bool auth_metadata_fetch_enabled_ {false}
 
std::shared_ptr< MetaDatameta_data_
 
mysql_harness::MySQLRouterThread refresh_thread_
 refresh thread facade More...
 
mysql_harness::MySQLRouterThread notification_thread_
 notification thread facade More...
 
std::mutex cache_refreshing_mutex_
 
std::mutex metadata_servers_mutex_
 
std::atomic< bool > terminated_ {false}
 
bool refresh_requested_ {false}
 
bool use_cluster_notifications_
 
std::condition_variable refresh_wait_
 
std::mutex refresh_wait_mtx_
 
std::condition_variable refresh_completed_
 
std::mutex refresh_completed_mtx_
 
std::mutex cluster_instances_change_callbacks_mtx_
 
std::mutex acceptor_handler_callbacks_mtx_
 
std::mutex md_refresh_callbacks_mtx_
 
std::set< metadata_cache::ClusterStateListenerInterface * > state_listeners_
 
std::set< metadata_cache::AcceptorUpdateHandlerInterface * > acceptor_update_listeners_
 
std::set< metadata_cache::MetadataRefreshListenerInterface * > md_refresh_listeners_
 
Monitor< Statsstats_ {{}}
 
bool initial_attributes_update_done_ {false}
 
uint32_t periodic_stats_update_counter_ {1}
 
std::chrono::steady_clock::time_point last_periodic_stats_update_timestamp_
 
bool ready_announced_ {false}
 
std::atomic< bool > fetch_whole_topology_ {false}
 
std::atomic< bool > trigger_acceptor_update_on_next_refresh_ {false}
 Flag indicating if socket acceptors state should be updated on next metadata refresh even if instance information has not changed. More...
 
metadata_cache::RouterAttributes router_attributes_
 

Constructor & Destructor Documentation

◆ GRMetadataCache()

GRMetadataCache::GRMetadataCache ( const unsigned  router_id,
const std::string &  clusterset_id,
const std::vector< mysql_harness::TCPAddress > &  metadata_servers,
std::shared_ptr< MetaData cluster_metadata,
const metadata_cache::MetadataCacheTTLConfig ttl_config,
const mysqlrouter::SSLOptions ssl_options,
const mysqlrouter::TargetCluster target_cluster,
const metadata_cache::RouterAttributes router_attributes,
size_t  thread_stack_size = mysql_harness::kDefaultStackSizeInKiloBytes,
bool  use_gr_notifications = false 
)
inline

Initialize a connection to the MySQL Metadata server.

Parameters
router_idid of the router in the cluster metadata
clusterset_idUUID of the ClusterSet the Cluster belongs to (if bootstrapped as a ClusterSet, empty otherwise)
metadata_serversThe servers that store the metadata
cluster_metadatametadata of the cluster
ttl_configmetadata TTL configuration
ssl_optionsSSL related options for connection
target_clusterobject identifying the Cluster this operation refers to
router_attributesRouter attributes to be registered in the metadata
thread_stack_sizeThe maximum memory allocated for thread's stack
use_gr_notificationsFlag indicating if the metadata cache should use GR notifications as an additional trigger for metadata refresh

Member Function Documentation

◆ cluster_type()

mysqlrouter::ClusterType GRMetadataCache::cluster_type ( ) const
inlineoverridevirtualnoexcept

Implements MetadataCache.

◆ log_cluster_details()

void GRMetadataCache::log_cluster_details ( ) const
private

◆ refresh()

bool GRMetadataCache::refresh ( bool  needs_writable_node)
overridevirtual

Refreshes the cache.

Implements MetadataCache.


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