MySQL 8.0.39
Source Code Documentation
recovery_endpoints.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 RECOVERY_ENDPOINTS_INCLUDE
25#define RECOVERY_ENDPOINTS_INCLUDE
26
27#include <set>
28#include <string>
29#include <vector>
30
31#include <include/my_inttypes.h>
33
34/**
35 @class Recovery_endpoints
36
37 Validate recovery endpoints
38*/
40 protected:
41 /**
42 @enum enum_status
43
44 This enumeration describes error status
45 */
46 enum class enum_status { OK = 0, INVALID, BADFORMAT, ERROR };
47
48 /**
49 Recovery_endpoints constructor
50 */
52
53 /**
54 Recovery_endpoints destructor
55 */
57
58 /**
59 Validate recovery endpoints and log errors if it fails.
60
61 @param endpoints advertised recovery endpoints
62
63 @return the operation status
64 @retval false OK
65 @retval true Error
66 */
67 std::pair<enum_status, std::string> check(const char *endpoints);
68
69 /**
70 Return recovery endpoints
71
72 @return list with recovery endpoints
73 */
74 std::vector<std::pair<std::string, uint>> get_endpoints();
75
76 /**
77 Set ports allowed on advertised recovery endpoints
78
79 It shall be called when validating local recovery endpoints.
80
81 @param mysqld_port mysqld port allowed on advertised recovery endpoints
82 @param admin_port mysqld admin port allowed on advertised recovery
83 endpoints
84 */
85 void set_port_settings(uint mysqld_port, uint admin_port);
86
87 private:
88 /**
89 Validate if recovery endpoint is a host name.
90
91 @param host hostname to be checked
92 @param host_ips list of host IPs
93
94 @return the operation status
95 @retval 0 OK
96 @retval !=0 Error
97 */
98 int hostname_check_and_log(std::string host, std::set<std::string> host_ips);
99
100 /**
101 Retrieve from host all ip address
102
103 @param[out] local_ips list of IPs present on host
104
105 @return the operation status
106 @retval 0 OK
107 @retval !=0 Error
108 */
109 int local_interfaces_ips(std::set<std::string> &local_ips);
110
111 /**
112 Mysql bind port
113 */
115
116 /**
117 Mysql bind admin port
118 */
120
121 /**
122 Advertised recovery valid endpoints
123 */
124 std::vector<std::pair<std::string, uint>> m_endpoints;
125
126 /**
127 Recovery endpoints are from donor
128 */
130};
131
132/**
133 @class Advertised_recovery_endpoints
134
135 Validate advertised recovery endpoints
136*/
138 public:
139 /**
140 @enum enum_log_context
141
142 This enumeration describes which log context is being used.
143 */
145
146 /**
147 Advertised_recovery_endpoints constructor
148 */
150
151 /**
152 Advertised_recovery_endpoints destructor
153 */
155
156 /**
157 Validate recovery endpoints and log errors if it fails.
158
159 @param endpoints advertised recovery endpoints
160 @param where context where being executed
161
162 @return the operation status
163 @retval false OK
164 @retval true Error
165 */
166 bool check(const char *endpoints, enum_log_context where);
167};
168
169/**
170 @class Donor_recovery_endpoints
171
172 Validate donor recovery endpoints
173*/
175 public:
176 /**
177 Donor_recovery_endpoints constructor
178 */
180
181 /**
182 Donor_recovery_endpoints destructor
183 */
185
186 /**
187 Get recovery endpoints
188
189 @param donor group member info from donor
190
191 @return endpoints
192 */
193 std::vector<std::pair<std::string, uint>> get_endpoints(
194 Group_member_info *donor);
195};
196
197#endif /* RECOVERY_ENDPOINTS_INCLUDE */
Validate advertised recovery endpoints.
Definition: recovery_endpoints.h:137
bool check(const char *endpoints, enum_log_context where)
Validate recovery endpoints and log errors if it fails.
Definition: recovery_endpoints.cc:363
Advertised_recovery_endpoints()
Advertised_recovery_endpoints constructor.
~Advertised_recovery_endpoints() override
Advertised_recovery_endpoints destructor.
enum_log_context
This enumeration describes which log context is being used.
Definition: recovery_endpoints.h:144
Validate donor recovery endpoints.
Definition: recovery_endpoints.h:174
~Donor_recovery_endpoints() override
Donor_recovery_endpoints destructor.
Donor_recovery_endpoints()
Donor_recovery_endpoints constructor.
Definition: member_info.h:81
Validate recovery endpoints.
Definition: recovery_endpoints.h:39
uint m_mysqld_admin_port
Mysql bind admin port.
Definition: recovery_endpoints.h:119
bool m_remote
Recovery endpoints are from donor.
Definition: recovery_endpoints.h:129
int hostname_check_and_log(std::string host, std::set< std::string > host_ips)
Validate if recovery endpoint is a host name.
Definition: recovery_endpoints.cc:182
void set_port_settings(uint mysqld_port, uint admin_port)
Set ports allowed on advertised recovery endpoints.
Definition: recovery_endpoints.cc:48
uint m_mysqld_port
Mysql bind port.
Definition: recovery_endpoints.h:114
std::vector< std::pair< std::string, uint > > m_endpoints
Advertised recovery valid endpoints.
Definition: recovery_endpoints.h:124
std::pair< enum_status, std::string > check(const char *endpoints)
Validate recovery endpoints and log errors if it fails.
Definition: recovery_endpoints.cc:234
std::vector< std::pair< std::string, uint > > get_endpoints()
Return recovery endpoints.
Definition: recovery_endpoints.cc:42
virtual ~Recovery_endpoints()
Recovery_endpoints destructor.
Recovery_endpoints()
Recovery_endpoints constructor.
Definition: recovery_endpoints.cc:37
enum_status
This enumeration describes error status.
Definition: recovery_endpoints.h:46
int local_interfaces_ips(std::set< std::string > &local_ips)
Retrieve from host all ip address.
Definition: recovery_endpoints.cc:66
Some integer typedefs for easier portability.
const char * host
Definition: mysqladmin.cc:59
uint mysqld_port
Definition: mysqld.cc:1323
static char * where
Definition: mysqldump.cc:140
unsigned int uint
Definition: uca9-dump.cc:75