MySQL 9.3.0
Source Code Documentation
log_resource.h
Go to the documentation of this file.
1/* Copyright (c) 2017, 2025, 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/**
25 @addtogroup Backup
26 @{
27
28 @file
29
30 @brief Log resource definitions. This includes code for the server
31 resources that will take part on the results of the
32 performance_schema.log_status table.
33*/
34
35#ifndef LOG_RESOURCE_H
36#define LOG_RESOURCE_H
37
38#include "sql/binlog.h"
39#include "sql/handler.h"
40#include "sql/rpl_gtid.h"
41#include "sql/rpl_mi.h"
42
43class Json_dom;
44
45/**
46 @class Log_resource
47
48 This is the base class that the logic of collecting a MySQL server instance
49 resources log will call.
50
51 It basically contains lock, unlock and collect functions that shall be
52 overridden by more specialized classes to handle the specific cases of
53 resources participating in the process.
54*/
55
57 /* JSON object to be filled by the do_collect_info function */
58 Json_dom *json = nullptr;
59
60 public:
61 /**
62 There must be one function of this kind in order for the symbols in the
63 server's dynamic library to be visible to plugins.
64 */
65
67
68 /**
69 Log_resource constructor.
70
71 @param[in] json_arg the pointer to the JSON object to be populated with the
72 resource log information.
73 */
74
75 Log_resource(Json_dom *json_arg) : json(json_arg) {}
76
77 /**
78 Destructor.
79
80 This function will point the JSON object to nullptr.
81 */
82
83 virtual ~Log_resource() { json = nullptr; }
84
85 /**
86 Return the pointer to the JSON object that should be used to fill the
87 resource log information.
88
89 @return the Json_object pointer to be filled with the log information.
90 */
91
92 Json_dom *get_json() { return json; }
93
94 /*
95 Next three virtual functions need to be overridden by any more specialized
96 class inheriting from this to support a specific resource participating in
97 the collection process.
98 */
99
100 /**
101 Lock the resource avoiding updates.
102 */
103
104 virtual void lock() = 0;
105
106 /**
107 Unlock the resource allowing updates.
108 */
109
110 virtual void unlock() = 0;
111
112 /**
113 Collect resource log information.
114
115 @return false on success.
116 true if there was an error collecting the information.
117 */
118
119 virtual bool collect_info() = 0;
120};
121
122/**
123 @class Log_resource_mi_wrapper
124
125 This is the Log_resource to handle Master_info resources.
126*/
128 Master_info *mi = nullptr;
129
130 public:
131 /**
132 Log_resource_mi_wrapper constructor.
133
134 @param[in] mi_arg the pointer to the Master_info object resource.
135 @param[in] json_arg the pointer to the JSON object to be populated with the
136 resource log information.
137 */
138
140 : Log_resource(json_arg), mi(mi_arg) {}
141
142 void lock() override;
143 void unlock() override;
144 bool collect_info() override;
145};
146
147/**
148 @class Log_resource_binlog_wrapper
149
150 This is the Log_resource to handle MYSQL_BIN_LOG resources.
151*/
154
155 public:
156 /**
157 Log_resource_binlog_wrapper constructor.
158
159 @param[in] binlog_arg the pointer to the MYSQL_BIN_LOG object resource.
160 @param[in] json_arg the pointer to the JSON object to be populated with the
161 resource log information.
162 */
163
165 : Log_resource(json_arg), binlog(binlog_arg) {}
166
167 void lock() override;
168 void unlock() override;
169 bool collect_info() override;
170};
171
172/**
173 @class Log_resource_gtid_state_wrapper
174
175 This is the Log_resource to handle Gtid_state resources.
176*/
180
181 public:
182 /**
183 Log_resource_gtid_state_wrapper constructor.
184
185 @param[in] gtid_state_arg the pointer to the Gtid_state object resource.
186 @param[in] json_arg the pointer to the JSON object to be populated with the
187 resource log information.
188 @param[in] binlog_arg the pointer to the MYSQL_BIN_LOG object resource.
189 */
190
192 Json_dom *json_arg, MYSQL_BIN_LOG *binlog_arg)
193 : Log_resource(json_arg),
194 gtid_state(gtid_state_arg),
195 binlog(binlog_arg) {}
196
197 void lock() override;
198 void unlock() override;
199 bool collect_info() override;
200};
201
202/**
203 @class Log_resource_hton_wrapper
204
205 This is the Log_resource to handle handlerton resources.
206*/
208 handlerton *hton = nullptr;
209
210 public:
211 /**
212 Log_resource_hton_wrapper constructor.
213
214 @param[in] hton_arg the pointer to the hton resource.
215 @param[in] json_arg the pointer to the JSON object to be populated with the
216 resource log information.
217 */
218
220 : Log_resource(json_arg), hton(hton_arg) {}
221
222 void lock() override;
223 void unlock() override;
224 bool collect_info() override;
225};
226
227/**
228 @class Log_resource_factory
229
230 This is the Log_resource factory to create wrappers for supported
231 resources.
232*/
234 public:
235 /**
236 Creates a Log_resource wrapper based on a Master_info object.
237
238 @param[in] mi the pointer to the Master_info object resource.
239 @param[in] json the pointer to the JSON object to be populated with the
240 resource log information.
241 @return the pointer to the new Log_resource.
242 */
243
244 static Log_resource *get_wrapper(Master_info *mi, Json_dom *json);
245
246 /**
247 Creates a Log_resource wrapper based on a Master_info object.
248
249 @param[in] binlog the pointer to the MYSQL_BIN_LOG object resource.
250 @param[in] json the pointer to the JSON object to be populated with the
251 resource log information.
252 @return the pointer to the new Log_resource.
253 */
254
256
257 /**
258 Creates a Log_resource wrapper based on a Gtid_state object.
259
260 @param[in] gtid_state the pointer to the Gtid_state object resource.
261 @param[in] json the pointer to the JSON object to be populated with the
262 resource log information.
263 @param[in] binlog the pointer to the MYSQL_BIN_LOG object resource.
264 @return the pointer to the new Log_resource.
265 */
266
269
270 /**
271 Creates a Log_resource wrapper based on a handlerton.
272
273 @param[in] hton the pointer to the handlerton resource.
274 @param[in] json the pointer to the JSON object to be populated with the
275 resource log information.
276 @return the pointer to the new Log_resource.
277 */
278
279 static Log_resource *get_wrapper(handlerton *hton, Json_dom *json);
280};
281
282/**
283 @} (End of group Backup)
284*/
285
286#endif /* LOG_RESOURCE_H */
Represents the server's GTID state: the set of committed GTIDs, the set of lost gtids,...
Definition: rpl_gtid.h:2875
JSON DOM abstract base class.
Definition: json_dom.h:172
This is the Log_resource to handle MYSQL_BIN_LOG resources.
Definition: log_resource.h:152
Log_resource_binlog_wrapper(MYSQL_BIN_LOG *binlog_arg, Json_dom *json_arg)
Log_resource_binlog_wrapper constructor.
Definition: log_resource.h:164
void lock() override
Lock the resource avoiding updates.
Definition: log_resource.cc:62
void unlock() override
Unlock the resource allowing updates.
Definition: log_resource.cc:66
bool collect_info() override
Collect resource log information.
Definition: log_resource.cc:70
This is the Log_resource factory to create wrappers for supported resources.
Definition: log_resource.h:233
static Log_resource * get_wrapper(Master_info *mi, Json_dom *json)
Creates a Log_resource wrapper based on a Master_info object.
Definition: log_resource.cc:134
This is the Log_resource to handle Gtid_state resources.
Definition: log_resource.h:177
Gtid_state * gtid_state
Definition: log_resource.h:178
Log_resource_gtid_state_wrapper(Gtid_state *gtid_state_arg, Json_dom *json_arg, MYSQL_BIN_LOG *binlog_arg)
Log_resource_gtid_state_wrapper constructor.
Definition: log_resource.h:191
bool collect_info() override
Collect resource log information.
Definition: log_resource.cc:102
void unlock() override
Unlock the resource allowing updates.
Definition: log_resource.cc:100
void lock() override
Lock the resource avoiding updates.
Definition: log_resource.cc:90
This is the Log_resource to handle handlerton resources.
Definition: log_resource.h:207
bool collect_info() override
Collect resource log information.
Definition: log_resource.cc:126
Log_resource_hton_wrapper(handlerton *hton_arg, Json_dom *json_arg)
Log_resource_hton_wrapper constructor.
Definition: log_resource.h:219
void unlock() override
Unlock the resource allowing updates.
Definition: log_resource.cc:122
void lock() override
Lock the resource avoiding updates.
Definition: log_resource.cc:118
handlerton * hton
Definition: log_resource.h:208
This is the Log_resource to handle Master_info resources.
Definition: log_resource.h:127
void lock() override
Lock the resource avoiding updates.
Definition: log_resource.cc:32
bool collect_info() override
Collect resource log information.
Definition: log_resource.cc:36
void unlock() override
Unlock the resource allowing updates.
Definition: log_resource.cc:34
Master_info * mi
Definition: log_resource.h:128
Log_resource_mi_wrapper(Master_info *mi_arg, Json_dom *json_arg)
Log_resource_mi_wrapper constructor.
Definition: log_resource.h:139
This is the base class that the logic of collecting a MySQL server instance resources log will call.
Definition: log_resource.h:56
static int dummy_function_to_ensure_we_are_linked_into_the_server()
There must be one function of this kind in order for the symbols in the server's dynamic library to b...
Definition: log_resource.cc:28
Log_resource(Json_dom *json_arg)
Log_resource constructor.
Definition: log_resource.h:75
Json_dom * json
Definition: log_resource.h:58
virtual void lock()=0
Lock the resource avoiding updates.
virtual ~Log_resource()
Destructor.
Definition: log_resource.h:83
virtual void unlock()=0
Unlock the resource allowing updates.
Json_dom * get_json()
Return the pointer to the JSON object that should be used to fill the resource log information.
Definition: log_resource.h:92
virtual bool collect_info()=0
Collect resource log information.
Definition: binlog.h:107
Definition: rpl_mi.h:87
Gtid_state * gtid_state
Global state of GTIDs.
Definition: mysqld.cc:1851
Definition: pfs.cc:38
handlerton is a singleton structure - one instance per storage engine - to provide access to storage ...
Definition: handler.h:2765