MySQL 9.4.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"
43#include "mrs/gtid_manager.h"
47
48namespace mrs {
49namespace database {
50
52 public:
55 mrs::EndpointManager *dbobject_manager,
58 mrs::GtidManager *gtid_manager,
60 mrs::ResponseCache *response_cache,
61 mrs::ResponseCache *file_cache,
62 SlowQueryMonitor *slow_query_monitor,
63 MetadataLogger *metadata_logger);
65
66 void start();
67 void stop();
68 void reset();
69
70 private:
72 public:
74 const bool is_dynamic)
75 : cache_{cache}, is_dynamic_{is_dynamic} {}
76
77 std::optional<collector::MysqlCacheManager::CachedObject> get_rw_session();
78 bool handle_error();
79
80 private:
82
84 DestinationState::k_read_only}; // initialize with read-only to force
85 // check on the first run
87
89 const bool is_dynamic_;
90 };
91
92 void run();
94 std::pair<std::string, std::string> get_router_name_and_address();
95
96 class Waitable : public WaitableMonitor<void *> {
97 public:
99 using Parent::WaitableMonitor;
100 };
101
103
105 std::optional<std::string> router_name_;
119};
120
121} // namespace database
122} // namespace mrs
123
124#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:49
Definition: endpoint_manager.h:55
Definition: gtid_manager.h:50
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:486
DestinationState current_destination_state_
Definition: schema_monitor.h:83
collector::MysqlCacheManager * cache_
Definition: schema_monitor.h:88
DestinationState previous_destination_state_
Definition: schema_monitor.h:86
MetadataSourceDestination(collector::MysqlCacheManager *cache, const bool is_dynamic)
Definition: schema_monitor.h:73
const bool is_dynamic_
Definition: schema_monitor.h:89
std::optional< collector::MysqlCacheManager::CachedObject > get_rw_session()
Definition: schema_monitor.cc:437
Definition: schema_monitor.h:96
Definition: schema_monitor.h:51
collector::MysqlCacheManager * cache_
Definition: schema_monitor.h:106
mrs::GtidManager * gtid_manager_
Definition: schema_monitor.h:110
void stop()
Definition: schema_monitor.cc:170
void run()
Definition: schema_monitor.cc:201
mrs::EndpointManager * dbobject_manager_
Definition: schema_monitor.h:107
~SchemaMonitor()
Definition: schema_monitor.cc:161
std::pair< std::string, std::string > get_router_name_and_address()
Definition: schema_monitor.cc:410
mrs::observability::EntitiesManager * entities_manager_
Definition: schema_monitor.h:109
mrs::ResponseCache * response_cache_
Definition: schema_monitor.h:114
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:137
MetadataSourceDestination md_source_destination_
Definition: schema_monitor.h:118
const mrs::Configuration configuration_
Definition: schema_monitor.h:104
SlowQueryMonitor * slow_query_monitor_
Definition: schema_monitor.h:116
std::optional< std::string > router_name_
Definition: schema_monitor.h:105
void start()
Definition: schema_monitor.cc:163
void reset()
Definition: schema_monitor.cc:179
bool wait_until_next_refresh()
Definition: schema_monitor.cc:402
mrs::ResponseCache * file_cache_
Definition: schema_monitor.h:115
WaitableVariable< State > state_
Definition: schema_monitor.h:111
MetadataLogger * metadata_logger_
Definition: schema_monitor.h:117
State
Definition: schema_monitor.h:102
@ k_running
Definition: schema_monitor.h:102
@ k_stopped
Definition: schema_monitor.h:102
@ k_initializing
Definition: schema_monitor.h:102
mrs::authentication::AuthorizeManager * auth_manager_
Definition: schema_monitor.h:108
mrs::database::QueryFactoryProxy * proxy_query_factory_
Definition: schema_monitor.h:113
Waitable waitable_
Definition: schema_monitor.h:112
Definition: slow_query_monitor.h:47
Definition: entities_manager.h:40
Definition: authorize_manager.h:48
required string configuration
Definition: replication_asynchronous_connection_failover.proto:49