MySQL 8.0.32
Source Code Documentation
gcs_xcom_proxy.h
Go to the documentation of this file.
1/* Copyright (c) 2015, 2022, 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 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 GCS_XCOM_PROXY_INCLUDED
24#define GCS_XCOM_PROXY_INCLUDED
25
26#include <string>
27#include <unordered_set> // std::unordered_set
29
40#include "plugin/group_replication/libmysqlgcs/xdr_gen/xcom_vp.h"
41
42#define XCOM_COMM_STATUS_UNDEFINED -1
43
44/**
45 @class gcs_xcom_control_proxy
46
47 This class is an abstraction layer between xcom and the actual
48 implementation. The purpose of this is to allow Gcs_xcom_control_interface
49 to be unit testable by creating mock classes on top of it.
50*/
52 public:
53 explicit Gcs_xcom_proxy() = default;
54
55 /**
56 The destructor.
57 */
58 virtual ~Gcs_xcom_proxy() = default;
59
60 /**
61 This is an utility member function that is used to call into XCom for
62 creating list with node's addresses and their associated UUIDs. Note
63 that callers must provide the UUID.
64
65 @param n The number of elements in the list
66 @param names The names to be put on the list
67 @param uuids The UUIDs to be put on the list
68 @return a pointer to the list containing all the elements needed. The
69 caller is responsible to reclaim memory once he is done with this data
70 @c delete_node_address
71 */
72
73 virtual node_address *new_node_address_uuid(unsigned int n,
74 char const *names[],
75 blob uuids[]) = 0;
76
77 /**
78 This function is responsible to delete the list of nodes that had been
79 previously created by @c new_node_address.
80
81 @param n the length of the list
82 @param na the list to delete
83 */
84
85 virtual void delete_node_address(unsigned int n, node_address *na) = 0;
86
87 /**
88 This member function is responsible to call into XCom consensus and add a
89 node to the group. The caller is responsible for ensuring that the session
90 has been opened before @c open_session and also that the node is not yet
91 in the configuration.
92
93 The callee must have opened an XCom connection before calling this
94 function. @c xcom_client_open_connection.
95
96 @param fd the file descriptor to the XCom connection established earlier
97 @param nl The node list containing the list of peers to add
98 @param group_id the identifier of the group to which the nodes should
99 be added
100 @returns true (false) on success (failure). Success means that XCom will
101 process our request, failure means it won't. There could be errors
102 later in the process of adding a node. Since this is basically an
103 asynchronous function, one needs to wait for the actual view change
104 to validate that the node was added to the configuration.
105 */
106
107 virtual bool xcom_client_add_node(connection_descriptor *fd, node_list *nl,
108 uint32_t group_id) = 0;
109
110 /**
111 This member function is responsible for triggering the removal of a node
112 from the XCom configuration. This function is asynchronous, so you need to
113 wait for the view change to actually validate that the removal was
114 successful.
115
116 The caller is responsible for making sure that the server to be removed is
117 in the group.
118
119 This function MUST be called after opening the local XCom session
120 @c xcom_input_connect.
121
122 @param nl The list of nodes to remove from the group
123 @param group_id The identifier of the group from which the nodes will
124 be removed
125 @returns true (false) on success (failure). Success means that XCom will
126 process our request, failure means it won't. There could be errors
127 later in the process of removing a node. Since this is basically an
128 asynchronous function, one needs to wait for the actual view change
129 to validate that the nodes were removed from the configuration.
130 */
131
132 virtual bool xcom_client_remove_node(node_list *nl, uint32_t group_id) = 0;
133
134 /**
135 This member function is responsible for triggering the removal of a node
136 from the XCom configuration. This function is asynchronous, so you need to
137 wait for the view change to actually validate that the removal was
138 successful.
139
140 The caller is responsible for making sure that the server to be removed is
141 in the group.
142
143 The callee must have opened an XCom connection before calling this
144 function. @c xcom_client_open_connection.
145
146 @param fd the file descriptor to the XCom connection established earlier
147 @param nl The list of nodes to remove from the group
148 @param group_id The identifier of the group from which the nodes will
149 be removed
150 @returns true (false) on success (failure). Success means that XCom will
151 process our request, failure means it won't. There could be errors
152 later in the process of removing a node. Since this is basically an
153 asynchronous function, one needs to wait for the actual view change
154 to validate that the nodes were removed from the configuration.
155 */
156
157 virtual bool xcom_client_remove_node(connection_descriptor *fd, node_list *nl,
158 uint32_t group_id) = 0;
159
160 /**
161 This member function is responsible for retrieving the event horizon of the
162 XCom configuration.
163
164 This function REQUIRES a prior call to @c xcom_open_handlers to establish a
165 connection to XCom.
166
167 @param[in] group_id The identifier of the group from which the event horizon
168 will be retrieved
169 @param[out] event_horizon A reference to where the group's event horizon
170 value will be written to
171 @retval true if successful and @c event_horizon was written to
172 @retval false otherwise
173
174 */
176 uint32_t group_id, xcom_event_horizon &event_horizon) = 0;
177
178 /**
179 This member function is responsible for triggering the reconfiguration of
180 the event horizon of the XCom configuration. This function is asynchronous,
181 so you need to poll @c xcom_get_event_horizon to actually validate that the
182 reconfiguration was successful.
183
184 This function REQUIRES a prior call to @c xcom_open_handlers to establish a
185 connection to XCom.
186
187 @param event_horizon The desired event horizon value
188 @param group_id The identifier of the group from which the nodes will
189 be removed
190 @returns true (false) on success (failure). Success means that XCom will
191 process our request, failure means it won't. There could be errors
192 later in the process of setting the event horizon. Since this is
193 basically an asynchronous function, one needs to busy-wait on
194 @c xcom_client_get_event_horizon to validate that the event horizon
195 was modified.
196 */
198 uint32_t group_id, xcom_event_horizon event_horizon) = 0;
199
200 /**
201 This member function is responsible for triggering the reconfiguration of
202 the leaders of the XCom configuration. This function is asynchronous, so you
203 need to poll @c xcom_get_leaders to actually validate that the
204 reconfiguration was successful.
205
206 @param group_id The identifier of the group
207 @param nr_preferred_leaders Number of preferred leaders, i.e. elements in
208 @c preferred_leaders
209 @param preferred_leaders The "host:port" of the preferred leaders
210 @param max_nr_leaders Maximum number of active leaders
211 @returns true (false) on success (failure). Success means that XCom will
212 process our request, failure means it won't. There could be errors
213 later in the process of setting the leaders. Since this is
214 basically an asynchronous function, one needs to busy-wait on
215 @c xcom_client_get_leaders to validate that the leaders were
216 modified.
217 */
218 virtual bool xcom_client_set_leaders(uint32_t group_id,
219 u_int nr_preferred_leaders,
220 char const *preferred_leaders[],
221 node_no max_nr_leaders) = 0;
222
223 /**
224 This member function is responsible for retrieving the leaders of the
225 XCom configuration.
226
227 @param[in] group_id The identifier of the group
228 @param[out] leaders A reference to where the group's leaders will be written
229 to
230 @retval true if successful and @c leaders was written to
231 @retval false otherwise
232 */
233 virtual bool xcom_client_get_leaders(uint32_t group_id,
234 leader_info_data &leaders) = 0;
235
236 /**
237 This member function is responsible for retrieving the application payloads
238 decided in the synodes in @c synodes, from the XCom instance connected to
239 via @c fd.
240
241 @param[in] fd The file descriptor to the XCom connection established
242 earlier
243 @param[in] group_id The identifier of the group from which the payloads
244 will be retrieved
245 @param[in] synodes The desired synodes
246 @param[out] reply Where the requested payloads will be written to
247 @returns true (false) on success (failure). Success means that XCom had the
248 requested payloads, which were written to @c reply.
249 */
251 connection_descriptor *fd, uint32_t group_id, synode_no_array &synodes,
252 synode_app_data_array &reply) = 0;
253
254 /**
255 This member function is responsible for setting a new value for the maximum
256 size of the XCom cache.
257
258 This function is asynchronous, so the return value indicates only whether
259 the request to change the value was successfully pushed to XCom or not.
260 However, since the cache size is set only for the local node, and makes no
261 further verifications on the value, if XCom processes the request, it will
262 accept the new value. The callers of this function must validate that the
263 value set is within the limits set to the maximum size of the XCom cache.
264
265 This function REQUIRES a prior call to @c xcom_open_handlers to establish a
266 connection to XCom.
267
268 @param size The new value for the maximum size of the XCom cache.
269 @returns true (false) on success (failure). Success means that XCom will
270 process our request, failure means it won't.
271 */
272 virtual bool xcom_client_set_cache_size(uint64_t size) = 0;
273
274 /**
275 This member function is responsible for pushing data into consensus on
276 XCom. The caller is responsible to making sure that there is an open XCom
277 session @c xcom_input_connect and also that the server is part of the XCom
278 configuration before sending data to it.
279
280 @c data must have been allocated by one of the functions of the malloc
281 family, because @c data will be passed on to XCom. XCom is implemented in
282 C and will use @c free to dispose of @c data when it is finished with @c
283 data.
284
285 This function takes ownership of @c data. This means that this
286 function becomes responsible for the lifetime of @c data. Since this
287 function takes ownership of @c data, the caller must not interact with @c
288 data after passing it to this function.
289
290 @param size the size of the payload
291 @param data the payload
292 @returns true (false) on success (failure). Success means that XCom will
293 process our request, failure means it won't.
294 */
295
296 virtual bool xcom_client_send_data(unsigned long long size, char *data) = 0;
297
298 /**
299 This member function initializes XCom. This function must be called before
300 anything else and from within the XCom thread. It will eventually call
301 the main loop inside XCom.
302
303 @param listen_port the port that the local XCom is to be listening on.
304 */
305
306 virtual void xcom_init(xcom_port listen_port) = 0;
307
308 /**
309 This member function finishes the XCom thread. This function must be
310 called when the XCOM thread was started but the node has not joined
311 a group.
312
313 There could be errors later in the process of exiting XCom. Since this is
314 basically an asynchronous function, one needs to wait for the XCom thread to
315 to ensure that XCom terminated.
316 */
317
318 virtual void xcom_exit() = 0;
319
320 /*
321 Return the operation mode as an integer from an operation mode provided
322 as a string. Note that the string must be provided in upper case letters
323 and the possible values are: "DISABLED", "PREFERRED", "REQUIRED",
324 "VERIFY_CA" or "VERIFY_IDENTITY".
325
326 If a different value is provide, INVALID_SSL_MODE (-1) is returned.
327 */
328
329 virtual int xcom_get_ssl_mode(const char *mode) = 0;
330
331 /*
332 Set the operation mode which might be the following:
333
334 . SSL_DISABLED (1): The SSL mode will be disabled and this is the default
335 value.
336
337 . SSL_PREFERRED (2): The SSL mode will be always disabled if this value is
338 provided and is only allowed to keep the solution compatibility with
339 MySQL server.
340
341 . SSL_REQUIRED (4): The SSL mode will be enabled but the verifications
342 described in the next modes are not performed.
343
344 . SSL_VERIFY_CA (4) - Verify the server TLS certificate against the
345 configured Certificate Authority (CA) certificates. The connection attempt
346 fails if no valid matching CA certificates are found.
347
348 . SSL_VERIFY_IDENTITY (5): Like VERIFY_CA, but additionally verify that the
349 server certificate matches the host to which the connection is attempted.
350
351 If a different value is provide, INVALID_SSL_MODE (-1) is returned.
352 */
353
354 virtual int xcom_set_ssl_mode(int mode) = 0;
355
356 /*
357 Return the operation fips mode as an integer from an operation fips mode
358 provided as a string. Note that the string must be provided in upper case
359 letters and the possible values are: "OFF", "ON", "STRICT",
360
361 If a different value is provide, INVALID_SSL_MODE (-1) is returned.
362 */
363
364 virtual int xcom_get_ssl_fips_mode(const char *mode) = 0;
365
366 /*
367 Set the operation fips mode which might be the following:
368
369 . SSL_FIPS_MODE_OFF (0): This will set openssl fips mode value to 0
370
371 . SSL_FIPS_MODE_ON (1): This will set openssl fips mode value to 1
372
373 . SSL_FIPS_MODE_STRICT (2): This will set openssl fips mode value to 2
374
375 If a different value is provide, INVALID_SSL_FIPS_MODE (-1) is returned.
376 */
377
378 virtual int xcom_set_ssl_fips_mode(int mode) = 0;
379
380 /**
381 Initialize the SSL.
382
383 @returns true on error. False otherwise.
384 */
385
386 virtual bool xcom_init_ssl() = 0;
387
388 /*
389 Destroy the SSL Configuration freeing allocated memory.
390 */
391
392 virtual void xcom_destroy_ssl() = 0;
393
394 /**
395 Return whether the SSL will be used to encrypt data or not.
396
397 @returns true (false) if XCom will (not) use SSL
398 */
399
400 virtual bool xcom_use_ssl() = 0;
401
403 tls_parameters tls) = 0;
404
405 virtual site_def const *find_site_def(synode_no synode) = 0;
406
407 /**
408 This member function boots XCom.
409
410 @param nl List with a single member - the one that boots the group
411 @param group_id the Group identifier to which the member belongs to
412 @returns true (false) on success (failure). Success means that XCom will
413 process our request, failure means it won't. There could be errors
414 later in the process of booting. Since this is basically an
415 asynchronous function, one needs to wait for XCom to signal it is
416 ready to validate whether it booted.
417 */
418
419 virtual bool xcom_client_boot(node_list *nl, uint32_t group_id) = 0;
420
421 /**
422 This member function opens a connection to an XCom instance.
423
424 @param addr The XCom instance address
425 @param port The XCom instance port
426 @return a valid file descriptor on success, -1 otherwise
427 */
428
430 std::string addr, xcom_port port) = 0;
431
432 /**
433 This member function closes the connection to an XCom instance.
434
435 @param fd The connection file descriptor
436 @returns true (false) on success (failure)
437 */
438
440
441 /**
442 This member waits for XCom to be initialized.
443 */
444
446
447 /*
448 This member retrieves the value of XCom initialized
449 */
450 virtual bool xcom_is_ready() = 0;
451
452 /*
453 This member sets the value of XCom initialized
454 */
455 virtual void xcom_set_ready(bool value) = 0;
456
457 /*
458 This member signals that XCom has initialized.
459 */
460 virtual void xcom_signal_ready() = 0;
461
462 /**
463 @brief Call this method to wait for XCom communications to be initialized.
464
465 Call this method to wait for XCom communications to be initialized. It will
466 block until XCom communications are either OK or error out. The value of
467 the status (XCOM_COMMS_OK or XCOM_COMMS_ERROR) is written into the status
468 out parameters.
469
470 @param [out] status value of the XCom communication layer status.
471 It can be either XCOM_COMMS_OK or XCOM_COMMS_ERROR
472 */
474
475 /*
476 This verifies if the communication status callback from XCom has been called
477 and if the internal cached status is different from
478 XCOM_COMM_STATUS_UNDEFINED
479 */
481
482 /*
483 This sets the status value of communication status callback from XCom.
484 Its main purpose is to reset the internal cached status to
485 XCOM_COMM_STATUS_UNDEFINED
486
487 @param status the new status value
488 */
489 virtual void xcom_set_comms_status(int status) = 0;
490
491 /*
492 This modifies the internal cached status to whatever value is delivered
493 by the XCom communication status callback. Then, it signals all threads
494 that might be waiting on xcom_wait_for_xcom_comms_status_change.
495
496 @param status the new status value
497 */
499
500 /**
501 @brief Call this method to wait for XCom to exit.
502
503 Call this method to wait for XCom to exit. It will block until XCom has
504 exit or an error occurs.
505
506 @return GCS_OK if success, otherwise GCS_NOK.
507 */
508
510
511 /**
512 This verifies if XCom has finished or not.
513 */
514
515 virtual bool xcom_is_exit() = 0;
516
517 /**
518 This sets whether XCom has finished or not.
519 */
520
521 virtual void xcom_set_exit(bool value) = 0;
522
523 /**
524 Clean up variables used to notify states in the XCOM's state
525 machine.
526 */
527 virtual void xcom_set_cleanup() = 0;
528
529 /**
530 This modifies the internal cached status and signals all threads
531 that might be waiting on xcom_wait_exit.
532 */
533
534 virtual void xcom_signal_exit() = 0;
535
536 /**
537 This method forces XCom to inject a new configuration in the group,
538 even if it does not contain a majority of members.
539
540 @param nl The list of nodes that will belong to this new configuration
541 @param group_id The identifier of the group from which the nodes will
542 belong
543 @returns true (false) on success (failure). Success means that XCom will
544 process our request, failure means it won't. There could be errors
545 later in the process of forcing the configuration. Since this is
546 basically an asynchronous function, one needs to wait for the
547 actual view change to validate that the configuration was forced.
548 */
549 virtual bool xcom_client_force_config(node_list *nl, uint32_t group_id) = 0;
550
551 /**
552 Function used to boot a node in XCOM.
553
554 @param node Node information.
555 @param group_id_hash Hash of group identifier.
556 @returns true (false) on success (failure). Success means that XCom will
557 process our request, failure means it won't. There could be errors
558 later in the process of booting. Since this is basically an
559 asynchronous function, one needs to wait for XCom to signal it is
560 ready to validate whether it booted.
561 */
563 uint32_t group_id_hash) = 0;
564
565 /**
566 Function to remove a set of nodes from XCOM.
567
568 @param nodes Set of nodes.
569 @param group_id_hash Hash of group identifier.
570 @returns true (false) on success (failure). Success means that XCom will
571 process our request, failure means it won't. There could be errors
572 later in the process of removing a node. Since this is basically an
573 asynchronous function, one needs to wait for the actual view change
574 to validate that the nodes were removed from the configuration.
575 */
576
578 uint32_t group_id_hash) = 0;
579
580 /**
581 Function to remove a set of nodes from XCOM.
582
583 @param con Connection to a node that will carry on the request.
584 @param nodes Set of nodes to remove.
585 @param group_id_hash Hash of group identifier.
586 @returns true (false) on success (failure). Success means that XCom will
587 process our request, failure means it won't. There could be errors
588 later in the process of removing a node. Since this is basically an
589 asynchronous function, one needs to wait for the actual view change
590 to validate that the nodes were removed from the configuration.
591 */
592
594 Gcs_xcom_nodes &nodes,
595 uint32_t group_id_hash) = 0;
596
597 /**
598 Function to remove a node from XCOM.
599
600 @param node Node information.
601 @param group_id_hash Hash of group identifier.
602 @returns true (false) on success (failure). Success means that XCom will
603 process our request, failure means it won't. There could be errors
604 later in the process of removing a node. Since this is basically an
605 asynchronous function, one needs to wait for the actual view change
606 to validate that the node was removed from the configuration.
607 */
608
610 uint32_t group_id_hash) = 0;
611
612 /**
613 Function to add a set of nodes to XCOM.
614
615 @param con Connection to a node that will carry on the request.
616 @param nodes Set of nodes.
617 @param group_id_hash Hash of group identifier.
618 @returns true (false) on success (failure). Success means that XCom will
619 process our request, failure means it won't. There could be errors
620 later in the process of adding a node. Since this is basically an
621 asynchronous function, one needs to wait for the actual view change
622 to validate that the nodes were added to the configuration.
623 */
624
626 uint32_t group_id_hash) = 0;
627
628 /**
629 Function to add a node to XCOM.
630
631 @param con Connection to a node that will carry on the request.
632 @param node Node information.
633 @param group_id_hash Hash of group identifier.
634 @returns true (false) on success (failure). Success means that XCom will
635 process our request, failure means it won't. There could be errors
636 later in the process of adding a node. Since this is basically an
637 asynchronous function, one needs to wait for the actual view change
638 to validate that the node was added to the configuration.
639 */
640
642 const Gcs_xcom_node_information &node,
643 uint32_t group_id_hash) = 0;
644
645 /**
646 Function to retrieve XCOM's minimum supported event horizon value.
647 */
648 virtual xcom_event_horizon xcom_get_minimum_event_horizon() = 0;
649
650 /**
651 Function to retrieve XCOM's maximum supported event horizon value.
652 */
653 virtual xcom_event_horizon xcom_get_maximum_event_horizon() = 0;
654
655 /**
656 Function to retrieve XCOM's event horizon.
657
658 @param[in] group_id_hash Hash of group identifier.
659 @param[out] event_horizon A reference to where the group's event horizon
660 value will be written to
661
662 @return true if successful, false otherwise
663 */
664 virtual bool xcom_get_event_horizon(uint32_t group_id_hash,
665 xcom_event_horizon &event_horizon) = 0;
666
667 /**
668 Function to retrieve the application payloads decided on a set of synodes.
669
670 @param[in] xcom_instance The XCom instance to connect to
671 @param[in] group_id_hash Hash of group identifier.
672 @param[in] synode_set The desired synodes
673 @param[out] reply Where the requested payloads will be written to
674 @returns true (false) on success (failure). Success means that XCom had the
675 requested payloads, which were written to @c reply.
676 */
678 Gcs_xcom_node_information const &xcom_instance, uint32_t group_id_hash,
679 const std::unordered_set<Gcs_xcom_synode> &synode_set,
680 synode_app_data_array &reply) = 0;
681
682 /**
683 Function to reconfigure XCOM's event horizon.
684
685 @param group_id_hash Hash of group identifier.
686 @param event_horizon Desired event horizon value.
687
688 @return true if successful, false otherwise
689 */
690 virtual bool xcom_set_event_horizon(uint32_t group_id_hash,
691 xcom_event_horizon event_horizon) = 0;
692
693 virtual bool xcom_set_leaders(uint32_t group_id_hash,
694 u_int nr_preferred_leaders,
695 char const *preferred_leaders[],
696 node_no max_nr_leaders) = 0;
697 virtual bool xcom_get_leaders(uint32_t group_id_hash,
698 leader_info_data &leaders) = 0;
699
700 /**
701 Function to reconfigure the maximum size of the XCom cache.
702
703 @param size Cache size limit.
704 @return true if the operation is successfully pushed to XCom's queue,
705 false otherwise
706 */
707 virtual bool xcom_set_cache_size(uint64_t size) = 0;
708
709 /**
710 Function to force the set of nodes in XCOM's configuration.
711
712 @param nodes Set of nodes.
713 @param group_id_hash Hash of group identifier.
714 @returns true (false) on success (failure). Success means that XCom will
715 process our request, failure means it won't. There could be errors
716 later in the process of forcing the configuration. Since this is
717 basically an asynchronous function, one needs to wait for the
718 actual view change to validate that the configuration was forced.
719 */
720
721 virtual bool xcom_force_nodes(Gcs_xcom_nodes &nodes,
722 unsigned int group_id_hash) = 0;
723
724 /**
725 Function that retrieves the value that signals that XCom
726 must be forcefully stopped.
727
728 @return 1 if XCom needs to forcefully exit. 0 otherwise.
729 */
730 virtual bool get_should_exit() = 0;
731
732 /**
733 Function that sets the value that signals that XCom
734 must be forcefully stopped.
735 */
736 virtual void set_should_exit(bool should_exit) = 0;
737
738 /**
739 * Opens the input channel to XCom.
740 *
741 * @param address address to connect to
742 * @param port port to connect to
743 * @retval true if successful
744 * @retval false otherwise
745 */
746 virtual bool xcom_input_connect(std::string const &address,
747 xcom_port port) = 0;
748
749 /**
750 * Closes the input channel to XCom.
751 */
752 virtual void xcom_input_disconnect() = 0;
753
754 /**
755 * Attempts to send the command @c data to XCom. (Called by GCS.)
756 *
757 * The function takes ownership of @c data.
758 *
759 * @pre The input channel to XCom is open, i.e. @c xcom_input_connect
760 * @param data the command to send to XCom
761 * @retval true if the command was sent to XCom
762 * @retval false if the command was not sent to XCom
763 */
764 virtual bool xcom_input_try_push(app_data_ptr data) = 0;
765
766 /**
767 * Attempts to send the command @c data to XCom, and returns a future to
768 * XCom's reply. (Called by GCS.)
769 *
770 * The function takes ownership of @c data.
771 *
772 * @pre The input channel to XCom is open, i.e. @c xcom_input_connect
773 * @param data the command to send to XCom
774 * @returns a future pointer to a Reply object if successful, a future pointer
775 * to nullptr otherwise
776 */
778 app_data_ptr data) = 0;
779
780 /**
781 * Attempts to retrieve incoming commands. (Called by XCom.)
782 *
783 * @pre The input channel to XCom is open, i.e. @c xcom_input_connect
784 * @retval app_data_ptr linked list of the queued commands if the queue is
785 * not empty
786 * @retval nullptr if the queue is empty
787 */
789
790 /**
791 * Performs a test connection to the given XCom instance via TCP.
792 *
793 * @param host the XCom instance's host
794 * @param port the XCom instance's port
795 * @returns true if we were able to successfully connect, false otherwise.
796 */
797 virtual bool test_xcom_tcp_connection(std::string &host, xcom_port port) = 0;
798
799 /**
800 * @brief Initializes XCom's Network Manager. This must be called to ensure
801 * that we have client connection abilities since the start of GCS.
802 *
803 * @return true in case of error, false otherwise.
804 */
805 virtual bool initialize_network_manager() = 0;
806
807 /**
808 * @brief Finalizes XCom's Network Manager. This cleans up everythins
809 * regarding network.
810 *
811 * @return true in case of error, false otherwise.
812 */
813 virtual bool finalize_network_manager() = 0;
814
815 /**
816 * @brief Set XCom's network manager active provider
817 *
818 * @param new_value the value of the Communication Stack to use.
819 *
820 * @return true in case of error, false otherwise.
821 */
823 enum_transport_protocol new_value) = 0;
824};
825
826/*
827 Virtual class that contains implementation of methods used to
828 map a node representation into XCOM's representation.
829 This layer becomes necessary to avoid duplicating code in test
830 cases.
831*/
833 public:
834 explicit Gcs_xcom_proxy_base() = default;
835 ~Gcs_xcom_proxy_base() override = default;
836
838 uint32_t group_id_hash) override;
840 uint32_t group_id_hash) override;
842 uint32_t group_id_hash) override;
844 uint32_t group_id_hash) override;
846 uint32_t group_id_hash) override;
848 const Gcs_xcom_node_information &node,
849 uint32_t group_id_hash) override;
850 xcom_event_horizon xcom_get_minimum_event_horizon() override;
851 xcom_event_horizon xcom_get_maximum_event_horizon() override;
852 bool xcom_get_event_horizon(uint32_t group_id_hash,
853 xcom_event_horizon &event_horizon) override;
854 bool xcom_set_event_horizon(uint32_t group_id_hash,
855 xcom_event_horizon event_horizon) override;
856 bool xcom_set_leaders(uint32_t group_id_hash, u_int nr_preferred_leaders,
857 char const *preferred_leaders[],
858 node_no max_nr_leaders) override;
859 bool xcom_get_leaders(uint32_t group_id_hash,
860 leader_info_data &leaders) override;
862 Gcs_xcom_node_information const &xcom_instance, uint32_t group_id_hash,
863 const std::unordered_set<Gcs_xcom_synode> &synode_set,
864 synode_app_data_array &reply) override;
865 bool xcom_set_cache_size(uint64_t size) override;
866 bool xcom_force_nodes(Gcs_xcom_nodes &nodes, uint32_t group_id_hash) override;
867
868 bool initialize_network_manager() override;
869 bool finalize_network_manager() override;
871 enum_transport_protocol new_value) override;
872
873 private:
874 /* Serialize information on nodes to be sent to XCOM */
875 bool serialize_nodes_information(Gcs_xcom_nodes &nodes, node_list &nl);
876
877 /* Free information on nodes sent to XCOM */
878 void free_nodes_information(node_list &nl);
879 bool test_xcom_tcp_connection(std::string &host, xcom_port port) override;
880};
881
882/**
883 @class gcs_xcom_control_proxy_impl
884
885 Implementation of gcs_xcom_control_proxy to be used by whom
886 instantiates Gcs_xcom_control_interface to be used in a real
887 scenario.
888*/
890 public:
891 explicit Gcs_xcom_proxy_impl();
892 Gcs_xcom_proxy_impl(unsigned int wt);
893 ~Gcs_xcom_proxy_impl() override;
894
895 node_address *new_node_address_uuid(unsigned int n, char const *names[],
896 blob uuids[]) override;
897 void delete_node_address(unsigned int n, node_address *na) override;
898 bool xcom_client_add_node(connection_descriptor *fd, node_list *nl,
899 uint32_t group_id) override;
900 bool xcom_client_remove_node(node_list *nl, uint32_t group_id) override;
901 bool xcom_client_remove_node(connection_descriptor *fd, node_list *nl,
902 uint32_t group_id) override;
904 uint32_t group_id, xcom_event_horizon &event_horizon) override;
905 bool xcom_client_set_event_horizon(uint32_t group_id,
906 xcom_event_horizon event_horizon) override;
907 bool xcom_client_set_leaders(uint32_t gid, u_int nr_preferred_leaders,
908 char const *preferred_leaders[],
909 node_no max_nr_leaders) override;
910 bool xcom_client_get_leaders(uint32_t gid,
911 leader_info_data &leaders) override;
912
914 uint32_t group_id_hash,
915 synode_no_array &synodes,
916 synode_app_data_array &reply) override;
917
918 bool xcom_client_set_cache_size(uint64_t size) override;
919 bool xcom_client_boot(node_list *nl, uint32_t group_id) override;
921 xcom_port port) override;
923 bool xcom_client_send_data(unsigned long long size, char *data) override;
924 void xcom_init(xcom_port listen_port) override;
925 void xcom_exit() override;
926 int xcom_get_ssl_mode(const char *mode) override;
927 int xcom_get_ssl_fips_mode(const char *mode) override;
928 int xcom_set_ssl_fips_mode(int mode) override;
929 int xcom_set_ssl_mode(int mode) override;
930 bool xcom_init_ssl() override;
931 void xcom_destroy_ssl() override;
932 bool xcom_use_ssl() override;
934 site_def const *find_site_def(synode_no synode) override;
935
937 bool xcom_is_ready() override;
938 void xcom_set_ready(bool value) override;
939 void xcom_signal_ready() override;
940
942 bool xcom_has_comms_status_changed() override;
943 void xcom_set_comms_status(int status) override;
944 void xcom_signal_comms_status_changed(int status) override;
945
947 bool xcom_is_exit() override;
948 void xcom_set_exit(bool value) override;
949 void xcom_signal_exit() override;
950
951 void xcom_set_cleanup() override;
952
953 bool xcom_client_force_config(node_list *nl, uint32_t group_id) override;
954 bool get_should_exit() override;
955 void set_should_exit(bool should_exit) override;
956
957 bool xcom_input_connect(std::string const &address, xcom_port port) override;
958 void xcom_input_disconnect() override;
959 bool xcom_input_try_push(app_data_ptr data) override;
961 app_data_ptr data) override;
963
964 private:
965 /*
966 Maximum waiting time used by timed_waits in xcom_wait_ready and
967 xcom_wait_for_xcom_comms_status_change.
968 */
969 unsigned int m_wait_time;
970
971 // For synchronization between XCom and MySQL GCS infrastructure at startup.
975
979
983
985
986 // Stores SSL parameters
988 const char *m_server_key_file;
990 const char *m_client_key_file;
992 const char *m_ca_file;
993 const char *m_ca_path;
994 const char *m_crl_file;
995 const char *m_crl_path;
996 const char *m_cipher;
997 const char *m_tls_version;
999
1000 std::atomic_bool m_should_exit;
1001
1002 /* Input channel to XCom */
1004
1005 /*
1006 Auxiliary function for the "xcom_wait_*" functions. Executes the actual
1007 timed wait for the variable associated with the condition to be changed
1008 and performs error checking.
1009
1010 The function will lock @c condition_lock, so it must be unlocked when the
1011 function is called.
1012
1013 @param condition Cond variable on which we want to wait.
1014 @param condition_lock Lock to access the @c condition variable.
1015 @param need_to_wait A function implemented by the caller that verifies if
1016 the wait shall be executed. The function must return
1017 true when the wait must be executed, false otherwise.
1018 @param condition_event A function that returns the string identifying the
1019 event associated with the cond. The string will be
1020 printed as a suffix to the error messages:
1021 "<error code> while waiting for <cond_event string>"
1022 The function receives the error code of the timed
1023 wait as an argument.
1024
1025 @retval GCS_OK if the wait is successful;
1026 GCS_NOK if the timed wait terminates with an error.
1027 */
1029 My_xp_cond_impl &condition, My_xp_mutex_impl &condition_lock,
1030 std::function<bool(void)> need_to_wait,
1031 std::function<const std::string(int res)> condition_event);
1032
1033 /*
1034 Disabling the copy constructor and assignment operator.
1035 */
1038};
1039
1040/**
1041 A Gcs_xcom_interface needs to have an instance of this class
1042 initialized before engaging XCom.
1043 */
1045 public:
1046 explicit Gcs_xcom_app_cfg() = default;
1047
1048 virtual ~Gcs_xcom_app_cfg() = default;
1049
1050 /**
1051 Initializes the data structures to communicate with
1052 XCom the application injected configuration options.
1053 */
1054 void init();
1055
1056 /**
1057 Configures how many loops to spin before blocking on
1058 the poll system call.
1059 @param loops the number of spins.
1060 */
1061 void set_poll_spin_loops(unsigned int loops);
1062
1063 /**
1064 Configures the maximum size of the xcom cache.
1065 @param size the maximum size of the cache.
1066 */
1067 void set_xcom_cache_size(uint64_t size);
1068
1069 /**
1070 Configures XCom with its unique instance identifier, i.e. its (address,
1071 incarnation) pair.
1072
1073 Takes ownership of @c identity.
1074
1075 @param identity the unique identifier
1076 @retval true if there was an error configuring XCom
1077 @retval false if configuration was successful
1078 */
1079 bool set_identity(node_address *identity);
1080
1081 /**
1082 * @brief Sets the network namespace manager
1083 *
1084 * @param ns_mgr a reference to a Network_namespace_manager implementation
1085 */
1087
1088 /**
1089 Must be called when XCom is not engaged anymore.
1090 */
1091 void deinit();
1092};
1093
1096 unsigned int port;
1097};
1098
1099#endif /* GCS_XCOM_PROXY_INCLUDED */
A Gcs_xcom_interface needs to have an instance of this class initialized before engaging XCom.
Definition: gcs_xcom_proxy.h:1044
void set_poll_spin_loops(unsigned int loops)
Configures how many loops to spin before blocking on the poll system call.
Definition: gcs_xcom_proxy.cc:625
bool set_identity(node_address *identity)
Configures XCom with its unique instance identifier, i.e.
Definition: gcs_xcom_proxy.cc:638
void init()
Initializes the data structures to communicate with XCom the application injected configuration optio...
Definition: gcs_xcom_proxy.cc:621
virtual ~Gcs_xcom_app_cfg()=default
void deinit()
Must be called when XCom is not engaged anymore.
Definition: gcs_xcom_proxy.cc:623
void set_xcom_cache_size(uint64_t size)
Configures the maximum size of the xcom cache.
Definition: gcs_xcom_proxy.cc:629
Gcs_xcom_app_cfg()=default
void set_network_namespace_manager(Network_namespace_manager *ns_mgr)
Sets the network namespace manager.
Definition: gcs_xcom_proxy.cc:633
MPSC queue with FIFO semantics used to send commands to XCom.
Definition: gcs_xcom_input_queue.h:56
std::future< std::unique_ptr< Reply > > future_reply
Definition: gcs_xcom_input_queue.h:59
It represents a node within a group and is identified by the member identifier, unique identifier and...
Definition: gcs_xcom_group_member_information.h:192
This class contains information on the configuration, i.e set of nodes or simply site definition.
Definition: gcs_xcom_group_member_information.h:390
Definition: gcs_xcom_proxy.h:832
bool xcom_force_nodes(Gcs_xcom_nodes &nodes, uint32_t group_id_hash) override
Definition: gcs_xcom_proxy.cc:810
xcom_event_horizon xcom_get_minimum_event_horizon() override
Function to retrieve XCOM's minimum supported event horizon value.
Definition: gcs_xcom_proxy.cc:709
bool xcom_add_node(connection_descriptor &con, const Gcs_xcom_node_information &node, uint32_t group_id_hash) override
Function to add a node to XCOM.
Definition: gcs_xcom_proxy.cc:890
bool xcom_get_synode_app_data(Gcs_xcom_node_information const &xcom_instance, uint32_t group_id_hash, const std::unordered_set< Gcs_xcom_synode > &synode_set, synode_app_data_array &reply) override
Function to retrieve the application payloads decided on a set of synodes.
Definition: gcs_xcom_proxy.cc:774
xcom_event_horizon xcom_get_maximum_event_horizon() override
Function to retrieve XCOM's maximum supported event horizon value.
Definition: gcs_xcom_proxy.cc:713
bool test_xcom_tcp_connection(std::string &host, xcom_port port) override
Performs a test connection to the given XCom instance via TCP.
Definition: gcs_xcom_proxy.cc:899
bool serialize_nodes_information(Gcs_xcom_nodes &nodes, node_list &nl)
Definition: gcs_xcom_proxy.cc:825
bool xcom_get_leaders(uint32_t group_id_hash, leader_info_data &leaders) override
Definition: gcs_xcom_proxy.cc:742
~Gcs_xcom_proxy_base() override=default
bool xcom_add_nodes(connection_descriptor &con, Gcs_xcom_nodes &nodes, uint32_t group_id_hash) override
Function to add a set of nodes to XCOM.
Definition: gcs_xcom_proxy.cc:874
Gcs_xcom_proxy_base()=default
bool set_network_manager_active_provider(enum_transport_protocol new_value) override
Set XCom's network manager active provider.
Definition: gcs_xcom_proxy.cc:922
bool xcom_remove_nodes(Gcs_xcom_nodes &nodes, uint32_t group_id_hash) override
Function to remove a set of nodes from XCOM.
Definition: gcs_xcom_proxy.cc:672
void free_nodes_information(node_list &nl)
Definition: gcs_xcom_proxy.cc:851
bool xcom_boot_node(Gcs_xcom_node_information &node, uint32_t group_id_hash) override
Function used to boot a node in XCOM.
Definition: gcs_xcom_proxy.cc:857
bool xcom_set_event_horizon(uint32_t group_id_hash, xcom_event_horizon event_horizon) override
Function to reconfigure XCOM's event horizon.
Definition: gcs_xcom_proxy.cc:723
bool xcom_set_cache_size(uint64_t size) override
Function to reconfigure the maximum size of the XCom cache.
Definition: gcs_xcom_proxy.cc:805
bool xcom_set_leaders(uint32_t group_id_hash, u_int nr_preferred_leaders, char const *preferred_leaders[], node_no max_nr_leaders) override
Definition: gcs_xcom_proxy.cc:729
bool xcom_remove_node(const Gcs_xcom_node_information &node, uint32_t group_id_hash) override
Function to remove a node from XCOM.
Definition: gcs_xcom_proxy.cc:701
bool initialize_network_manager() override
Initializes XCom's Network Manager.
Definition: gcs_xcom_proxy.cc:914
bool xcom_get_event_horizon(uint32_t group_id_hash, xcom_event_horizon &event_horizon) override
Function to retrieve XCOM's event horizon.
Definition: gcs_xcom_proxy.cc:717
bool finalize_network_manager() override
Finalizes XCom's Network Manager.
Definition: gcs_xcom_proxy.cc:918
Definition: gcs_xcom_proxy.h:889
void xcom_signal_exit() override
This modifies the internal cached status and signals all threads that might be waiting on xcom_wait_e...
Definition: gcs_xcom_proxy.cc:525
bool get_should_exit() override
Function that retrieves the value that signals that XCom must be forcefully stopped.
Definition: gcs_xcom_proxy.cc:576
int m_ssl_mode
Definition: gcs_xcom_proxy.h:987
void xcom_exit() override
This member function finishes the XCom thread.
Definition: gcs_xcom_proxy.cc:250
const char * m_server_cert_file
Definition: gcs_xcom_proxy.h:989
void xcom_destroy_ssl() override
Definition: gcs_xcom_proxy.cc:298
enum_gcs_error xcom_wait_ready() override
This member waits for XCom to be initialized.
Definition: gcs_xcom_proxy.cc:464
void xcom_set_comms_status(int status) override
Definition: gcs_xcom_proxy.cc:563
bool xcom_client_set_leaders(uint32_t gid, u_int nr_preferred_leaders, char const *preferred_leaders[], node_no max_nr_leaders) override
This member function is responsible for triggering the reconfiguration of the leaders of the XCom con...
Definition: gcs_xcom_proxy.cc:128
const char * m_client_cert_file
Definition: gcs_xcom_proxy.h:991
node_address * new_node_address_uuid(unsigned int n, char const *names[], blob uuids[]) override
This is an utility member function that is used to call into XCom for creating list with node's addre...
Definition: gcs_xcom_proxy.cc:420
int xcom_get_ssl_fips_mode(const char *mode) override
Definition: gcs_xcom_proxy.cc:262
const char * m_tls_version
Definition: gcs_xcom_proxy.h:997
Gcs_xcom_proxy_impl(Gcs_xcom_proxy_impl const &)
bool xcom_is_exit() override
This verifies if XCom has finished or not.
Definition: gcs_xcom_proxy.cc:509
const char * m_crl_file
Definition: gcs_xcom_proxy.h:994
void set_should_exit(bool should_exit) override
Function that sets the value that signals that XCom must be forcefully stopped.
Definition: gcs_xcom_proxy.cc:580
enum_gcs_error xcom_wait_exit() override
Call this method to wait for XCom to exit.
Definition: gcs_xcom_proxy.cc:496
void xcom_set_cleanup() override
Clean up variables used to notify states in the XCOM's state machine.
Definition: gcs_xcom_proxy.cc:252
bool xcom_input_connect(std::string const &address, xcom_port port) override
Opens the input channel to XCom.
Definition: gcs_xcom_proxy.cc:584
bool xcom_client_close_connection(connection_descriptor *fd) override
This member function closes the connection to an XCom instance.
Definition: gcs_xcom_proxy.cc:45
My_xp_mutex_impl m_lock_xcom_comms_status
Definition: gcs_xcom_proxy.h:976
bool xcom_client_boot(node_list *nl, uint32_t group_id) override
This member function boots XCom.
Definition: gcs_xcom_proxy.cc:204
bool xcom_client_force_config(node_list *nl, uint32_t group_id) override
This method forces XCom to inject a new configuration in the group, even if it does not contain a maj...
Definition: gcs_xcom_proxy.cc:648
const char * m_ca_file
Definition: gcs_xcom_proxy.h:992
void xcom_wait_for_xcom_comms_status_change(int &status) override
Call this method to wait for XCom communications to be initialized.
Definition: gcs_xcom_proxy.cc:532
Gcs_xcom_input_queue m_xcom_input_queue
Definition: gcs_xcom_proxy.h:1003
site_def const * find_site_def(synode_no synode) override
Definition: gcs_xcom_proxy.cc:416
connection_descriptor * xcom_client_open_connection(std::string, xcom_port port) override
This member function opens a connection to an XCom instance.
Definition: gcs_xcom_proxy.cc:50
bool xcom_input_try_push(app_data_ptr data) override
Attempts to send the command data to XCom.
Definition: gcs_xcom_proxy.cc:598
bool xcom_client_add_node(connection_descriptor *fd, node_list *nl, uint32_t group_id) override
This member function is responsible to call into XCom consensus and add a node to the group.
Definition: gcs_xcom_proxy.cc:56
void xcom_set_ssl_parameters(ssl_parameters ssl, tls_parameters tls) override
Definition: gcs_xcom_proxy.cc:308
My_xp_cond_impl m_cond_xcom_ready
Definition: gcs_xcom_proxy.h:973
void xcom_set_ready(bool value) override
Definition: gcs_xcom_proxy.cc:483
void xcom_set_exit(bool value) override
This sets whether XCom has finished or not.
Definition: gcs_xcom_proxy.cc:519
bool xcom_use_ssl() override
Return whether the SSL will be used to encrypt data or not.
Definition: gcs_xcom_proxy.cc:302
int xcom_get_ssl_mode(const char *mode) override
Definition: gcs_xcom_proxy.cc:258
void xcom_input_disconnect() override
Closes the input channel to XCom.
Definition: gcs_xcom_proxy.cc:594
xcom_input_request_ptr xcom_input_try_pop() override
Attempts to retrieve incoming commands.
Definition: gcs_xcom_proxy.cc:617
const char * m_cipher
Definition: gcs_xcom_proxy.h:996
unsigned int m_wait_time
Definition: gcs_xcom_proxy.h:969
bool xcom_init_ssl() override
Initialize the SSL.
Definition: gcs_xcom_proxy.cc:275
const char * m_client_key_file
Definition: gcs_xcom_proxy.h:990
My_xp_cond_impl m_cond_xcom_exit
Definition: gcs_xcom_proxy.h:981
My_xp_socket_util * m_socket_util
Definition: gcs_xcom_proxy.h:984
Gcs_xcom_input_queue::future_reply xcom_input_try_push_and_get_reply(app_data_ptr data) override
Attempts to send the command data to XCom, and returns a future to XCom's reply.
Definition: gcs_xcom_proxy.cc:608
const char * m_crl_path
Definition: gcs_xcom_proxy.h:995
bool m_is_xcom_ready
Definition: gcs_xcom_proxy.h:974
void xcom_signal_ready() override
Definition: gcs_xcom_proxy.cc:489
~Gcs_xcom_proxy_impl() override
Definition: gcs_xcom_proxy.cc:403
int m_xcom_comms_status
Definition: gcs_xcom_proxy.h:978
My_xp_cond_impl m_cond_xcom_comms_status
Definition: gcs_xcom_proxy.h:977
bool xcom_client_remove_node(node_list *nl, uint32_t group_id) override
This member function is responsible for triggering the removal of a node from the XCom configuration.
Definition: gcs_xcom_proxy.cc:66
const char * m_server_key_file
Definition: gcs_xcom_proxy.h:988
Gcs_xcom_proxy_impl()
Definition: gcs_xcom_proxy.cc:325
bool xcom_client_set_cache_size(uint64_t size) override
This member function is responsible for setting a new value for the maximum size of the XCom cache.
Definition: gcs_xcom_proxy.cc:192
int xcom_set_ssl_mode(int mode) override
Definition: gcs_xcom_proxy.cc:267
const char * m_tls_ciphersuites
Definition: gcs_xcom_proxy.h:998
void xcom_init(xcom_port listen_port) override
This member function initializes XCom.
Definition: gcs_xcom_proxy.cc:243
void xcom_signal_comms_status_changed(int status) override
Definition: gcs_xcom_proxy.cc:569
const char * m_ca_path
Definition: gcs_xcom_proxy.h:993
My_xp_mutex_impl m_lock_xcom_ready
Definition: gcs_xcom_proxy.h:972
void delete_node_address(unsigned int n, node_address *na) override
This function is responsible to delete the list of nodes that had been previously created by new_node...
Definition: gcs_xcom_proxy.cc:40
bool xcom_is_ready() override
Definition: gcs_xcom_proxy.cc:473
Gcs_xcom_proxy_impl & operator=(Gcs_xcom_proxy_impl const &)
std::atomic_bool m_should_exit
Definition: gcs_xcom_proxy.h:1000
bool xcom_client_send_data(unsigned long long size, char *data) override
This member function is responsible for pushing data into consensus on XCom.
Definition: gcs_xcom_proxy.cc:215
bool xcom_client_get_leaders(uint32_t gid, leader_info_data &leaders) override
This member function is responsible for retrieving the leaders of the XCom configuration.
Definition: gcs_xcom_proxy.cc:153
My_xp_mutex_impl m_lock_xcom_exit
Definition: gcs_xcom_proxy.h:980
bool xcom_client_get_event_horizon(uint32_t group_id, xcom_event_horizon &event_horizon) override
This member function is responsible for retrieving the event horizon of the XCom configuration.
Definition: gcs_xcom_proxy.cc:86
enum_gcs_error xcom_wait_for_condition(My_xp_cond_impl &condition, My_xp_mutex_impl &condition_lock, std::function< bool(void)> need_to_wait, std::function< const std::string(int res)> condition_event)
Definition: gcs_xcom_proxy.cc:426
bool m_is_xcom_exit
Definition: gcs_xcom_proxy.h:982
bool xcom_has_comms_status_changed() override
Definition: gcs_xcom_proxy.cc:553
int xcom_set_ssl_fips_mode(int mode) override
Definition: gcs_xcom_proxy.cc:271
bool xcom_client_set_event_horizon(uint32_t group_id, xcom_event_horizon event_horizon) override
This member function is responsible for triggering the reconfiguration of the event horizon of the XC...
Definition: gcs_xcom_proxy.cc:115
bool xcom_client_get_synode_app_data(connection_descriptor *con, uint32_t group_id_hash, synode_no_array &synodes, synode_app_data_array &reply) override
This member function is responsible for retrieving the application payloads decided in the synodes in...
Definition: gcs_xcom_proxy.cc:182
Definition: gcs_xcom_proxy.h:51
virtual enum_gcs_error xcom_wait_exit()=0
Call this method to wait for XCom to exit.
virtual bool xcom_client_add_node(connection_descriptor *fd, node_list *nl, uint32_t group_id)=0
This member function is responsible to call into XCom consensus and add a node to the group.
virtual void xcom_set_cleanup()=0
Clean up variables used to notify states in the XCOM's state machine.
virtual void xcom_set_ready(bool value)=0
virtual bool xcom_add_nodes(connection_descriptor &con, Gcs_xcom_nodes &nodes, uint32_t group_id_hash)=0
Function to add a set of nodes to XCOM.
virtual bool xcom_add_node(connection_descriptor &con, const Gcs_xcom_node_information &node, uint32_t group_id_hash)=0
Function to add a node to XCOM.
virtual xcom_event_horizon xcom_get_maximum_event_horizon()=0
Function to retrieve XCOM's maximum supported event horizon value.
virtual node_address * new_node_address_uuid(unsigned int n, char const *names[], blob uuids[])=0
This is an utility member function that is used to call into XCom for creating list with node's addre...
virtual site_def const * find_site_def(synode_no synode)=0
virtual void xcom_signal_exit()=0
This modifies the internal cached status and signals all threads that might be waiting on xcom_wait_e...
virtual bool xcom_has_comms_status_changed()=0
virtual void xcom_wait_for_xcom_comms_status_change(int &status)=0
Call this method to wait for XCom communications to be initialized.
virtual bool xcom_client_get_synode_app_data(connection_descriptor *fd, uint32_t group_id, synode_no_array &synodes, synode_app_data_array &reply)=0
This member function is responsible for retrieving the application payloads decided in the synodes in...
virtual bool xcom_is_exit()=0
This verifies if XCom has finished or not.
virtual bool xcom_client_get_event_horizon(uint32_t group_id, xcom_event_horizon &event_horizon)=0
This member function is responsible for retrieving the event horizon of the XCom configuration.
virtual int xcom_set_ssl_mode(int mode)=0
virtual bool xcom_boot_node(Gcs_xcom_node_information &node, uint32_t group_id_hash)=0
Function used to boot a node in XCOM.
virtual bool test_xcom_tcp_connection(std::string &host, xcom_port port)=0
Performs a test connection to the given XCom instance via TCP.
virtual bool xcom_get_event_horizon(uint32_t group_id_hash, xcom_event_horizon &event_horizon)=0
Function to retrieve XCOM's event horizon.
virtual int xcom_get_ssl_mode(const char *mode)=0
virtual void xcom_destroy_ssl()=0
virtual void xcom_exit()=0
This member function finishes the XCom thread.
virtual bool xcom_set_event_horizon(uint32_t group_id_hash, xcom_event_horizon event_horizon)=0
Function to reconfigure XCOM's event horizon.
virtual xcom_event_horizon xcom_get_minimum_event_horizon()=0
Function to retrieve XCOM's minimum supported event horizon value.
virtual void set_should_exit(bool should_exit)=0
Function that sets the value that signals that XCom must be forcefully stopped.
virtual bool xcom_get_synode_app_data(Gcs_xcom_node_information const &xcom_instance, uint32_t group_id_hash, const std::unordered_set< Gcs_xcom_synode > &synode_set, synode_app_data_array &reply)=0
Function to retrieve the application payloads decided on a set of synodes.
virtual bool xcom_client_close_connection(connection_descriptor *fd)=0
This member function closes the connection to an XCom instance.
virtual connection_descriptor * xcom_client_open_connection(std::string addr, xcom_port port)=0
This member function opens a connection to an XCom instance.
virtual bool xcom_client_remove_node(connection_descriptor *fd, node_list *nl, uint32_t group_id)=0
This member function is responsible for triggering the removal of a node from the XCom configuration.
virtual bool xcom_get_leaders(uint32_t group_id_hash, leader_info_data &leaders)=0
virtual bool xcom_remove_nodes(Gcs_xcom_nodes &nodes, uint32_t group_id_hash)=0
Function to remove a set of nodes from XCOM.
virtual bool xcom_remove_nodes(connection_descriptor &con, Gcs_xcom_nodes &nodes, uint32_t group_id_hash)=0
Function to remove a set of nodes from XCOM.
virtual bool xcom_init_ssl()=0
Initialize the SSL.
virtual bool xcom_client_force_config(node_list *nl, uint32_t group_id)=0
This method forces XCom to inject a new configuration in the group, even if it does not contain a maj...
virtual void xcom_signal_ready()=0
virtual void xcom_input_disconnect()=0
Closes the input channel to XCom.
virtual bool initialize_network_manager()=0
Initializes XCom's Network Manager.
virtual bool xcom_force_nodes(Gcs_xcom_nodes &nodes, unsigned int group_id_hash)=0
Function to force the set of nodes in XCOM's configuration.
virtual enum_gcs_error xcom_wait_ready()=0
This member waits for XCom to be initialized.
virtual bool finalize_network_manager()=0
Finalizes XCom's Network Manager.
virtual bool xcom_client_set_event_horizon(uint32_t group_id, xcom_event_horizon event_horizon)=0
This member function is responsible for triggering the reconfiguration of the event horizon of the XC...
virtual void xcom_set_comms_status(int status)=0
virtual int xcom_set_ssl_fips_mode(int mode)=0
virtual bool xcom_client_set_cache_size(uint64_t size)=0
This member function is responsible for setting a new value for the maximum size of the XCom cache.
virtual bool xcom_set_leaders(uint32_t group_id_hash, u_int nr_preferred_leaders, char const *preferred_leaders[], node_no max_nr_leaders)=0
virtual bool xcom_input_try_push(app_data_ptr data)=0
Attempts to send the command data to XCom.
virtual void xcom_signal_comms_status_changed(int status)=0
virtual void xcom_set_ssl_parameters(ssl_parameters ssl, tls_parameters tls)=0
virtual bool get_should_exit()=0
Function that retrieves the value that signals that XCom must be forcefully stopped.
virtual int xcom_get_ssl_fips_mode(const char *mode)=0
virtual bool xcom_set_cache_size(uint64_t size)=0
Function to reconfigure the maximum size of the XCom cache.
virtual bool xcom_remove_node(const Gcs_xcom_node_information &node, uint32_t group_id_hash)=0
Function to remove a node from XCOM.
virtual xcom_input_request_ptr xcom_input_try_pop()=0
Attempts to retrieve incoming commands.
virtual bool xcom_input_connect(std::string const &address, xcom_port port)=0
Opens the input channel to XCom.
Gcs_xcom_proxy()=default
virtual bool xcom_client_set_leaders(uint32_t group_id, u_int nr_preferred_leaders, char const *preferred_leaders[], node_no max_nr_leaders)=0
This member function is responsible for triggering the reconfiguration of the leaders of the XCom con...
virtual void delete_node_address(unsigned int n, node_address *na)=0
This function is responsible to delete the list of nodes that had been previously created by new_node...
virtual bool xcom_is_ready()=0
virtual bool set_network_manager_active_provider(enum_transport_protocol new_value)=0
Set XCom's network manager active provider.
virtual bool xcom_client_remove_node(node_list *nl, uint32_t group_id)=0
This member function is responsible for triggering the removal of a node from the XCom configuration.
virtual ~Gcs_xcom_proxy()=default
The destructor.
virtual void xcom_set_exit(bool value)=0
This sets whether XCom has finished or not.
virtual void xcom_init(xcom_port listen_port)=0
This member function initializes XCom.
virtual bool xcom_client_boot(node_list *nl, uint32_t group_id)=0
This member function boots XCom.
virtual bool xcom_client_send_data(unsigned long long size, char *data)=0
This member function is responsible for pushing data into consensus on XCom.
virtual bool xcom_use_ssl()=0
Return whether the SSL will be used to encrypt data or not.
virtual bool xcom_client_get_leaders(uint32_t group_id, leader_info_data &leaders)=0
This member function is responsible for retrieving the leaders of the XCom configuration.
virtual Gcs_xcom_input_queue::future_reply xcom_input_try_push_and_get_reply(app_data_ptr data)=0
Attempts to send the command data to XCom, and returns a future to XCom's reply.
Definition: my_xp_cond.h:135
Definition: my_xp_mutex.h:122
Interface for socket utility methods.
Definition: my_xp_util.h:153
Class that provides Network Namespace services.
Definition: network_provider.h:213
enum_gcs_error
This enumeration describes errors which can occur during group communication operations.
Definition: gcs_types.h:40
const char * host
Definition: mysqladmin.cc:58
constexpr value_type ssl
Definition: classic_protocol_constants.h:48
constexpr value_type blob
Definition: classic_protocol_constants.h:269
mode
Definition: file_handle.h:59
enum_transport_protocol
Enum that describes the available XCom Communication Stacks.
Definition: network_provider.h:42
required uint64 port
Definition: replication_asynchronous_connection_failover.proto:32
required uint32 status
Definition: replication_asynchronous_connection_failover.proto:60
Definition: gcs_xcom_proxy.h:1094
Gcs_xcom_proxy * proxy
Definition: gcs_xcom_proxy.h:1095
unsigned int port
Definition: gcs_xcom_proxy.h:1096
Definition: node_connection.h:46
Definition: site_struct.h:42
Definition: network_provider.h:131
Definition: network_provider.h:143
Definition: xcom_input_request.cc:30
__u_int u_int
Definition: types.h:72
int n
Definition: xcom_base.cc:508
unsigned short xcom_port
Definition: xcom_common.h:45