MySQL 8.3.0
Source Code Documentation
metadata_cache::MetadataCacheAPIBase Class Referenceabstract

#include <metadata_cache.h>

Inheritance diagram for metadata_cache::MetadataCacheAPIBase:
[legend]

Classes

struct  RefreshStatus
 

Public Types

using metadata_factory_t = std::function< std::shared_ptr< MetaData >(mysqlrouter::ClusterType cluster_type, const metadata_cache::MetadataCacheMySQLSessionConfig &session_config, const mysqlrouter::SSLOptions &ssl_options, const bool use_cluster_notifications, unsigned view_id)>
 

Public Member Functions

virtual 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=mysql_harness::kDefaultStackSizeInKiloBytes, bool use_cluster_notifications=false, const uint64_t view_id=0)=0
 Initialize a MetadataCache object and start caching. More...
 
virtual void instance_name (const std::string &inst_name)=0
 
virtual std::string instance_name () const =0
 
virtual bool is_initialized () noexcept=0
 
virtual bool fetch_whole_topology () const =0
 
virtual void fetch_whole_topology (bool val)=0
 
virtual mysqlrouter::ClusterType cluster_type () const =0
 
virtual void cache_start ()=0
 Start the metadata cache. More...
 
virtual void cache_stop () noexcept=0
 Teardown the metadata cache. More...
 
virtual cluster_nodes_list_t get_cluster_nodes ()=0
 Returns list of managed server in a HA cluster. More...
 
virtual ClusterTopology get_cluster_topology ()=0
 Return object containing current cluster topology. More...
 
virtual bool wait_primary_failover (const std::string &primary_server_uuid, const std::chrono::seconds &timeout)=0
 Wait until there's a primary member in the cluster. More...
 
void add_state_listener (ClusterStateListenerInterface *listener) override=0
 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=0
 Unregister observer previously registered with add_state_listener() More...
 
virtual void add_acceptor_handler_listener (AcceptorUpdateHandlerInterface *listener)=0
 Register observer that is notified when the state of listening socket acceptors should be updated on the next metadata refresh. More...
 
virtual void remove_acceptor_handler_listener (AcceptorUpdateHandlerInterface *listener)=0
 Unregister observer previously registered with add_acceptor_handler_listener() More...
 
virtual void add_md_refresh_listener (MetadataRefreshListenerInterface *listener)=0
 Register observer that is notified when the metadata refresh is triggered. More...
 
virtual void remove_md_refresh_listener (MetadataRefreshListenerInterface *listener)=0
 Unregister observer previously registered with add_md_refresh_listener() More...
 
virtual std::pair< bool, std::pair< std::string, rapidjson::Document > > get_rest_user_auth_data (const std::string &username) const =0
 Get authentication data (password hash and privileges) for the given user. More...
 
virtual void enable_fetch_auth_metadata ()=0
 Enable fetching authentication metadata when using metadata_cache http authentication backend. More...
 
virtual void force_cache_update ()=0
 Force cache update in refresh loop. More...
 
virtual void check_auth_metadata_timers () const =0
 Check values of auth_cache_ttl and auth_cache_refresh_interval timers. More...
 
virtual void handle_sockets_acceptors_on_md_refresh ()=0
 Toggle socket acceptors state update on next metadata refresh. More...
 
 MetadataCacheAPIBase ()=default
 
 MetadataCacheAPIBase (const MetadataCacheAPIBase &)=delete
 
MetadataCacheAPIBaseoperator= (const MetadataCacheAPIBase &)=delete
 
 ~MetadataCacheAPIBase () override=default
 
virtual RefreshStatus get_refresh_status ()=0
 
virtual mysqlrouter::TargetCluster target_cluster () const =0
 
virtual std::chrono::milliseconds ttl () const =0
 
virtual void set_instance_factory (metadata_factory_t cb)=0
 

Member Typedef Documentation

◆ metadata_factory_t

