MySQL 9.0.0
Source Code Documentation
log_resource.h
Go to the documentation of this file.
1/* Copyright (c) 2017, 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/**
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*/
179
180 public:
181 /**
182 Log_resource_gtid_state_wrapper constructor.
183
184 @param[in] gtid_state_arg the pointer to the Gtid_state object resource.
185 @param[in] json_arg the pointer to the JSON object to be populated with the
186 resource log information.
187 */
188
190 Json_dom *json_arg)
191 : Log_resource(json_arg), gtid_state(gtid_state_arg) {}
192
193 void lock() override;
194 void unlock() override;
195 bool collect_info() override;
196};
197
198/**
199 @class Log_resource_hton_wrapper
200
201 This is the Log_resource to handle handlerton resources.
202*/
204 handlerton *hton = nullptr;
205
206 public:
207 /**
208 Log_resource_hton_wrapper constructor.
209
210 @param[in] hton_arg the pointer to the hton resource.
211 @param[in] json_arg the pointer to the JSON object to be populated with the
212 resource log information.
213 */
214
216 : Log_resource(json_arg), hton(hton_arg) {}
217
218 void lock() override;
219 void unlock() override;
220 bool collect_info() override;
221};
222
223/**
224 @class Log_resource_factory
225
226 This is the Log_resource factory to create wrappers for supported
227 resources.
228*/
230 public:
231 /**
232 Creates a Log_resource wrapper based on a Master_info object.
233
234 @param[in] mi the pointer to the Master_info object resource.
235 @param[in] json the pointer to the JSON object to be populated with the
236 resource log information.
237 @return the pointer to the new Log_resource.
238 */
239
240 static Log_resource *get_wrapper(Master_info *mi, Json_dom *json);
241
242 /**
243 Creates a Log_resource wrapper based on a Master_info object.
244
245 @param[in] binlog the pointer to the MYSQL_BIN_LOG object resource.
246 @param[in] json the pointer to the JSON object to be populated with the
247 resource log information.
248 @return the pointer to the new Log_resource.
249 */
250
252
253 /**
254 Creates a Log_resource wrapper based on a Gtid_state object.
255
256 @param[in] gtid_state the pointer to the Gtid_state object resource.
257 @param[in] json the pointer to the JSON object to be populated with the
258 resource log information.
259 @return the pointer to the new Log_resource.
260 */
261
263
264 /**
265 Creates a Log_resource wrapper based on a handlerton.
266
267 @param[in] hton the pointer to the handlerton resource.
268 @param[in] json the pointer to the JSON object to be populated with the
269 resource log information.
270 @return the pointer to the new Log_resource.
271 */
272
273 static Log_resource *get_wrapper(handlerton *hton, Json_dom *json);
274};
275
276/**
277 @} (End of group Backup)
278*/
279
280#endif /* LOG_RESOURCE_H */
Represents the server's GTID state: the set of committed GTIDs, the set of lost gtids,...
Definition: rpl_gtid.h:2853
JSON DOM abstract base class.
Definition: json_dom.h:173
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:229
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:126
This is the Log_resource to handle Gtid_state resources.
Definition: log_resource.h:177
Gtid_state * gtid_state
Definition: log_resource.h:178
bool collect_info() override
Collect resource log information.
Definition: log_resource.cc:94
void unlock() override
Unlock the resource allowing updates.
Definition: log_resource.cc:92
Log_resource_gtid_state_wrapper(Gtid_state *gtid_state_arg, Json_dom *json_arg)
Log_resource_gtid_state_wrapper constructor.
Definition: log_resource.h:189
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:203
bool collect_info() override
Collect resource log information.
Definition: log_resource.cc:118
Log_resource_hton_wrapper(handlerton *hton_arg, Json_dom *json_arg)
Log_resource_hton_wrapper constructor.
Definition: log_resource.h:215
void unlock() override
Unlock the resource allowing updates.
Definition: log_resource.cc:114
void lock() override
Lock the resource avoiding updates.
Definition: log_resource.cc:110
handlerton * hton
Definition: log_resource.h:204
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:1828
Definition: pfs.cc:38
handlerton is a singleton structure - one instance per storage engine - to provide access to storage ...
Definition: handler.h:2734