1 /* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. 2 3 This program is free software; you can redistribute it and/or modify 4 it under the terms of the GNU General Public License, version 2.0, 5 as published by the Free Software Foundation. 6 7 This program is also distributed with certain software (including 8 but not limited to OpenSSL) that is licensed under separate terms, 9 as designated in a particular file or component or in included license 10 documentation. The authors of MySQL hereby grant you an additional 11 permission to link the program and your derivative works with the 12 separately licensed software that they have included with MySQL. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License, version 2.0, for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 23 #ifndef GCS_XCOM_GROUP_MANAGEMENT_INCLUDED 24 #define GCS_XCOM_GROUP_MANAGEMENT_INCLUDED 25 26 #include "plugin/group_replication/libmysqlgcs/include/mysql/gcs/gcs_group_management_interface.h" // Base class: Gcs_group_management_interface 27 #include "plugin/group_replication/libmysqlgcs/include/mysql/gcs/xplatform/my_xp_mutex.h" 28 #include "plugin/group_replication/libmysqlgcs/src/bindings/xcom/gcs_xcom_group_member_information.h" 29 #include "plugin/group_replication/libmysqlgcs/src/bindings/xcom/gcs_xcom_proxy.h" 30 #include "plugin/group_replication/libmysqlgcs/src/bindings/xcom/gcs_xcom_state_exchange.h" 31 32 #include <string> 33 #include <vector> 34 35 class Gcs_xcom_group_management : public Gcs_group_management_interface { 36 public: 37 explicit Gcs_xcom_group_management( 38 Gcs_xcom_proxy *xcom_proxy, const Gcs_group_identifier &group_identifier); 39 virtual ~Gcs_xcom_group_management(); 40 41 enum_gcs_error modify_configuration( 42 const Gcs_interface_parameters &reconfigured_group); 43 44 enum_gcs_error get_write_concurrency(uint32_t &event_horizon) const; 45 46 enum_gcs_error set_write_concurrency(uint32_t event_horizon); 47 48 uint32_t get_minimum_write_concurrency() const; 49 50 uint32_t get_maximum_write_concurrency() const; 51 52 /** 53 Save information on the latest nodes seen by this node so that it 54 can safely reconfigure the group if it loses the majority. This 55 information is required to extract the set of possible alive nodes 56 and their UUIDs. If the UUIDs in the reconfiguration request do not 57 match those stored in XCOM, it will not allow the reconfiguration 58 to proceed. 59 60 Note also that the set of nodes is updated by the MySQL GCS thread 61 whenever a new configuration is delivered and that a user thread is 62 responsible for calling the reconfiguration process. If a user is 63 trying to reconfigure the system, this usually and unfortunately 64 means that it has lost the majority and nothing will be updated by 65 the MySQL GCS thread. However, just for the sake of completeness, 66 we will use a mutex here to control access to this data structure. 67 68 Finally, it is worth noting that we cannot use get_site_def() here 69 because information on nodes could be concurrently updated by the 70 XCOM thread and we cannot add a mutex to it. 71 */ 72 void set_xcom_nodes(const Gcs_xcom_nodes &xcom_nodes); 73 74 /* 75 Get a copy of the nodes in the current configuration that are in the 76 filter list. 77 78 @param[out] result_xcom_nodes The set of Gcs_xcom_nodes that are in the 79 filter list 80 @param[in] filter The list of nodes identified as a string that one is 81 interested in retrieving information on 82 */ 83 void get_xcom_nodes(Gcs_xcom_nodes &result_xcom_nodes, 84 const std::vector<std::string> &filter); 85 86 /* 87 Get a copy of the nodes in the current configuration that are in the 88 filter list. 89 90 @param[out] result_xcom_nodes The set of Gcs_xcom_nodes that are in the 91 filter list 92 @param[in] filter The list of nodes identified as Gcs_member_identifier(s) 93 that one is interested in retrieving information on 94 */ 95 void get_xcom_nodes(Gcs_xcom_nodes &result_xcom_nodes, 96 const std::vector<Gcs_member_identifier> &filter); 97 98 /* 99 Get a copy of the nodes in the current configuration that are in the 100 filter list. 101 102 @param[out] result_xcom_nodes The set of Gcs_xcom_nodes that are in the 103 filter list 104 @param[in] filter The list of nodes identified as Gcs_member_identifier(s) 105 that one is interested in retrieving information on 106 */ 107 void get_xcom_nodes(Gcs_xcom_nodes &result_xcom_nodes, 108 const std::vector<Gcs_member_identifier *> &filter); 109 110 private: 111 Gcs_xcom_proxy *m_xcom_proxy; 112 Gcs_group_identifier *m_gid; 113 Gcs_xcom_nodes m_xcom_nodes; 114 unsigned int m_gid_hash; 115 116 /* 117 Mutex used to prevent concurrent access to nodes. 118 */ 119 My_xp_mutex_impl m_nodes_mutex; 120 121 /* 122 Disabling the copy constructor and assignment operator. 123 */ 124 Gcs_xcom_group_management(Gcs_xcom_group_management const &); 125 Gcs_xcom_group_management &operator=(Gcs_xcom_group_management const &); 126 }; 127 #endif // GCS_XCOM_GROUP_MANAGEMENT_INCLUDED 128