![]() |
MySQL 9.2.0
Source Code Documentation
|
#include <metadata_cache.h>
Classes | |
struct | RefreshStatus |
Public Types | |
using | update_routing_guidelines_callback_t = std::function< routing_guidelines::Routing_guidelines_engine::RouteChanges(const std::string &)> |
Callback which is going to update the routing guidelines used by the routing guidelines engine. More... | |
using | on_routing_guidelines_change_callback_t = std::function< void(const routing_guidelines::Routing_guidelines_engine::RouteChanges &)> |
Callback used to verify existing connections according to the new routing guidelines. More... | |
using | update_router_info_callback_t = std::function< void(const routing_guidelines::Router_info &)> |
Callback used to update the router information used by the routing guidelines engine. More... | |
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, bool close_connection_after_refresh=false)=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 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... | |
virtual void | add_routing_guidelines_update_callbacks (update_routing_guidelines_callback_t, on_routing_guidelines_change_callback_t)=0 |
virtual void | clear_routing_guidelines_update_callbacks ()=0 |
virtual void | add_router_info_update_callback (update_router_info_callback_t clb)=0 |
virtual void | clear_router_info_update_callback ()=0 |
MetadataCacheAPIBase ()=default | |
MetadataCacheAPIBase (const MetadataCacheAPIBase &)=delete | |
MetadataCacheAPIBase & | operator= (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 |
![]() | |
ClusterStateNotifierInterface ()=default | |
ClusterStateNotifierInterface (const ClusterStateNotifierInterface &)=delete | |
ClusterStateNotifierInterface & | operator= (const ClusterStateNotifierInterface &)=delete |
virtual | ~ClusterStateNotifierInterface () |
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)> |
using metadata_cache::MetadataCacheAPIBase::on_routing_guidelines_change_callback_t = std::function<void( const routing_guidelines::Routing_guidelines_engine::RouteChanges &)> |
Callback used to verify existing connections according to the new routing guidelines.
using metadata_cache::MetadataCacheAPIBase::update_router_info_callback_t = std::function<void(const routing_guidelines::Router_info &)> |
Callback used to update the router information used by the routing guidelines engine.
using metadata_cache::MetadataCacheAPIBase::update_routing_guidelines_callback_t = std::function<routing_guidelines::Routing_guidelines_engine::RouteChanges( const std::string &)> |
Callback which is going to update the routing guidelines used by the routing guidelines engine.
|
default |
|
explicitdelete |
|
overridedefault |
|
pure virtual |
Register observer that is notified when the state of listening socket acceptors should be updated on the next metadata refresh.
listener | Observer object that is notified when replicaset nodes state is changed. |
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtual |
Register observer that is notified when the metadata refresh is triggered.
listener | Observer object that is notified on metadata refresh. |
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtual |
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtual |
Implemented in metadata_cache::MetadataCacheAPI.
|
overridepure virtual |
Register observer that is notified when there is a change in the cluster nodes setup/state discovered.
listener | Observer object that is notified when cluster nodes state is changed. |
Implements metadata_cache::ClusterStateNotifierInterface.
Implemented in metadata_cache::MetadataCacheAPI.
|
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.
cluster_type | type of the cluster the metadata cache object will represent (GR or ReplicaSet) |
router_id | id of the router in the cluster metadata |
clusterset_id | UUID of the ClusterSet the Cluster belongs to (if bootstrapped as a ClusterSet, empty otherwise) |
metadata_servers | The list of cluster metadata servers |
ttl_config | metadata TTL configuration |
ssl_options | SSL related options for connection |
target_cluster | object identifying the Cluster this operation refers to |
session_config | Metadata MySQL session configuration |
router_attributes | Router attributes to be registered in the metadata |
thread_stack_size | memory in kilobytes allocated for thread's stack |
use_cluster_notifications | Flag indicating if the metadata cache should use cluster notifications as an additional trigger for metadata refresh (only available for GR cluster type) |
view_id | last known view_id of the cluster metadata (only relevant for ReplicaSet cluster) |
close_connection_after_refresh | if the connection should be closed after a refresh. |
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtual |
Start the metadata cache.
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtualnoexcept |
Teardown the metadata cache.
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtual |
Check values of auth_cache_ttl and auth_cache_refresh_interval timers.
std::invalid_argument | for each of the following scenarios:
|
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtual |
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtual |
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtual |
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtual |
Enable fetching authentication metadata when using metadata_cache http authentication backend.
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtual |
Force cache update in refresh loop.
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtual |
Returns list of managed server in a HA cluster.
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtual |
Return object containing current cluster topology.
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtual |
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtual |
Get authentication data (password hash and privileges) for the given user.
username | - name of the user for which the authentidation data is requested |
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtual |
Toggle socket acceptors state update on next metadata refresh.
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtual |
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtual |
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtualnoexcept |
Implemented in metadata_cache::MetadataCacheAPI.
|
delete |
|
pure virtual |
Unregister observer previously registered with add_acceptor_handler_listener()
listener | Observer object that should be unregistered. |
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtual |
Unregister observer previously registered with add_md_refresh_listener()
listener | Observer object that should be unregistered. |
Implemented in metadata_cache::MetadataCacheAPI.
|
overridepure virtual |
Unregister observer previously registered with add_state_listener()
listener | Observer object that should be unregistered. |
Implements metadata_cache::ClusterStateNotifierInterface.
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtual |
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtual |
Implemented in metadata_cache::MetadataCacheAPI.
|
pure virtual |
Implemented in metadata_cache::MetadataCacheAPI.
|
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.
primary_server_uuid | - server_uuid of the PRIMARY that shall be failover from. |
timeout | - amount of time to wait for a failover, in seconds |
Implemented in metadata_cache::MetadataCacheAPI.