MySQL 9.1.0
Source Code Documentation
reference_caching_setup.h
Go to the documentation of this file.
1/* Copyright (c) 2022, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
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, version 2.0, 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#ifndef SQL_REFERENCE_CACHING_SETUP_H
25#define SQL_REFERENCE_CACHING_SETUP_H
26
27#include <atomic>
28#include <unordered_map>
29#include <utility>
30#include <vector>
31
33#include "mysql/plugin_audit.h"
34
36
37using Event_map = std::unordered_map<std::string, size_t>;
38using Channel_vector = std::vector<reference_caching_channel>;
39using Cache_vector = std::vector<reference_caching_cache>;
40
42 public:
43 class Event_mapping final {
44 public:
47 bool map(const std::string &event, std::pair<size_t, size_t> &index);
48 bool map(const std::string &event, size_t &index);
49
50 private:
52 };
53
56
57 bool map(const std::string &event, std::pair<size_t, size_t> &index) {
58 return event_mapping_.map(event, index);
59 }
60
61 bool map(const std::string &event, size_t &index) {
62 return event_mapping_.map(event, index);
63 }
64
65 bool service_notification(const char *name, bool load);
66
69 }
70
71 bool valid() const { return valid_; }
72
73 bool create_cache(Cache_vector &cache_vector);
74
75 bool service_exists(Event_tracking_class event_tracking_class) {
76 return (
77 service_counters_[static_cast<size_t>(event_tracking_class)].load() >
78 0);
79 }
80
81 private:
83 bool init();
84 void deinit();
85
86 /** Validity */
87 bool valid_{false};
88 /** Handle to @sa reference_caching_channel service */
91 /** Handle to @sa reference_caching_cache service */
94 /** Handle to @sa reference_caching_channel_ignore_list */
95 SERVICE_TYPE_NO_CONST(reference_caching_channel_ignore_list)
97
98 /** Event map */
100 /** Reference caching channels */
102 /** Service counters */
103 std::atomic_int
105};
106
108
110 public:
113 bool get(Event_tracking_class event_tracking_class,
114 const my_h_service **services);
115 bool valid() const { return valid_; }
116 void refresh_all();
117
118 private:
119 void deinit();
120 bool valid_{false};
123 nullptr};
124};
125
126#endif // !SQL_REFERENCE_CACHING_SETUP_H
Definition: reference_caching_setup.h:109
Event_reference_caching_cache()
Definition: reference_caching_setup.cc:214
Cache_vector local_cache_vector_
Definition: reference_caching_setup.h:121
bool get(Event_tracking_class event_tracking_class, const my_h_service **services)
Definition: reference_caching_setup.cc:234
const mysql_service_reference_caching_cache_t * reference_caching_cache_service_
Definition: reference_caching_setup.h:122
~Event_reference_caching_cache()
Definition: reference_caching_setup.cc:222
void deinit()
Definition: reference_caching_setup.cc:224
void refresh_all()
Definition: reference_caching_setup.cc:247
bool valid() const
Definition: reference_caching_setup.h:115
bool valid_
Definition: reference_caching_setup.h:120
Definition: reference_caching_setup.h:43
Event_mapping()
Definition: reference_caching_setup.cc:96
~Event_mapping()
Definition: reference_caching_setup.h:46
bool map(const std::string &event, std::pair< size_t, size_t > &index)
Definition: reference_caching_setup.cc:103
Event_map event_map_
Definition: reference_caching_setup.h:51
Definition: reference_caching_setup.h:41
const mysql_service_reference_caching_cache_t * get_reference_caching_cache_handle()
Definition: reference_caching_setup.h:67
bool map(const std::string &event, std::pair< size_t, size_t > &index)
Definition: reference_caching_setup.h:57
Event_mapping event_mapping_
Event map.
Definition: reference_caching_setup.h:99
bool init()
Definition: reference_caching_setup.cc:136
bool valid_
Validity.
Definition: reference_caching_setup.h:87
std::atomic_int service_counters_[static_cast< size_t >(Event_tracking_class::LAST)]
Service counters.
Definition: reference_caching_setup.h:104
bool service_exists(Event_tracking_class event_tracking_class)
Definition: reference_caching_setup.h:75
void deinit()
Definition: reference_caching_setup.cc:164
bool create_cache(Cache_vector &cache_vector)
Definition: reference_caching_setup.cc:179
bool map(const std::string &event, size_t &index)
Definition: reference_caching_setup.h:61
static Event_reference_caching_channels * create()
Definition: reference_caching_setup.cc:173
mysql_service_reference_caching_channel_ignore_list_t * reference_caching_channel_ignore_list_
Handle to.
Definition: reference_caching_setup.h:96
mysql_service_reference_caching_channel_t * reference_caching_channel_service_
Handle to.
Definition: reference_caching_setup.h:90
bool service_notification(const char *name, bool load)
Definition: reference_caching_setup.cc:194
mysql_service_reference_caching_cache_t * reference_caching_cache_service_
Handle to.
Definition: reference_caching_setup.h:93
~Event_reference_caching_channels()
Definition: reference_caching_setup.cc:124
bool valid() const
Definition: reference_caching_setup.h:71
Channel_vector channels_
Reference caching channels.
Definition: reference_caching_setup.h:101
struct my_h_service_imp * my_h_service
A handle type for acquired Service.
Definition: registry.h:33
bool load(THD *, const dd::String_type &fname, dd::String_type *buf)
Read an sdi file from disk and store in a buffer.
Definition: sdi_file.cc:308
Definition: services.cc:40
struct reference_caching_cache_imp * reference_caching_cache
A handle of a "reference cache".
Definition: reference_caching.h:47
struct reference_caching_channel_imp * reference_caching_channel
Handle for "producer channels".
Definition: reference_caching.h:39
std::unordered_map< std::string, size_t > Event_map
Definition: reference_caching_setup.h:37
Event_reference_caching_channels * g_event_channels
All reference caching channels maintained by server to handle event tracking broadcasts.
Definition: reference_caching_setup.cc:33
std::vector< reference_caching_cache > Cache_vector
Definition: reference_caching_setup.h:39
std::vector< reference_caching_channel > Channel_vector
Definition: reference_caching_setup.h:38
required string event
Definition: replication_group_member_actions.proto:32
#define SERVICE_TYPE(name)
Generates the standard Service type name.
Definition: service.h:76
#define SERVICE_TYPE_NO_CONST(name)
Generates the standard Service type name.
Definition: service.h:71
Event_tracking_class
Event tracking classes If a new event tracking class is introduced, this class should be kept in sync...
Definition: sql_event_tracking_to_audit_event_mapping.h:41
case opt name
Definition: sslopt-case.h:29