26#ifndef METADATA_CACHE_METADATA_CACHE_INCLUDED
27#define METADATA_CACHE_METADATA_CACHE_INCLUDED
78 const unsigned router_id,
const std::string &clusterset_id,
79 const std::vector<mysql_harness::TCPAddress> &metadata_servers,
80 std::shared_ptr<MetaData> cluster_metadata,
86 bool use_cluster_notifications =
false);
100 void stop()
noexcept;
137 bool wait_primary_failover(
const std::string &
server_uuid,
141 void refresh_thread();
144 static void *run_thread(
void *context);
171 void add_acceptor_handler_listener(
180 void remove_acceptor_handler_listener(
188 void add_md_refresh_listener(
197 void remove_md_refresh_listener(
201 return stats_([](
auto const &
stats)
203 return {
stats.refresh_failed,
204 stats.refresh_succeeded,
205 stats.last_refresh_succeeded,
206 stats.last_refresh_failed,
207 stats.last_metadata_server_host,
208 stats.last_metadata_server_port};
212 std::chrono::milliseconds
ttl()
const {
return ttl_config_.ttl; }
219 void enable_fetch_auth_metadata() { auth_metadata_fetch_enabled_ =
true; }
223 void check_auth_metadata_timers()
const;
225 std::pair<bool, MetaData::auth_credentials_t::mapped_type>
226 get_rest_user_auth_data(
const std::string &
user);
232 trigger_acceptor_update_on_next_refresh_ =
true;
237 void fetch_whole_topology(
bool val);
243 virtual bool refresh(
bool needs_writable_node) = 0;
245 void on_refresh_failed(
bool terminated,
bool md_servers_reachable =
false);
246 void on_refresh_succeeded(
251 void on_instances_changed(
252 const bool md_servers_reachable,
254 uint64_t view_id = 0);
261 void on_handle_sockets_acceptors();
270 void on_md_refresh(
const bool cluster_nodes_changed,
274 void on_refresh_requested();
277 void on_refresh_completed();
280 bool update_auth_cache();
283 void update_router_attributes();
286 void update_router_last_check_in();
321 bool auth_metadata_fetch_enabled_{
false};
343 std::atomic<bool> terminated_{
false};
345 bool refresh_requested_{
false};
360 std::set<metadata_cache::AcceptorUpdateHandlerInterface *>
362 std::set<metadata_cache::MetadataRefreshListenerInterface *>
368 uint64_t refresh_failed{0};
369 uint64_t refresh_succeeded{0};
377 bool initial_attributes_update_done_{
false};
378 uint32_t periodic_stats_update_counter_{1};
379 std::chrono::steady_clock::time_point last_periodic_stats_update_timestamp_{
380 std::chrono::steady_clock::now()};
382 bool ready_announced_{
false};
383 std::atomic<bool> fetch_whole_topology_{
false};
389 std::atomic<bool> trigger_acceptor_update_on_next_refresh_{
false};
393 bool needs_initial_attributes_update();
394 bool needs_last_check_in_update();
Monitor pattern.
Definition: monitor.h:39
MySQLRouterThread provides higher level interface to managing threads.
Definition: mysql_router_thread.h:77
Defines an IP address with port number
Definition: tcp_address.h:40
Definition: cluster_metadata.h:161
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:177
Logging interface for using and extending the logging subsystem.
char * user
Definition: mysqladmin.cc:60
char server_uuid[UUID_LENGTH+1]
Definition: mysqld.cc:1468
static bool timeout(bool(*wait_condition)())
Timeout function.
Definition: log0meb.cc:496
static const size_t kDefaultStackSizeInKiloBytes
Definition: mysql_router_thread.h:44
ClusterType
Definition: cluster_metadata.h:141
Definition: gcs_xcom_synode.h:64
mode
Definition: file_handle.h:60
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2875
SSL connection related options.
Definition: datatypes.h:39
Definition: mysqlslap.cc:238
double seconds()
Definition: task.cc:310