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