]>
Commit | Line | Data |
---|---|---|
1e59de90 | 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
9f95a23c | 2 | // vim: ts=8 sw=2 smarttab ft=cpp |
11fdf7f2 | 3 | |
7c673cae FG |
4 | /* |
5 | * Ceph - scalable distributed file system | |
6 | * | |
7 | * Copyright (C) 2013 eNovance SAS <licensing@enovance.com> | |
8 | * | |
9 | * This is free software; you can redistribute it and/or | |
10 | * modify it under the terms of the GNU Lesser General Public | |
11 | * License version 2.1, as published by the Free Software | |
12 | * Foundation. See file COPYING. | |
13 | * | |
14 | */ | |
15 | ||
9f95a23c | 16 | #pragma once |
7c673cae | 17 | |
f67539c2 TL |
18 | #include "rgw_datalog.h" |
19 | #include "rgw_rest.h" | |
20 | #include "rgw_rest_s3.h" | |
7c673cae | 21 | #include "rgw_metadata.h" |
9f95a23c | 22 | #include "rgw_mdlog.h" |
1e59de90 | 23 | #include "rgw_data_sync.h" |
7c673cae FG |
24 | |
25 | class RGWOp_BILog_List : public RGWRESTOp { | |
26 | bool sent_header; | |
1e59de90 TL |
27 | uint32_t format_ver{0}; |
28 | bool truncated{false}; | |
29 | std::optional<rgw::bucket_log_layout_generation> next_log_layout; | |
30 | ||
7c673cae FG |
31 | public: |
32 | RGWOp_BILog_List() : sent_header(false) {} | |
33 | ~RGWOp_BILog_List() override {} | |
34 | ||
9f95a23c | 35 | int check_caps(const RGWUserCaps& caps) override { |
7c673cae FG |
36 | return caps.check_cap("bilog", RGW_CAP_READ); |
37 | } | |
f67539c2 | 38 | int verify_permission(optional_yield y) override { |
9f95a23c | 39 | return check_caps(s->user->get_caps()); |
7c673cae FG |
40 | } |
41 | void send_response() override; | |
20effc67 | 42 | virtual void send_response(std::list<rgw_bi_log_entry>& entries, std::string& marker); |
7c673cae | 43 | virtual void send_response_end(); |
f67539c2 | 44 | void execute(optional_yield y) override; |
11fdf7f2 | 45 | const char* name() const override { |
7c673cae FG |
46 | return "list_bucket_index_log"; |
47 | } | |
48 | }; | |
49 | ||
50 | class RGWOp_BILog_Info : public RGWRESTOp { | |
20effc67 TL |
51 | std::string bucket_ver; |
52 | std::string master_ver; | |
53 | std::string max_marker; | |
c07f9fc5 | 54 | bool syncstopped; |
1e59de90 TL |
55 | uint64_t oldest_gen = 0; |
56 | uint64_t latest_gen = 0; | |
57 | std::vector<store_gen_shards> generations; | |
58 | ||
7c673cae | 59 | public: |
c07f9fc5 | 60 | RGWOp_BILog_Info() : bucket_ver(), master_ver(), syncstopped(false) {} |
7c673cae FG |
61 | ~RGWOp_BILog_Info() override {} |
62 | ||
9f95a23c | 63 | int check_caps(const RGWUserCaps& caps) override { |
7c673cae FG |
64 | return caps.check_cap("bilog", RGW_CAP_READ); |
65 | } | |
f67539c2 | 66 | int verify_permission(optional_yield y) override { |
9f95a23c | 67 | return check_caps(s->user->get_caps()); |
7c673cae FG |
68 | } |
69 | void send_response() override; | |
f67539c2 | 70 | void execute(optional_yield y) override; |
11fdf7f2 | 71 | const char* name() const override { |
7c673cae FG |
72 | return "bucket_index_log_info"; |
73 | } | |
74 | }; | |
75 | ||
76 | class RGWOp_BILog_Delete : public RGWRESTOp { | |
77 | public: | |
78 | RGWOp_BILog_Delete() {} | |
79 | ~RGWOp_BILog_Delete() override {} | |
80 | ||
9f95a23c | 81 | int check_caps(const RGWUserCaps& caps) override { |
7c673cae FG |
82 | return caps.check_cap("bilog", RGW_CAP_WRITE); |
83 | } | |
f67539c2 | 84 | void execute(optional_yield y) override; |
11fdf7f2 | 85 | const char* name() const override { |
7c673cae FG |
86 | return "trim_bucket_index_log"; |
87 | } | |
88 | }; | |
89 | ||
90 | class RGWOp_MDLog_List : public RGWRESTOp { | |
20effc67 TL |
91 | std::list<cls_log_entry> entries; |
92 | std::string last_marker; | |
7c673cae FG |
93 | bool truncated; |
94 | public: | |
95 | RGWOp_MDLog_List() : truncated(false) {} | |
96 | ~RGWOp_MDLog_List() override {} | |
97 | ||
9f95a23c | 98 | int check_caps(const RGWUserCaps& caps) override { |
7c673cae FG |
99 | return caps.check_cap("mdlog", RGW_CAP_READ); |
100 | } | |
f67539c2 | 101 | int verify_permission(optional_yield y) override { |
9f95a23c | 102 | return check_caps(s->user->get_caps()); |
7c673cae | 103 | } |
f67539c2 | 104 | void execute(optional_yield y) override; |
7c673cae | 105 | void send_response() override; |
11fdf7f2 | 106 | const char* name() const override { |
7c673cae FG |
107 | return "list_metadata_log"; |
108 | } | |
109 | }; | |
110 | ||
111 | class RGWOp_MDLog_Info : public RGWRESTOp { | |
112 | unsigned num_objects; | |
113 | RGWPeriodHistory::Cursor period; | |
114 | public: | |
115 | RGWOp_MDLog_Info() : num_objects(0) {} | |
116 | ~RGWOp_MDLog_Info() override {} | |
117 | ||
9f95a23c | 118 | int check_caps(const RGWUserCaps& caps) override { |
7c673cae FG |
119 | return caps.check_cap("mdlog", RGW_CAP_READ); |
120 | } | |
f67539c2 | 121 | int verify_permission(optional_yield y) override { |
9f95a23c | 122 | return check_caps(s->user->get_caps()); |
7c673cae | 123 | } |
f67539c2 | 124 | void execute(optional_yield y) override; |
7c673cae | 125 | void send_response() override; |
11fdf7f2 | 126 | const char* name() const override { |
7c673cae FG |
127 | return "get_metadata_log_info"; |
128 | } | |
129 | }; | |
130 | ||
131 | class RGWOp_MDLog_ShardInfo : public RGWRESTOp { | |
132 | RGWMetadataLogInfo info; | |
133 | public: | |
134 | RGWOp_MDLog_ShardInfo() {} | |
135 | ~RGWOp_MDLog_ShardInfo() override {} | |
136 | ||
9f95a23c | 137 | int check_caps(const RGWUserCaps& caps) override { |
7c673cae FG |
138 | return caps.check_cap("mdlog", RGW_CAP_READ); |
139 | } | |
f67539c2 | 140 | int verify_permission(optional_yield y) override { |
9f95a23c | 141 | return check_caps(s->user->get_caps()); |
7c673cae | 142 | } |
f67539c2 | 143 | void execute(optional_yield y) override; |
7c673cae | 144 | void send_response() override; |
11fdf7f2 | 145 | const char* name() const override { |
7c673cae FG |
146 | return "get_metadata_log_shard_info"; |
147 | } | |
148 | }; | |
149 | ||
150 | class RGWOp_MDLog_Lock : public RGWRESTOp { | |
151 | public: | |
152 | RGWOp_MDLog_Lock() {} | |
153 | ~RGWOp_MDLog_Lock() override {} | |
154 | ||
9f95a23c | 155 | int check_caps(const RGWUserCaps& caps) override { |
7c673cae FG |
156 | return caps.check_cap("mdlog", RGW_CAP_WRITE); |
157 | } | |
f67539c2 | 158 | void execute(optional_yield y) override; |
11fdf7f2 | 159 | const char* name() const override { |
7c673cae FG |
160 | return "lock_mdlog_object"; |
161 | } | |
162 | }; | |
163 | ||
164 | class RGWOp_MDLog_Unlock : public RGWRESTOp { | |
165 | public: | |
166 | RGWOp_MDLog_Unlock() {} | |
167 | ~RGWOp_MDLog_Unlock() override {} | |
168 | ||
9f95a23c | 169 | int check_caps(const RGWUserCaps& caps) override { |
7c673cae FG |
170 | return caps.check_cap("mdlog", RGW_CAP_WRITE); |
171 | } | |
f67539c2 | 172 | void execute(optional_yield y) override; |
11fdf7f2 | 173 | const char* name() const override { |
7c673cae FG |
174 | return "unlock_mdlog_object"; |
175 | } | |
176 | }; | |
177 | ||
178 | class RGWOp_MDLog_Notify : public RGWRESTOp { | |
179 | public: | |
180 | RGWOp_MDLog_Notify() {} | |
181 | ~RGWOp_MDLog_Notify() override {} | |
182 | ||
9f95a23c | 183 | int check_caps(const RGWUserCaps& caps) override { |
7c673cae FG |
184 | return caps.check_cap("mdlog", RGW_CAP_WRITE); |
185 | } | |
f67539c2 | 186 | void execute(optional_yield y) override; |
11fdf7f2 | 187 | const char* name() const override { |
7c673cae FG |
188 | return "mdlog_notify"; |
189 | } | |
20effc67 | 190 | RGWOpType get_type() override { return RGW_OP_SYNC_MDLOG_NOTIFY; } |
7c673cae FG |
191 | }; |
192 | ||
193 | class RGWOp_MDLog_Delete : public RGWRESTOp { | |
194 | public: | |
195 | RGWOp_MDLog_Delete() {} | |
196 | ~RGWOp_MDLog_Delete() override {} | |
197 | ||
9f95a23c | 198 | int check_caps(const RGWUserCaps& caps) override { |
7c673cae FG |
199 | return caps.check_cap("mdlog", RGW_CAP_WRITE); |
200 | } | |
f67539c2 | 201 | void execute(optional_yield y) override; |
11fdf7f2 | 202 | const char* name() const override { |
7c673cae FG |
203 | return "trim_metadata_log"; |
204 | } | |
205 | }; | |
206 | ||
207 | class RGWOp_DATALog_List : public RGWRESTOp { | |
f67539c2 TL |
208 | std::vector<rgw_data_change_log_entry> entries; |
209 | std::string last_marker; | |
7c673cae FG |
210 | bool truncated; |
211 | bool extra_info; | |
212 | public: | |
213 | RGWOp_DATALog_List() : truncated(false), extra_info(false) {} | |
214 | ~RGWOp_DATALog_List() override {} | |
215 | ||
9f95a23c | 216 | int check_caps(const RGWUserCaps& caps) override { |
7c673cae FG |
217 | return caps.check_cap("datalog", RGW_CAP_READ); |
218 | } | |
f67539c2 | 219 | int verify_permission(optional_yield y) override { |
9f95a23c | 220 | return check_caps(s->user->get_caps()); |
7c673cae | 221 | } |
f67539c2 | 222 | void execute(optional_yield y) override; |
7c673cae | 223 | void send_response() override; |
11fdf7f2 | 224 | const char* name() const override { |
7c673cae FG |
225 | return "list_data_changes_log"; |
226 | } | |
227 | }; | |
228 | ||
229 | class RGWOp_DATALog_Info : public RGWRESTOp { | |
230 | unsigned num_objects; | |
231 | public: | |
232 | RGWOp_DATALog_Info() : num_objects(0) {} | |
233 | ~RGWOp_DATALog_Info() override {} | |
234 | ||
9f95a23c | 235 | int check_caps(const RGWUserCaps& caps) override { |
7c673cae FG |
236 | return caps.check_cap("datalog", RGW_CAP_READ); |
237 | } | |
f67539c2 | 238 | int verify_permission(optional_yield y) override { |
9f95a23c | 239 | return check_caps(s->user->get_caps()); |
7c673cae | 240 | } |
f67539c2 | 241 | void execute(optional_yield y) override; |
7c673cae | 242 | void send_response() override; |
11fdf7f2 | 243 | const char* name() const override { |
7c673cae FG |
244 | return "get_data_changes_log_info"; |
245 | } | |
246 | }; | |
247 | ||
248 | class RGWOp_DATALog_ShardInfo : public RGWRESTOp { | |
249 | RGWDataChangesLogInfo info; | |
250 | public: | |
251 | RGWOp_DATALog_ShardInfo() {} | |
252 | ~RGWOp_DATALog_ShardInfo() override {} | |
253 | ||
9f95a23c | 254 | int check_caps(const RGWUserCaps& caps) override { |
7c673cae FG |
255 | return caps.check_cap("datalog", RGW_CAP_READ); |
256 | } | |
f67539c2 | 257 | int verify_permission(optional_yield y) override { |
9f95a23c | 258 | return check_caps(s->user->get_caps()); |
7c673cae | 259 | } |
f67539c2 | 260 | void execute(optional_yield y) override; |
7c673cae | 261 | void send_response() override; |
11fdf7f2 | 262 | const char* name() const override { |
7c673cae FG |
263 | return "get_data_changes_log_shard_info"; |
264 | } | |
265 | }; | |
266 | ||
7c673cae FG |
267 | class RGWOp_DATALog_Notify : public RGWRESTOp { |
268 | public: | |
269 | RGWOp_DATALog_Notify() {} | |
270 | ~RGWOp_DATALog_Notify() override {} | |
271 | ||
9f95a23c | 272 | int check_caps(const RGWUserCaps& caps) override { |
7c673cae FG |
273 | return caps.check_cap("datalog", RGW_CAP_WRITE); |
274 | } | |
f67539c2 | 275 | void execute(optional_yield y) override; |
11fdf7f2 | 276 | const char* name() const override { |
7c673cae FG |
277 | return "datalog_notify"; |
278 | } | |
20effc67 | 279 | RGWOpType get_type() override { return RGW_OP_SYNC_DATALOG_NOTIFY; } |
7c673cae FG |
280 | }; |
281 | ||
1e59de90 TL |
282 | class RGWOp_DATALog_Notify2 : public RGWRESTOp { |
283 | rgw_data_notify_entry data_notify; | |
284 | public: | |
285 | RGWOp_DATALog_Notify2() {} | |
286 | ~RGWOp_DATALog_Notify2() override {} | |
287 | ||
288 | int check_caps(const RGWUserCaps& caps) override { | |
289 | return caps.check_cap("datalog", RGW_CAP_WRITE); | |
290 | } | |
291 | void execute(optional_yield y) override; | |
292 | const char* name() const override { | |
293 | return "datalog_notify2"; | |
294 | } | |
295 | RGWOpType get_type() override { return RGW_OP_SYNC_DATALOG_NOTIFY2; } | |
296 | }; | |
297 | ||
7c673cae FG |
298 | class RGWOp_DATALog_Delete : public RGWRESTOp { |
299 | public: | |
300 | RGWOp_DATALog_Delete() {} | |
301 | ~RGWOp_DATALog_Delete() override {} | |
302 | ||
9f95a23c | 303 | int check_caps(const RGWUserCaps& caps) override { |
7c673cae FG |
304 | return caps.check_cap("datalog", RGW_CAP_WRITE); |
305 | } | |
f67539c2 | 306 | void execute(optional_yield y) override; |
11fdf7f2 | 307 | const char* name() const override { |
7c673cae FG |
308 | return "trim_data_changes_log"; |
309 | } | |
310 | }; | |
311 | ||
312 | class RGWHandler_Log : public RGWHandler_Auth_S3 { | |
313 | protected: | |
314 | RGWOp *op_get() override; | |
315 | RGWOp *op_delete() override; | |
316 | RGWOp *op_post() override; | |
317 | ||
f67539c2 | 318 | int read_permissions(RGWOp*, optional_yield) override { |
7c673cae FG |
319 | return 0; |
320 | } | |
321 | public: | |
322 | using RGWHandler_Auth_S3::RGWHandler_Auth_S3; | |
323 | ~RGWHandler_Log() override = default; | |
324 | }; | |
325 | ||
326 | class RGWRESTMgr_Log : public RGWRESTMgr { | |
327 | public: | |
328 | RGWRESTMgr_Log() = default; | |
329 | ~RGWRESTMgr_Log() override = default; | |
330 | ||
1e59de90 TL |
331 | RGWHandler_REST* get_handler(rgw::sal::Driver* driver, |
332 | req_state* const, | |
7c673cae FG |
333 | const rgw::auth::StrategyRegistry& auth_registry, |
334 | const std::string& frontend_prefixs) override { | |
335 | return new RGWHandler_Log(auth_registry); | |
336 | } | |
337 | }; |