MySQL 9.1.0
Source Code Documentation
gcs_xcom_expels_in_progress.h
Go to the documentation of this file.
1/* Copyright (c) 2020, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef GCS_XCOM_EXPELS_IN_PROGRESS_INCLUDED
25#define GCS_XCOM_EXPELS_IN_PROGRESS_INCLUDED
26
27#include <vector>
30#include "plugin/group_replication/libmysqlgcs/xdr_gen/xcom_vp.h"
31
32/**
33 @class Gcs_xcom_expels_in_progress
34
35 The set of expels we have issued but that have not yet taken effect.
36 An expel is identified as the pair (m, c), which means that we expelled the
37 member `m` based on view(s) pertaining to the XCom configuration/membership
38 `c`.
39
40 Whenever we issue the expel of some member `m`, we take note in this
41 structure; see @c remember_expels_issued.
42
43 Whenever we process a view where some member `m` that we have expelled is no
44 longer present, we remove `m` from this structure; see @c
45 forget_expels_that_have_taken_effect.
46
47 Please note that we keep track of the configuration ID `c` where we expelled
48 `m` to guard against the possibility of removing `m` from this structure due
49 to receiving a view "from the past," e.g. receiving a view from
50 configuration `b` < `c` where `m` is not a member, after having expelled `m`
51 due to views from configuration `c`.
52 It is unclear whether XCom can sometimes deliver views "from the past," so we
53 account for this situation by only removing `m` from this structure if we
54 receive a view from a configuration `d` > `c` where `m` is no longer present.
55*/
57 public:
62 default;
64 default;
65
66 /**
67 * @brief Keep track of members we expelled @c expels_issued together with
68 * the XCom configuration @c config_id_where_expels_were_issued that triggered
69 * the expel.
70 *
71 * @param config_id_where_expels_were_issued XCom configuration that triggered
72 * the expel
73 * @param expels_issued members expelled
74 */
76 synode_no const config_id_where_expels_were_issued,
77 Gcs_xcom_nodes const &expels_issued);
78
79 /**
80 * @brief Forget about any expel we issued for the nodes in @c
81 * members_that_left that have taken effect in the XCom configuration
82 * identified by @c config_id_where_members_left.
83 *
84 * @param config_id_where_members_left XCom configuration where the nodes left
85 * @param members_that_left nodes that left
86 */
88 synode_no const config_id_where_members_left,
89 std::vector<Gcs_member_identifier *> const &members_that_left);
90
91 /**
92 * @brief How many of the expels in progress do not pertain to suspected
93 * nodes.
94 *
95 * @param suspected_members suspected nodes that are members in the current
96 * GCS view
97 * @param suspected_nonmembers suspected nodes that are not yet members in the
98 * current GCS view
99 * @return how many of the expels in progress do not pertain to suspected
100 * nodes
101 */
103 std::vector<Gcs_member_identifier *> const &suspected_members,
104 std::vector<Gcs_member_identifier *> const &suspected_nonmembers) const;
105
106 /**
107 * @brief Whether all expels in progress are for members in @c xcom_nodes.
108 *
109 * @param xcom_nodes XCom view
110 * @retval true if all expels in progress are for members in @c xcom_nodes
111 * @retval false otherwise
112 */
113 bool all_still_in_view(Gcs_xcom_nodes const &xcom_nodes) const;
114
115 /**
116 * @brief How many expels are in progress.
117 *
118 * @return how many expels are in progress
119 */
120 std::size_t size() const;
121
122 /**
123 * @brief Whether there is an expel in progress for @c member issued during
124 * the XCom configuration identified by @c synode.
125 *
126 * @param member member to check
127 * @param synode XCom configuration to check
128 * @retval true there is an expel in progress for @c member issued during the
129 * configuration identified by @c synode
130 * @retval false otherwise
131 */
132 bool contains(Gcs_member_identifier const &member,
133 synode_no const synode) const;
134
135 private:
136 std::vector<std::pair<Gcs_member_identifier, synode_no>> m_expels_in_progress;
137};
138
139#endif /* GCS_XCOM_EXPELS_IN_PROGRESS_INCLUDED */
It represents the identity of a group member within a certain group.
Definition: gcs_member_identifier.h:40
The set of expels we have issued but that have not yet taken effect.
Definition: gcs_xcom_expels_in_progress.h:56
void forget_expels_that_have_taken_effect(synode_no const config_id_where_members_left, std::vector< Gcs_member_identifier * > const &members_that_left)
Forget about any expel we issued for the nodes in members_that_left that have taken effect in the XCo...
Definition: gcs_xcom_expels_in_progress.cc:39
Gcs_xcom_expels_in_progress(Gcs_xcom_expels_in_progress &&)=default
std::vector< std::pair< Gcs_member_identifier, synode_no > > m_expels_in_progress
Definition: gcs_xcom_expels_in_progress.h:136
std::size_t size() const
How many expels are in progress.
Definition: gcs_xcom_expels_in_progress.cc:148
Gcs_xcom_expels_in_progress & operator=(Gcs_xcom_expels_in_progress &&)=default
Gcs_xcom_expels_in_progress(Gcs_xcom_expels_in_progress const &)=default
Gcs_xcom_expels_in_progress & operator=(Gcs_xcom_expels_in_progress const &)=default
void remember_expels_issued(synode_no const config_id_where_expels_were_issued, Gcs_xcom_nodes const &expels_issued)
Keep track of members we expelled expels_issued together with the XCom configuration config_id_where_...
Definition: gcs_xcom_expels_in_progress.cc:30
std::size_t number_of_expels_not_about_suspects(std::vector< Gcs_member_identifier * > const &suspected_members, std::vector< Gcs_member_identifier * > const &suspected_nonmembers) const
How many of the expels in progress do not pertain to suspected nodes.
Definition: gcs_xcom_expels_in_progress.cc:105
bool all_still_in_view(Gcs_xcom_nodes const &xcom_nodes) const
Whether all expels in progress are for members in xcom_nodes.
Definition: gcs_xcom_expels_in_progress.cc:129
bool contains(Gcs_member_identifier const &member, synode_no const synode) const
Whether there is an expel in progress for member issued during the XCom configuration identified by s...
Definition: gcs_xcom_expels_in_progress.cc:152
This class contains information on the configuration, i.e set of nodes or simply site definition.
Definition: gcs_xcom_group_member_information.h:391