MySQL 9.0.0
Source Code Documentation
channel_observation_manager.h
Go to the documentation of this file.
1/* Copyright (c) 2015, 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 CHANNEL_OBSERVATION_MANAGER_INCLUDE
25#define CHANNEL_OBSERVATION_MANAGER_INCLUDE
26
28#include <list>
29
30#include "my_inttypes.h"
31#include "mysql/plugin.h"
32
34
35/**
36 A interface class to code channel state response methods
37*/
39 public:
41 virtual int thread_start(Binlog_relay_IO_param *param) = 0;
42 virtual int thread_stop(Binlog_relay_IO_param *param) = 0;
43 virtual int applier_start(Binlog_relay_IO_param *param) = 0;
44 virtual int applier_stop(Binlog_relay_IO_param *param, bool aborted) = 0;
46 uint32 flags) = 0;
47 virtual int after_read_event(Binlog_relay_IO_param *param, const char *packet,
48 unsigned long len, const char **event_buf,
49 unsigned long *event_len) = 0;
51 const char *event_buf, unsigned long event_len,
52 uint32 flags) = 0;
55 Trans_param *trans_param, int &out) = 0;
56};
57
58/**
59 A class to hold different channel observation manager.
60
61 @note Slave channels observation and group replication channel observation
62 serves different purposes and can interfere with one another.
63 For that reason they are separated here.
64*/
66 public:
67 /**
68 Constructor.
69 Initializes the given number of channel observation manager
70 and register an observer in the server.
71
72 @param plugin_info The plugin info to register the hooks
73 @param num_managers The number of channel observation manager instantiated
74 */
76
77 /**
78 Destructor.
79 Unregister the server observer
80 and deletes all the channel observation manager.
81 */
83
84 /**
85 A method to add channel observation manager to the
86 channel_observation_manager list.
87
88 @param manager A channel observation manager implementation.
89 */
91
92 /**
93 A method to remove a channel observation manager from
94 channel_observation_manager list.
95
96 @param manager A channel observation manager implementation.
97 */
99
100 /**
101 Get all the channel observation manager
102
103 @return The list of all channel observation manager
104 */
105 std::list<Channel_observation_manager *>
107
108 /**
109 Get particular channel observation manager
110
111 @param position get iterator value at position
112 @return The channel observation manager
113 */
115 uint position = 0);
116
117 private:
118 /** Server relay log observer struct */
120
121 /** server plugin handle */
123
124 /** list of channel observation manager */
125 std::list<Channel_observation_manager *> channel_observation_manager;
126};
127
128/**
129 A class to register observers for channel state events.
130*/
132 public:
133 /**
134 Initialize the class.
135 */
137
138 /**
139 Destructor.
140 Deletes all the channel state observers.
141 */
143
144 /**
145 A method to register observers to the events that come from the server.
146
147 @param observer A channel state observer implementation.
148 */
150
151 /**
152 A method to remove a channel state observer.
153
154 @param observer A channel state observer implementation.
155 */
157
158 /**
159 Get all registered observers
160
161 @note to get the list and while using it, you should take a read lock from
162 channel_list_lock (you can use the read_lock_channel_list method)
163
164 @return The list of all registered observers
165 */
166 std::list<Channel_state_observer *> &get_channel_state_observers();
167
168 /** Locks the observer list for reads */
170 /** Locks the observer list for writes */
172 /** Unlocks the observer list */
173 void unlock_channel_list();
174
175 private:
176 /** list of channel state observer */
177 std::list<Channel_state_observer *> channel_observers;
178
179 // run conditions and locks
181};
182
183#endif /* CHANNEL_OBSERVATION_MANAGER_INCLUDE */
A class to hold different channel observation manager.
Definition: channel_observation_manager.h:65
std::list< Channel_observation_manager * > channel_observation_manager
list of channel observation manager
Definition: channel_observation_manager.h:125
Channel_observation_manager * get_channel_observation_manager(uint position=0)
Get particular channel observation manager.
Definition: channel_observation_manager.cc:79
std::list< Channel_observation_manager * > & get_channel_observation_manager_list()
Get all the channel observation manager.
Definition: channel_observation_manager.cc:73
void add_channel_observation_manager(Channel_observation_manager *manager)
A method to add channel observation manager to the channel_observation_manager list.
Definition: channel_observation_manager.cc:62
Binlog_relay_IO_observer server_channel_state_observers
Server relay log observer struct.
Definition: channel_observation_manager.h:119
MYSQL_PLUGIN group_replication_plugin_info
server plugin handle
Definition: channel_observation_manager.h:122
void remove_channel_observation_manager(Channel_observation_manager *manager)
A method to remove a channel observation manager from channel_observation_manager list.
Definition: channel_observation_manager.cc:67
Channel_observation_manager_list(MYSQL_PLUGIN plugin_info, uint num_managers)
Constructor.
Definition: channel_observation_manager.cc:32
~Channel_observation_manager_list()
Destructor.
Definition: channel_observation_manager.cc:46
A class to register observers for channel state events.
Definition: channel_observation_manager.h:131
void write_lock_channel_list()
Locks the observer list for writes.
Definition: channel_observation_manager.cc:142
void unlock_channel_list()
Unlocks the observer list.
Definition: channel_observation_manager.cc:146
void register_channel_observer(Channel_state_observer *observer)
A method to register observers to the events that come from the server.
Definition: channel_observation_manager.cc:122
void unregister_channel_observer(Channel_state_observer *observer)
A method to remove a channel state observer.
Definition: channel_observation_manager.cc:130
Checkable_rwlock * channel_list_lock
Definition: channel_observation_manager.h:180
std::list< Channel_state_observer * > & get_channel_state_observers()
Get all registered observers.
Definition: channel_observation_manager.cc:114
~Channel_observation_manager()
Destructor.
Definition: channel_observation_manager.cc:98
Channel_observation_manager()
Initialize the class.
Definition: channel_observation_manager.cc:90
void read_lock_channel_list()
Locks the observer list for reads.
Definition: channel_observation_manager.cc:138
std::list< Channel_state_observer * > channel_observers
list of channel state observer
Definition: channel_observation_manager.h:177
A interface class to code channel state response methods.
Definition: channel_observation_manager.h:38
virtual int applier_stop(Binlog_relay_IO_param *param, bool aborted)=0
virtual int applier_start(Binlog_relay_IO_param *param)=0
virtual int after_reset_slave(Binlog_relay_IO_param *param)=0
virtual int thread_start(Binlog_relay_IO_param *param)=0
virtual int after_queue_event(Binlog_relay_IO_param *param, const char *event_buf, unsigned long event_len, uint32 flags)=0
virtual int applier_log_event(Binlog_relay_IO_param *param, Trans_param *trans_param, int &out)=0
virtual ~Channel_state_observer()=0
virtual int before_request_transmit(Binlog_relay_IO_param *param, uint32 flags)=0
virtual int after_read_event(Binlog_relay_IO_param *param, const char *packet, unsigned long len, const char **event_buf, unsigned long *event_len)=0
virtual int thread_stop(Binlog_relay_IO_param *param)=0
This has the functionality of mysql_rwlock_t, with two differences:
Definition: rpl_gtid.h:324
static int flags[50]
Definition: hp_test1.cc:40
void * MYSQL_PLUGIN
Definition: plugin.h:82
Some integer typedefs for easier portability.
uint32_t uint32
Definition: my_inttypes.h:67
static MYSQL_PLUGIN plugin_info
Definition: rewriter_plugin.cc:89
Observes and extends the service of slave IO thread.
Definition: replication.h:726
Replication binlog relay IO observer parameter.
Definition: replication.h:590
Transaction observer parameter.
Definition: replication.h:136