MySQL 9.3.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
connection_control_coordinator.h
Go to the documentation of this file.
1/* Copyright (c) 2024, 2025, 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 CONNECTION_CONTROL_COORDINATOR_H
25#define CONNECTION_CONTROL_COORDINATOR_H
26
30
31namespace connection_control {
33 public:
35 Connection_event_observer **subscriber,
38 {
39 m_subscriber = *subscriber;
40
41 /* Reset the list first */
42 for (uint i = static_cast<uint>(OPT_FAILED_CONNECTIONS_THRESHOLD);
43 i < static_cast<uint>(OPT_LAST); ++i) {
44 m_sys_vars[i] = false;
45 }
46
47 /* Now set the bits which are requested by subscriber */
48 if (sys_vars != nullptr) {
49 for (const auto &var : *sys_vars) {
50 m_sys_vars[var] = true;
51 }
52 }
53 }
54 }
57};
58
59/**
60 Connection event coordinator.
61 This class will keep list of subscribers for different subevents
62 and notify them based on their preference.
63*/
64
66 public:
68
69 /* Functions to receive notification from server */
70 void notify_event(
71 MYSQL_THD thd,
72 const mysql_event_tracking_connection_data *connection_event);
73 void notify_sys_var(opt_connection_control variable, void *new_value);
74
75 /* Services provided to observers */
77 Connection_event_observer **subscriber,
82
84 stats_connection_control status_var,
86
87 private:
88 void reset();
93};
94} // namespace connection_control
95#endif // !CONNECTION_CONTROL_COORDINATOR_H
#define MYSQL_THD
Definition: backup_page_tracker.h:38
Definition: connection_control_memory.h:41
Connection event coordinator.
Definition: connection_control_coordinator.h:65
Connection_event_coordinator()
Definition: connection_control_coordinator.h:67
std::vector< Connection_event_subscriber, CustomAllocator< Connection_event_subscriber > > m_subscribers
Definition: connection_control_coordinator.h:91
bool register_event_subscriber(Connection_event_observer **subscriber, std::vector< opt_connection_control, CustomAllocator< opt_connection_control > > *sys_vars, std::vector< stats_connection_control, CustomAllocator< stats_connection_control > > *status_vars)
Register an event subscriber.
Definition: connection_control_coordinator.cc:59
void notify_sys_var(opt_connection_control variable, void *new_value)
Process change in sys_var value.
Definition: connection_control_coordinator.cc:156
bool notify_status_var(Connection_event_observer **observer, stats_connection_control status_var, status_var_action action)
Update a status variable.
Definition: connection_control_coordinator.cc:177
void notify_event(MYSQL_THD thd, const mysql_event_tracking_connection_data *connection_event)
Handle connection event.
Definition: connection_control_coordinator.cc:135
Connection_event_observer * m_status_vars_subscription[STAT_LAST]
Definition: connection_control_coordinator.h:92
void reset()
Reset Connection_event_coordinator information.
Definition: connection_control_coordinator.cc:33
Interface for defining action on connection events.
Definition: connection_control_interfaces.h:42
Definition: connection_control_coordinator.h:32
Connection_event_observer * m_subscriber
Definition: connection_control_coordinator.h:55
Connection_event_subscriber(Connection_event_observer **subscriber, std::vector< opt_connection_control, CustomAllocator< opt_connection_control > > *sys_vars)
Definition: connection_control_coordinator.h:34
bool m_sys_vars[OPT_LAST]
Definition: connection_control_coordinator.h:56
Definition: connection_control_pfs_table.h:39
opt_connection_control
Enum for system variables : Must be in sync with members of Connection_control_variables.
Definition: connection_control_data.h:35
@ OPT_LAST
Definition: connection_control_data.h:39
@ OPT_FAILED_CONNECTIONS_THRESHOLD
Definition: connection_control_data.h:36
stats_connection_control
Enum for status variables : Must be in sync with members of Connection_control_statistics.
Definition: connection_control_data.h:46
@ STAT_LAST
Definition: connection_control_data.h:49
SHOW_VAR status_vars[]
Definition: mysqld.cc:11644
Definition: connection_control.h:70
status_var_action
Definition: connection_control_interfaces.h:54
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2876
repeated Action action
Definition: replication_group_member_actions.proto:43
Structure for Connection event tracking.
Definition: event_tracking_connection_defs.h:60