MySQL 9.3.0
Source Code Documentation
DestinationManager Class Referenceabstract

Manage destinations for a Connection Routing. More...

#include <destination.h>

Inheritance diagram for DestinationManager:
[legend]

Public Types

using DestVector = std::vector< mysql_harness::Destination >
 

Public Member Functions

 DestinationManager (net::io_context &io_ctx, MySQLRoutingContext &routing_ctx)
 Default constructor. More...
 
virtual ~DestinationManager ()=default
 Destructor. More...
 
 DestinationManager (const DestinationManager &other)=delete
 
 DestinationManager (DestinationManager &&other)=delete
 
DestinationManageroperator= (const DestinationManager &other)=delete
 
DestinationManageroperator= (DestinationManager &&other)=delete
 
virtual void connect_status (std::error_code ec)=0
 
virtual void start (const mysql_harness::PluginFuncEnv *env)=0
 Start the destination manager. More...
 
virtual stdx::expected< void, std::error_code > init_destinations (const routing_guidelines::Session_info &session_info)=0
 Set up destination manager, prepare the destinations. More...
 
virtual mysqlrouter::ServerMode purpose () const
 
virtual bool refresh_destinations (const routing_guidelines::Session_info &)=0
 refresh destinations. More...
 
virtual void handle_sockets_acceptors ()=0
 Trigger listening socket acceptors state handler based on the destination type. More...
 
virtual std::unique_ptr< Destinationget_next_destination (const routing_guidelines::Session_info &)=0
 Get destination that should be used for connection attempt. More...
 
virtual std::unique_ptr< Destinationget_last_used_destination () const =0
 Get destination that was selected as a destination candidate. More...
 
virtual std::vector< mysql_harness::Destinationget_destination_candidates () const =0
 Get addresses of all nodes that are a possible destination candidates. More...
 
bool routing_guidelines_session_rand_used () const
 Check if routing guidelines uses $.session.rand as a match criterion. More...
 
routing_guidelines::Router_info get_router_info () const
 Get information about this given Router instance. More...
 
virtual bool has_read_write () const =0
 Check if there are read-write destinations that could be used. More...
 
virtual bool has_read_only () const =0
 Check if there are read-only destinations that could be used. More...
 
- Public Member Functions inherited from DestinationNodesStateNotifier
virtual ~DestinationNodesStateNotifier ()=default
 
AllowedNodesChangeCallbacksListIterator register_allowed_nodes_change_callback (const AllowedNodesChangedCallback &clb)
 Registers the callback for notification on the change in the state if the destination nodes. More...
 
void unregister_allowed_nodes_change_callback (const AllowedNodesChangeCallbacksListIterator &it)
 Unregisters the callback registered with register_allowed_nodes_change_callback(). More...
 
void register_start_router_socket_acceptor (const StartSocketAcceptorCallback &clb)
 Registers the callback for notification that the routing socket acceptor should accept new connections. More...
 
void unregister_start_router_socket_acceptor ()
 Unregisters the callback registered with register_start_router_socket_acceptor(). More...
 
void register_stop_router_socket_acceptor (const StopSocketAcceptorCallback &clb)
 Registers the callback for notification that the routing socket acceptor should stop accepting new connections. More...
 
void unregister_stop_router_socket_acceptor ()
 Unregisters the callback registered with register_stop_router_socket_acceptor(). More...
 
void register_md_refresh_callback (const MetadataRefreshCallback &callback)
 Registers a callback that is going to be used on metadata refresh. More...
 
void unregister_md_refresh_callback ()
 Unregisters the callback registered with register_md_refresh_callback(). More...
 
void register_query_quarantined_destinations (const QueryQuarantinedDestinationsCallback &clb)
 Registers a callback that could be used for checking if the provided destination candidate is currently quarantined. More...
 
void unregister_query_quarantined_destinations ()
 Unregisters the callback registered with register_query_quarantined_destinations(). More...
 
virtual bool is_dynamic ()
 Specifies if the destination addresses can be added/removed from the set. More...
 
virtual std::string get_dynamic_plugin_name ()
 

Protected Member Functions

const MySQLRoutingContextget_routing_context () const
 

Protected Attributes

net::io_contextio_ctx_
 
MySQLRoutingContextrouting_ctx_
 
std::mutex state_mtx_
 
std::error_code last_ec_
 
- Protected Attributes inherited from DestinationNodesStateNotifier
AllowedNodesChangeCallbacksList allowed_nodes_change_callbacks_
 
MetadataRefreshCallback md_refresh_callback_
 
StartSocketAcceptorCallback start_router_socket_acceptor_callback_
 
StopSocketAcceptorCallback stop_router_socket_acceptor_callback_
 
QueryQuarantinedDestinationsCallback query_quarantined_destinations_callback_
 
std::mutex allowed_nodes_change_callbacks_mtx_
 
std::mutex md_refresh_callback_mtx_
 
std::mutex socket_acceptor_handle_callbacks_mtx
 
