MySQL 26.10.0
Source Code Documentation
schema_monitor.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2021, 2026, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef ROUTER_SRC_REST_MRS_SRC_MRS_MONITOR_H_
27#define ROUTER_SRC_REST_MRS_SRC_MRS_MONITOR_H_
28
29#include <vector>
30
33#include "mrs/configuration.h"
40#include "mrs/gtid_manager.h"
44
47
48namespace mrs {
49
50class MrsStartObserver;
51
52namespace database {
53
55 public:
58 mrs::EndpointManager *dbobject_manager,
61 mrs::GtidManager *gtid_manager,
63 mrs::ResponseCache *response_cache,
64 mrs::ResponseCache *file_cache,
65 SlowQueryMonitor *slow_query_monitor,
66 MetadataLogger *metadata_logger);
68
69 // Notify the observer after entering the running state and before starting
70 // the blocking run loop.
71 void start(MrsStartObserver *observer);
72 void stop();
73 void reset();
74
75 private:
76 template <typename T>
78
80 public:
82 const bool is_dynamic)
83 : cache_{cache}, is_dynamic_{is_dynamic} {}
84
85 std::optional<collector::MysqlCacheManager::CachedObject> get_rw_session();
86 bool handle_error();
87
88 private:
90
92 DestinationState::k_read_only}; // initialize with read-only to force
93 // check on the first run
95
97 const bool is_dynamic_;
98 };
99
100 void run();
102 std::pair<std::string, std::string> get_router_name_and_address();
103
104 class Waitable : public WaitableMonitor<void *> {
105 public:
107 using Parent::WaitableMonitor;
108 };
109
111
113 std::optional<std::string> router_name_;
127};
128
129} // namespace database
130} // namespace mrs
131
132#endif // ROUTER_SRC_REST_MRS_SRC_MRS_MONITOR_H_
Monitor can be waited for.
Definition: monitor.h:62
Definition: mysql_cache_manager.h:82
Definition: configuration.h:49
Definition: endpoint_manager.h:55
Definition: gtid_manager.h:50
Definition: mrs_start_observer.h:33
Definition: response_cache.h:66
Definition: authorize_manager.h:52
Definition: metadata_logger.h:74
Definition: query_factory_proxy.h:38
bool handle_error()
Definition: schema_monitor.cc:501
DestinationState current_destination_state_
Definition: schema_monitor.h:91
collector::MysqlCacheManager * cache_
Definition: schema_monitor.h:96
DestinationState previous_destination_state_
Definition: schema_monitor.h:94
MetadataSourceDestination(collector::MysqlCacheManager *cache, const bool is_dynamic)
Definition: schema_monitor.h:81
const bool is_dynamic_
Definition: schema_monitor.h:97
std::optional< collector::MysqlCacheManager::CachedObject > get_rw_session()
Definition: schema_monitor.cc:455
Definition: schema_monitor.h:104
Definition: schema_monitor.h:54
collector::MysqlCacheManager * cache_
Definition: schema_monitor.h:114
mrs::GtidManager * gtid_manager_
Definition: schema_monitor.h:118
void stop()
Definition: schema_monitor.cc:177
void run()
Definition: schema_monitor.cc:208
mrs::EndpointManager * dbobject_manager_
Definition: schema_monitor.h:115
~SchemaMonitor()
Definition: schema_monitor.cc:162
std::pair< std::string, std::string > get_router_name_and_address()
Definition: schema_monitor.cc:428
mrs::observability::EntitiesManager * entities_manager_
Definition: schema_monitor.h:117
mrs::ResponseCache * response_cache_
Definition: schema_monitor.h:122
SchemaMonitor(const mrs::Configuration &configuration, collector::MysqlCacheManager *cache, mrs::EndpointManager *dbobject_manager, authentication::AuthorizeManager *auth_manager, mrs::observability::EntitiesManager *entities_manager, mrs::GtidManager *gtid_manager, mrs::database::QueryFactoryProxy *query_factory, mrs::ResponseCache *response_cache, mrs::ResponseCache *file_cache, SlowQueryMonitor *slow_query_monitor, MetadataLogger *metadata_logger)
Definition: schema_monitor.cc:138
MetadataSourceDestination md_source_destination_
Definition: schema_monitor.h:126
const mrs::Configuration configuration_
Definition: schema_monitor.h:112
void start(MrsStartObserver *observer)
Definition: schema_monitor.cc:164
SlowQueryMonitor * slow_query_monitor_
Definition: schema_monitor.h:124
std::optional< std::string > router_name_
Definition: schema_monitor.h:113
void reset()
Definition: schema_monitor.cc:186
bool wait_until_next_refresh()
Definition: schema_monitor.cc:420
mrs::ResponseCache * file_cache_
Definition: schema_monitor.h:123
WaitableVariable< State > state_
Definition: schema_monitor.h:119
MetadataLogger * metadata_logger_
Definition: schema_monitor.h:125
State
Definition: schema_monitor.h:110
@ k_running
Definition: schema_monitor.h:110
@ k_stopped
Definition: schema_monitor.h:110
@ k_initializing
Definition: schema_monitor.h:110
mrs::authentication::AuthorizeManager * auth_manager_
Definition: schema_monitor.h:116
mrs::database::QueryFactoryProxy * proxy_query_factory_
Definition: schema_monitor.h:121
Waitable waitable_
Definition: schema_monitor.h:120
Definition: slow_query_monitor.h:47
Definition: entities_manager.h:40
Definition: wait_variable.h:37
Definition: authorize_manager.h:48
required string configuration
Definition: replication_asynchronous_connection_failover.proto:49