MySQL 8.4.0
Source Code Documentation
ConnectionContainer Class Reference

container for connections to MySQL Server. More...

#include <connection_container.h>

Public Types

using ConnData = MySQLRoutingAPI::ConnData
 

Public Member Functions

std::vector< ConnDataget_all_connections_info ()
 
void add_connection (std::shared_ptr< MySQLRoutingConnectionBase > connection)
 Adds new connection to container. More...
 
unsigned disconnect (const AllowedNodes &nodes)
 Disconnects all connections to servers that are not allowed any longer. More...
 
void disconnect_all ()
 Disconnects all connection in the ConnectionContainer. More...
 
MySQLRoutingConnectionBaseget_connection (const std::string &client_endpoint)
 Retrieve the connection object for the given client endpoint. More...
 
void remove_connection (MySQLRoutingConnectionBase *connection)
 removes connection from container More...
 
bool empty () const
 check if container is empty. More...
 

Public Attributes

std::condition_variable connection_removed_cond_
 number of active client threads. More...
 
std::mutex connection_removed_cond_m_
 

Private Attributes

concurrent_map< MySQLRoutingConnectionBase *, std::shared_ptr< MySQLRoutingConnectionBase > > connections_
 

Detailed Description

container for connections to MySQL Server.

When thread of execution for connection to MySQL Server is completed, it should call remove_connection to remove itself from connection container.

Member Typedef Documentation

◆ ConnData

Member Function Documentation

◆ add_connection()

void ConnectionContainer::add_connection ( std::shared_ptr< MySQLRoutingConnectionBase connection)

Adds new connection to container.

Parameters
connectionThe connection to MySQL server

◆ disconnect()

unsigned ConnectionContainer::disconnect ( const AllowedNodes nodes)

Disconnects all connections to servers that are not allowed any longer.

Parameters
nodesAllowed servers. Connections to servers that are not in nodes are closed.
Returns
number of connections marked to be disconnected

◆ disconnect_all()

void ConnectionContainer::disconnect_all ( )

Disconnects all connection in the ConnectionContainer.

◆ empty()

bool ConnectionContainer::empty ( ) const
inline

check if container is empty.

as the map is concurrent, empty() only gives a reasonable result if it is ensured no other thread is currently adding connections.

◆ get_all_connections_info()

std::vector< ConnData > ConnectionContainer::get_all_connections_info ( )
inline

◆ get_connection()

MySQLRoutingConnectionBase * ConnectionContainer::get_connection ( const std::string &  client_endpoint)

Retrieve the connection object for the given client endpoint.

Parameters
client_endpointThe endpoint string
Returns
the connection object, or nullptr

◆ remove_connection()

void ConnectionContainer::remove_connection ( MySQLRoutingConnectionBase connection)

removes connection from container

This function should be called by thread of execution when connection thread completes. Do NOT call this function before connection's thread of execution completes.

Parameters
connectionThe connection to remove from container

Member Data Documentation

◆ connection_removed_cond_

std::condition_variable ConnectionContainer::connection_removed_cond_

number of active client threads.

◆ connection_removed_cond_m_

std::mutex ConnectionContainer::connection_removed_cond_m_

◆ connections_

concurrent_map<MySQLRoutingConnectionBase *, std::shared_ptr<MySQLRoutingConnectionBase> > ConnectionContainer::connections_
private

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