MySQL 9.2.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
StaticDestinationsManager Class Referencefinal

#include <dest_static.h>

Inheritance diagram for StaticDestinationsManager:
[legend]

Public Member Functions

 StaticDestinationsManager (routing::RoutingStrategy strategy, net::io_context &io_ctx, MySQLRoutingContext &routing_ctx)
 
void add (const mysql_harness::Destination &dest)
 Adds a destination. More...
 
void start (const mysql_harness::PluginFuncEnv *) override
 Start the destination manager. More...
 
std::vector< mysql_harness::Destinationget_destination_candidates () const override
 Get addresses of all nodes that are a possible destination candidates. More...
 
bool refresh_destinations (const routing_guidelines::Session_info &) override
 refresh destinations. More...
 
void handle_sockets_acceptors () override
 Trigger listening socket acceptors state handler based on the destination type. More...
 
std::unique_ptr< Destinationget_next_destination (const routing_guidelines::Session_info &) override
 Get destination that should be used for connection attempt. More...
 
std::unique_ptr< Destinationget_last_used_destination () const override
 Get destination that was selected as a destination candidate. More...
 
stdx::expected< void, std::error_code > init_destinations (const routing_guidelines::Session_info &) override
 Set up destination manager, prepare the destinations. More...
 
void connect_status (std::error_code ec) override
 
bool has_read_write () const override
 Check if there are read-write destinations that could be used. More...
 
bool has_read_only () const override
 Check if there are read-only destinations that could be used. More...
 
- Public Member Functions inherited from DestinationManager
 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 mysqlrouter::ServerMode purpose () const
 
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...
 
- Public Member Functions inherited from DestinationNodesStateNotifier
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...
 

Private Attributes

std::unique_ptr< StrategyHandlerstrategy_handler_
 Get destination index based on routing strategy for static routes. More...
 
DestVector destinations_
 List of destinations. More...
 
Destination last_destination_
 
Protocol::Type protocol_
 Protocol for the endpoint. More...
 

Additional Inherited Members

- Public Types inherited from DestinationManager
using DestVector = std::vector< mysql_harness::Destination >
 
- Protected Member Functions inherited from DestinationManager
const MySQLRoutingContextget_routing_context () const
 
- Protected Attributes inherited from DestinationManager
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_
 
std::mutex allowed_nodes_change_callbacks_mtx_
 
std::mutex md_refresh_callback_mtx_
 
std::mutex socket_acceptor_handle_callbacks_mtx
 

Constructor & Destructor Documentation

◆ StaticDestinationsManager()

StaticDestinationsManager::StaticDestinationsManager ( routing::RoutingStrategy  strategy,
net::io_context io_ctx,
MySQLRoutingContext routing_ctx 
)

Member Function Documentation

◆ add()

void StaticDestinationsManager::add ( const mysql_harness::Destination dest)

Adds a destination.

Adds a destination using the given address and port number.

Parameters
destdestination address

◆ connect_status()

void StaticDestinationsManager::connect_status ( std::error_code  ec)
overridevirtual

Implements DestinationManager.

◆ get_destination_candidates()

std::vector< mysql_harness::Destination > StaticDestinationsManager::get_destination_candidates ( ) const
inlineoverridevirtual

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

Implements DestinationManager.

◆ get_last_used_destination()

std::unique_ptr< Destination > StaticDestinationsManager::get_last_used_destination ( ) const
inlineoverridevirtual

Get destination that was selected as a destination candidate.

Implements DestinationManager.

◆ get_next_destination()

std::unique_ptr< Destination > StaticDestinationsManager::get_next_destination ( const routing_guidelines::Session_info )
overridevirtual

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.

Implements DestinationManager.

◆ handle_sockets_acceptors()

void StaticDestinationsManager::handle_sockets_acceptors ( )
inlineoverridevirtual

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

Implements DestinationManager.

◆ has_read_only()

bool StaticDestinationsManager::has_read_only ( ) const
inlineoverridevirtual

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

Implements DestinationManager.

◆ has_read_write()

bool StaticDestinationsManager::has_read_write ( ) const
inlineoverridevirtual

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

Implements DestinationManager.

◆ init_destinations()

stdx::expected< void, std::error_code > StaticDestinationsManager::init_destinations ( const routing_guidelines::Session_info session_info)
inlineoverridevirtual

Set up destination manager, prepare the destinations.

Returns
error code on failure

Implements DestinationManager.

◆ refresh_destinations()

bool StaticDestinationsManager::refresh_destinations ( const routing_guidelines::Session_info )
inlineoverridevirtual

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.

Implements DestinationManager.

◆ start()

void StaticDestinationsManager::start ( const mysql_harness::PluginFuncEnv env)
overridevirtual

Start the destination manager.

Parameters
envpointer to the PluginFuncEnv object

Implements DestinationManager.

Member Data Documentation

◆ destinations_

DestVector StaticDestinationsManager::destinations_
private

List of destinations.

◆ last_destination_

Destination StaticDestinationsManager::last_destination_
private

◆ protocol_

Protocol::Type StaticDestinationsManager::protocol_
private

Protocol for the endpoint.

◆ strategy_handler_

std::unique_ptr<StrategyHandler> StaticDestinationsManager::strategy_handler_
private

Get destination index based on routing strategy for static routes.


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