MySQL 8.0.40
Source Code Documentation
metadata_cache::MetadataCacheAPI Class Reference

#include <metadata_cache.h>

Inheritance diagram for metadata_cache::MetadataCacheAPI:
[legend]

Classes

struct  InstData
 

Public Member Functions

void cache_init (const mysqlrouter::ClusterType cluster_type, const unsigned router_id, const std::string &clusterset_id, const metadata_servers_list_t &metadata_servers, const MetadataCacheTTLConfig &ttl_config, const mysqlrouter::SSLOptions &ssl_options, const mysqlrouter::TargetCluster &target_cluster, const MetadataCacheMySQLSessionConfig &session_config, const RouterAttributes &router_attributes, size_t thread_stack_size, bool use_cluster_notifications, const uint64_t view_id) override
 Initialize the metadata cache. More...
 
mysqlrouter::ClusterType cluster_type () const override
 
void instance_name (const std::string &inst_name) override
 
std::string instance_name () const override
 
mysqlrouter::TargetCluster target_cluster () const override
 
std::chrono::milliseconds ttl () const override
 
bool is_initialized () noexcept override
 
void cache_start () override
 Start the metadata cache. More...
 
void cache_stop () noexcept override
 Teardown the metadata cache. More...
 
cluster_nodes_list_t get_cluster_nodes () override
 Lookup the servers that belong to the cluster. More...
 
ClusterTopology get_cluster_topology () override
 Return object containing current cluster topology. More...
 
bool wait_primary_failover (const std::string &primary_server_uuid, const std::chrono::seconds &timeout) override
 Wait until there's a primary member in the cluster. More...
 
