1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
5 * Ceph - scalable distributed file system
7 * Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
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.
18 #include "rgw_datalog.h"
20 #include "rgw_rest_s3.h"
21 #include "rgw_metadata.h"
22 #include "rgw_mdlog.h"
23 #include "rgw_data_sync.h"
25 class RGWOp_BILog_List
: public RGWRESTOp
{
27 uint32_t format_ver
{0};
28 bool truncated
{false};
29 std::optional
<rgw::bucket_log_layout_generation
> next_log_layout
;
32 RGWOp_BILog_List() : sent_header(false) {}
33 ~RGWOp_BILog_List() override
{}
35 int check_caps(const RGWUserCaps
& caps
) override
{
36 return caps
.check_cap("bilog", RGW_CAP_READ
);
38 int verify_permission(optional_yield y
) override
{
39 return check_caps(s
->user
->get_caps());
41 void send_response() override
;
42 virtual void send_response(std::list
<rgw_bi_log_entry
>& entries
, std::string
& marker
);
43 virtual void send_response_end();
44 void execute(optional_yield y
) override
;
45 const char* name() const override
{
46 return "list_bucket_index_log";
50 class RGWOp_BILog_Info
: public RGWRESTOp
{
51 std::string bucket_ver
;
52 std::string master_ver
;
53 std::string max_marker
;
55 uint64_t oldest_gen
= 0;
56 uint64_t latest_gen
= 0;
57 std::vector
<store_gen_shards
> generations
;
60 RGWOp_BILog_Info() : bucket_ver(), master_ver(), syncstopped(false) {}
61 ~RGWOp_BILog_Info() override
{}
63 int check_caps(const RGWUserCaps
& caps
) override
{
64 return caps
.check_cap("bilog", RGW_CAP_READ
);
66 int verify_permission(optional_yield y
) override
{
67 return check_caps(s
->user
->get_caps());
69 void send_response() override
;
70 void execute(optional_yield y
) override
;
71 const char* name() const override
{
72 return "bucket_index_log_info";
76 class RGWOp_BILog_Delete
: public RGWRESTOp
{
78 RGWOp_BILog_Delete() {}
79 ~RGWOp_BILog_Delete() override
{}
81 int check_caps(const RGWUserCaps
& caps
) override
{
82 return caps
.check_cap("bilog", RGW_CAP_WRITE
);
84 void execute(optional_yield y
) override
;
85 const char* name() const override
{
86 return "trim_bucket_index_log";
90 class RGWOp_MDLog_List
: public RGWRESTOp
{
91 std::list
<cls_log_entry
> entries
;
92 std::string last_marker
;
95 RGWOp_MDLog_List() : truncated(false) {}
96 ~RGWOp_MDLog_List() override
{}
98 int check_caps(const RGWUserCaps
& caps
) override
{
99 return caps
.check_cap("mdlog", RGW_CAP_READ
);
101 int verify_permission(optional_yield y
) override
{
102 return check_caps(s
->user
->get_caps());
104 void execute(optional_yield y
) override
;
105 void send_response() override
;
106 const char* name() const override
{
107 return "list_metadata_log";
111 class RGWOp_MDLog_Info
: public RGWRESTOp
{
112 unsigned num_objects
;
113 RGWPeriodHistory::Cursor period
;
115 RGWOp_MDLog_Info() : num_objects(0) {}
116 ~RGWOp_MDLog_Info() override
{}
118 int check_caps(const RGWUserCaps
& caps
) override
{
119 return caps
.check_cap("mdlog", RGW_CAP_READ
);
121 int verify_permission(optional_yield y
) override
{
122 return check_caps(s
->user
->get_caps());
124 void execute(optional_yield y
) override
;
125 void send_response() override
;
126 const char* name() const override
{
127 return "get_metadata_log_info";
131 class RGWOp_MDLog_ShardInfo
: public RGWRESTOp
{
132 RGWMetadataLogInfo info
;
134 RGWOp_MDLog_ShardInfo() {}
135 ~RGWOp_MDLog_ShardInfo() override
{}
137 int check_caps(const RGWUserCaps
& caps
) override
{
138 return caps
.check_cap("mdlog", RGW_CAP_READ
);
140 int verify_permission(optional_yield y
) override
{
141 return check_caps(s
->user
->get_caps());
143 void execute(optional_yield y
) override
;
144 void send_response() override
;
145 const char* name() const override
{
146 return "get_metadata_log_shard_info";
150 class RGWOp_MDLog_Lock
: public RGWRESTOp
{
152 RGWOp_MDLog_Lock() {}
153 ~RGWOp_MDLog_Lock() override
{}
155 int check_caps(const RGWUserCaps
& caps
) override
{
156 return caps
.check_cap("mdlog", RGW_CAP_WRITE
);
158 void execute(optional_yield y
) override
;
159 const char* name() const override
{
160 return "lock_mdlog_object";
164 class RGWOp_MDLog_Unlock
: public RGWRESTOp
{
166 RGWOp_MDLog_Unlock() {}
167 ~RGWOp_MDLog_Unlock() override
{}
169 int check_caps(const RGWUserCaps
& caps
) override
{
170 return caps
.check_cap("mdlog", RGW_CAP_WRITE
);
172 void execute(optional_yield y
) override
;
173 const char* name() const override
{
174 return "unlock_mdlog_object";
178 class RGWOp_MDLog_Notify
: public RGWRESTOp
{
180 RGWOp_MDLog_Notify() {}
181 ~RGWOp_MDLog_Notify() override
{}
183 int check_caps(const RGWUserCaps
& caps
) override
{
184 return caps
.check_cap("mdlog", RGW_CAP_WRITE
);
186 void execute(optional_yield y
) override
;
187 const char* name() const override
{
188 return "mdlog_notify";
190 RGWOpType
get_type() override
{ return RGW_OP_SYNC_MDLOG_NOTIFY
; }
193 class RGWOp_MDLog_Delete
: public RGWRESTOp
{
195 RGWOp_MDLog_Delete() {}
196 ~RGWOp_MDLog_Delete() override
{}
198 int check_caps(const RGWUserCaps
& caps
) override
{
199 return caps
.check_cap("mdlog", RGW_CAP_WRITE
);
201 void execute(optional_yield y
) override
;
202 const char* name() const override
{
203 return "trim_metadata_log";
207 class RGWOp_DATALog_List
: public RGWRESTOp
{
208 std::vector
<rgw_data_change_log_entry
> entries
;
209 std::string last_marker
;
213 RGWOp_DATALog_List() : truncated(false), extra_info(false) {}
214 ~RGWOp_DATALog_List() override
{}
216 int check_caps(const RGWUserCaps
& caps
) override
{
217 return caps
.check_cap("datalog", RGW_CAP_READ
);
219 int verify_permission(optional_yield y
) override
{
220 return check_caps(s
->user
->get_caps());
222 void execute(optional_yield y
) override
;
223 void send_response() override
;
224 const char* name() const override
{
225 return "list_data_changes_log";
229 class RGWOp_DATALog_Info
: public RGWRESTOp
{
230 unsigned num_objects
;
232 RGWOp_DATALog_Info() : num_objects(0) {}
233 ~RGWOp_DATALog_Info() override
{}
235 int check_caps(const RGWUserCaps
& caps
) override
{
236 return caps
.check_cap("datalog", RGW_CAP_READ
);
238 int verify_permission(optional_yield y
) override
{
239 return check_caps(s
->user
->get_caps());
241 void execute(optional_yield y
) override
;
242 void send_response() override
;
243 const char* name() const override
{
244 return "get_data_changes_log_info";
248 class RGWOp_DATALog_ShardInfo
: public RGWRESTOp
{
249 RGWDataChangesLogInfo info
;
251 RGWOp_DATALog_ShardInfo() {}
252 ~RGWOp_DATALog_ShardInfo() override
{}
254 int check_caps(const RGWUserCaps
& caps
) override
{
255 return caps
.check_cap("datalog", RGW_CAP_READ
);
257 int verify_permission(optional_yield y
) override
{
258 return check_caps(s
->user
->get_caps());
260 void execute(optional_yield y
) override
;
261 void send_response() override
;
262 const char* name() const override
{
263 return "get_data_changes_log_shard_info";
267 class RGWOp_DATALog_Notify
: public RGWRESTOp
{
269 RGWOp_DATALog_Notify() {}
270 ~RGWOp_DATALog_Notify() override
{}
272 int check_caps(const RGWUserCaps
& caps
) override
{
273 return caps
.check_cap("datalog", RGW_CAP_WRITE
);
275 void execute(optional_yield y
) override
;
276 const char* name() const override
{
277 return "datalog_notify";
279 RGWOpType
get_type() override
{ return RGW_OP_SYNC_DATALOG_NOTIFY
; }
282 class RGWOp_DATALog_Notify2
: public RGWRESTOp
{
283 rgw_data_notify_entry data_notify
;
285 RGWOp_DATALog_Notify2() {}
286 ~RGWOp_DATALog_Notify2() override
{}
288 int check_caps(const RGWUserCaps
& caps
) override
{
289 return caps
.check_cap("datalog", RGW_CAP_WRITE
);
291 void execute(optional_yield y
) override
;
292 const char* name() const override
{
293 return "datalog_notify2";
295 RGWOpType
get_type() override
{ return RGW_OP_SYNC_DATALOG_NOTIFY2
; }
298 class RGWOp_DATALog_Delete
: public RGWRESTOp
{
300 RGWOp_DATALog_Delete() {}
301 ~RGWOp_DATALog_Delete() override
{}
303 int check_caps(const RGWUserCaps
& caps
) override
{
304 return caps
.check_cap("datalog", RGW_CAP_WRITE
);
306 void execute(optional_yield y
) override
;
307 const char* name() const override
{
308 return "trim_data_changes_log";
312 class RGWHandler_Log
: public RGWHandler_Auth_S3
{
314 RGWOp
*op_get() override
;
315 RGWOp
*op_delete() override
;
316 RGWOp
*op_post() override
;
318 int read_permissions(RGWOp
*, optional_yield
) override
{
322 using RGWHandler_Auth_S3::RGWHandler_Auth_S3
;
323 ~RGWHandler_Log() override
= default;
326 class RGWRESTMgr_Log
: public RGWRESTMgr
{
328 RGWRESTMgr_Log() = default;
329 ~RGWRESTMgr_Log() override
= default;
331 RGWHandler_REST
* get_handler(rgw::sal::Driver
* driver
,
333 const rgw::auth::StrategyRegistry
& auth_registry
,
334 const std::string
& frontend_prefixs
) override
{
335 return new RGWHandler_Log(auth_registry
);