MySQL 8.3.0
Source Code Documentation
reference_caching_setup.h
Go to the documentation of this file.
1/* Copyright (c) 2022, 2023, 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 also distributed 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 included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef SQL_REFERENCE_CACHING_SETUP_H
24#define SQL_REFERENCE_CACHING_SETUP_H
25
26#include <atomic>
27#include <unordered_map>
28#include <utility>
29#include <vector>
30
32#include "mysql/plugin_audit.h"
33
35
36using Event_map = std::unordered_map<std::string, size_t>;
37using Channel_vector = std::vector<reference_caching_channel>;
38using Cache_vector = std::vector<reference_caching_cache>;
39
41 public:
42 class Event_mapping final {
43 public:
46 bool map(const std::string &event, std::pair<size_t, size_t> &index);
47 bool map(const std::string &event, size_t &index);
48
49 private:
51 };
52
55
56 bool map(const std::string &event, std::pair<size_t, size_t> &index) {
57 return event_mapping_.map(event, index);
58 }
59
60 bool map(const std::string &event, size_t &index) {
61 return event_mapping_.map(event, index);
62 }
63
64 bool service_notification(const char *name, bool load);
65
68 }
69
70 bool valid() const { return valid_; }
71
72 bool create_cache(Cache_vector &cache_vector);
73
74 bool service_exists(Event_tracking_class event_tracking_class) {
75 return (
76 service_counters_[static_cast<size_t>(event_tracking_class)].load() >
77 0);
78 }
79
80 private:
82 bool init();
83 void deinit();
84
85 /** Validity */
86 bool valid_{false};
87 /** Handle to @sa reference_caching_channel service */
90 /** Handle to @sa reference_caching_cache service */
93 /** Handle to @sa reference_caching_channel_ignore_list */
94 SERVICE_TYPE_NO_CONST(reference_caching_channel_ignore_list)
96
97 /** Event map */
99 /** Reference caching channels */
101 /** Service counters */
102 std::atomic_int
104};
105
107
109 public:
112 bool get(Event_tracking_class event_tracking_class,
113 const my_h_service **services);
114 bool valid() const { return valid_; }
115 void refresh_all();
116
117 private:
118 void deinit();
119 bool valid_{false};
122 nullptr};
123};
124
125#endif // !SQL_REFERENCE_CACHING_SETUP_H
Definition: reference_caching_setup.h:108
Event_reference_caching_cache()
Definition: reference_caching_setup.cc:213
Cache_vector local_cache_vector_
Definition: reference_caching_setup.h:120
bool get(Event_tracking_class event_tracking_class, const my_h_service **services)
Definition: reference_caching_setup.cc:233
const mysql_service_reference_caching_cache_t * reference_caching_cache_service_
Definition: reference_caching_setup.h:121
~Event_reference_caching_cache()
Definition: reference_caching_setup.cc:221
void deinit()
Definition: reference_caching_setup.cc:223
void refresh_all()
Definition: reference_caching_setup.cc:246
bool valid() const
Definition: reference_caching_setup.h:114
bool valid_
Definition: reference_caching_setup.h:119
Definition: reference_caching_setup.h:42
Event_mapping()
Definition: reference_caching_setup.cc:95
~Event_mapping()
Definition: reference_caching_setup.h:45
bool map(const std::string &event, std::pair< size_t, size_t > &index)
Definition: reference_caching_setup.cc:102
Event_map event_map_
Definition: reference_caching_setup.h:50
Definition: reference_caching_setup.h:40
const mysql_service_reference_caching_cache_t * get_reference_caching_cache_handle()
Definition: reference_caching_setup.h:66
bool map(const std::string &event, std::pair< size_t, size_t > &index)
Definition: reference_caching_setup.h:56
Event_mapping event_mapping_
Event map.
Definition: reference_caching_setup.h:98
bool init()
Definition: reference_caching_setup.cc:135
bool valid_
Validity.
Definition: reference_caching_setup.h:86
std::atomic_int service_counters_[static_cast< size_t >(Event_tracking_class::LAST)]
Service counters.
Definition: reference_caching_setup.h:103
bool service_exists(Event_tracking_class event_tracking_class)
Definition: reference_caching_setup.h:74
void deinit()
Definition: reference_caching_setup.cc:163
bool create_cache(Cache_vector &cache_vector)
Definition: reference_caching_setup.cc:178
bool map(const std::string &event, size_t &index)
Definition: reference_caching_setup.h:60
static Event_reference_caching_channels * create()
Definition: reference_caching_setup.cc:172
mysql_service_reference_caching_channel_ignore_list_t * reference_caching_channel_ignore_list_
Handle to.
Definition: reference_caching_setup.h:95
mysql_service_reference_caching_channel_t * reference_caching_channel_service_
Handle to.
Definition: reference_caching_setup.h:89
bool service_notification(const char *name, bool load)
Definition: reference_caching_setup.cc:193
mysql_service_reference_caching_cache_t * reference_caching_cache_service_
Handle to.
Definition: reference_caching_setup.h:92
~Event_reference_caching_channels()
Definition: reference_caching_setup.cc:123
bool valid() const
Definition: reference_caching_setup.h:70
Channel_vector channels_
Reference caching channels.
Definition: reference_caching_setup.h:100
struct my_h_service_imp * my_h_service
A handle type for acquired Service.
Definition: registry.h:32
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:307
Definition: services.cc:39
struct reference_caching_cache_imp * reference_caching_cache
A handle of a "reference cache".
Definition: reference_caching.h:46
struct reference_caching_channel_imp * reference_caching_channel
Handle for "producer channels".
Definition: reference_caching.h:38
std::unordered_map< std::string, size_t > Event_map
Definition: reference_caching_setup.h:36
Event_reference_caching_channels * g_event_channels
All reference caching channels maintained by server to handle event tracking broadcasts.
Definition: reference_caching_setup.cc:32
std::vector< reference_caching_cache > Cache_vector
Definition: reference_caching_setup.h:38
std::vector< reference_caching_channel > Channel_vector
Definition: reference_caching_setup.h:37
required string event
Definition: replication_group_member_actions.proto:31
#define SERVICE_TYPE(name)
Generates the standard Service type name.
Definition: service.h:75
#define SERVICE_TYPE_NO_CONST(name)
Generates the standard Service type name.
Definition: service.h:70
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:40
case opt name
Definition: sslopt-case.h:32