void add_state_listener (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 (ClusterStateListenerInterface *listener) override
 Unregister observer previously registered with add_state_listener() More...
 
void add_acceptor_handler_listener (AcceptorUpdateHandlerInterface *listener) override
 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 (AcceptorUpdateHandlerInterface *listener) override
 Unregister observer previously registered with add_acceptor_handler_listener() More...
 
void add_md_refresh_listener (MetadataRefreshListenerInterface *listener) override
 Register observer that is notified when the metadata refresh is triggered. More...
 
void remove_md_refresh_listener (MetadataRefreshListenerInterface *listener) override
 Unregister observer previously registered with add_md_refresh_listener() More...
 
RefreshStatus get_refresh_status () override
 
std::pair< bool, std::pair< std::string, rapidjson::Document > > get_rest_user_auth_data (const std::string &user) const override
 Get authentication data (password hash and privileges) for the given user. More...
 
void enable_fetch_auth_metadata () override
 Enable fetching authentication metadata when using metadata_cache http authentication backend. More...
 
void force_cache_update () override
 Force cache update in refresh loop. More...
 
void check_auth_metadata_timers () const override
 Check values of auth_cache_ttl and auth_cache_refresh_interval timers. More...
 
void handle_sockets_acceptors_on_md_refresh () override
 Toggle socket acceptors state update on next metadata refresh. More...
 
void set_instance_factory (metadata_factory_t cb) override
 
bool fetch_whole_topology () const override
 
void fetch_whole_topology (bool val) override
 

Static Public Member Functions

static MetadataCacheAPIBaseinstance ()
 

Private Member Functions

 MetadataCacheAPI ()=default
 
 MetadataCacheAPI (const MetadataCacheAPI &)=delete
 
MetadataCacheAPIoperator= (const MetadataCacheAPI &)=delete
 

Private Attributes

metadata_factory_t instance_factory_ {&metadata_factory_get_instance}
 
Monitor< InstDatainst_ {{}}
 
std::atomic< bool > is_initialized_ {false}
 

Additional Inherited Members

Constructor & Destructor Documentation

◆ MetadataCacheAPI() [1/2]

metadata_cache::MetadataCacheAPI::MetadataCacheAPI ( )
privatedefault

◆ MetadataCacheAPI() [2/2]

metadata_cache::MetadataCacheAPI::MetadataCacheAPI ( const MetadataCacheAPI )
privatedelete

Member Function Documentation

◆ add_acceptor_handler_listener()

void metadata_cache::MetadataCacheAPI::add_acceptor_handler_listener ( AcceptorUpdateHandlerInterface listener)
overridevirtual

Register observer that is notified when the state of listening socket acceptors should be updated on the next metadata refresh.

Parameters
listenerObserver object that is notified when replicaset nodes state is changed.

Implements metadata_cache::MetadataCacheAPIBase.

◆ add_md_refresh_listener()

void metadata_cache::MetadataCacheAPI::add_md_refresh_listener ( MetadataRefreshListenerInterface listener)
overridevirtual

Register observer that is notified when the metadata refresh is triggered.

Parameters
listenerObserver object that is notified on metadata refresh.

Implements metadata_cache::MetadataCacheAPIBase.

◆ add_state_listener()

void metadata_cache::MetadataCacheAPI::add_state_listener ( ClusterStateListenerInterface listener)
overridevirtual

Register observer that is notified when there is a change in the cluster nodes setup/state discovered.

Parameters
listenerObserver object that is notified when cluster nodes state is changed.

Implements metadata_cache::MetadataCacheAPIBase.

◆ cache_init()

void metadata_cache::MetadataCacheAPI::cache_init ( const mysqlrouter::ClusterType  cluster_type,
const unsigned  router_id,
const std::string &  clusterset_id,
const metadata_servers_list_t metadata_servers,
const MetadataCacheTTLConfig ttl_config,
const mysqlrouter::SSLOptions ssl_options,
const mysqlrouter::TargetCluster target_cluster,
const MetadataCacheMySQLSessionConfig session_config,
const RouterAttributes router_attributes,
size_t  thread_stack_size,
bool  use_cluster_notifications,
const uint64_t  view_id 
)
overridevirtual

Initialize the metadata cache.

Parameters
cluster_typetype of the cluster the metadata cache object will represent (GR or ReplicaSet)
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 list of cluster metadata servers
ttl_configmetadata TTL configuration
ssl_optionsSSL related options for connections
target_clusterobject identifying the Cluster this operation refers to
session_configMetadata MySQL session configuration
router_attributesRouter attributes to be registered in the metadata
thread_stack_sizememory in kilobytes allocated for thread's stack
use_cluster_notificationsFlag indicating if the metadata cache should use cluster notifications as an additional trigger for metadata refresh (only available for GR cluster type)
view_idlast known view_id of the cluster metadata (only relevant for ReplicaSet cluster)

Implements metadata_cache::MetadataCacheAPIBase.

◆ cache_start()

void metadata_cache::MetadataCacheAPI::cache_start ( )
overridevirtual

Start the metadata cache.

Implements metadata_cache::MetadataCacheAPIBase.

◆ cache_stop()

void metadata_cache::MetadataCacheAPI::cache_stop ( )
overridevirtualnoexcept

Teardown the metadata cache.

Implements metadata_cache::MetadataCacheAPIBase.

◆ check_auth_metadata_timers()

void metadata_cache::MetadataCacheAPI::check_auth_metadata_timers ( ) const
overridevirtual

Check values of auth_cache_ttl and auth_cache_refresh_interval timers.

Exceptions
std::invalid_argumentfor each of the following scenarios:
  1. auth_cache_ttl < ttl
  2. auth_cache_refresh_interval < ttl
  3. auth_cache_refresh_interval > auth_cache_ttl

Implements metadata_cache::MetadataCacheAPIBase.

◆ cluster_type()

mysqlrouter::ClusterType metadata_cache::MetadataCacheAPI::cluster_type ( ) const
overridevirtual

◆ enable_fetch_auth_metadata()

void metadata_cache::MetadataCacheAPI::enable_fetch_auth_metadata ( )
overridevirtual

Enable fetching authentication metadata when using metadata_cache http authentication backend.

Implements metadata_cache::MetadataCacheAPIBase.

◆ fetch_whole_topology() [1/2]

bool metadata_cache::MetadataCacheAPI::fetch_whole_topology ( ) const
overridevirtual

◆ fetch_whole_topology() [2/2]

void metadata_cache::MetadataCacheAPI::fetch_whole_topology ( bool  val)
overridevirtual

◆ force_cache_update()

void metadata_cache::MetadataCacheAPI::force_cache_update ( )
overridevirtual

Force cache update in refresh loop.

Implements metadata_cache::MetadataCacheAPIBase.

◆ get_cluster_nodes()

cluster_nodes_list_t metadata_cache::MetadataCacheAPI::get_cluster_nodes ( )
overridevirtual

Lookup the servers that belong to the cluster.

Returns
An object that encapsulates a list of managed MySQL servers.

Implements metadata_cache::MetadataCacheAPIBase.

◆ get_cluster_topology()

ClusterTopology metadata_cache::MetadataCacheAPI::get_cluster_topology ( )
overridevirtual

Return object containing current cluster topology.

Returns
List of ManagedInstance objects

Implements metadata_cache::MetadataCacheAPIBase.

◆ get_refresh_status()

MetadataCacheAPI::RefreshStatus metadata_cache::MetadataCacheAPI::get_refresh_status ( )
overridevirtual

◆ get_rest_user_auth_data()

std::pair< bool, MetaData::auth_credentials_t::mapped_type > metadata_cache::MetadataCacheAPI::get_rest_user_auth_data ( const std::string &  username) const
overridevirtual

Get authentication data (password hash and privileges) for the given user.

Parameters
username- name of the user for which the authentidation data is requested
Returns
true and password hash with privileges - authentication data requested for the given user.
false and empty data set - username is not found or authentication data expired.

Implements metadata_cache::MetadataCacheAPIBase.

◆ handle_sockets_acceptors_on_md_refresh()

void metadata_cache::MetadataCacheAPI::handle_sockets_acceptors_on_md_refresh ( )
overridevirtual

Toggle socket acceptors state update on next metadata refresh.

Implements metadata_cache::MetadataCacheAPIBase.

◆ instance()

MetadataCacheAPIBase * metadata_cache::MetadataCacheAPI::instance ( )
static

◆ instance_name() [1/2]

std::string metadata_cache::MetadataCacheAPI::instance_name ( ) const
overridevirtual

◆ instance_name() [2/2]

void metadata_cache::MetadataCacheAPI::instance_name ( const std::string &  inst_name)
overridevirtual

◆ is_initialized()

bool metadata_cache::MetadataCacheAPI::is_initialized ( )
inlineoverridevirtualnoexcept

◆ operator=()

MetadataCacheAPI & metadata_cache::MetadataCacheAPI::operator= ( const MetadataCacheAPI )
privatedelete

◆ remove_acceptor_handler_listener()

void metadata_cache::MetadataCacheAPI::remove_acceptor_handler_listener ( AcceptorUpdateHandlerInterface listener)
overridevirtual

Unregister observer previously registered with add_acceptor_handler_listener()

Parameters
listenerObserver object that should be unregistered.

Implements metadata_cache::MetadataCacheAPIBase.

◆ remove_md_refresh_listener()

void metadata_cache::MetadataCacheAPI::remove_md_refresh_listener ( MetadataRefreshListenerInterface listener)
overridevirtual

Unregister observer previously registered with add_md_refresh_listener()

Parameters
listenerObserver object that should be unregistered.

Implements metadata_cache::MetadataCacheAPIBase.

◆ remove_state_listener()

void metadata_cache::MetadataCacheAPI::remove_state_listener ( ClusterStateListenerInterface listener)
overridevirtual

Unregister observer previously registered with add_state_listener()

Parameters
listenerObserver object that should be unregistered.

Implements metadata_cache::MetadataCacheAPIBase.

◆ set_instance_factory()

void metadata_cache::MetadataCacheAPI::set_instance_factory ( metadata_factory_t  cb)
inlineoverridevirtual

◆ target_cluster()

mysqlrouter::TargetCluster metadata_cache::MetadataCacheAPI::target_cluster ( ) const
overridevirtual

◆ ttl()

std::chrono::milliseconds metadata_cache::MetadataCacheAPI::ttl ( ) const
overridevirtual

◆ wait_primary_failover()

bool metadata_cache::MetadataCacheAPI::wait_primary_failover ( const std::string &  primary_server_uuid,
const std::chrono::seconds timeout 
)
overridevirtual

Wait until there's a primary member in the cluster.

To be called when the primary member of a single-primary cluster is down and we want to wait until one becomes elected.

Parameters
primary_server_uuid- server_uuid of the PRIMARY that shall be failover from.
timeout- amount of time to wait for a failover, in seconds
Returns
true if a primary member exists

Implements metadata_cache::MetadataCacheAPIBase.

Member Data Documentation

◆ inst_

Monitor<InstData> metadata_cache::MetadataCacheAPI::inst_ {{}}
private

◆ instance_factory_

metadata_factory_t metadata_cache::MetadataCacheAPI::instance_factory_ {&metadata_factory_get_instance}
private

◆ is_initialized_

std::atomic<bool> metadata_cache::MetadataCacheAPI::is_initialized_ {false}
private

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