26#ifndef ROUTING_CONNECTION_CONTAINER_INCLUDED
27#define ROUTING_CONNECTION_CONTAINER_INCLUDED
52template <
typename Key,
typename Value,
typename Hash = std::hash<Key>>
61 const Hash &hasher = Hash())
67 template <
typename Predicate>
72 template <
typename Predicate>
75 each_bucket.for_each(
p);
88 result += each_bucket.size();
94 for (
const auto &each_bucket :
buckets_) {
95 if (!each_bucket.empty())
return false;
107 data_.emplace(
key, std::move(value));
115 template <
typename Predicate>
119 if (found !=
data_.end())
p(found->second);
122 template <
typename Predicate>
135 return data_.empty();
169 std::shared_ptr<MySQLRoutingConnectionBase>>
176 std::vector<ConnData> connection_datas;
180 const auto stats = conn.second->get_stats();
182 connection_datas.push_back({
183 conn.second->get_client_address(),
184 conn.second->get_server_address(),
188 stats.connected_to_server,
189 stats.last_sent_to_server,
190 stats.last_received_from_server,
194 return connection_datas;
201 void add_connection(std::shared_ptr<MySQLRoutingConnectionBase> connection);
225 const std::string &client_endpoint);
container for connections to MySQL Server.
Definition: connection_container.h:167
void disconnect_all()
Disconnects all connection in the ConnectionContainer.
Definition: connection_container.cc:78
std::vector< ConnData > get_all_connections_info()
Definition: connection_container.h:175
bool empty() const
check if container is empty.
Definition: connection_container.h:248
unsigned disconnect(const AllowedNodes &nodes)
Disconnects all connections to servers that are not allowed any longer.
Definition: connection_container.cc:36
std::mutex connection_removed_cond_m_
Definition: connection_container.h:240
std::condition_variable connection_removed_cond_
number of active client threads.
Definition: connection_container.h:239
MySQLRoutingConnectionBase * get_connection(const std::string &client_endpoint)
Retrieve the connection object for the given client endpoint.
Definition: connection_container.cc:61
void add_connection(std::shared_ptr< MySQLRoutingConnectionBase > connection)
Adds new connection to container.
Definition: connection_container.cc:31
void remove_connection(MySQLRoutingConnectionBase *connection)
removes connection from container
Definition: connection_container.cc:83
concurrent_map< MySQLRoutingConnectionBase *, std::shared_ptr< MySQLRoutingConnectionBase > > connections_
Definition: connection_container.h:170
Definition: connection.h:43
a nullable SQL value.
Definition: sql_value.h:40
Definition: connection_container.h:103
std::mutex data_mutex_
Definition: connection_container.h:144
std::size_t size() const
Definition: connection_container.h:128
void for_each(Predicate &p)
Definition: connection_container.h:123
BucketData data_
Definition: connection_container.h:143
typename BucketData::iterator BucketIterator
Definition: connection_container.h:140
void put(const Key &key, Value &&value)
Definition: connection_container.h:105
std::map< Key, Value > BucketData
Definition: connection_container.h:139
typename BucketData::const_iterator ConstBucketIterator
Definition: connection_container.h:141
void for_one(const Key &key, Predicate &p)
Definition: connection_container.h:116
void erase(const Key &key)
Definition: connection_container.h:110
bool empty() const
Definition: connection_container.h:133
Basic Concurrent Map.
Definition: connection_container.h:53
concurrent_map(const concurrent_map &other)=delete
concurrent_map(unsigned num_buckets=kDefaultNumberOfBucket, const Hash &hasher=Hash())
Definition: connection_container.h:60
void erase(const Key &key)
Definition: connection_container.h:83
std::size_t size() const
Definition: connection_container.h:85
Bucket & get_bucket(const Key &key)
Definition: connection_container.h:150
static const unsigned kDefaultNumberOfBucket
Definition: connection_container.h:101
void for_each(Predicate p)
Definition: connection_container.h:73
void for_one(const Key &key, Predicate &p)
Definition: connection_container.h:68
concurrent_map & operator=(const concurrent_map &other)=delete
Hash hasher_
Definition: connection_container.h:148
void put(const Key &key, Value &&value)
Definition: connection_container.h:79
const Bucket & get_bucket(const Key &key) const
Definition: connection_container.h:155
bool empty() const
Definition: connection_container.h:93
Hash hash_type
Definition: connection_container.h:57
typename std::map< Key, Value >::value_type value_type
Definition: connection_container.h:58
std::vector< Bucket > buckets_
Definition: connection_container.h:147
Key key_type
Definition: connection_container.h:55
const char * p
Definition: ctype-mb.cc:1237
std::vector< AvailableDestination > AllowedNodes
Definition: destination_status_types.h:59
void for_each(const Shards< COUNT > &shards, Function &&f) noexcept
Iterate over the shards.
Definition: ut0counter.h:323
uint16_t value_type
Definition: vt100.h:184
std::string_view Key
The key type for the hash structure in HashJoinRowBuffer.
Definition: hash_join_buffer.h:102
static std::mutex lock
Definition: net_ns.cc:56
struct result result
Definition: result.h:34
required string key
Definition: replication_asynchronous_connection_failover.proto:60
Definition: routing_component.h:74
A filter of some sort that is not a join condition (those are stored in JoinPredicate objects).
Definition: access_path.h:117
Definition: mysqlslap.cc:238