MySQL 8.3.0
Source Code Documentation
metadata.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2016, 2023, 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 also distributed 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 included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23*/
24
25#ifndef METADATA_CACHE_METADATA_INTERFACE_INCLUDED
26#define METADATA_CACHE_METADATA_INTERFACE_INCLUDED
27
29
30#include <atomic>
31#include <chrono>
32#include <map>
33#include <optional>
34#include <string>
35#include <vector>
36
37#include "my_rapidjson_size_t.h"
38
39#include <rapidjson/document.h>
40
45
46/**
47 * The metadata class is used to create a pluggable transport layer
48 * from which the metadata is fetched for the metadata cache.
49 */
51 public:
52 using JsonAllocator = rapidjson::CrtAllocator;
53 using JsonDocument = rapidjson::Document;
54 // username as key, password hash and privileges as value
56 std::map<std::string, std::pair<std::string, JsonDocument>>;
57
58 // fetch instances from vector of metadata servers
61 const std::atomic<bool> &terminated,
62 mysqlrouter::TargetCluster &target_cluster, const unsigned router_id,
63 const metadata_cache::metadata_servers_list_t &metadata_servers,
64 bool needs_writable_node, const std::string &clusterset_id,
65 bool whole_topology, std::size_t &instance_id) = 0;
66
68 const metadata_cache::metadata_server_t &rw_server,
69 const unsigned router_id,
70 const metadata_cache::RouterAttributes &router_attributes) = 0;
71
73 const metadata_cache::metadata_server_t &rw_server,
74 const unsigned router_id) = 0;
75
77 const metadata_cache::metadata_server_t &metadata_server) = 0;
78
79 virtual void disconnect() = 0;
80
82 const metadata_cache::ClusterTopology &cluster_topology,
83 const std::function<void()> &callback) = 0;
84
86
87 virtual std::shared_ptr<mysqlrouter::MySQLSession> get_connection() = 0;
88
90
92 const metadata_cache::metadata_server_t &md_server,
93 const mysqlrouter::TargetCluster &target_cluster) = 0;
94
95 virtual std::optional<std::chrono::seconds>
97
98 MetaData() = default;
99 // disable copy as it isn't needed right now. Feel free to enable
100 // must be explicitly defined though.
101 explicit MetaData(const MetaData &) = delete;
102 MetaData &operator=(const MetaData &) = delete;
103 virtual ~MetaData() = default;
104};
105
106#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:50
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:52
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:53
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:56
Defines an IP address with port number
Definition: tcp_address.h:39
Definition: cluster_metadata.h:161
Definition: expected.h:943
#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:145
ClusterType
Definition: cluster_metadata.h:141
Represents a cluster (a GR group or AR members) and its metadata servers.
Definition: metadata_cache_datatypes.h:182
Definition: metadata_cache_datatypes.h:238