std::mutex query_quarantined_destinations_callback_mtx_
 

Detailed Description

Manage destinations for a Connection Routing.

This class manages destinations which are used in Connection Routing. A destination is usually a MySQL Server and is stored using the IP or hostname together with the TCP port (defaulting to 3306 for classic protocol or to 33060 for x protocol).

Member Typedef Documentation

◆ DestVector

Constructor & Destructor Documentation

◆ DestinationManager() [1/3]

DestinationManager::DestinationManager ( net::io_context io_ctx,
MySQLRoutingContext routing_ctx 
)
inline

Default constructor.

Parameters
io_ctxIO context
routing_ctxRouting context

◆ ~DestinationManager()

virtual DestinationManager::~DestinationManager ( )
virtualdefault

Destructor.

◆ DestinationManager() [2/3]

DestinationManager::DestinationManager ( const DestinationManager other)
delete

◆ DestinationManager() [3/3]

DestinationManager::DestinationManager ( DestinationManager &&  other)
delete

Member Function Documentation

◆ connect_status()

virtual void DestinationManager::connect_status ( std::error_code  ec)
pure virtual

◆ get_destination_candidates()

virtual std::vector< mysql_harness::Destination > DestinationManager::get_destination_candidates ( ) const
pure virtual

Get addresses of all nodes that are a possible destination candidates.

Implemented in DestMetadataCacheManager, and StaticDestinationsManager.

◆ get_last_used_destination()

virtual std::unique_ptr< Destination > DestinationManager::get_last_used_destination ( ) const
pure virtual

Get destination that was selected as a destination candidate.

Implemented in DestMetadataCacheManager, and StaticDestinationsManager.

◆ get_next_destination()

virtual std::unique_ptr< Destination > DestinationManager::get_next_destination ( const routing_guidelines::Session_info )
pure virtual

Get destination that should be used for connection attempt.

It uses routing strategies and internal information (last used indexes, failed attempt information) for destination selection.

Returns
Destination candidate used for connection attempt.

Implemented in StaticDestinationsManager, and DestMetadataCacheManager.

◆ get_router_info()

routing_guidelines::Router_info DestinationManager::get_router_info ( ) const
inline

Get information about this given Router instance.

◆ get_routing_context()

const MySQLRoutingContext & DestinationManager::get_routing_context ( ) const
inlineprotected

◆ handle_sockets_acceptors()

virtual void DestinationManager::handle_sockets_acceptors ( )
pure virtual

Trigger listening socket acceptors state handler based on the destination type.

Implemented in DestMetadataCacheManager, and StaticDestinationsManager.

◆ has_read_only()

virtual bool DestinationManager::has_read_only ( ) const
pure virtual

Check if there are read-only destinations that could be used.

Implemented in DestMetadataCacheManager, and StaticDestinationsManager.

◆ has_read_write()

virtual bool DestinationManager::has_read_write ( ) const
pure virtual

Check if there are read-write destinations that could be used.

Implemented in DestMetadataCacheManager, and StaticDestinationsManager.

◆ init_destinations()

virtual stdx::expected< void, std::error_code > DestinationManager::init_destinations ( const routing_guidelines::Session_info session_info)
pure virtual

Set up destination manager, prepare the destinations.

Returns
error code on failure

Implemented in StaticDestinationsManager, and DestMetadataCacheManager.

◆ operator=() [1/2]

DestinationManager & DestinationManager::operator= ( const DestinationManager other)
delete

◆ operator=() [2/2]

DestinationManager & DestinationManager::operator= ( DestinationManager &&  other)
delete

◆ purpose()

virtual mysqlrouter::ServerMode DestinationManager::purpose ( ) const
inlinevirtual

Reimplemented in DestMetadataCacheManager.

◆ refresh_destinations()

virtual bool DestinationManager::refresh_destinations ( const routing_guidelines::Session_info )
pure virtual

refresh destinations.

should be called after connecting to all destinations failed.

Return values
truerefresh suceeded, there are destinations that could be used.
falserefresh failed, there are no destinations that could be used.

Implemented in StaticDestinationsManager, and DestMetadataCacheManager.

◆ routing_guidelines_session_rand_used()

bool DestinationManager::routing_guidelines_session_rand_used ( ) const
inline

Check if routing guidelines uses $.session.rand as a match criterion.

◆ start()

virtual void DestinationManager::start ( const mysql_harness::PluginFuncEnv env)
pure virtual

Start the destination manager.

Parameters
envpointer to the PluginFuncEnv object

Implemented in StaticDestinationsManager, and DestMetadataCacheManager.

Member Data Documentation

◆ io_ctx_

net::io_context& DestinationManager::io_ctx_
protected

◆ last_ec_

std::error_code DestinationManager::last_ec_
protected

◆ routing_ctx_

MySQLRoutingContext& DestinationManager::routing_ctx_
protected

◆ state_mtx_

std::mutex DestinationManager::state_mtx_
protected

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