MySQL  8.0.20
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  */
89  void add_channel_observation_manager(Channel_observation_manager *manager);
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  */
97  void remove_channel_observation_manager(Channel_observation_manager *manager);
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 *>
105  &get_channel_observation_manager_list();
106 
107  /**
108  Get particular channel observation manager
109 
110  @param position get iterator value at position
111  @return The channel observation manager
112  */
113  Channel_observation_manager *get_channel_observation_manager(
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  */
148  void register_channel_observer(Channel_state_observer *observer);
149 
150  /**
151  A method to remove a channel state observer.
152 
153  @param observer A channel state observer implementation.
154  */
155  void unregister_channel_observer(Channel_state_observer *observer);
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 */
170  void write_lock_channel_list();
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 */
static MYSQL_PLUGIN plugin_info
Definition: rewriter_plugin.cc:71
A class to hold different channel observation manager.
Definition: channel_observation_manager.h:64
Some integer typedefs for easier portability.
Transaction observer parameter.
Definition: replication.h:131
Observes and extends the service of slave IO thread.
Definition: replication.h:710
virtual int thread_start(Binlog_relay_IO_param *param)=0
virtual int after_reset_slave(Binlog_relay_IO_param *param)=0
A class to register observers for channel state events.
Definition: channel_observation_manager.h:130
virtual int applier_start(Binlog_relay_IO_param *param)=0
virtual int applier_log_event(Binlog_relay_IO_param *param, Trans_param *trans_param, int &out)=0
virtual int after_queue_event(Binlog_relay_IO_param *param, const char *event_buf, unsigned long event_len, uint32 flags)=0
void * MYSQL_PLUGIN
Definition: plugin.h:73
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
Checkable_rwlock * channel_list_lock
Definition: channel_observation_manager.h:179
virtual ~Channel_state_observer()=0
Definition: channel_observation_manager.cc:29
std::list< Channel_state_observer * > channel_observers
list of channel state observer
Definition: channel_observation_manager.h:176
unsigned int uint
Definition: uca-dump.cc:29
uint32_t uint32
Definition: my_inttypes.h:66
Replication binlog relay IO observer parameter.
Definition: replication.h:576
std::list< Channel_observation_manager * > channel_observation_manager
list of channel observation manager
Definition: channel_observation_manager.h:124
Binlog_relay_IO_observer server_channel_state_observers
Server relay log observer struct.
Definition: channel_observation_manager.h:118
MYSQL_PLUGIN group_replication_plugin_info
server plugin handle
Definition: channel_observation_manager.h:121
virtual int applier_stop(Binlog_relay_IO_param *param, bool aborted)=0
A interface class to code channel state response methods.
Definition: channel_observation_manager.h:37
This has the functionality of mysql_rwlock_t, with two differences:
Definition: rpl_gtid.h:431
static int flags[50]
Definition: hp_test1.cc:39
virtual int thread_stop(Binlog_relay_IO_param *param)=0
virtual int before_request_transmit(Binlog_relay_IO_param *param, uint32 flags)=0