MySQL 8.0.39
Source Code Documentation
mysqlrouter::ClusterMetadata Class Referenceabstract

#include <cluster_metadata.h>

Inheritance diagram for mysqlrouter::ClusterMetadata:
[legend]

Public Member Functions

 ClusterMetadata (const MetadataSchemaVersion &schema_version, MySQLSession *mysql, mysql_harness::SocketOperationsBase *sockops=mysql_harness::SocketOperations::instance())
 
virtual ~ClusterMetadata ()=default
 
virtual mysqlrouter::ClusterType get_type ()=0
 
virtual void verify_router_id_is_ours (const uint32_t router_id, const std::string &hostname_override="")=0
 Checks if Router with given id is already registered in metadata database, and belongs to our machine. More...
 
virtual uint32_t register_router (const std::string &router_name, const bool overwrite, const std::string &hostname_override="")=0
 Registers Router in metadata database. More...
 
virtual void update_router_info (const uint32_t router_id, const std::string &cluster_id, const std::string &target_cluster, const std::string &rw_endpoint, const std::string &ro_endpoint, const std::string &rw_x_endpoint, const std::string &ro_x_endpoint, const std::string &username)=0
 
virtual std::vector< std::string > get_routing_mode_queries ()=0
 
virtual void require_metadata_is_ok ()
 Verify that host is a valid metadata server. More...
 
virtual void require_cluster_is_ok ()=0
 Verify that host is a valid cluster member (either Group Replication or ReplicaSet cluster) More...
 
virtual std::string get_cluster_type_specific_id ()=0
 
virtual ClusterInfo fetch_metadata_servers ()=0
 
virtual std::vector< std::string > get_grant_statements (const std::string &new_accounts) const =0
 
virtual std::vector< std::tuple< std::string, unsigned long > > fetch_cluster_hosts ()=0
 
MySQLSessionget_session ()
 
virtual uint64_t get_view_id (const std::string &)
 

Protected Member Functions

virtual uint64_t query_cluster_count ()=0
 

Protected Attributes

MySQLSessionmysql_
 
mysql_harness::SocketOperationsBasesocket_operations_
 
mysqlrouter::MetadataSchemaVersion schema_version_
 

Constructor & Destructor Documentation

◆ ClusterMetadata()

mysqlrouter::ClusterMetadata::ClusterMetadata ( const MetadataSchemaVersion schema_version,
MySQLSession mysql,
mysql_harness::SocketOperationsBase sockops = mysql_harness::SocketOperations::instance() 
)
inline

◆ ~ClusterMetadata()

virtual mysqlrouter::ClusterMetadata::~ClusterMetadata ( )
virtualdefault

Member Function Documentation

◆ fetch_cluster_hosts()

virtual std::vector< std::tuple< std::string, unsigned long > > mysqlrouter::ClusterMetadata::fetch_cluster_hosts ( )
pure virtual

◆ fetch_metadata_servers()

virtual ClusterInfo mysqlrouter::ClusterMetadata::fetch_metadata_servers ( )
pure virtual

◆ get_cluster_type_specific_id()

virtual std::string mysqlrouter::ClusterMetadata::get_cluster_type_specific_id ( )
pure virtual

◆ get_grant_statements()

virtual std::vector< std::string > mysqlrouter::ClusterMetadata::get_grant_statements ( const std::string &  new_accounts) const
pure virtual

◆ get_routing_mode_queries()

virtual std::vector< std::string > mysqlrouter::ClusterMetadata::get_routing_mode_queries ( )
pure virtual

◆ get_session()

MySQLSession & mysqlrouter::ClusterMetadata::get_session ( )
inline

◆ get_type()

◆ get_view_id()

virtual uint64_t mysqlrouter::ClusterMetadata::get_view_id ( const std::string &  )
inlinevirtual

◆ query_cluster_count()

virtual uint64_t mysqlrouter::ClusterMetadata::query_cluster_count ( )
protectedpure virtual

◆ register_router()

virtual uint32_t mysqlrouter::ClusterMetadata::register_router ( const std::string &  router_name,
const bool  overwrite,
const std::string &  hostname_override = "" 
)
pure virtual

Registers Router in metadata database.

Parameters
router_nameRouter name
overwriteif Router name is already registered, allow this registration to be "hijacked" instead of throwing
hostname_overrideIf non-empty, this hostname will be used instead of getting queried from OS
Returns
newly-assigned router_id
Exceptions
LocalHostnameResolutionError(std::runtime_error)on hostname query failure, std::runtime_error on other failure

Implemented in mysqlrouter::ClusterMetadataGRV1, mysqlrouter::ClusterMetadataGRV2, and mysqlrouter::ClusterMetadataAR.

◆ require_cluster_is_ok()

virtual void mysqlrouter::ClusterMetadata::require_cluster_is_ok ( )
pure virtual

Verify that host is a valid cluster member (either Group Replication or ReplicaSet cluster)

Exceptions
MySQLSession::Error
std::runtime_error
std::out_of_range
std::logic_error

Implemented in mysqlrouter::ClusterMetadataGR, and mysqlrouter::ClusterMetadataAR.

◆ require_metadata_is_ok()

void ClusterMetadata::require_metadata_is_ok ( )
virtual

Verify that host is a valid metadata server.

Exceptions
MySQLSession::Error
std::runtime_error
std::out_of_range
std::logic_error

checks that the server

  • has the metadata in the correct version
  • contains metadata for the group it's in (in case of GR cluster) (metadata server group must be same as managed group currently)

Reimplemented in mysqlrouter::ClusterMetadataGRInClusterSet.

◆ update_router_info()

virtual void mysqlrouter::ClusterMetadata::update_router_info ( const uint32_t  router_id,
const std::string &  cluster_id,
const std::string &  target_cluster,
const std::string &  rw_endpoint,
const std::string &  ro_endpoint,
const std::string &  rw_x_endpoint,
const std::string &  ro_x_endpoint,
const std::string &  username 
)
pure virtual

◆ verify_router_id_is_ours()

virtual void mysqlrouter::ClusterMetadata::verify_router_id_is_ours ( const uint32_t  router_id,
const std::string &  hostname_override = "" 
)
pure virtual

Checks if Router with given id is already registered in metadata database, and belongs to our machine.

Parameters
router_idRouter id
hostname_overrideIf non-empty, this hostname will be used instead of getting queried from OS
Exceptions
LocalHostnameResolutionError(std::runtime_error)on hostname query failure
std::runtime_errorif router_id doesn't exist, or is associated with a different host
MySQLSession::Error(std::runtime_error)on database error

Implemented in mysqlrouter::ClusterMetadataGRV1, mysqlrouter::ClusterMetadataGRV2, and mysqlrouter::ClusterMetadataAR.

Member Data Documentation

◆ mysql_

MySQLSession* mysqlrouter::ClusterMetadata::mysql_
protected

◆ schema_version_

mysqlrouter::MetadataSchemaVersion mysqlrouter::ClusterMetadata::schema_version_
protected

◆ socket_operations_

mysql_harness::SocketOperationsBase* mysqlrouter::ClusterMetadata::socket_operations_
protected

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