using metadata_cache::MetadataCacheAPIBase::metadata_factory_t = std::function<std::shared_ptr<MetaData>( mysqlrouter::ClusterType cluster_type, const metadata_cache::MetadataCacheMySQLSessionConfig &session_config, const mysqlrouter::SSLOptions &ssl_options, const bool use_cluster_notifications, unsigned view_id)>

Constructor & Destructor Documentation

◆ MetadataCacheAPIBase() [1/2]

metadata_cache::MetadataCacheAPIBase::MetadataCacheAPIBase ( )
default

◆ MetadataCacheAPIBase() [2/2]

metadata_cache::MetadataCacheAPIBase::MetadataCacheAPIBase ( const MetadataCacheAPIBase )
explicitdelete

◆ ~MetadataCacheAPIBase()

metadata_cache::MetadataCacheAPIBase::~MetadataCacheAPIBase ( )
overridedefault

Member Function Documentation

◆ add_acceptor_handler_listener()

virtual void metadata_cache::MetadataCacheAPIBase::add_acceptor_handler_listener ( AcceptorUpdateHandlerInterface listener)
pure virtual

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.

Implemented in metadata_cache::MetadataCacheAPI.

◆ add_md_refresh_listener()

virtual void metadata_cache::MetadataCacheAPIBase::add_md_refresh_listener ( MetadataRefreshListenerInterface listener)
pure virtual

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

Parameters
listenerObserver object that is notified on metadata refresh.

Implemented in metadata_cache::MetadataCacheAPI.

◆ add_state_listener()

void metadata_cache::MetadataCacheAPIBase::add_state_listener ( ClusterStateListenerInterface listener)
overridepure virtual

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::ClusterStateNotifierInterface.

Implemented in metadata_cache::MetadataCacheAPI.

◆ cache_init()

virtual void metadata_cache::MetadataCacheAPIBase::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 = mysql_harness::kDefaultStackSizeInKiloBytes,
bool  use_cluster_notifications = false,
const uint64_t  view_id = 0 
)
pure virtual

Initialize a MetadataCache object and start caching.

The metadata_cache::cache_init function will initialize a MetadataCache object using the given arguments and store it globally using the given cache_name.

Parameters host, port, user, password are used to setup the connection with the metadata server.

Cache name given by cache_name can be empty, but must be unique.

The parameters connection_timeout and connection_attempts are used when connected to the metadata server.

Throws a std::runtime_error when the cache object was already initialized.

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 connection
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)

Implemented in metadata_cache::MetadataCacheAPI.

◆ cache_start()

virtual void metadata_cache::MetadataCacheAPIBase::cache_start ( )
pure virtual

Start the metadata cache.

Implemented in metadata_cache::MetadataCacheAPI.

◆ cache_stop()

virtual void metadata_cache::MetadataCacheAPIBase::cache_stop ( )
pure virtualnoexcept

Teardown the metadata cache.

Implemented in metadata_cache::MetadataCacheAPI.

◆ check_auth_metadata_timers()

virtual void metadata_cache::MetadataCacheAPIBase::check_auth_metadata_timers ( ) const
pure virtual

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

Implemented in metadata_cache::MetadataCacheAPI.

◆ cluster_type()

virtual mysqlrouter::ClusterType metadata_cache::MetadataCacheAPIBase::cluster_type ( ) const
pure virtual

◆ enable_fetch_auth_metadata()

virtual void metadata_cache::MetadataCacheAPIBase::enable_fetch_auth_metadata ( )
pure virtual

Enable fetching authentication metadata when using metadata_cache http authentication backend.

Implemented in metadata_cache::MetadataCacheAPI.

◆ fetch_whole_topology() [1/2]

virtual bool metadata_cache::MetadataCacheAPIBase::fetch_whole_topology ( ) const
pure virtual

◆ fetch_whole_topology() [2/2]

virtual void metadata_cache::MetadataCacheAPIBase::fetch_whole_topology ( bool  val)
pure virtual

◆ force_cache_update()

virtual void metadata_cache::MetadataCacheAPIBase::force_cache_update ( )
pure virtual

Force cache update in refresh loop.

