MySQL 9.2.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
plugin_config.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_PLUGIN_CONFIG_INCLUDED
27#define METADATA_CACHE_PLUGIN_CONFIG_INCLUDED
28
30
31#include <chrono>
32#include <string>
33#include <vector>
34
37#include "mysql/harness/plugin.h"
41#include "router_options.h"
42
43extern "C" {
44extern mysql_harness::Plugin METADATA_CACHE_PLUGIN_EXPORT
46}
47
50 public:
51 /** @brief Constructor
52 *
53 * @param section from configuration file provided as ConfigSection
54 */
56
57 /**
58 * @param option name of the option
59 */
60 std::string get_default(std::string_view option) const override;
61 bool is_required(std::string_view option) const override;
62
63 mutable std::unique_ptr<ClusterMetadataDynamicState>
65 /** @brief MySQL Metadata hosts to connect with */
67 /** @brief User used for authenticating with MySQL Metadata */
68 std::string user;
69 /** @brief TTL used for storing data in the cache */
70 std::chrono::milliseconds ttl;
71 /** @brief TTL used for limiting the lifetime of the rest user authentication
72 * data stored in the metadata */
73 std::chrono::milliseconds auth_cache_ttl;
74 /** @brief Refresh rate of the rest user authentication data stored in the
75 * cache */
76 std::chrono::milliseconds auth_cache_refresh_interval;
77 /** @brief Name of the Cluster this Router instance was bootstrapped to use.
78 */
79 std::string cluster_name;
80 /** @brief connect_timeout The time in seconds after which trying to connect
81 * to metadata server timeouts */
82 unsigned int connect_timeout;
83 /** @brief read_timeout The time in seconds after which read from metadata
84 * server timeouts */
85 unsigned int read_timeout;
86 /** @brief memory in kilobytes allocated for thread's stack */
87 unsigned int thread_stack_size;
88 /** @brief Whether we should listen to GR notifications from the cluster
89 * nodes. */
91 /** @brief Type of the cluster this configuration was bootstrap against. */
93 /** @brief Id of the router in the metadata. */
94 unsigned int router_id;
95
96 // close the connection after a refresh.
98
99 /** @brief SSL settings for metadata cache connection. */
101
102 // options configured in the metadata
103 std::string target_cluster;
105 invalidated_cluster_policy{kDefautlInvalidatedClusterRoutingPolicy};
106 bool use_replica_primary_as_rw{false};
107 QuorumConnectionLostAllowTraffic unreachable_quorum_allowed_traffic{
109 std::chrono::seconds stats_updates_frequency{std::chrono::seconds(-1)};
111
112 /** @brief Gets (Group Replication ID for GR cluster or cluster_id for
113 * ReplicaSet cluster) if preset in the dynamic configuration.
114 *
115 * @note If there is no dynamic configuration (backward compatibility) it
116 * returns empty string.
117 */
118 std::string get_cluster_type_specific_id() const;
119
120 std::string get_clusterset_id() const;
121
122 /** @brief Gets last know ReplicaSet cluster metadata view_id stored in the
123 * dynamic state file . */
124 uint64_t get_view_id() const;
125
126 void expose_configuration(const mysql_harness::ConfigSection &default_section,
127 const bool initial) const;
128
129 private:
130 /** @brief Gets a list of metadata servers.
131 *
132 *
133 * Throws std::invalid_argument on errors.
134 *
135 * @param default_port Use this port when none was provided
136 * @return std::vector<mysql_harness::TcpDestination>
137 */
138 std::vector<mysql_harness::TcpDestination> get_metadata_servers(
139 uint16_t default_port) const;
140
142 const mysql_harness::ConfigSection *section);
143
144 std::unique_ptr<ClusterMetadataDynamicState> get_dynamic_state(
145 const mysql_harness::ConfigSection *section);
146};
147
148#endif // METADATA_CACHE_PLUGIN_CONFIG_INCLUDED
Definition: plugin_config.h:49
std::chrono::milliseconds auth_cache_ttl
TTL used for limiting the lifetime of the rest user authentication data stored in the metadata.
Definition: plugin_config.h:73
bool close_connection_after_refresh
Definition: plugin_config.h:97
std::string target_cluster
Definition: plugin_config.h:103
std::string user
User used for authenticating with MySQL Metadata.
Definition: plugin_config.h:68
unsigned int connect_timeout
connect_timeout The time in seconds after which trying to connect to metadata server timeouts
Definition: plugin_config.h:82
std::chrono::milliseconds auth_cache_refresh_interval
Refresh rate of the rest user authentication data stored in the cache.
Definition: plugin_config.h:76
unsigned int router_id
Id of the router in the metadata.
Definition: plugin_config.h:94
bool use_gr_notifications
Whether we should listen to GR notifications from the cluster nodes.
Definition: plugin_config.h:90
const metadata_cache::metadata_servers_list_t metadata_servers_addresses
MySQL Metadata hosts to connect with.
Definition: plugin_config.h:66
std::unique_ptr< ClusterMetadataDynamicState > metadata_cache_dynamic_state
Definition: plugin_config.h:64
std::string cluster_name
Name of the Cluster this Router instance was bootstrapped to use.
Definition: plugin_config.h:79
mysqlrouter::ClusterType cluster_type
Type of the cluster this configuration was bootstrap against.
Definition: plugin_config.h:92
std::chrono::milliseconds ttl
TTL used for storing data in the cache.
Definition: plugin_config.h:70
mysqlrouter::SSLOptions ssl_options
SSL settings for metadata cache connection.
Definition: plugin_config.h:100
unsigned int read_timeout
read_timeout The time in seconds after which read from metadata server timeouts
Definition: plugin_config.h:85
unsigned int thread_stack_size
memory in kilobytes allocated for thread's stack
Definition: plugin_config.h:87
mysqlrouter::ClusterType get_cluster_type(const mysql_harness::ConfigSection *section)
Retrieve and manage plugin configuration.
Definition: plugin_config.h:62
virtual bool is_required(std::string_view option) const =0
Returns whether the given option is required.
virtual std::string get_default(std::string_view option) const =0
Gets the default for the given option.
Configuration section.
Definition: config_parser.h:141
InvalidatedClusterRoutingPolicy
Definition: cluster_metadata.h:138
static stdx::expected< std::string, std::error_code > get_clusterset_id(mysqlrouter::MySQLSession &session, const mysqlrouter::TargetCluster &target_cluster)
Definition: cluster_metadata_gr.cc:1145
static void expose_configuration(mysql_harness::PluginFuncEnv *env, const char *, bool initial)
Definition: connection_pool_plugin.cc:177
mysql_harness::Plugin METADATA_CACHE_PLUGIN_EXPORT harness_plugin_metadata_cache
Definition: metadata_cache_plugin.cc:287
#define METADATA_CACHE_PLUGIN_EXPORT
Definition: metadata_cache_plugin_export.h:15
std::vector< metadata_server_t > metadata_servers_list_t
Definition: metadata_cache_datatypes.h:168
ClusterType
Definition: cluster_metadata.h:116
ReadOnlyTargets
Definition: router_options.h:39
static const auto kDefautlInvalidatedClusterRoutingPolicy
Definition: router_options.h:36
static const QuorumConnectionLostAllowTraffic kDefaultQuorumConnectionLostAllowTraffic
Definition: router_options.h:47
static const ReadOnlyTargets kDefaultReadOnlyTargets
Definition: router_options.h:40
QuorumConnectionLostAllowTraffic
Definition: router_options.h:45
SSL connection related options.
Definition: datatypes.h:34
double seconds()
Definition: task.cc:314