MySQL 8.4.0
Source Code Documentation
metadata.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2016, 2024, 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 METADATA_CACHE_METADATA_INTERFACE_INCLUDED
27#define METADATA_CACHE_METADATA_INTERFACE_INCLUDED
28
30
31#include <atomic>
32#include <chrono>
33#include <map>
34#include <optional>
35#include <string>
36#include <vector>
37
38#include "my_rapidjson_size_t.h"
39
40#include <rapidjson/document.h>
41
46
47/**
48 * The metadata class is used to create a pluggable transport layer
49 * from which the metadata is fetched for the metadata cache.
50 */
52 public:
53 using JsonAllocator = rapidjson::CrtAllocator;
54 using JsonDocument = rapidjson::Document;
55 // username as key, password hash and privileges as value
57 std::map<std::string, std::pair<std::string, JsonDocument>>;
58
59 // fetch instances from vector of metadata servers
62 const std::atomic<bool> &terminated,
63 mysqlrouter::TargetCluster &target_cluster, const unsigned router_id,
64 const metadata_cache::metadata_servers_list_t &metadata_servers,
65 bool needs_writable_node, const std::string &clusterset_id,
66 bool whole_topology, std::size_t &instance_id) = 0;
67
69 const metadata_cache::metadata_server_t &rw_server,
70 const unsigned router_id,
71 const metadata_cache::RouterAttributes &router_attributes) = 0;
72
74 const metadata_cache::metadata_server_t &rw_server,
75 const unsigned router_id) = 0;
76
78 const metadata_cache::metadata_server_t &metadata_server) = 0;
79
80 virtual void disconnect() = 0;
81
83 const metadata_cache::ClusterTopology &cluster_topology,
84 const std::function<void()> &callback) = 0;
85
87
88 virtual std::shared_ptr<mysqlrouter::MySQLSession> get_connection() = 0;
89
91
93 const metadata_cache::metadata_server_t &md_server,
94 const mysqlrouter::TargetCluster &target_cluster) = 0;
95
96 virtual std::optional<std::chrono::seconds>
98
99 MetaData() = default;
100 // disable copy as it isn't needed right now. Feel free to enable
101 // must be explicitly defined though.
102 explicit MetaData(const MetaData &) = delete;
103 MetaData &operator=(const MetaData &) = delete;
104 virtual ~MetaData() = default;
105};
106
107#endif // METADATA_CACHE_METADATA_INTERFACE_INCLUDED
The metadata class is used to create a pluggable transport layer from which the metadata is fetched f...
Definition: metadata.h:51
virtual bool update_router_last_check_in(const metadata_cache::metadata_server_t &rw_server, const unsigned router_id)=0
virtual void disconnect()=0
rapidjson::CrtAllocator JsonAllocator
Definition: metadata.h:53
virtual bool connect_and_setup_session(const metadata_cache::metadata_server_t &metadata_server)=0
virtual mysqlrouter::ClusterType get_cluster_type()=0
rapidjson::Document JsonDocument
Definition: metadata.h:54
virtual std::optional< std::chrono::seconds > get_periodic_stats_update_frequency() noexcept=0
virtual stdx::expected< metadata_cache::ClusterTopology, std::error_code > fetch_cluster_topology(const std::atomic< bool > &terminated, mysqlrouter::TargetCluster &target_cluster, const unsigned router_id, const metadata_cache::metadata_servers_list_t &metadata_servers, bool needs_writable_node, const std::string &clusterset_id, bool whole_topology, std::size_t &instance_id)=0
virtual bool update_router_attributes(const metadata_cache::metadata_server_t &rw_server, const unsigned router_id, const metadata_cache::RouterAttributes &router_attributes)=0
virtual void shutdown_notifications_listener()=0
virtual void setup_notifications_listener(const metadata_cache::ClusterTopology &cluster_topology, const std::function< void()> &callback)=0
virtual std::shared_ptr< mysqlrouter::MySQLSession > get_connection()=0
virtual auth_credentials_t fetch_auth_credentials(const metadata_cache::metadata_server_t &md_server, const mysqlrouter::TargetCluster &target_cluster)=0
std::map< std::string, std::pair< std::string, JsonDocument > > auth_credentials_t
Definition: metadata.h:57
Defines an IP address with port number
Definition: tcp_address.h:40
Definition: cluster_metadata.h:158
Definition: expected.h:284
#define METADATA_CACHE_EXPORT
Definition: metadata_cache_export.h:15
Define rapidjson::SizeType to be std::size_t.
std::vector< metadata_server_t > metadata_servers_list_t
Definition: metadata_cache_datatypes.h:146
ClusterType
Definition: cluster_metadata.h:139
Represents a cluster (a GR group or AR members) and its metadata servers.
Definition: metadata_cache_datatypes.h:183
Definition: metadata_cache_datatypes.h:239