MySQL  8.0.21
Source Code Documentation
member_info.h
Go to the documentation of this file.
1 /* Copyright (c) 2014, 2020, 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 MEMBER_INFO_INCLUDE
24 #define MEMBER_INFO_INCLUDE
25 
26 /*
27  The file contains declarations relevant to Member state and
28  its identification by the Protocol Client.
29 */
30 
31 /*
32  Since this file is used on unit tests includes must set here and
33  not through plugin_server_include.h.
34 */
35 
36 #include <list>
37 #include <map>
38 #include <set>
39 #include <sstream>
40 #include <string>
41 #include <vector>
42 
43 #include "my_inttypes.h"
44 #include "my_sys.h"
50 
51 /*
52  Encoding of the group_replication_enforce_update_everywhere_checks
53  config value in the member info structure.
54 */
55 #define CNF_ENFORCE_UPDATE_EVERYWHERE_CHECKS_F 0x1
56 
57 /*
58  Encoding of the group_replication_single_primary_mode config value
59  in the member info structure.
60 */
61 #define CNF_SINGLE_PRIMARY_MODE_F 0x2
62 
63 /*
64  Valid values of lower_case_table_names are 0 - 2.
65  So when member has DEFAULT_NOT_RECEIVED value, it means its
66  lower_case_table_names value is not known.
67 */
68 #define DEFAULT_NOT_RECEIVED_LOWER_CASE_TABLE_NAMES 65540
69 #ifndef DBUG_OFF
70 #define SKIP_ENCODING_LOWER_CASE_TABLE_NAMES 65541
71 #endif
72 
73 /*
74  @class Group_member_info
75 
76  Describes all the properties of a group member
77 */
79  public:
81  // This type should not be used anywhere.
83 
84  // Length of the payload item: variable
86 
87  // Length of the payload item: 2 bytes
88  PIT_PORT = 2,
89 
90  // Length of the payload item: variable
91  PIT_UUID = 3,
92 
93  // Length of the payload item: variable
95 
96  // Length of the payload item: 1 byte
98 
99  // Length of the payload item: 4 bytes
101 
102  // Length of the payload item: 2 bytes
104 
105  // Length of the payload item: variable
107 
108  // Length of the payload item: variable
110 
111  // Length of the payload item: 8 bytes
113 
114  // length of the role item: 1 byte
116 
117  // length of the configuration flags: 4 bytes
119 
120  // length of the conflict detection enabled: 1 byte
122 
123  // Length of the payload item: 2 bytes
125 
126  // Length of the payload item: 2 bytes
128 
129  // Length of the payload item: 1 bytes
131 
132  // Length of the payload item: 1 bytes
134 
135  // Length of the payload item: 1 bytes
137 
138  // Length of the payload item: variable
140 
141  // Length of the payload item: variable
143 
144  // No valid type codes can appear after this one.
145  PIT_MAX = 21
146  };
147 
148  /*
149  @enum Member_recovery_status
150 
151  This enumeration describes all the states that a member can assume while in a
152  group.
153  */
154  typedef enum {
160  MEMBER_END // the end of the enum
162 
163  /*
164  @enum Group_member_role
165 
166  This enumeration describes all the roles a server can have.
167  */
168  typedef enum {
173 
174  /**
175  Group_member_info constructor
176 
177  @param[in] hostname_arg member hostname
178  @param[in] port_arg member port
179  @param[in] uuid_arg member uuid
180  @param[in] write_set_extraction_algorithm write set extraction
181  algorithm
182  @param[in] gcs_member_id_arg member GCS member
183  identifier
184  @param[in] status_arg member Recovery status
185  @param[in] member_version_arg member version
186  @param[in] gtid_assignment_block_size_arg member gtid assignment
187  block size
188  @param[in] role_arg member role within the
189  group
190  @param[in] in_single_primary_mode is member in single mode
191  @param[in] has_enforces_update_everywhere_checks has member enforce update
192  check
193  @param[in] member_weight_arg member_weight
194  @param[in] lower_case_table_names_arg lower case table names
195  @param[in] psi_mutex_key_arg mutex key
196  @param[in] default_table_encryption_arg default_table_encryption
197  @param[in] recovery_endpoints_arg recovery endpoints
198  advertised
199  */
200  Group_member_info(const char *hostname_arg, uint port_arg,
201  const char *uuid_arg, int write_set_extraction_algorithm,
202  const std::string &gcs_member_id_arg,
204  Member_version &member_version_arg,
205  ulonglong gtid_assignment_block_size_arg,
207  bool in_single_primary_mode,
209  uint member_weight_arg, uint lower_case_table_names_arg,
210  bool default_table_encryption_arg,
211  const char *recovery_endpoints_arg,
212  PSI_mutex_key psi_mutex_key_arg =
214 
215  /**
216  Copy constructor
217 
218  @param other source of the copy
219  */
221 
222  /**
223  * Group_member_info raw data constructor
224  *
225  * @param[in] data raw data
226  * @param[in] len raw data length
227  * @param[in] psi_mutex_key_arg mutex key
228  */
229  Group_member_info(const uchar *data, size_t len,
230  PSI_mutex_key psi_mutex_key_arg =
232 
233  /**
234  Destructor
235  */
236  virtual ~Group_member_info();
237 
238  /**
239  Update Group_member_info.
240 
241  @param[in] hostname_arg member hostname
242  @param[in] port_arg member port
243  @param[in] uuid_arg member uuid
244  @param[in] write_set_extraction_algorithm write set extraction
245  algorithm
246  @param[in] gcs_member_id_arg member GCS member
247  identifier
248  @param[in] status_arg member Recovery status
249  @param[in] member_version_arg member version
250  @param[in] gtid_assignment_block_size_arg member gtid assignment
251  block size
252  @param[in] role_arg member role within the
253  group
254  @param[in] in_single_primary_mode is member in single mode
255  @param[in] has_enforces_update_everywhere_checks has member enforce update
256  check
257  @param[in] member_weight_arg member_weight
258  @param[in] lower_case_table_names_arg lower case table names
259  @param[in] default_table_encryption_arg default table encryption
260  @param[in] recovery_endpoints_arg recovery endpoints
261  advertised
262  */
263  void update(const char *hostname_arg, uint port_arg, const char *uuid_arg,
265  const std::string &gcs_member_id_arg,
267  Member_version &member_version_arg,
268  ulonglong gtid_assignment_block_size_arg,
270  bool in_single_primary_mode,
272  uint member_weight_arg, uint lower_case_table_names_arg,
273  bool default_table_encryption_arg,
274  const char *recovery_endpoints_arg);
275 
276  /**
277  Update Group_member_info.
278 
279  @param other source of the copy
280  */
281  void update(Group_member_info &other);
282 
283  /**
284  @return the member hostname
285  */
286  std::string get_hostname();
287 
288  /**
289  @return the member port
290  */
291  uint get_port();
292 
293  /**
294  @return the member uuid
295  */
296  std::string get_uuid();
297 
298  /**
299  @return the member identifier in the GCS layer
300  */
302 
303  /**
304  @return the member recovery status
305  */
306  Group_member_status get_recovery_status();
307 
308  /**
309  @return the member role type code.
310  */
311  Group_member_role get_role();
312 
313  /**
314  @return the member role type code in string
315  */
316  const char *get_member_role_string();
317 
318  /**
319  @return the member plugin version
320  */
322 
323  /**
324  @return the member GTID_EXECUTED set
325  */
326  std::string get_gtid_executed();
327 
328  /**
329  @return the member GTID_PURGED set
330  */
331  std::string get_gtid_purged();
332 
333  /**
334  @return the member GTID_RETRIEVED set for the applier channel
335  */
336  std::string get_gtid_retrieved();
337 
338  /**
339  @return the member algorithm for extracting write sets
340  */
342 
343  /**
344  @return the member gtid assignment block size
345  */
347 
348  /**
349  @return the member configuration flags
350  */
352 
353  /**
354  Set the primary flag
355  @param in_primary_mode is the member in primary mode
356  */
358 
359  /**
360  Set the enforces_update_everywhere_checks flag
361  @param enforce_everywhere_checks are the update everywhere checks active or
362  not
363  */
365  bool enforce_everywhere_checks);
366 
367  /**
368  @return the global-variable lower case table names value
369  */
371 
372  /**
373  @return the global-variable lower case table names value
374  */
376 
377  /**
378  @return the member state of system variable
379  group_replication_single_primary_mode
380  */
381  bool in_primary_mode();
382 
383  /**
384  @return the member state of system variable
385  group_replication_enforce_update_everywhere_checks
386  */
388 
389  /**
390  Updates this object recovery status
391 
392  @param[in] new_status the status to set
393  */
394  void update_recovery_status(Group_member_status new_status);
395 
396  /**
397  Updates this object GTID sets
398 
399  @param[in] executed_gtids the status to set
400  @param[in] purged_gtids the status to set
401  @param[in] retrieve_gtids the status to set
402  */
403  void update_gtid_sets(std::string &executed_gtids, std::string &purged_gtids,
404  std::string &retrieve_gtids);
405 
406  /**
407  Updates this object member role.
408 
409  @param[in] new_role the role to set.
410  */
411  void set_role(Group_member_role new_role);
412 
413  /**
414  @return the member status as string.
415  */
416  static const char *get_member_status_string(Group_member_status status);
417 
418  /**
419  @return configuration flag as string
420  */
421  static const char *get_configuration_flag_string(
422  const uint32 configuation_flag);
423 
424  /**
425  @return the member configuration flags as string
426  */
427  static std::string get_configuration_flags_string(
428  const uint32 configuation_flags);
429 
430  /**
431  @return Compare two members using member version
432  */
434  Group_member_info *m2);
435 
436  /**
437  @return Compare two members using server uuid
438  */
440  Group_member_info *m2);
441 
442  /**
443  @return Compare two members using member weight
444  @note if the weight is same, the member is sorted in
445  lexicographical order using its uuid.
446  */
448  Group_member_info *m2);
449 
450  /**
451  Return true if member version is higher than other member version
452  */
454 
455  /**
456  Return true if server uuid is lower than other member server uuid
457  */
458  bool has_lower_uuid(Group_member_info *other);
459 
460  /**
461  Return true if member weight is higher than other member weight
462  */
464 
465  /**
466  Redefinition of operate ==, which operate upon the uuid
467  */
468  bool operator==(Group_member_info &other);
469 
470  /**
471  Sets this member as unreachable.
472  */
473  void set_unreachable();
474 
475  /**
476  Sets this member as reachable.
477  */
478  void set_reachable();
479 
480  /**
481  Return true if this has been flagged as unreachable.
482  */
483  bool is_unreachable();
484 
485  /**
486  Update this member conflict detection to true
487  */
489 
490  /**
491  Update this member conflict detection to false
492  */
494 
495  /**
496  Return true if conflict detection is enable on this member
497  */
499 
500  /**
501  Update member weight
502 
503  @param[in] new_member_weight new member_weight to set
504  */
505  void set_member_weight(uint new_member_weight);
506 
507  /**
508  Return member weight
509  */
511 
512  /**
513  @return is a group action running in this member
514  */
516 
517  /**
518  Sets if the member is currently running a group action
519  @param is_running is an action running
520  */
522 
523  /**
524  @return is a primary election running in this member
525  */
527 
528  /**
529  Sets if the member is currently running a primary election
530  @param is_running is an election running
531  */
533 
534  /**
535  List of member advertised recovery endpoints
536  @return recovery endpoints
537  */
538  std::string get_recovery_endpoints();
539 
540  /**
541  Save list of member advertised recovery endpoints
542  @param endpoints list of advertised recovery endpoints
543  */
544  void set_recovery_endpoints(const char *endpoints);
545 
546  protected:
547  void encode_payload(std::vector<unsigned char> *buffer) const;
548  void decode_payload(const unsigned char *buffer, const unsigned char *);
549 
550  private:
551  /**
552  Internal method without concurrency control.
553 
554  @return the member state of system variable
555  group_replication_single_primary_mode
556  */
558 
559  /**
560  Return true if server uuid is lower than other member server uuid
561  Internal method without concurrency control.
562  */
564 
566  std::string hostname;
568  std::string uuid;
569  Group_member_status status;
572  std::string executed_gtid_set;
573  std::string purged_gtid_set;
574  std::string retrieved_gtid_set;
578  Group_member_role role;
586  std::string recovery_endpoints;
587 #ifndef DBUG_OFF
588  public:
590 #endif
591  // Allow use copy constructor on unit tests.
593 };
594 
595 /*
596  @interface Group_member_info_manager_interface
597 
598  Defines the set of operations that a Group_member_info_manager should provide.
599  This is a component that lies on top of the GCS, on the application level,
600  providing richer and relevant information to the plugin.
601  */
603  public:
605 
606  virtual size_t get_number_of_members() = 0;
607 
608  /**
609  Is the member present in the group info
610 
611  @param[in] uuid uuid to check
612  @return true if present, false otherwise
613  */
614  virtual bool is_member_info_present(const std::string &uuid) = 0;
615 
616  /**
617  Retrieves a registered Group member by its uuid
618 
619  @param[in] uuid uuid to retrieve
620  @return reference to a copy of Group_member_info. NULL if not managed.
621  The return value must deallocated by the caller.
622  */
623  virtual Group_member_info *get_group_member_info(const std::string &uuid) = 0;
624 
625  /**
626  Retrieves a registered Group member by an index function.
627  One is free to determine the index function. Nevertheless, it should have
628  the same result regardless of the member of the group where it is called
629 
630  @param[in] idx the index
631  @return reference to a Group_member_info. NULL if not managed
632  */
633  virtual Group_member_info *get_group_member_info_by_index(int idx) = 0;
634 
635  /**
636  Return lowest member version.
637 
638  @return group lowest version, if used at place where member can be OFFLINE
639  or in ERROR state, version 0xFFFFFF may be returned(not found)
640  */
641  virtual Member_version get_group_lowest_online_version() = 0;
642 
643  /**
644  Retrieves a registered Group member by its backbone GCS identifier
645 
646  @param[in] idx the GCS identifier
647  @return reference to a copy of Group_member_info. NULL if not managed.
648  The return value must deallocated by the caller.
649  */
650  virtual Group_member_info *get_group_member_info_by_member_id(
651  Gcs_member_identifier idx) = 0;
652 
653  /**
654  Retrieves all Group members managed by this site
655 
656  @return a vector with copies to all managed Group_member_info
657  */
658  virtual std::vector<Group_member_info *> *get_all_members() = 0;
659 
660  /**
661  Retrieves all ONLINE Group members managed by this site, or
662  NULL if any group member version is from a version lower than
663  #TRANSACTION_WITH_GUARANTEES_VERSION.
664 
665  @return list of all ONLINE members, if all members have version
666  equal or greater than #TRANSACTION_WITH_GUARANTEES_VERSION
667  otherwise NULL
668 
669  @note the memory allocated for the list ownership belongs to the
670  caller
671  */
672  virtual std::list<Gcs_member_identifier> *get_online_members_with_guarantees(
673  const Gcs_member_identifier &exclude_member) = 0;
674 
675  /**
676  Adds a new member to be managed by this Group manager
677 
678  @param[in] new_member new group member
679  */
680  virtual void add(Group_member_info *new_member) = 0;
681 
682  /**
683  Removes all members of the group and update new local member.
684 
685  @param[in] update_local_member new Group member
686  */
687  virtual void update(Group_member_info *update_local_member) = 0;
688 
689  /**
690  Updates all members of the group. Typically used after a view change.
691 
692  @param[in] new_members new Group members
693  */
694  virtual void update(std::vector<Group_member_info *> *new_members) = 0;
695 
696  /**
697  Updates the status of a single member
698 
699  @param[in] uuid member uuid
700  @param[in] new_status status to change to
701  @param[in,out] ctx The notification context to update.
702  */
703  virtual void update_member_status(
704  const std::string &uuid,
706  Notification_context &ctx) = 0;
707 
708  /**
709  Updates the GTID sets on a single member
710 
711 
712  @param[in] uuid member uuid
713  @param[in] gtid_executed the member executed GTID set
714  @param[in] purged_gtids the server purged GTID set
715  @param[in] gtid_retrieved the member retrieved GTID set for the applier
716  */
717  virtual void update_gtid_sets(const std::string &uuid,
718  std::string &gtid_executed,
719  std::string &purged_gtids,
720  std::string &gtid_retrieved) = 0;
721  /**
722  Updates the role of a single member
723 
724  @param[in] uuid member uuid
725  @param[in] new_role role to change to
726  @param[in,out] ctx The notification context to update.
727  */
728  virtual void update_member_role(const std::string &uuid,
730  Notification_context &ctx) = 0;
731 
732  /**
733  Updates the primary/secondary roles of the group.
734  This method allows for all roles to be updated at once in the same method
735 
736  @param[in] uuid the primary member uuid
737  @param[in,out] ctx The notification context to update.
738  */
739  virtual void update_group_primary_roles(const std::string &uuid,
740  Notification_context &ctx) = 0;
741 
742  /**
743  Updates the weight of a single member
744 
745  @param[in] uuid member uuid
746  @param[in] member_weight the new weight
747 */
748  virtual void update_member_weight(const std::string &uuid,
749  uint member_weight) = 0;
750 
751  /**
752  Changes the primary flag on all members
753  @param in_primary_mode is the member in primary mode
754  */
755  virtual void update_primary_member_flag(bool in_primary_mode) = 0;
756 
757  /**
758  Set the enforces_update_everywhere_checks flag on all members
759  @param enforce_everywhere are the update everywhere checks active or not
760  */
761  virtual void update_enforce_everywhere_checks_flag(
762  bool enforce_everywhere) = 0;
763 
764  /**
765  Encodes this object to send via the network
766 
767  @param[out] to_encode out parameter to receive the encoded data
768  */
769  virtual void encode(std::vector<uchar> *to_encode) = 0;
770 
771  /**
772  Decodes the raw format of this object
773 
774  @param[in] to_decode raw encoded data
775  @param[in] length raw encoded data length
776  @return a vector of Group_member_info references
777  */
778  virtual std::vector<Group_member_info *> *decode(const uchar *to_decode,
779  size_t length) = 0;
780 
781  /**
782  Check if some member of the group has the conflict detection enable
783 
784  @return true if at least one member has conflict detection enabled
785  */
786  virtual bool is_conflict_detection_enabled() = 0;
787 
788  /**
789  Return the uuid for the for the primary
790 
791  @param[out] primary_member_uuid the uuid of the primary will be assigned
792  here.
793 
794  @note If there is no primary or the member is on error state, the returned
795  uuid is "UNDEFINED". If not on primary mode it returns an empty string.
796 
797  @return true if the member is in primary mode, false if it is not.
798  */
799  virtual bool get_primary_member_uuid(std::string &primary_member_uuid) = 0;
800 
801  /**
802  Return the group member info for the current group primary
803 
804  @note the returned reference must be deallocated by the caller.
805 
806  @return reference to a Group_member_info. NULL if not managed
807  */
808  virtual Group_member_info *get_primary_member_info() = 0;
809 
810  /**
811  Check if majority of the group is unreachable
812 
813  This approach is optimistic, right after return the majority can be
814  reestablish or go away.
815 
816  @return true if majority of the group is unreachable
817  */
818  virtual bool is_majority_unreachable() = 0;
819 
820  /**
821  Check if an unreachable member exists
822 
823  This approach is optimistic, right after return a member can be marked as
824  rechable/unreachable
825 
826  @return true if an unreachable member exists
827  */
828  virtual bool is_unreachable_member_present() = 0;
829 
830  /**
831  Check if a member in recovery exists in the group
832 
833  This approach is optimistic, right after return a member can enter the group
834 
835  @return true if a member in recovery exists
836  */
837  virtual bool is_recovering_member_present() = 0;
838 
839  /**
840  This method returns all ONLINE and RECOVERING members comma separated
841  host and port in string format.
842 
843  @return hosts and port of all ONLINE and RECOVERING members
844  */
845  virtual std::string get_string_current_view_active_hosts() const = 0;
846 
847  /**
848  This method returns the update lock for consistent read of member state.
849 
850  @return update_lock reference
851  */
852  virtual mysql_mutex_t *get_update_lock() = 0;
853 };
854 
855 /**
856  @class Group_member_info_manager
857 
858  Implementation of the interface Group_member_info_manager_interface
859  */
861  public:
866 
867  virtual ~Group_member_info_manager();
868 
869  size_t get_number_of_members();
870 
871  bool is_member_info_present(const std::string &uuid);
872 
873  Group_member_info *get_group_member_info(const std::string &uuid);
874 
875  Group_member_info *get_group_member_info_by_index(int idx);
876 
877  Member_version get_group_lowest_online_version();
878 
879  Group_member_info *get_group_member_info_by_member_id(
881 
882  std::vector<Group_member_info *> *get_all_members();
883 
884  std::list<Gcs_member_identifier> *get_online_members_with_guarantees(
885  const Gcs_member_identifier &exclude_member);
886 
887  void add(Group_member_info *new_member);
888 
889  void update(Group_member_info *update_local_member);
890 
891  void update(std::vector<Group_member_info *> *new_members);
892 
893  void update_member_status(const std::string &uuid,
895  Notification_context &ctx);
896 
897  void update_gtid_sets(const std::string &uuid, std::string &gtid_executed,
898  std::string &purged_gtids, std::string &gtid_retrieved);
899 
900  void update_member_role(const std::string &uuid,
902  Notification_context &ctx);
903 
904  void update_group_primary_roles(const std::string &uuid,
905  Notification_context &ctx);
906 
907  void update_member_weight(const std::string &uuid, uint member_weight);
908 
909  void update_primary_member_flag(bool in_primary_mode);
910 
911  void update_enforce_everywhere_checks_flag(bool enforce_everywhere);
912 
913  void encode(std::vector<uchar> *to_encode);
914 
915  std::vector<Group_member_info *> *decode(const uchar *to_decode,
916  size_t length);
917 
919 
920  bool get_primary_member_uuid(std::string &primary_member_uuid);
921 
922  Group_member_info *get_primary_member_info();
923 
924  bool is_majority_unreachable();
925 
926  bool is_unreachable_member_present();
927 
928  bool is_recovering_member_present();
929 
930  std::string get_string_current_view_active_hosts() const;
931 
933 
934  private:
935  void clear_members();
936 
937  std::map<std::string, Group_member_info *> *members;
939 
941 };
942 
943 /**
944  This is the Group_member_info_manager message.
945  It is composed by a fixed header and 1 or more Group_member_info messages.
946  Each Group_member_info message does have its own fixed header.
947 
948  The on-the-wire representation of the message is:
949 
950  +-------------------+-----------+--------------------------------------+
951  | field | wire size | description |
952  +===================+===========+======================================+
953  | version | 4 bytes | protocol version |
954  | fixed_hdr_len | 2 bytes | length of the fixed header |
955  | message_len | 8 bytes | length of the message |
956  | cargo_type | 2 bytes | the cargo type in the payload |
957  +-------------------+-----------+--------------------------------------+
958  | payload_item_type | 2 bytes | PIT_MEMBERS_NUMBER |
959  | payload_item_len | 8 bytes | size of PIT_MEMBERS_NUMBER value |
960  | payload_item | X bytes | number of members |
961  +-------------------+-----------+--------------------------------------+
962  | payload_item_type | 2 bytes | PIT_MEMBER_DATA |
963  | payload_item_len | 8 bytes | size of CT_MEMBER_INFO_MESSAGE data |
964  | payload_item | X bytes | CT_MEMBER_INFO_MESSAGE data |
965  +-------------------+-----------+--------------------------------------+
966 
967  The last tree lines occur the number of times specified on
968  PIT_MEMBERS_NUMBER.
969 */
971  public:
973  // This type should not be used anywhere.
975 
976  // Length of the payload item: 2 bytes
977  PIT_MEMBERS_NUMBER = 1,
978 
979  // Length of the payload item: variable
980  PIT_MEMBER_DATA = 2,
981 
982  // No valid type codes can appear after this one.
984  };
985 
986  /**
987  Group_member_info_manager_message constructor.
988  */
990 
991  /**
992  Group_member_info_manager_message constructor.
993 
994  @param[in] group_info Group_member_info_manager members information
995  */
997 
998  /**
999  Group_member_info_manager_message constructor.
1000 
1001  @param[in] member_info Group_member_info one member information
1002  */
1004 
1005  /**
1006  Group_member_info_manager_message destructor.
1007  */
1009 
1010  /**
1011  Retrieves all Group members on this message.
1012 
1013  @return a vector with copies to all members.
1014  */
1015  std::vector<Group_member_info *> *get_all_members();
1016 
1017  protected:
1018  void encode_payload(std::vector<unsigned char> *buffer) const;
1019  void decode_payload(const unsigned char *buffer, const unsigned char *end);
1020 
1021  private:
1022  /**
1023  Clear members and its allocated memory.
1024  */
1025  void clear_members();
1026 
1027  std::vector<Group_member_info *> *members;
1028 };
1029 
1030 #endif /* MEMBER_INFO_INCLUDE */
Definition: member_info.h:94
void encode(std::vector< unsigned char > *buffer) const
Encodes the contents of this instance into the buffer.
Definition: gcs_plugin_messages.cc:55
bool is_group_action_running()
Definition: member_info.cc:627
Definition: member_info.h:82
unsigned long long int ulonglong
Definition: my_inttypes.h:55
void set_unreachable()
Sets this member as unreachable.
Definition: member_info.cc:592
unsigned char uchar
Definition: my_inttypes.h:51
void decode_payload(const unsigned char *buffer, const unsigned char *)
Decodes the contents of the buffer and sets the payload field values according to the values decoded...
Definition: member_info.cc:297
uint lower_case_table_names
Definition: member_info.h:582
void add(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1)
Definition: suite_stubs.c:69
static const char * get_member_status_string(Group_member_status status)
Definition: member_info.cc:652
bool has_greater_weight(Group_member_info *other)
Return true if member weight is higher than other member weight.
Definition: member_info.cc:746
static bool comparator_group_member_weight(Group_member_info *m1, Group_member_info *m2)
Definition: member_info.cc:725
Group_member_info * local_member_info
Definition: member_info.h:938
bool unreachable
Definition: member_info.h:577
Definition: member_info.h:156
char buffer[STRING_BUFFER]
Definition: test_sql_9_sessions.cc:57
std::map< std::string, Group_member_info * > * members
Definition: member_info.h:937
Group_member_status
Definition: member_info.h:154
std::string get_recovery_endpoints()
List of member advertised recovery endpoints.
Definition: member_info.cc:710
Definition: member_info.h:106
bool has_greater_version(Group_member_info *other)
Return true if member version is higher than other member version.
Definition: member_info.cc:730
Some integer typedefs for easier portability.
void set_recovery_endpoints(const char *endpoints)
Save list of member advertised recovery endpoints.
Definition: member_info.cc:715
uint64 gtid_assignment_block_size
Definition: member_info.h:576
Definition: member_info.h:157
ulonglong get_gtid_assignment_block_size()
Definition: member_info.cc:531
void set_role(Group_member_role new_role)
Updates this object member role.
Definition: member_info.cc:501
std::vector< Group_member_info * > * members
Definition: member_info.h:1027
Definition: member_info.h:91
PSI_mutex_key key_GR_LOCK_group_member_info_manager_update_lock
Definition: plugin_psi.cc:30
Definition: member_info.h:602
std::string executed_gtid_set
Definition: member_info.h:572
enum_payload_item_type
Definition: member_info.h:972
Member_version * member_version
Definition: member_info.h:571
std::string retrieved_gtid_set
Definition: member_info.h:574
This is the base GCS plugin message.
Definition: gcs_plugin_messages.h:63
Definition: member_info.h:160
void set_enforces_update_everywhere_checks_flag(bool enforce_everywhere_checks)
Set the enforces_update_everywhere_checks flag.
Definition: member_info.cc:551
uint get_lower_case_table_names()
Definition: member_info.cc:577
Definition: member_info.h:159
Group_member_status status
Definition: member_info.h:569
Definition: member_info.h:78
void update_recovery_status(Group_member_status new_status)
Updates this object recovery status.
Definition: member_info.cc:487
Definition: member_version.h:30
bool conflict_detection_enable
Definition: member_info.h:580
uint get_member_weight()
Return member weight.
Definition: member_info.cc:622
std::string get_hostname()
Definition: member_info.cc:439
unsigned int PSI_mutex_key
Instrumented mutex key.
Definition: psi_mutex_bits.h:49
void decode(const unsigned char *buffer, size_t length)
Decodes the contents of the buffer and sets the field values according to the values decoded...
Definition: gcs_plugin_messages.cc:78
void set_is_group_action_running(bool is_running)
Sets if the member is currently running a group action.
Definition: member_info.cc:632
Definition: member_info.h:124
std::string purged_gtid_set
Definition: member_info.h:573
bool has_lower_uuid_internal(Group_member_info *other)
Return true if server uuid is lower than other member server uuid Internal method without concurrency...
Definition: member_info.cc:737
Gcs_member_identifier get_gcs_member_id()
Definition: member_info.cc:482
uint get_port()
Definition: member_info.cc:444
bool is_unreachable()
Return true if this has been flagged as unreachable.
Definition: member_info.cc:582
Definition: member_info.h:85
static const char * get_configuration_flag_string(const uint32 configuation_flag)
Definition: member_info.cc:670
This is the Group_member_info_manager message.
Definition: member_info.h:970
PSI_mutex_key psi_mutex_key
Definition: member_info.h:592
void update(const char *hostname_arg, uint port_arg, const char *uuid_arg, int write_set_extraction_algorithm, const std::string &gcs_member_id_arg, Group_member_info::Group_member_status status_arg, Member_version &member_version_arg, ulonglong gtid_assignment_block_size_arg, Group_member_info::Group_member_role role_arg, bool in_single_primary_mode, bool has_enforces_update_everywhere_checks, uint member_weight_arg, uint lower_case_table_names_arg, bool default_table_encryption_arg, const char *recovery_endpoints_arg)
Update Group_member_info.
Definition: member_info.cc:139
bool default_table_encryption
Definition: member_info.h:583
void set_reachable()
Sets this member as reachable.
Definition: member_info.cc:597
bool in_primary_mode_internal()
Internal method without concurrency control.
Definition: member_info.cc:563
std::string recovery_endpoints
Definition: member_info.h:586
Definition: member_info.h:109
enum_payload_item_type
Definition: member_info.h:80
uint get_write_set_extraction_algorithm()
Definition: member_info.cc:526
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:188
bool primary_election_running
Definition: member_info.h:585
mysql_mutex_t * get_update_lock()
This method returns the update lock for consistent read of member state.
Definition: member_info.h:932
Definition: member_info.h:142
Group_member_role get_role()
Definition: member_info.cc:460
It represents the identity of a group member within a certain group.
Definition: gcs_member_identifier.h:39
void set_member_weight(uint new_member_weight)
Update member weight.
Definition: member_info.cc:617
std::string uuid
Definition: member_info.h:568
unsigned int uint
Definition: uca-dump.cc:29
Group_member_info * local_member_info
Definition: plugin.cc:125
virtual ~Group_member_info()
Destructor.
Definition: member_info.cc:133
uint write_set_extraction_algorithm
Definition: member_info.h:575
uint32_t uint32
Definition: my_inttypes.h:66
Member_version get_member_version()
Definition: member_info.cc:506
uint member_weight
Definition: member_info.h:581
mysql_mutex_t update_lock
Definition: member_info.h:940
bool is_conflict_detection_enabled()
Return true if conflict detection is enable on this member.
Definition: member_info.cc:612
Definition: member_info.h:170
Definition: member_info.h:155
virtual ~Group_member_info_manager_interface()
Definition: member_info.h:604
bool in_primary_mode()
Definition: member_info.cc:567
Common header for many mysys elements.
Group_member_role
Definition: member_info.h:168
void encode_payload(std::vector< unsigned char > *buffer) const
Encodes the contents of this instance payload into the buffer.
Definition: member_info.cc:207
Definition: member_info.h:97
A convenience context class used to share information between the event handlers and the notifier...
Definition: notification.h:34
Implementation of the interface Group_member_info_manager_interface.
Definition: member_info.h:860
Definition: member_info.h:115
uint port
Definition: member_info.h:567
uint32 get_configuration_flags()
Definition: member_info.cc:536
static void update_member_weight(MYSQL_THD, SYS_VAR *, void *var_ptr, const void *save)
Definition: plugin.cc:3323
void set_is_primary_election_running(bool is_running)
Sets if the member is currently running a primary election.
Definition: member_info.cc:642
bool is_running(const PluginFuncEnv *env) noexcept
Definition: loader.cc:357
const char * get_member_role_string()
Definition: member_info.cc:465
bool is_primary_election_running()
Definition: member_info.cc:637
bool operator==(Group_member_info &other)
Redefinition of operate ==, which operate upon the uuid.
Definition: member_info.cc:647
bool group_action_running
Definition: member_info.h:584
std::string get_gtid_purged()
Definition: member_info.cc:516
Definition: member_info.h:171
std::string get_gtid_executed()
Definition: member_info.cc:511
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49
Definition: member_info.h:88
static bool comparator_group_member_uuid(Group_member_info *m1, Group_member_info *m2)
Definition: member_info.cc:720
static std::string get_configuration_flags_string(const uint32 configuation_flags)
Definition: member_info.cc:684
uint32 configuration_flags
Definition: member_info.h:579
Definition: member_info.h:100
std::string get_gtid_retrieved()
Definition: member_info.cc:521
bool skip_encode_default_table_encryption
Definition: member_info.h:589
std::string get_uuid()
Definition: member_info.cc:449
Definition: member_info.h:169
Definition: member_info.h:158
void disable_conflict_detection()
Update this member conflict detection to false.
Definition: member_info.cc:607
Gcs_member_identifier * gcs_member_id
Definition: member_info.h:570
void update_gtid_sets(std::string &executed_gtids, std::string &purged_gtids, std::string &retrieve_gtids)
Updates this object GTID sets.
Definition: member_info.cc:492
Definition: member_info.h:118
void set_primary_mode_flag(bool in_primary_mode)
Set the primary flag.
Definition: member_info.cc:541
Group_member_role role
Definition: member_info.h:578
bool has_enforces_update_everywhere_checks()
Definition: member_info.cc:572
Group_member_info(const char *hostname_arg, uint port_arg, const char *uuid_arg, int write_set_extraction_algorithm, const std::string &gcs_member_id_arg, Group_member_info::Group_member_status status_arg, Member_version &member_version_arg, ulonglong gtid_assignment_block_size_arg, Group_member_info::Group_member_role role_arg, bool in_single_primary_mode, bool has_enforces_update_everywhere_checks, uint member_weight_arg, uint lower_case_table_names_arg, bool default_table_encryption_arg, const char *recovery_endpoints_arg, PSI_mutex_key psi_mutex_key_arg=key_GR_LOCK_group_member_info_update_lock)
Group_member_info constructor.
Definition: member_info.cc:37
Group_member_status get_recovery_status()
Definition: member_info.cc:455
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:75
uint64_t uint64
Definition: my_inttypes.h:68
Definition: member_info.h:145
void enable_conflict_detection()
Update this member conflict detection to true.
Definition: member_info.cc:602
bool has_lower_uuid(Group_member_info *other)
Return true if server uuid is lower than other member server uuid.
Definition: member_info.cc:741
Definition: member_info.h:139
mysql_mutex_t update_lock
Definition: member_info.h:565
Definition: member_info.h:130
static bool comparator_group_member_version(Group_member_info *m1, Group_member_info *m2)
Definition: member_info.cc:705
std::string hostname
Definition: member_info.h:566
bool get_default_table_encryption()
Definition: member_info.cc:587
PSI_mutex_key key_GR_LOCK_group_member_info_update_lock
Definition: plugin_psi.cc:30