MySQL 9.6.0
Source Code Documentation
gcs_interface.h
Go to the documentation of this file.
1/* Copyright (c) 2014, 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 GCS_INTERFACE_INCLUDED
25#define GCS_INTERFACE_INCLUDED
26
27#include <string>
28
35
36/**
37 * @brief Runtime external resources that should be provided to an instance of
38 * Gcs_interface
39 *
40 */
42 /**
43 * @brief External network provider, if needed.
44 *
45 */
46 std::shared_ptr<Network_provider> provider;
47
48 /**
49 * @brief Provider of Network Namespace services
50 *
51 */
53
54 /**
55 * @brief A class that provides the textual representation of the timestamps
56 * in the debug/trace log created by GCS.
57 */
58 std::shared_ptr<Clock_timestamp_interface> clock_timestamp_provider;
59};
60
61/**
62 @class Gcs_interface
63
64 This interface must be implemented by all specific binding implementations
65 as its entry point.
66
67 It should afterwards be distributed via a Factory, in order to allow
68 its transparent instantiation.
69
70 All of the interfaces are group-oriented, meaning that all methods that
71 allow the retrieval of sub-interfaces (control, communication,
72 statistics) are oriented to serve all operations to a single group.
73
74 It provides two main functionalities:
75 - Binding startup and finish;
76 - Allow access to the control, communication and statistics interface.
77
78 A typical usage of this interface shall be:
79
80 @code{.cpp}
81 Gcs_interface *group_if= new My_GCS_Gcs_interface();
82
83 Gcs_interface_parameters params;
84 params.add_parameter("name1", "value2");
85 if (!group_if->is_initialized())
86 {
87 group_if->initialize(params);
88 }
89
90 // Inject a logger if wanted
91 Logger_interface *logger= new My_GCS_Logger_interface();
92 group_if->set_logger(logger);
93
94 Gcs_group_identifier *group_id= new Gcs_group_identifier("my_group");
95
96 Gcs_control_interface *ctrl_if= group_if->get_control_session(group_id);
97
98 ctrl_if->join(); // notice here that group id is not used anymore...
99
100 // Do some operations here, retrieve other interfaces...
101
102 ctrl_if->leave();
103
104 group_if->finalize();
105 @endcode
106*/
108 public:
109 /**
110 Method used by a binding implementation in order to implement any
111 internal startup procedure.
112
113 @retval GCS_OK in case of everything goes well. Any other value of
114 gcs_error in case of error.
115 */
116
118 const Gcs_interface_parameters &interface_params) = 0;
119
120 /**
121 Method used to report if the binding interface has already been
122 initialized.
123
124 @retval true if already initialized
125 */
126
127 virtual bool is_initialized() = 0;
128
129 /**
130 Method used by a binding implementation in order to implement any type of
131 necessary dynamic reconfiguration.
132
133 An example of this could be an underlying GCS that needs to adjust itself
134 to changes in a group. Note, however, that the method must be only used
135 when the system is not running in order to avoid possible concurrency
136 issues. Using cached information by the caller, after this member function
137 has been called, results in undefined behavior.
138
139 @retval GCS_OK in case of everything goes well. Any other value of
140 gcs_error in case of error.
141 */
142
144 const Gcs_interface_parameters &interface_params) = 0;
145
146 /**
147 Method used by a binding implementation in order to implement any
148 internal shutdown procedure.
149
150 @retval GCS_OK in case of everything goes well. Any other value of
151 gcs_error in case of error
152 */
153
155
156 /**
157 Method that retrieves the binding implementation of the Control Session
158 interface.
159
160 @param[in] group_identifier the group in which this implementation pertains
161
162 @return A valid reference to a gcs_control_interface implementation, NULL,
163 in case of error.
164 */
165
167 const Gcs_group_identifier &group_identifier) = 0;
168
169 /**
170 Method that retrieves the binding implementation of the Communication
171 Session interface.
172
173 @param[in] group_identifier the group in which this implementation pertains
174
175 @return A valid reference to a gcs_communication_interface implementation.
176 NULL, in case of error.
177 */
178
180 const Gcs_group_identifier &group_identifier) = 0;
181
182 /**
183 Method that retrieves the binding implementation of the Statistics
184 interface.
185
186 @param[in] group_identifier the group in which this implementation pertains
187
188 @return A valid reference to a gcs_statistics_interface implementation.
189 NULL, in case of error.
190 */
191
193 const Gcs_group_identifier &group_identifier) = 0;
194
195 /**
196 Method that retrieves the binding implementation of the Group
197 Management Session interface.
198
199 @param[in] group_identifier the group in which this implementation pertains
200
201 @return A valid reference to a Gcs_group_management_interface
202 implementation, NULL, in case of error.
203 */
205 const Gcs_group_identifier &group_identifier) = 0;
206
207 /**
208 Method that retrieves the binding implementation of the Group
209 Management Session interface.
210
211 @param[in] logger the logger implementation for GCS to use
212
213 @retval GCS_OK in case of everything goes well. Any other value of
214 gcs_error in case of error
215 */
217
218 /**
219 * @brief Set the up runtime resources
220 *
221 * @param reqs a Gcs_interface_runtime_requirements filled with all the
222 * requirements
223 */
226
227 /**
228 * @brief Does the necessary cleanup for runtime resources
229 *
230 * @param reqs a Gcs_interface_runtime_requirements filled with all the
231 * requirements and their references
232 */
235
236 virtual ~Gcs_interface() = default;
237};
238
239/**
240 Enum that lists all implementations of Gcs_interface available to be
241 returned
242*/
244 /* XCom binding implementation */
246 NONE
248
249/**
250 @class Gcs_interface_factory
251
252 @brief This class shall be used by an API user as an aggregator utility to
253 retrieve implementations of Gcs_interface.
254*/
256 public:
257 /**
258 Static method that allows retrieval of an instantiated implementation
259 of a binding implementation.
260
261 @param[in] binding an enum value of the binding implementation to retrieve.
262
263 @return An instantiated object of a binding implementation.NULL in case of
264 error.
265 */
266
269
270 /**
271 Static method that allows retrieval of an instantiated implementation
272 of a binding implementation.
273
274 @param[in] binding a string matching the enum available_interfaces value of
275 the binding implementation to retrieve.
276
277 @return An instantiated object of a binding implementation. NULL in case of
278 error.
279 */
280
282 const std::string &binding);
283
284 /**
285 Static method that allows the cleanup of the Gcs_interface singleton
286 instance according to the binding parameter.
287
288 @param[in] binding an enum value of the binding implementation to retrieve.
289 */
290
291 static void cleanup(enum_available_interfaces binding);
292
293 /**
294 Static method that allows the cleanup of the Gcs_interface singleton
295 instance according to the binding parameter.
296
297 @param[in] binding a string matching the enum available_interfaces value of
298 the binding implementation to retrieve.
299 */
300
301 static void cleanup(const std::string &binding);
302
303 /**
304 Static method that cleans up thread-local communication resources in the
305 Gcs_interface singleton instance according to the binding parameter.
306 This is required by the XCom backend when SSL is provided by OpenSSL.
307
308 @param[in] binding an enum value of the binding implementation to retrieve.
309 */
310
313
314 /**
315 Static method that cleans up thread-local communication resources in the
316 Gcs_interface singleton instance according to the binding parameter.
317 This is required by the XCom backend when SSL is provided by OpenSSL.
318
319 @param[in] binding a string matching the enum available_interfaces value of
320 the binding implementation to retrieve.
321 */
322
324 const std::string &binding);
325
326 private:
327 static enum_available_interfaces from_string(const std::string &binding);
328};
329
330#endif // gcs_interface_INCLUDED
This interface represents all the communication facilities that a binding implementation should provi...
Definition: gcs_communication_interface.h:90
This interface represents all the control functionalities that a binding implementation must provide.
Definition: gcs_control_interface.h:111
This represents the unique identification of a group.
Definition: gcs_group_identifier.h:35
Definition: gcs_group_management_interface.h:32
This class shall be used by an API user as an aggregator utility to retrieve implementations of Gcs_i...
Definition: gcs_interface.h:255
static void cleanup_thread_communication_resources(enum_available_interfaces binding)
Static method that cleans up thread-local communication resources in the Gcs_interface singleton inst...
Definition: gcs_interface_factory.cc:83
static void cleanup(enum_available_interfaces binding)
Static method that allows the cleanup of the Gcs_interface singleton instance according to the bindin...
Definition: gcs_interface_factory.cc:64
static enum_available_interfaces from_string(const std::string &binding)
Definition: gcs_interface_factory.cc:94
static Gcs_interface * get_interface_implementation(enum_available_interfaces binding)
Static method that allows retrieval of an instantiated implementation of a binding implementation.
Definition: gcs_interface_factory.cc:34
This class is to be used to provide parameters to bindings in a transparent and generic way.
Definition: gcs_types.h:59
This interface must be implemented by all specific binding implementations as its entry point.
Definition: gcs_interface.h:107
virtual Gcs_group_management_interface * get_management_session(const Gcs_group_identifier &group_identifier)=0
Method that retrieves the binding implementation of the Group Management Session interface.
virtual Gcs_communication_interface * get_communication_session(const Gcs_group_identifier &group_identifier)=0
Method that retrieves the binding implementation of the Communication Session interface.
virtual enum_gcs_error finalize()=0
Method used by a binding implementation in order to implement any internal shutdown procedure.
virtual enum_gcs_error set_logger(Logger_interface *logger)=0
Method that retrieves the binding implementation of the Group Management Session interface.
virtual enum_gcs_error cleanup_runtime_resources(Gcs_interface_runtime_requirements &reqs)=0
Does the necessary cleanup for runtime resources.
virtual enum_gcs_error setup_runtime_resources(Gcs_interface_runtime_requirements &reqs)=0
Set the up runtime resources.
virtual bool is_initialized()=0
Method used to report if the binding interface has already been initialized.
virtual Gcs_control_interface * get_control_session(const Gcs_group_identifier &group_identifier)=0
Method that retrieves the binding implementation of the Control Session interface.
virtual ~Gcs_interface()=default
virtual enum_gcs_error initialize(const Gcs_interface_parameters &interface_params)=0
Method used by a binding implementation in order to implement any internal startup procedure.
virtual enum_gcs_error configure(const Gcs_interface_parameters &interface_params)=0
Method used by a binding implementation in order to implement any type of necessary dynamic reconfigu...
virtual Gcs_statistics_interface * get_statistics(const Gcs_group_identifier &group_identifier)=0
Method that retrieves the binding implementation of the Statistics interface.
This interface represents all statistics that a binding implementation should provide.
Definition: gcs_statistics_interface.h:49
Logger interface that must be used to define a logger object.
Definition: gcs_logging.h:160
Class that provides Network Namespace services.
Definition: network_provider.h:242
enum_available_interfaces
Enum that lists all implementations of Gcs_interface available to be returned.
Definition: gcs_interface.h:243
@ XCOM
Definition: gcs_interface.h:245
@ NONE
Definition: gcs_interface.h:246
enum_gcs_error
This enumeration describes errors which can occur during group communication operations.
Definition: gcs_types.h:41
static Logger logger
The "top-level" logger used when no connection context is given.
Definition: test_trace_plugin.cc:296
Runtime external resources that should be provided to an instance of Gcs_interface.
Definition: gcs_interface.h:41
std::shared_ptr< Network_provider > provider
External network provider, if needed.
Definition: gcs_interface.h:46
Network_namespace_manager * namespace_manager
Provider of Network Namespace services.
Definition: gcs_interface.h:52
std::shared_ptr< Clock_timestamp_interface > clock_timestamp_provider
A class that provides the textual representation of the timestamps in the debug/trace log created by ...
Definition: gcs_interface.h:58