MySQL 8.0.40
Source Code Documentation
RouteDestination Class Referenceabstract

Manage destinations for a Connection Routing. More...

#include <destination.h>

Inheritance diagram for RouteDestination:
[legend]

Public Types

using AddrVector = std::vector< mysql_harness::TCPAddress >
 

Public Member Functions

 RouteDestination (net::io_context &io_ctx, Protocol::Type protocol=Protocol::get_default())
 Default constructor. More...
 
virtual ~RouteDestination ()=default
 Destructor. More...
 
 RouteDestination (const RouteDestination &other)=delete
 
 RouteDestination (RouteDestination &&other)=delete
 
RouteDestinationoperator= (const RouteDestination &other)=delete
 
RouteDestinationoperator= (RouteDestination &&other)=delete
 
virtual routing::RoutingStrategy get_strategy ()=0
 Return our routing strategy. More...
 
virtual void add (const mysql_harness::TCPAddress dest)
 Adds a destination. More...
 
virtual void add (const std::string &address, uint16_t port)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
virtual void remove (const std::string &address, uint16_t port)
 Removes a destination. More...
 
virtual mysql_harness::TCPAddress get (const std::string &address, uint16_t port)
 Gets destination based on address and port. More...
 
virtual void clear ()
 Removes all destinations. More...
 
size_t size () noexcept
 Gets the number of destinations. More...
 
virtual bool empty () const noexcept
 Returns whether there are destinations. More...
 
virtual void start (const mysql_harness::PluginFuncEnv *env)
 Start the destination threads (if any) More...
 
AddrVector::iterator begin ()
 
AddrVector::const_iterator begin () const
 
AddrVector::iterator end ()
 
AddrVector::const_iterator end () const
 
virtual AddrVector get_destinations () const
 
virtual Destinations destinations ()=0
 get destinations to connect() to. More...
 
virtual std::optional< Destinationsrefresh_destinations (const Destinations &dests)
 refresh destinations. More...
 
virtual void handle_sockets_acceptors ()
 Trigger listening socket acceptors state handler based on the destination type. 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...
 
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...
 

Protected Attributes

AddrVector destinations_
 List of destinations. More...
 
std::mutex mutex_update_
 Mutex for updating destinations and iterator. More...
 
net::io_contextio_ctx_
 
Protocol::Type protocol_
 Protocol for the destination. More...
 
- 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).

RouteDestination is meant to be a base class and used to inherite and create class which change the behavior. For example, the get_next() method is usually changed to get the next server in the list.

Member Typedef Documentation

◆ AddrVector

Constructor & Destructor Documentation

◆ RouteDestination() [1/3]

RouteDestination::RouteDestination ( net::io_context io_ctx,
Protocol::Type  protocol = Protocol::get_default() 
)
inline

Default constructor.

Parameters
io_ctxcontext for IO operations
protocolProtocol for the destination, defaults to value returned by Protocol::get_default()

◆ ~RouteDestination()

virtual RouteDestination::~RouteDestination ( )
virtualdefault

Destructor.

◆ RouteDestination() [2/3]

RouteDestination::RouteDestination ( const RouteDestination other)
delete

◆ RouteDestination() [3/3]

RouteDestination::RouteDestination ( RouteDestination &&  other)
delete

Member Function Documentation

◆ add() [1/2]

void RouteDestination::add ( const mysql_harness::TCPAddress  dest)
virtual

Adds a destination.

Adds a destination using the given address and port number.

Parameters
destdestination address

Reimplemented in DestMetadataCacheGroup.

◆ add() [2/2]

void RouteDestination::add ( const std::string &  address,
uint16_t  port 
)
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Reimplemented in DestMetadataCacheGroup.

◆ begin() [1/2]

AddrVector::iterator RouteDestination::begin ( )
inline

◆ begin() [2/2]

AddrVector::const_iterator RouteDestination::begin ( ) const
inline

◆ clear()

void RouteDestination::clear ( )
virtual

Removes all destinations.

Removes all destinations from the list.

◆ destinations()

virtual Destinations RouteDestination::destinations ( )
pure virtual

get destinations to connect() to.

destinations are in order of preference.

Implemented in DestFirstAvailable, DestMetadataCacheGroup, DestNextAvailable, and DestRoundRobin.

◆ empty()

virtual bool RouteDestination::empty ( ) const
inlinevirtualnoexcept

Returns whether there are destinations.

Returns
whether the destination is empty

Reimplemented in DestMetadataCacheGroup.

◆ end() [1/2]

AddrVector::iterator RouteDestination::end ( )
inline

◆ end() [2/2]

AddrVector::const_iterator RouteDestination::end ( ) const
inline

◆ get()

TCPAddress RouteDestination::get ( const std::string &  address,
uint16_t  port 
)
virtual

Gets destination based on address and port.

Gets destination base on given address and port and returns a pair with the information.

Raises std::out_of_range when the combination of address and port is not in the list of destinations.

This function can be used to check whether given destination is in the list.

Parameters
addressIP or name
portPort number
Returns
an instance of mysql_harness::TCPAddress

◆ get_destinations()

std::vector< mysql_harness::TCPAddress > RouteDestination::get_destinations ( ) const
virtual

Reimplemented in DestMetadataCacheGroup.

◆ get_strategy()

virtual routing::RoutingStrategy RouteDestination::get_strategy ( )
pure virtual

Return our routing strategy.

Implemented in DestFirstAvailable, DestMetadataCacheGroup, DestNextAvailable, and DestRoundRobin.

◆ handle_sockets_acceptors()

virtual void RouteDestination::handle_sockets_acceptors ( )
inlinevirtual

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

Reimplemented in DestMetadataCacheGroup.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ refresh_destinations()

std::optional< Destinations > RouteDestination::refresh_destinations ( const Destinations dests)
virtual

refresh destinations.

should be called after connecting to all destinations failed.

Parameters
destsprevious destinations.
Returns
new destinations, if there are any.

Reimplemented in DestMetadataCacheGroup.

◆ remove()

void RouteDestination::remove ( const std::string &  address,
uint16_t  port 
)
virtual

Removes a destination.

Removes a destination using the given address and port number.

Parameters
addressIP or name
portPort number

◆ size()

size_t RouteDestination::size ( )
noexcept

Gets the number of destinations.

Gets the number of destinations currently in the list.

Returns
Number of destinations as size_t

◆ start()

void RouteDestination::start ( const mysql_harness::PluginFuncEnv env)
virtual

Start the destination threads (if any)

Parameters
envpointer to the PluginFuncEnv object

Reimplemented in DestMetadataCacheGroup.

Member Data Documentation

◆ destinations_

AddrVector RouteDestination::destinations_
protected

List of destinations.

◆ io_ctx_

net::io_context& RouteDestination::io_ctx_
protected

◆ mutex_update_

std::mutex RouteDestination::mutex_update_
protected

Mutex for updating destinations and iterator.

◆ protocol_

Protocol::Type RouteDestination::protocol_
protected

Protocol for the destination.


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