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"
24 class RGWOp_BILog_List
: public RGWRESTOp
{
27 RGWOp_BILog_List() : sent_header(false) {}
28 ~RGWOp_BILog_List() override
{}
30 int check_caps(const RGWUserCaps
& caps
) override
{
31 return caps
.check_cap("bilog", RGW_CAP_READ
);
33 int verify_permission(optional_yield y
) override
{
34 return check_caps(s
->user
->get_caps());
36 void send_response() override
;
37 virtual void send_response(std::list
<rgw_bi_log_entry
>& entries
, std::string
& marker
);
38 virtual void send_response_end();
39 void execute(optional_yield y
) override
;
40 const char* name() const override
{
41 return "list_bucket_index_log";
45 class RGWOp_BILog_Info
: public RGWRESTOp
{
46 std::string bucket_ver
;
47 std::string master_ver
;
48 std::string max_marker
;
51 RGWOp_BILog_Info() : bucket_ver(), master_ver(), syncstopped(false) {}
52 ~RGWOp_BILog_Info() override
{}
54 int check_caps(const RGWUserCaps
& caps
) override
{
55 return caps
.check_cap("bilog", RGW_CAP_READ
);
57 int verify_permission(optional_yield y
) override
{
58 return check_caps(s
->user
->get_caps());
60 void send_response() override
;
61 void execute(optional_yield y
) override
;
62 const char* name() const override
{
63 return "bucket_index_log_info";
67 class RGWOp_BILog_Delete
: public RGWRESTOp
{
69 RGWOp_BILog_Delete() {}
70 ~RGWOp_BILog_Delete() override
{}
72 int check_caps(const RGWUserCaps
& caps
) override
{
73 return caps
.check_cap("bilog", RGW_CAP_WRITE
);
75 void execute(optional_yield y
) override
;
76 const char* name() const override
{
77 return "trim_bucket_index_log";
81 class RGWOp_MDLog_List
: public RGWRESTOp
{
82 std::list
<cls_log_entry
> entries
;
83 std::string last_marker
;
86 RGWOp_MDLog_List() : truncated(false) {}
87 ~RGWOp_MDLog_List() override
{}
89 int check_caps(const RGWUserCaps
& caps
) override
{
90 return caps
.check_cap("mdlog", RGW_CAP_READ
);
92 int verify_permission(optional_yield y
) override
{
93 return check_caps(s
->user
->get_caps());
95 void execute(optional_yield y
) override
;
96 void send_response() override
;
97 const char* name() const override
{
98 return "list_metadata_log";
102 class RGWOp_MDLog_Info
: public RGWRESTOp
{
103 unsigned num_objects
;
104 RGWPeriodHistory::Cursor period
;
106 RGWOp_MDLog_Info() : num_objects(0) {}
107 ~RGWOp_MDLog_Info() override
{}
109 int check_caps(const RGWUserCaps
& caps
) override
{
110 return caps
.check_cap("mdlog", RGW_CAP_READ
);
112 int verify_permission(optional_yield y
) override
{
113 return check_caps(s
->user
->get_caps());
115 void execute(optional_yield y
) override
;
116 void send_response() override
;
117 const char* name() const override
{
118 return "get_metadata_log_info";
122 class RGWOp_MDLog_ShardInfo
: public RGWRESTOp
{
123 RGWMetadataLogInfo info
;
125 RGWOp_MDLog_ShardInfo() {}
126 ~RGWOp_MDLog_ShardInfo() override
{}
128 int check_caps(const RGWUserCaps
& caps
) override
{
129 return caps
.check_cap("mdlog", RGW_CAP_READ
);
131 int verify_permission(optional_yield y
) override
{
132 return check_caps(s
->user
->get_caps());
134 void execute(optional_yield y
) override
;
135 void send_response() override
;
136 const char* name() const override
{
137 return "get_metadata_log_shard_info";
141 class RGWOp_MDLog_Lock
: public RGWRESTOp
{
143 RGWOp_MDLog_Lock() {}
144 ~RGWOp_MDLog_Lock() override
{}
146 int check_caps(const RGWUserCaps
& caps
) override
{
147 return caps
.check_cap("mdlog", RGW_CAP_WRITE
);
149 void execute(optional_yield y
) override
;
150 const char* name() const override
{
151 return "lock_mdlog_object";
155 class RGWOp_MDLog_Unlock
: public RGWRESTOp
{
157 RGWOp_MDLog_Unlock() {}
158 ~RGWOp_MDLog_Unlock() override
{}
160 int check_caps(const RGWUserCaps
& caps
) override
{
161 return caps
.check_cap("mdlog", RGW_CAP_WRITE
);
163 void execute(optional_yield y
) override
;
164 const char* name() const override
{
165 return "unlock_mdlog_object";
169 class RGWOp_MDLog_Notify
: public RGWRESTOp
{
171 RGWOp_MDLog_Notify() {}
172 ~RGWOp_MDLog_Notify() override
{}
174 int check_caps(const RGWUserCaps
& caps
) override
{
175 return caps
.check_cap("mdlog", RGW_CAP_WRITE
);
177 void execute(optional_yield y
) override
;
178 const char* name() const override
{
179 return "mdlog_notify";
181 RGWOpType
get_type() override
{ return RGW_OP_SYNC_MDLOG_NOTIFY
; }
184 class RGWOp_MDLog_Delete
: public RGWRESTOp
{
186 RGWOp_MDLog_Delete() {}
187 ~RGWOp_MDLog_Delete() override
{}
189 int check_caps(const RGWUserCaps
& caps
) override
{
190 return caps
.check_cap("mdlog", RGW_CAP_WRITE
);
192 void execute(optional_yield y
) override
;
193 const char* name() const override
{
194 return "trim_metadata_log";
198 class RGWOp_DATALog_List
: public RGWRESTOp
{
199 std::vector
<rgw_data_change_log_entry
> entries
;
200 std::string last_marker
;
204 RGWOp_DATALog_List() : truncated(false), extra_info(false) {}
205 ~RGWOp_DATALog_List() override
{}
207 int check_caps(const RGWUserCaps
& caps
) override
{
208 return caps
.check_cap("datalog", RGW_CAP_READ
);
210 int verify_permission(optional_yield y
) override
{
211 return check_caps(s
->user
->get_caps());
213 void execute(optional_yield y
) override
;
214 void send_response() override
;
215 const char* name() const override
{
216 return "list_data_changes_log";
220 class RGWOp_DATALog_Info
: public RGWRESTOp
{
221 unsigned num_objects
;
223 RGWOp_DATALog_Info() : num_objects(0) {}
224 ~RGWOp_DATALog_Info() override
{}
226 int check_caps(const RGWUserCaps
& caps
) override
{
227 return caps
.check_cap("datalog", RGW_CAP_READ
);
229 int verify_permission(optional_yield y
) override
{
230 return check_caps(s
->user
->get_caps());
232 void execute(optional_yield y
) override
;
233 void send_response() override
;
234 const char* name() const override
{
235 return "get_data_changes_log_info";
239 class RGWOp_DATALog_ShardInfo
: public RGWRESTOp
{
240 RGWDataChangesLogInfo info
;
242 RGWOp_DATALog_ShardInfo() {}
243 ~RGWOp_DATALog_ShardInfo() override
{}
245 int check_caps(const RGWUserCaps
& caps
) override
{
246 return caps
.check_cap("datalog", RGW_CAP_READ
);
248 int verify_permission(optional_yield y
) override
{
249 return check_caps(s
->user
->get_caps());
251 void execute(optional_yield y
) override
;
252 void send_response() override
;
253 const char* name() const override
{
254 return "get_data_changes_log_shard_info";
258 class RGWOp_DATALog_Notify
: public RGWRESTOp
{
260 RGWOp_DATALog_Notify() {}
261 ~RGWOp_DATALog_Notify() override
{}
263 int check_caps(const RGWUserCaps
& caps
) override
{
264 return caps
.check_cap("datalog", RGW_CAP_WRITE
);
266 void execute(optional_yield y
) override
;
267 const char* name() const override
{
268 return "datalog_notify";
270 RGWOpType
get_type() override
{ return RGW_OP_SYNC_DATALOG_NOTIFY
; }
273 class RGWOp_DATALog_Delete
: public RGWRESTOp
{
275 RGWOp_DATALog_Delete() {}
276 ~RGWOp_DATALog_Delete() override
{}
278 int check_caps(const RGWUserCaps
& caps
) override
{
279 return caps
.check_cap("datalog", RGW_CAP_WRITE
);
281 void execute(optional_yield y
) override
;
282 const char* name() const override
{
283 return "trim_data_changes_log";
287 class RGWHandler_Log
: public RGWHandler_Auth_S3
{
289 RGWOp
*op_get() override
;
290 RGWOp
*op_delete() override
;
291 RGWOp
*op_post() override
;
293 int read_permissions(RGWOp
*, optional_yield
) override
{
297 using RGWHandler_Auth_S3::RGWHandler_Auth_S3
;
298 ~RGWHandler_Log() override
= default;
301 class RGWRESTMgr_Log
: public RGWRESTMgr
{
303 RGWRESTMgr_Log() = default;
304 ~RGWRESTMgr_Log() override
= default;
306 RGWHandler_REST
* get_handler(rgw::sal::Store
* store
,
307 struct req_state
* const,
308 const rgw::auth::StrategyRegistry
& auth_registry
,
309 const std::string
& frontend_prefixs
) override
{
310 return new RGWHandler_Log(auth_registry
);