MySQL 9.3.0
Source Code Documentation
schema_monitor.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2021, 2025, 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
32
36#include "mrs/configuration.h"
42#include "mrs/gtid_manager.h"
46
47namespace mrs {
48namespace database {
49
51 public:
54 mrs::EndpointManager *dbobject_manager,
57 mrs::GtidManager *gtid_manager,
59 mrs::ResponseCache *response_cache,
60 mrs::ResponseCache *file_cache,
61 SlowQueryMonitor *slow_query_monitor);
63
64 void start();
65 void stop();
66 void reset();
67
68 private:
70 public:
72 const bool is_dynamic)
73 : cache_{cache}, is_dynamic_{is_dynamic} {}
74
75 std::optional<collector::MysqlCacheManager::CachedObject> get_rw_session();
76 bool handle_error();
77
78 private:
80
82 DestinationState::k_read_only}; // initialize with read-only to force
83 // check on the first run
85
87 const bool is_dynamic_;
88 };
89
90 void run();
92
93 class Waitable : public WaitableMonitor<void *> {
94 public:
96 using Parent::WaitableMonitor;
97 };
98
100
114};
115
116} // namespace database
117} // namespace mrs
118
119#endif // ROUTER_SRC_REST_MRS_SRC_MRS_MONITOR_H_
Monitor can be waited for.
Definition: monitor.h:62
Definition: wait_variable.h:34
Definition: mysql_cache_manager.h:87
Definition: configuration.h:47
Definition: endpoint_manager.h:55
Definition: gtid_manager.h:50
Definition: response_cache.h:64
Definition: authorize_manager.h:52
Definition: query_factory_proxy.h:38
bool handle_error()
Definition: schema_monitor.cc:435
DestinationState current_destination_state_
Definition: schema_monitor.h:81
collector::MysqlCacheManager * cache_
Definition: schema_monitor.h:86
DestinationState previous_destination_state_
Definition: schema_monitor.h:84
MetadataSourceDestination(collector::MysqlCacheManager *cache, const bool is_dynamic)
Definition: schema_monitor.h:71
const bool is_dynamic_
Definition: schema_monitor.h:87
std::optional< collector::MysqlCacheManager::CachedObject > get_rw_session()
Definition: schema_monitor.cc:386
Definition: schema_monitor.h:93
Definition: schema_monitor.h:50
collector::MysqlCacheManager * cache_
Definition: schema_monitor.h:102
mrs::GtidManager * gtid_manager_
Definition: schema_monitor.h:106
void stop()
Definition: schema_monitor.cc:166
void run()
Definition: schema_monitor.cc:197
mrs::EndpointManager * dbobject_manager_
Definition: schema_monitor.h:103
~SchemaMonitor()
Definition: schema_monitor.cc:157
mrs::observability::EntitiesManager * entities_manager_
Definition: schema_monitor.h:105
mrs::ResponseCache * response_cache_
Definition: schema_monitor.h:110
MetadataSourceDestination md_source_destination_
Definition: schema_monitor.h:113
const mrs::Configuration configuration_
Definition: schema_monitor.h:101
SlowQueryMonitor * slow_query_monitor_
Definition: schema_monitor.h:112
void start()
Definition: schema_monitor.cc:159
void reset()
Definition: schema_monitor.cc:175
bool wait_until_next_refresh()
Definition: schema_monitor.cc:378
mrs::ResponseCache * file_cache_
Definition: schema_monitor.h:111
WaitableVariable< State > state_
Definition: schema_monitor.h:107
State
Definition: schema_monitor.h:99
@ k_running
Definition: schema_monitor.h:99
@ k_stopped
Definition: schema_monitor.h:99
@ k_initializing
Definition: schema_monitor.h:99
mrs::authentication::AuthorizeManager * auth_manager_
Definition: schema_monitor.h:104
mrs::database::QueryFactoryProxy * proxy_query_factory_
Definition: schema_monitor.h:109
Waitable waitable_
Definition: schema_monitor.h:108
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)
Definition: schema_monitor.cc:135
Definition: slow_query_monitor.h:47
Definition: entities_manager.h:39
Definition: authorize_manager.h:48
required string configuration
Definition: replication_asynchronous_connection_failover.proto:49