Implemented in metadata_cache::MetadataCacheAPI.

◆ get_cluster_nodes()

virtual cluster_nodes_list_t metadata_cache::MetadataCacheAPIBase::get_cluster_nodes ( )
pure virtual

Returns list of managed server in a HA cluster.

  • Returns a list of MySQL servers managed by the topology for the given HA cluster.
Returns
List of ManagedInstance objects

Implemented in metadata_cache::MetadataCacheAPI.

◆ get_cluster_topology()

virtual ClusterTopology metadata_cache::MetadataCacheAPIBase::get_cluster_topology ( )
pure virtual

Return object containing current cluster topology.

Returns
List of ManagedInstance objects

Implemented in metadata_cache::MetadataCacheAPI.

◆ get_refresh_status()

virtual RefreshStatus metadata_cache::MetadataCacheAPIBase::get_refresh_status ( )
pure virtual

◆ get_rest_user_auth_data()

virtual std::pair< bool, std::pair< std::string, rapidjson::Document > > metadata_cache::MetadataCacheAPIBase::get_rest_user_auth_data ( const std::string &  username) const
pure virtual

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.

Implemented in metadata_cache::MetadataCacheAPI.

◆ handle_sockets_acceptors_on_md_refresh()

virtual void metadata_cache::MetadataCacheAPIBase::handle_sockets_acceptors_on_md_refresh ( )
pure virtual

Toggle socket acceptors state update on next metadata refresh.

Implemented in metadata_cache::MetadataCacheAPI.

◆ instance_name() [1/2]

virtual std::string metadata_cache::MetadataCacheAPIBase::instance_name ( ) const
pure virtual

◆ instance_name() [2/2]

virtual void metadata_cache::MetadataCacheAPIBase::instance_name ( const std::string &  inst_name)
pure virtual

◆ is_initialized()

virtual bool metadata_cache::MetadataCacheAPIBase::is_initialized ( )
pure virtualnoexcept

◆ operator=()

MetadataCacheAPIBase & metadata_cache::MetadataCacheAPIBase::operator= ( const MetadataCacheAPIBase )
delete

◆ remove_acceptor_handler_listener()

virtual void metadata_cache::MetadataCacheAPIBase::remove_acceptor_handler_listener ( AcceptorUpdateHandlerInterface listener)
pure virtual

Unregister observer previously registered with add_acceptor_handler_listener()

Parameters
listenerObserver object that should be unregistered.

Implemented in metadata_cache::MetadataCacheAPI.

◆ remove_md_refresh_listener()

virtual void metadata_cache::MetadataCacheAPIBase::remove_md_refresh_listener ( MetadataRefreshListenerInterface listener)
pure virtual

Unregister observer previously registered with add_md_refresh_listener()

Parameters
listenerObserver object that should be unregistered.

Implemented in metadata_cache::MetadataCacheAPI.

◆ remove_state_listener()

void metadata_cache::MetadataCacheAPIBase::remove_state_listener ( ClusterStateListenerInterface listener)
overridepure virtual

Unregister observer previously registered with add_state_listener()

Parameters
listenerObserver object that should be unregistered.

Implements metadata_cache::ClusterStateNotifierInterface.

Implemented in metadata_cache::MetadataCacheAPI.

◆ set_instance_factory()

virtual void metadata_cache::MetadataCacheAPIBase::set_instance_factory ( metadata_factory_t  cb)
pure virtual

◆ target_cluster()

virtual mysqlrouter::TargetCluster metadata_cache::MetadataCacheAPIBase::target_cluster ( ) const
pure virtual

◆ ttl()

virtual std::chrono::milliseconds metadata_cache::MetadataCacheAPIBase::ttl ( ) const
pure virtual

◆ wait_primary_failover()

virtual bool metadata_cache::MetadataCacheAPIBase::wait_primary_failover ( const std::string &  primary_server_uuid,
const std::chrono::seconds timeout 
)
pure virtual

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

Implemented in metadata_cache::MetadataCacheAPI.


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