MySQL 8.4.0
Source Code Documentation
GRClusterSetMetadataBackend Class Reference
Inheritance diagram for GRClusterSetMetadataBackend:
[legend]

Public Member Functions

 GRClusterSetMetadataBackend (GRClusterMetadata *metadata, ConnectCallback &connect_clb)
 
mysqlrouter::ClusterType get_cluster_type () override
 
stdx::expected< metadata_cache::ClusterTopology, std::error_code > fetch_cluster_topology (MySQLSession::Transaction &transaction, mysqlrouter::TargetCluster &target_cluster, const metadata_cache::metadata_server_t &metadata_server, const metadata_cache::metadata_servers_list_t &metadata_servers, bool needs_writable_node, const RouterOptions &router_options, const std::string &clusterset_id="", bool whole_topology=false) override
 Returns cluster defined in the metadata given set of the metadata servers (cluster members) More...
 
void reset () override
 
std::vector< metadata_cache::metadata_servers_list_tget_metadata_servers (const metadata_cache::metadata_servers_list_t &metadata_servers) override
 
- Public Member Functions inherited from GRMetadataBackendV2
 GRMetadataBackendV2 (GRClusterMetadata *metadata, ConnectCallback &connect_clb)
 
metadata_cache::ClusterTopology fetch_instances_from_metadata_server (const mysqlrouter::TargetCluster &target_cluster, const std::string &clusterset_id="") override
 Queries the metadata server for the list of instances that belong to the desired cluster. More...
 
- Public Member Functions inherited from GRMetadataBackend
 GRMetadataBackend (GRClusterMetadata *metadata, ConnectCallback &connect_clb)
 
virtual ~GRMetadataBackend ()
 

Private Member Functions

metadata_cache::cluster_nodes_list_t fetch_target_cluster_instances_from_metadata_server (mysqlrouter::MySQLSession &session, const std::string &cluster_id)
 Returns vector of the cluster members according to the metadata of the selected server. More...
 
std::tuple< std::string, std::string, mysqlrouter::TargetClusterget_target_cluster_info_from_metadata_server (mysqlrouter::MySQLSession &session, const mysqlrouter::TargetCluster &target_cluster, const std::string &clusterset_id)
 
metadata_cache::ClusterTopology update_clusterset_topology_from_metadata_server (mysqlrouter::MySQLSession &session, const std::string &clusterset_id, uint64_t view_id)
 Queries the metada for the current ClusterSet topology. More...
 
void update_clusterset_status_from_gr (metadata_cache::ClusterTopology &cs_topology, bool needs_writable_node, bool whole_topology, const RouterOptions &router_options, const metadata_cache::metadata_servers_list_t &metadata_servers)
 Given the topology read from metadata updates the topology with the current status from GR tables. More...
 
std::optional< metadata_cache::metadata_server_tfind_rw_server ()
 Finds the writable node within the currently known ClusterSet topology. More...
 

Static Private Member Functions

static void update_metadata_servers_list (metadata_cache::ClusterTopology &cs_topology)
 Given the topology read from the metadata and updated with the current staus from the GR tables updates the metadata_servers list putting them in the following order: 1) Primary Node of Primary Cluster 2) Secondary Nodes of Primary Cluster 3) Nodes of Secondary Clusters starting with Primary Node for each. More...
 

Private Attributes

uint64_t view_id_ {0}
 
bool metadata_read_ {false}
 
std::optional< metadata_cache::ClusterTopologycluster_topology_ {}
 

Additional Inherited Members

- Protected Attributes inherited from GRMetadataBackend
GRClusterMetadatametadata_
 
ConnectCallback connect_clb_
 

Constructor & Destructor Documentation

◆ GRClusterSetMetadataBackend()

GRClusterSetMetadataBackend::GRClusterSetMetadataBackend ( GRClusterMetadata metadata,
ConnectCallback connect_clb 
)
inline

Member Function Documentation

◆ fetch_cluster_topology()

stdx::expected< metadata_cache::ClusterTopology, std::error_code > GRClusterSetMetadataBackend::fetch_cluster_topology ( MySQLSession::Transaction &  transaction,
mysqlrouter::TargetCluster target_cluster,
const metadata_cache::metadata_server_t metadata_server,
const metadata_cache::metadata_servers_list_t metadata_servers,
bool  needs_writable_node,
const RouterOptions router_options,
const std::string &  clusterset_id = "",
bool  whole_topology = false 
)
overridevirtual

Returns cluster defined in the metadata given set of the metadata servers (cluster members)

