MySQL 9.2.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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
47
48/**
49 * The metadata class is used to create a pluggable transport layer
50 * from which the metadata is fetched for the metadata cache.
51 */
53 public:
54 using JsonAllocator = rapidjson::CrtAllocator;
55 using JsonDocument = rapidjson::Document;
56 // username as key, password hash and privileges as value
58 std::map<std::string, std::pair<std::string, JsonDocument>>;
59
60 // fetch instances from vector of metadata servers
63 const std::atomic<bool> &terminated,
64 mysqlrouter::TargetCluster &target_cluster, const unsigned router_id,
65 const metadata_cache::metadata_servers_list_t &metadata_servers,
66 bool needs_writable_node, const std::string &clusterset_id,
67 std::size_t &instance_id, std::string &routing_guidelines) = 0;
68
70 const metadata_cache::metadata_server_t &rw_server,
71 const unsigned router_id,
72 const metadata_cache::RouterAttributes &router_attributes) = 0;
73
75 const metadata_cache::metadata_server_t &rw_server,
76 const unsigned router_id) = 0;
77
79 const std::string &guideline_name,
80 const metadata_cache::metadata_server_t &rw_server,
81 const unsigned router_id) = 0;
82
84 const metadata_cache::metadata_server_t &metadata_server) = 0;
85
86 virtual void disconnect() = 0;
87
89 const metadata_cache::ClusterTopology &cluster_topology,
90 const std::function<void()> &callback) = 0;
91
93
94 virtual std::shared_ptr<mysqlrouter::MySQLSession> get_connection() = 0;
95
97
99 const metadata_cache::metadata_server_t &md_server,
100 const mysqlrouter::TargetCluster &target_cluster) = 0;
101
102 virtual std::optional<std::chrono::seconds>
104
105 virtual std::optional<routing_guidelines::Router_info> fetch_router_info(
106 const uint16_t router_id) = 0;
107
108 virtual stdx::expected<std::string, std::error_code>
109 fetch_routing_guidelines_document(const uint16_t router_id) = 0;
110
111 MetaData() = default;
112 // disable copy as it isn't needed right now. Feel free to enable
113 // must be explicitly defined though.
114 explicit MetaData(const MetaData &) = delete;
115 MetaData &operator=(const MetaData &) = delete;
116 virtual ~MetaData() = default;
117};
118
119#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:52
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:54
virtual bool connect_and_setup_session(const metadata_cache::metadata_server_t &metadata_server)=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, std::size_t &instance_id, std::string &routing_guidelines)=0
virtual mysqlrouter::ClusterType get_cluster_type()=0
rapidjson::Document JsonDocument
Definition: metadata.h:55
virtual std::optional< std::chrono::seconds > get_periodic_stats_update_frequency() noexcept=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:58
virtual void report_guideline_name(const std::string &guideline_name, const metadata_cache::metadata_server_t &rw_server, const unsigned router_id)=0
Definition: destination.h:40
Definition: cluster_metadata.h:135
Definition: expected.h:286
#define METADATA_CACHE_EXPORT
Definition: metadata_cache_export.h:15
Define rapidjson::SizeType to be std::uint64_t.
std::vector< metadata_server_t > metadata_servers_list_t
Definition: metadata_cache_datatypes.h:168
ClusterType
Definition: cluster_metadata.h:116
Definition: routing_guidelines_datatypes.h:30
Definition: gcs_xcom_synode.h:64
Definition: bit.h:32
Represents a cluster (a GR group or AR members) and its metadata servers.
Definition: metadata_cache_datatypes.h:207
Definition: metadata_cache_datatypes.h:263