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