Parameters
transactiontransaction to be used for SQL queries required by this function
[in,out]target_clusterobject identifying the Cluster this operation refers to
metadata_serverinfo about the metadata server we are querying
metadata_serversset of all the metadata servers read during the bootstrap or the last metadata refresh, sorted by the staus of the cluster and status of the node in the cluster (Primary first)
needs_writable_nodeflag indicating if the caller needs us to query for writable node
router_optionsoptions configured for this Router in the metadata
clusterset_idUUID of the ClusterSet the Cluster belongs to (if bootstrapped as a ClusterSet)
whole_topologyreturn all usable nodes, ignore potential metadata filters or policies (like target_cluster etc.)
Returns
object containing cluster topology information in case of success, or error code in case of failure
Exceptions
metadata_cache::metadata_error

Reimplemented from GRMetadataBackend.

◆ fetch_target_cluster_instances_from_metadata_server()

metadata_cache::cluster_nodes_list_t GRClusterSetMetadataBackend::fetch_target_cluster_instances_from_metadata_server ( mysqlrouter::MySQLSession session,
const std::string &  cluster_id 
)
private

Returns vector of the cluster members according to the metadata of the selected server.

Parameters
sessionactive connection to the member that is checked for the metadata
cluster_idID of the cluster this operation refers to
Returns
vector of the cluster members

◆ find_rw_server()

std::optional< metadata_cache::metadata_server_t > GRClusterSetMetadataBackend::find_rw_server ( )
private

Finds the writable node within the currently known ClusterSet topology.

Returns
address of the current primary node if found
std::nullopt if did not find any writable node primary

◆ get_cluster_type()

mysqlrouter::ClusterType GRClusterSetMetadataBackend::get_cluster_type ( )
inlineoverridevirtual

Reimplemented from GRMetadataBackendV2.

◆ get_metadata_servers()

std::vector< metadata_cache::metadata_servers_list_t > GRClusterSetMetadataBackend::get_metadata_servers ( const metadata_cache::metadata_servers_list_t metadata_servers)
inlineoverridevirtual

Reimplemented from GRMetadataBackend.

◆ get_target_cluster_info_from_metadata_server()

std::tuple< std::string, std::string, mysqlrouter::TargetCluster > GRClusterSetMetadataBackend::get_target_cluster_info_from_metadata_server ( mysqlrouter::MySQLSession session,
const mysqlrouter::TargetCluster target_cluster,
const std::string &  clusterset_id 
)
private

◆ reset()

void GRClusterSetMetadataBackend::reset ( )
inlineoverridevirtual

Reimplemented from GRMetadataBackend.

◆ update_clusterset_status_from_gr()

void GRClusterSetMetadataBackend::update_clusterset_status_from_gr ( metadata_cache::ClusterTopology cs_topology,
bool  needs_writable_node,
bool  whole_topology,
const RouterOptions router_options,
const metadata_cache::metadata_servers_list_t metadata_servers 
)
private

Given the topology read from metadata updates the topology with the current status from GR tables.

Parameters
cs_topologyClusterSet topology as read from the metadata server
needs_writable_nodeflag indicating if the caller needs us to query for writable node
whole_topologyreturn all usable nodes, ignore potential metadata filters or policies (like target_cluster etc.)
router_optionsoptions configured for this Router in the metadata
metadata_serversthe list of ClusterSet metadata servers

◆ update_clusterset_topology_from_metadata_server()

metadata_cache::ClusterTopology GRClusterSetMetadataBackend::update_clusterset_topology_from_metadata_server ( mysqlrouter::MySQLSession session,
const std::string &  clusterset_id,
uint64_t  view_id 
)
private

Queries the metada for the current ClusterSet topology.

Stores the topology in the class state. Returns the set of the metadata server for the ClusterSet.

Parameters
sessionactive connection to the member that is checked for the metadata
clusterset_idID of the ClusterSet this operation refers to
view_idview id of the metadata
Returns
set of the servers that contains metadata for the ClusterSet

◆ update_metadata_servers_list()

void GRClusterSetMetadataBackend::update_metadata_servers_list ( metadata_cache::ClusterTopology cs_topology)
staticprivate

Given the topology read from the metadata and updated with the current staus from the GR tables updates the metadata_servers list putting them in the following order: 1) Primary Node of Primary Cluster 2) Secondary Nodes of Primary Cluster 3) Nodes of Secondary Clusters starting with Primary Node for each.

Parameters
cs_topologyClusterSet topology

Member Data Documentation

◆ cluster_topology_

std::optional<metadata_cache::ClusterTopology> GRClusterSetMetadataBackend::cluster_topology_ {}
private

◆ metadata_read_

bool GRClusterSetMetadataBackend::metadata_read_ {false}
private

◆ view_id_

uint64_t GRClusterSetMetadataBackend::view_id_ {0}
private

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