static string log_index_prefix = "1_";
-static int write_log_entry(cls_method_context_t hctx, string& index, cls_log_entry& entry)
+static int write_log_entry(cls_method_context_t hctx, string& index, cls::log::entry& entry)
{
bufferlist bl;
encode(entry, bl);
index = log_index_prefix + buf;
}
-static int read_header(cls_method_context_t hctx, cls_log_header& header)
+static int read_header(cls_method_context_t hctx, cls::log::header& header)
{
bufferlist header_bl;
return ret;
if (header_bl.length() == 0) {
- header = cls_log_header();
+ header = cls::log::header();
return 0;
}
return 0;
}
-static int write_header(cls_method_context_t hctx, cls_log_header& header)
+static int write_header(cls_method_context_t hctx, cls::log::header& header)
{
bufferlist header_bl;
encode(header, header_bl);
{
auto in_iter = in->cbegin();
- cls_log_add_op op;
+ cls::log::ops::add_op op;
try {
decode(op, in_iter);
} catch (ceph::buffer::error& err) {
- CLS_LOG(1, "ERROR: cls_log_add_op(): failed to decode op");
+ CLS_LOG(1, "ERROR: cls::log::ops::add_op(): failed to decode op");
return -EINVAL;
}
- cls_log_header header;
+ cls::log::header header;
int ret = read_header(hctx, header);
if (ret < 0)
return ret;
for (auto iter = op.entries.begin(); iter != op.entries.end(); ++iter) {
- cls_log_entry& entry = *iter;
+ cls::log::entry& entry = *iter;
string index;
{
auto in_iter = in->cbegin();
- cls_log_list_op op;
+ cls::log::ops::list_op op;
try {
decode(op, in_iter);
} catch (ceph::buffer::error& err) {
- CLS_LOG(1, "ERROR: cls_log_list_op(): failed to decode op");
+ CLS_LOG(1, "ERROR: cls::log::ops::list_op(): failed to decode op");
return -EINVAL;
}
if (!max_entries || max_entries > MAX_ENTRIES)
max_entries = MAX_ENTRIES;
- cls_log_list_ret ret;
+ cls::log::ops::list_ret ret;
int rc = cls_cxx_map_get_vals(hctx, from_index, log_index_prefix, max_entries, &keys, &ret.truncated);
if (rc < 0)
bufferlist& bl = iter->second;
auto biter = bl.cbegin();
try {
- cls_log_entry e;
+ cls::log::entry e;
decode(e, biter);
entries.push_back(e);
} catch (ceph::buffer::error& err) {
{
auto in_iter = in->cbegin();
- cls_log_trim_op op;
+ cls::log::ops::trim_op op;
try {
decode(op, in_iter);
} catch (ceph::buffer::error& err) {
{
auto in_iter = in->cbegin();
- cls_log_info_op op;
+ cls::log::ops::info_op op;
try {
decode(op, in_iter);
} catch (ceph::buffer::error& err) {
- CLS_LOG(1, "ERROR: cls_log_add_op(): failed to decode op");
+ CLS_LOG(1, "ERROR: cls::log::ops::add_op(): failed to decode op");
return -EINVAL;
}
- cls_log_info_ret ret;
+ cls::log::ops::info_ret ret;
int rc = read_header(hctx, ret.header);
if (rc < 0)
-void cls_log_add(librados::ObjectWriteOperation& op, vector<cls_log_entry>& entries, bool monotonic_inc)
+void cls_log_add(librados::ObjectWriteOperation& op, vector<cls::log::entry>& entries, bool monotonic_inc)
{
bufferlist in;
- cls_log_add_op call;
+ cls::log::ops::add_op call;
call.entries = entries;
encode(call, in);
op.exec("log", "add", in);
}
-void cls_log_add(librados::ObjectWriteOperation& op, cls_log_entry& entry)
+void cls_log_add(librados::ObjectWriteOperation& op, cls::log::entry& entry)
{
bufferlist in;
- cls_log_add_op call;
+ cls::log::ops::add_op call;
call.entries.push_back(entry);
encode(call, in);
op.exec("log", "add", in);
}
-void cls_log_add_prepare_entry(cls_log_entry& entry, ceph::real_time timestamp,
+void cls_log_add_prepare_entry(cls::log::entry& entry, ceph::real_time timestamp,
const string& section, const string& name, bufferlist& bl)
{
entry.timestamp = timestamp;
void cls_log_add(librados::ObjectWriteOperation& op, ceph::real_time timestamp,
const string& section, const string& name, bufferlist& bl)
{
- cls_log_entry entry;
+ cls::log::entry entry;
cls_log_add_prepare_entry(entry, timestamp, section, name, bl);
cls_log_add(op, entry);
ceph::real_time to_time, const string& from_marker, const string& to_marker)
{
bufferlist in;
- cls_log_trim_op call;
+ cls::log::ops::trim_op call;
call.from_time = from_time;
call.to_time = to_time;
call.from_marker = from_marker;
}
class LogListCtx : public ObjectOperationCompletion {
- vector<cls_log_entry> *entries;
+ vector<cls::log::entry>* entries;
string *marker;
bool *truncated;
public:
- LogListCtx(vector<cls_log_entry> *_entries, string *_marker, bool *_truncated) :
- entries(_entries), marker(_marker), truncated(_truncated) {}
+ LogListCtx(vector<cls::log::entry> *_entries, string *_marker, bool *_truncated) :
+ entries(_entries), marker(_marker), truncated(_truncated) {}
void handle_completion(int r, bufferlist& outbl) override {
if (r >= 0) {
- cls_log_list_ret ret;
+ cls::log::ops::list_ret ret;
try {
auto iter = outbl.cbegin();
decode(ret, iter);
void cls_log_list(librados::ObjectReadOperation& op, ceph::real_time from,
ceph::real_time to, const string& in_marker, int max_entries,
- vector<cls_log_entry>& entries,
+ vector<cls::log::entry>& entries,
string *out_marker, bool *truncated)
{
bufferlist inbl;
- cls_log_list_op call;
+ cls::log::ops::list_op call;
call.from_time = from;
call.to_time = to;
call.marker = in_marker;
}
class LogInfoCtx : public ObjectOperationCompletion {
- cls_log_header *header;
+ cls::log::header* header;
public:
- explicit LogInfoCtx(cls_log_header *_header) : header(_header) {}
+ explicit LogInfoCtx(cls::log::header *_header) : header(_header) {}
void handle_completion(int r, bufferlist& outbl) override {
if (r >= 0) {
- cls_log_info_ret ret;
+ cls::log::ops::info_ret ret;
try {
auto iter = outbl.cbegin();
decode(ret, iter);
}
};
-void cls_log_info(librados::ObjectReadOperation& op, cls_log_header *header)
+void cls_log_info(librados::ObjectReadOperation& op, cls::log::header *header)
{
bufferlist inbl;
- cls_log_info_op call;
+ cls::log::ops::info_op call;
encode(call, inbl);
* log objclass
*/
-void cls_log_add_prepare_entry(cls_log_entry& entry, ceph::real_time timestamp,
+void cls_log_add_prepare_entry(cls::log::entry& entry, ceph::real_time timestamp,
const std::string& section,
const std::string& name, ceph::buffer::list& bl);
-void cls_log_add(librados::ObjectWriteOperation& op, std::vector<cls_log_entry>& entries, bool monotonic_inc);
-void cls_log_add(librados::ObjectWriteOperation& op, cls_log_entry& entry);
+void cls_log_add(librados::ObjectWriteOperation& op, std::vector<cls::log::entry>& entries, bool monotonic_inc);
+void cls_log_add(librados::ObjectWriteOperation& op, cls::log::entry& entry);
void cls_log_add(librados::ObjectWriteOperation& op, ceph::real_time timestamp,
const std::string& section, const std::string& name, ceph::buffer::list& bl);
void cls_log_list(librados::ObjectReadOperation& op, ceph::real_time from,
ceph::real_time to, const std::string& in_marker,
- int max_entries, std::vector<cls_log_entry>& entries,
+ int max_entries, std::vector<cls::log::entry>& entries,
std::string *out_marker, bool *truncated);
void cls_log_trim(librados::ObjectWriteOperation& op, ceph::real_time from_time,
const std::string& from_marker, const std::string& to_marker);
#endif
-void cls_log_info(librados::ObjectReadOperation& op, cls_log_header *header);
+void cls_log_info(librados::ObjectReadOperation& op, cls::log::header* header);
#endif
#ifndef CEPH_CLS_LOG_OPS_H
#define CEPH_CLS_LOG_OPS_H
+#include <string>
+#include <vector>
+
+#include "common/ceph_time.h"
+
#include "cls_log_types.h"
-struct cls_log_add_op {
- std::vector<cls_log_entry> entries;
- bool monotonic_inc;
+namespace cls::log::ops {
+struct add_op {
+ std::vector<entry> entries;
+ bool monotonic_inc = true;
- cls_log_add_op() : monotonic_inc(true) {}
+ add_op() = default;
void encode(ceph::buffer::list& bl) const {
ENCODE_START(2, 1, bl);
encode_json("monotonic_inc", monotonic_inc, f);
}
- static void generate_test_instances(std::list<cls_log_add_op *>& l) {
+ static void generate_test_instances(std::list<add_op *>& l) {
using namespace std::literals;
- l.push_back(new cls_log_add_op);
- l.push_back(new cls_log_add_op);
- l.back()->entries.push_back(cls_log_entry());
- l.back()->entries.push_back(cls_log_entry());
+ l.push_back(new add_op);
+ l.push_back(new add_op);
+ l.back()->entries.push_back(entry{});
+ l.back()->entries.push_back(entry{});
l.back()->entries.back().section = "section";
l.back()->entries.back().name = "name";
l.back()->entries.back().timestamp = ceph::real_time{1s + 2ns};
l.back()->entries.back().id = "id";
}
};
-WRITE_CLASS_ENCODER(cls_log_add_op)
+WRITE_CLASS_ENCODER(add_op)
-struct cls_log_list_op {
+struct list_op {
ceph::real_time from_time;
std::string marker; /* if not empty, overrides from_time */
ceph::real_time to_time; /* not inclusive */
- int max_entries; /* upperbound to returned num of entries
- might return less than that and still be truncated */
+ int max_entries = 0; /* upperbound to returned num of entries
+ might return less than that and still be truncated */
- cls_log_list_op() : max_entries(0) {}
+ list_op() = default;
void encode(ceph::buffer::list& bl) const {
ENCODE_START(1, 1, bl);
DECODE_FINISH(bl);
}
};
-WRITE_CLASS_ENCODER(cls_log_list_op)
+WRITE_CLASS_ENCODER(list_op)
-struct cls_log_list_ret {
- std::vector<cls_log_entry> entries;
+struct list_ret {
+ std::vector<entry> entries;
std::string marker;
bool truncated;
- cls_log_list_ret() : truncated(false) {}
+ list_ret() : truncated(false) {}
void encode(ceph::buffer::list& bl) const {
ENCODE_START(1, 1, bl);
DECODE_FINISH(bl);
}
};
-WRITE_CLASS_ENCODER(cls_log_list_ret)
-
+WRITE_CLASS_ENCODER(list_ret)
/*
* operation will return 0 when successfully removed but not done. Will return
* -ENODATA when done, so caller needs to repeat sending request until that.
*/
-struct cls_log_trim_op {
+struct trim_op {
ceph::real_time from_time;
ceph::real_time to_time; /* inclusive */
std::string from_marker;
std::string to_marker;
- cls_log_trim_op() {}
+ trim_op() = default;
void encode(ceph::buffer::list& bl) const {
ENCODE_START(2, 1, bl);
DECODE_FINISH(bl);
}
};
-WRITE_CLASS_ENCODER(cls_log_trim_op)
+WRITE_CLASS_ENCODER(trim_op)
-struct cls_log_info_op {
- cls_log_info_op() {}
+struct info_op {
+ info_op() = default;
void encode(ceph::buffer::list& bl) const {
ENCODE_START(1, 1, bl);
DECODE_FINISH(bl);
}
};
-WRITE_CLASS_ENCODER(cls_log_info_op)
+WRITE_CLASS_ENCODER(info_op)
-struct cls_log_info_ret {
- cls_log_header header;
+struct info_ret {
+ cls::log::header header;
void encode(ceph::buffer::list& bl) const {
ENCODE_START(1, 1, bl);
- encode(header, bl);
+ encode(this->header, bl);
ENCODE_FINISH(bl);
}
void decode(ceph::buffer::list::const_iterator& bl) {
DECODE_START(1, bl);
- decode(header, bl);
+ decode(this->header, bl);
DECODE_FINISH(bl);
}
};
-WRITE_CLASS_ENCODER(cls_log_info_ret)
+WRITE_CLASS_ENCODER(info_ret)
+} // namespace cls::log::ops
#endif
class JSONObj;
class JSONDecoder;
-struct cls_log_entry {
+namespace cls::log {
+struct entry {
std::string id;
std::string section;
std::string name;
ceph::real_time timestamp;
ceph::buffer::list data;
- cls_log_entry() = default;
+ entry() = default;
- cls_log_entry(ceph::real_time timestamp, std::string section,
- std::string name, ceph::buffer::list&& data)
+ entry(ceph::real_time timestamp, std::string section,
+ std::string name, ceph::buffer::list&& data)
: section(std::move(section)), name(std::move(name)),
timestamp(timestamp), data(std::move(data)) {}
JSONDecoder::decode_json("id", id, obj);
}
- static void generate_test_instances(std::list<cls_log_entry *>& l) {
- l.push_back(new cls_log_entry{});
- l.push_back(new cls_log_entry);
+ static void generate_test_instances(std::list<cls::log::entry *>& l) {
+ l.push_back(new cls::log::entry{});
+ l.push_back(new cls::log::entry);
l.back()->id = "test_id";
l.back()->section = "test_section";
l.back()->name = "test_name";
l.back()->data = bl;
}
};
-WRITE_CLASS_ENCODER(cls_log_entry)
+WRITE_CLASS_ENCODER(entry)
-struct cls_log_header {
+struct header {
std::string max_marker;
ceph::real_time max_time;
decode(max_time, bl);
DECODE_FINISH(bl);
}
-};
-inline bool operator ==(const cls_log_header& lhs, const cls_log_header& rhs) {
- return (lhs.max_marker == rhs.max_marker &&
- lhs.max_time == rhs.max_time);
-}
-inline bool operator !=(const cls_log_header& lhs, const cls_log_header& rhs) {
- return !(lhs == rhs);
-}
-WRITE_CLASS_ENCODER(cls_log_header)
+ friend auto operator <=>(const header&, const header&) = default;
+};
+WRITE_CLASS_ENCODER(header)
+} // namespace cls::log
#endif
}
RGWRadosTimelogAddCR::RGWRadosTimelogAddCR(const DoutPrefixProvider *_dpp, rgw::sal::RadosStore* _store, const string& _oid,
- const cls_log_entry& entry) : RGWSimpleCoroutine(_store->ctx()),
+ const cls::log::entry& entry) : RGWSimpleCoroutine(_store->ctx()),
dpp(_dpp),
store(_store),
oid(_oid), cn(NULL)
class RGWRadosTimelogAddCR : public RGWSimpleCoroutine {
const DoutPrefixProvider *dpp;
rgw::sal::RadosStore* store;
- std::vector<cls_log_entry> entries;
+ std::vector<cls::log::entry> entries;
std::string oid;
public:
RGWRadosTimelogAddCR(const DoutPrefixProvider *dpp, rgw::sal::RadosStore* _store, const std::string& _oid,
- const cls_log_entry& entry);
+ const cls::log::entry& entry);
int send_request(const DoutPrefixProvider *dpp) override;
int request_complete() override;
}
class RGWDataChangesOmap final : public RGWDataChangesBE {
- using centries = std::vector<cls_log_entry>;
+ using centries = std::vector<cls::log::entry>;
std::vector<std::string> oids;
public:
out = centries();
}
- cls_log_entry e;
+ cls::log::entry e;
cls_log_add_prepare_entry(e, ut, {}, key, entry);
std::get<centries>(out).push_back(std::move(e));
}
std::optional<std::string_view> marker,
std::string* out_marker, bool* truncated,
optional_yield y) override {
- std::vector<cls_log_entry> log_entries;
+ std::vector<cls::log::entry> log_entries;
lr::ObjectReadOperation op;
cls_log_list(op, {}, {}, std::string(marker.value_or("")),
max_entries, log_entries, out_marker, truncated);
}
int get_info(const DoutPrefixProvider *dpp, int index,
RGWDataChangesLogInfo *info, optional_yield y) override {
- cls_log_header header;
+ cls::log::header header;
lr::ObjectReadOperation op;
cls_log_info(op, &header);
auto r = rgw_rados_operate(dpp, ioctx, oids[index], &op, nullptr, y);
}
int is_empty(const DoutPrefixProvider *dpp, optional_yield y) override {
for (auto shard = 0u; shard < oids.size(); ++shard) {
- std::vector<cls_log_entry> log_entries;
+ std::vector<cls::log::entry> log_entries;
lr::ObjectReadOperation op;
std::string out_marker;
bool truncated;
if (!zone->log_data)
return 0;
- /* we can't keep the bucket name as part of the cls_log_entry, and we need
+ /* we can't keep the bucket name as part of the cls::log::entry, and we need
* it later, so we keep two lists under the map */
bc::flat_map<int, std::pair<std::vector<BucketGen>,
RGWDataChangesBE::entries>> m;
#include "common/RefCountedObj.h"
#include "cls/log/cls_log_types.h"
-
#include "rgw_basic_types.h"
#include "rgw_log_backing.h"
#include "rgw_sync_policy.h"
return datalog.get_oid(gen_id, shard_id);
}
public:
- using entries = std::variant<std::vector<cls_log_entry>,
+ using entries = std::variant<std::vector<cls::log::entry>,
std::vector<ceph::buffer::list>>;
const uint64_t gen_id;
return 0;
}
-int RGWMetadataLog::store_entries_in_shard(const DoutPrefixProvider *dpp, vector<cls_log_entry>& entries, int shard_id, librados::AioCompletion *completion)
+int RGWMetadataLog::store_entries_in_shard(const DoutPrefixProvider *dpp, vector<cls::log::entry>& entries, int shard_id, librados::AioCompletion *completion)
{
string oid;
int RGWMetadataLog::list_entries(const DoutPrefixProvider *dpp, void *handle,
int max_entries,
- vector<cls_log_entry>& entries,
+ vector<cls::log::entry>& entries,
string *last_marker,
bool *truncated,
optional_yield y) {
string oid;
get_shard_oid(shard_id, oid);
- cls_log_header header;
+ cls::log::header header;
int ret = svc.cls->timelog.info(dpp, oid, &header, y);
if ((ret < 0) && (ret != -ENOENT))
std::string get_marker(void *handle);
- void dump_log_entry(cls_log_entry& entry, Formatter *f);
+ void dump_log_entry(cls::log::entry& entry, Formatter *f);
void get_sections(std::list<std::string>& sections);
s->formatter->open_array_section("entries");
for (auto iter = entries.begin();
iter != entries.end(); ++iter) {
- cls_log_entry& entry = *iter;
+ auto& entry = *iter;
static_cast<rgw::sal::RadosStore*>(driver)->ctl()->meta.mgr->dump_log_entry(entry, s->formatter);
flusher.flush();
}
};
class RGWOp_MDLog_List : public RGWRESTOp {
- std::vector<cls_log_entry> entries;
+ std::vector<cls::log::entry> entries;
std::string last_marker;
bool truncated;
public:
}
RGWCoroutine *RGWSyncErrorLogger::log_error_cr(const DoutPrefixProvider *dpp, const string& source_zone, const string& section, const string& name, uint32_t error_code, const string& message) {
- cls_log_entry entry;
+ cls::log::entry entry;
rgw_sync_error_info info(source_zone, error_code, message);
bufferlist bl;
}
public:
string marker;
- vector<cls_log_entry> entries;
+ vector<cls::log::entry> entries;
bool truncated;
RGWAsyncReadMDLogEntries(const DoutPrefixProvider *dpp, RGWCoroutine *caller, RGWAioCompletionNotifier *cn, rgw::sal::RadosStore* _store,
string marker;
string *pmarker;
int max_entries;
- vector<cls_log_entry> *entries;
+ vector<cls::log::entry> *entries;
bool *truncated;
RGWAsyncReadMDLogEntries *req{nullptr};
public:
RGWReadMDLogEntriesCR(RGWMetaSyncEnv *_sync_env, RGWMetadataLog* mdlog,
int _shard_id, string*_marker, int _max_entries,
- vector<cls_log_entry> *_entries, bool *_truncated)
+ vector<cls::log::entry> *_entries, bool *_truncated)
: RGWSimpleCoroutine(_sync_env->cct), sync_env(_sync_env), mdlog(mdlog),
shard_id(_shard_id), pmarker(_marker), max_entries(_max_entries),
entries(_entries), truncated(_truncated) {}
RGWMetaSyncShardMarkerTrack *marker_tracker = nullptr;
- vector<cls_log_entry> log_entries;
+ vector<cls::log::entry> log_entries;
decltype(log_entries)::iterator log_iter;
bool truncated = false;
const bool add_ref = false; // default constructs with refs=1
completion.reset(new RGWMetadataLogInfoCompletion(
- [this](int ret, const cls_log_header& header) {
+ [this](int ret, const cls::log::header& header) {
if (ret < 0) {
if (ret != -ENOENT) {
ldpp_dout(sync_env->dpp, 1) << "ERROR: failed to read mdlog info with "
int RGWCloneMetaLogCoroutine::state_store_mdlog_entries()
{
- vector<cls_log_entry> dest_entries;
+ vector<cls::log::entry> dest_entries;
vector<rgw_mdlog_entry>::iterator iter;
for (iter = data.entries.begin(); iter != data.entries.end(); ++iter) {
rgw_mdlog_entry& entry = *iter;
ldpp_dout(sync_env->dpp, 20) << "entry: name=" << entry.name << dendl;
- cls_log_entry dest_entry;
+ cls::log::entry dest_entry;
dest_entry.id = entry.id;
dest_entry.section = entry.section;
dest_entry.name = entry.name;
void decode_json(JSONObj *obj);
- bool convert_from(cls_log_entry& le) {
+ bool convert_from(cls::log::entry& le) {
id = le.id;
section = le.section;
name = le.name;
formatter->open_array_section("entries");
for (; i < g_ceph_context->_conf->rgw_md_log_max_shards; i++) {
void *handle;
- vector<cls_log_entry> entries;
+ vector<cls::log::entry> entries;
meta_log->init_list_entries(i, {}, {}, marker, &handle);
bool truncated;
}
for (auto iter = entries.begin(); iter != entries.end(); ++iter) {
- cls_log_entry& entry = *iter;
+ cls::log::entry& entry = *iter;
static_cast<rgw::sal::RadosStore*>(driver)->ctl()->meta.mgr->dump_log_entry(entry, formatter.get());
}
formatter->flush(cout);
string oid = RGWSyncErrorLogger::get_shard_oid(RGW_SYNC_ERROR_LOG_SHARD_PREFIX, shard_id);
do {
- vector<cls_log_entry> entries;
+ vector<cls::log::entry> entries;
ret = static_cast<rgw::sal::RadosStore*>(driver)->svc()->cls->timelog.list(dpp(), oid, {}, {}, max_entries - count, entries, marker, &marker, &truncated,
null_yield);
if (ret == -ENOENT) {
formatter->open_array_section("entries");
for (; i < g_ceph_context->_conf->rgw_data_log_num_shards; i++) {
- vector<cls_log_entry> entries;
+ vector<cls::log::entry> entries;
RGWDataChangesLogInfo info;
static_cast<rgw::sal::RadosStore*>(driver)->svc()->
class RGWMetadataLogInfoCompletion : public RefCountedObject {
public:
- using info_callback_t = std::function<void(int, const cls_log_header&)>;
+ using info_callback_t = std::function<void(int, const cls::log::header&)>;
private:
- cls_log_header header;
+ cls::log::header header;
RGWSI_RADOS::Obj io_obj;
librados::AioCompletion *completion;
std::mutex mutex; //< protects callback between cancel/complete
~RGWMetadataLogInfoCompletion() override;
RGWSI_RADOS::Obj& get_io_obj() { return io_obj; }
- cls_log_header& get_header() { return header; }
+ cls::log::header& get_header() { return header; }
librados::AioCompletion* get_completion() { return completion; }
void finish(librados::completion_t cb) {
int add_entry(const DoutPrefixProvider *dpp, const std::string& hash_key, const std::string& section, const std::string& key, bufferlist& bl, optional_yield y);
int get_shard_id(const std::string& hash_key, int *shard_id);
- int store_entries_in_shard(const DoutPrefixProvider *dpp, std::vector<cls_log_entry>& entries, int shard_id, librados::AioCompletion *completion);
+ int store_entries_in_shard(const DoutPrefixProvider *dpp, std::vector<cls::log::entry>& entries, int shard_id, librados::AioCompletion *completion);
struct LogListCtx {
int cur_shard;
int list_entries(const DoutPrefixProvider *dpp,
void *handle,
int max_entries,
- std::vector<cls_log_entry>& entries,
+ std::vector<cls::log::entry>& entries,
std::string *out_marker,
bool *truncated,
optional_yield y);
return h->handler->get_marker(h->handle);
}
-void RGWMetadataManager::dump_log_entry(cls_log_entry& entry, Formatter *f)
+void RGWMetadataManager::dump_log_entry(cls::log::entry& entry, Formatter *f)
{
f->open_object_section("entry");
f->dump_string("id", entry.id);
return 0;
}
-void RGWSI_Cls::TimeLog::prepare_entry(cls_log_entry& entry,
+void RGWSI_Cls::TimeLog::prepare_entry(cls::log::entry& entry,
const real_time& ut,
const string& section,
const string& key,
int RGWSI_Cls::TimeLog::add(const DoutPrefixProvider *dpp,
const string& oid,
- std::vector<cls_log_entry>& entries,
+ std::vector<cls::log::entry>& entries,
librados::AioCompletion *completion,
bool monotonic_inc,
optional_yield y)
const string& oid,
const real_time& start_time,
const real_time& end_time,
- int max_entries, std::vector<cls_log_entry>& entries,
+ int max_entries, std::vector<cls::log::entry>& entries,
const string& marker,
string *out_marker,
bool *truncated,
int RGWSI_Cls::TimeLog::info(const DoutPrefixProvider *dpp,
const string& oid,
- cls_log_header *header,
+ cls::log::header *header,
optional_yield y)
{
RGWSI_RADOS::Obj obj;
int RGWSI_Cls::TimeLog::info_async(const DoutPrefixProvider *dpp,
RGWSI_RADOS::Obj& obj,
const string& oid,
- cls_log_header *header,
+ cls::log::header *header,
librados::AioCompletion *completion)
{
int r = init_obj(dpp, oid, obj);
public:
TimeLog(CephContext *cct): ClsSubService(cct) {}
- void prepare_entry(cls_log_entry& entry,
+ void prepare_entry(cls::log::entry& entry,
const real_time& ut,
const std::string& section,
const std::string& key,
optional_yield y);
int add(const DoutPrefixProvider *dpp,
const std::string& oid,
- std::vector<cls_log_entry>& entries,
+ std::vector<cls::log::entry>& entries,
librados::AioCompletion *completion,
bool monotonic_inc,
optional_yield y);
const std::string& oid,
const real_time& start_time,
const real_time& end_time,
- int max_entries, std::vector<cls_log_entry>& entries,
+ int max_entries, std::vector<cls::log::entry>& entries,
const std::string& marker,
std::string *out_marker,
bool *truncated,
optional_yield y);
int info(const DoutPrefixProvider *dpp,
const std::string& oid,
- cls_log_header *header,
+ cls::log::header *header,
optional_yield y);
int info_async(const DoutPrefixProvider *dpp,
RGWSI_RADOS::Obj& obj,
const std::string& oid,
- cls_log_header *header,
+ cls::log::header *header,
librados::AioCompletion *completion);
int trim(const DoutPrefixProvider *dpp,
const std::string& oid,
return modify_time ? start_time + (i * 1s) : start_time;
}
-void check_entry(cls_log_entry& entry, real_time start_time, int i, bool modified_time)
+void check_entry(cls::log::entry& entry, real_time start_time, int i, bool modified_time)
{
string section = "global";
string name = get_name(i);
static int log_list(librados::IoCtx& ioctx, const std::string& oid,
real_time from, real_time to,
const string& in_marker, int max_entries,
- vector<cls_log_entry>& entries,
+ vector<cls::log::entry>& entries,
string *out_marker, bool *truncated)
{
librados::ObjectReadOperation rop;
static int log_list(librados::IoCtx& ioctx, const std::string& oid,
real_time from, real_time to, int max_entries,
- vector<cls_log_entry>& entries, bool *truncated)
+ vector<cls::log::entry>& entries, bool *truncated)
{
std::string marker;
return log_list(ioctx, oid, from, to, marker, max_entries,
}
static int log_list(librados::IoCtx& ioctx, const std::string& oid,
- vector<cls_log_entry>& entries)
+ vector<cls::log::entry>& entries)
{
real_time from, to;
bool truncated{false};
auto to_time = get_time(start_time, 1, true);
generate_log(ioctx, oid, 10, start_time, false);
- vector<cls_log_entry> entries;
+ vector<cls::log::entry> entries;
bool truncated;
/* check list */
ASSERT_EQ(10, (int)entries.size());
ASSERT_EQ(0, (int)truncated);
}
- vector<cls_log_entry>::iterator iter;
+ vector<cls::log::entry>::iterator iter;
/* need to sort returned entries, all were using the same time as key */
- map<int, cls_log_entry> check_ents;
+ map<int, cls::log::entry> check_ents;
for (iter = entries.begin(); iter != entries.end(); ++iter) {
- cls_log_entry& entry = *iter;
+ cls::log::entry& entry = *iter;
int num;
ASSERT_EQ(0, read_bl(entry.data, &num));
ASSERT_EQ(10, (int)check_ents.size());
- map<int, cls_log_entry>::iterator ei;
+ map<int, cls::log::entry>::iterator ei;
/* verify entries are as expected */
int i;
for (i = 0, ei = check_ents.begin(); i < 10; i++, ++ei) {
- cls_log_entry& entry = ei->second;
+ cls::log::entry& entry = ei->second;
ASSERT_EQ(i, ei->first);
check_entry(entry, start_time, i, false);
auto start_time = real_clock::now();
generate_log(ioctx, oid, 10, start_time, true);
- vector<cls_log_entry> entries;
+ vector<cls::log::entry> entries;
bool truncated;
auto to_time = start_time + (10 * 1s);
ASSERT_EQ(0, (int)truncated);
}
- vector<cls_log_entry>::iterator iter;
+ vector<cls::log::entry>::iterator iter;
/* returned entries should be sorted by time */
- map<int, cls_log_entry> check_ents;
+ map<int, cls::log::entry> check_ents;
int i;
for (i = 0, iter = entries.begin(); iter != entries.end(); ++iter, ++i) {
- cls_log_entry& entry = *iter;
+ cls::log::entry& entry = *iter;
int num;
auto start_time = real_clock::now();
generate_log(ioctx, oid, 10, start_time, true);
- vector<cls_log_entry> entries;
+ vector<cls::log::entry> entries;
bool truncated;
/* check list */
auto start_time = real_clock::now();
generate_log(ioctx, oid, 10, start_time, true);
- std::vector<cls_log_entry> log1;
+ std::vector<cls::log::entry> log1;
{
- vector<cls_log_entry> entries;
+ vector<cls::log::entry> entries;
ASSERT_EQ(0, log_list(ioctx, oid, entries));
ASSERT_EQ(10u, entries.size());
const std::string from = "";
const std::string to = log1[0].id;
ASSERT_EQ(0, do_log_trim(ioctx, oid, from, to));
- vector<cls_log_entry> entries;
+ vector<cls::log::entry> entries;
ASSERT_EQ(0, log_list(ioctx, oid, entries));
ASSERT_EQ(9u, entries.size());
EXPECT_EQ(log1[1].id, entries.begin()->id);
const std::string from = log1[8].id;
const std::string to = "9";
ASSERT_EQ(0, do_log_trim(ioctx, oid, from, to));
- vector<cls_log_entry> entries;
+ vector<cls::log::entry> entries;
ASSERT_EQ(0, log_list(ioctx, oid, entries));
ASSERT_EQ(8u, entries.size());
EXPECT_EQ(log1[8].id, entries.rbegin()->id);
const std::string from = log1[3].id;
const std::string to = log1[4].id;
ASSERT_EQ(0, do_log_trim(ioctx, oid, from, to));
- vector<cls_log_entry> entries;
+ vector<cls::log::entry> entries;
ASSERT_EQ(0, log_list(ioctx, oid, entries));
ASSERT_EQ(7u, entries.size());
ASSERT_EQ(-ENODATA, do_log_trim(ioctx, oid, from, to));
const std::string from = "";
const std::string to = "9";
ASSERT_EQ(0, do_log_trim(ioctx, oid, from, to));
- vector<cls_log_entry> entries;
+ vector<cls::log::entry> entries;
ASSERT_EQ(0, log_list(ioctx, oid, entries));
ASSERT_EQ(0u, entries.size());
ASSERT_EQ(-ENODATA, do_log_trim(ioctx, oid, from, to));
std::string to_marker;
{
lr::ObjectReadOperation op;
- std::vector<cls_log_entry> entries;
+ std::vector<cls::log::entry> entries;
bool truncated = false;
cls_log_list(op, {}, {}, {}, 1, entries, &to_marker, &truncated);
auto r = rgw_rados_operate(&dp, ioctx, oid, &op, nullptr, null_yield);
}
{
lr::ObjectReadOperation op;
- std::vector<cls_log_entry> entries;
+ std::vector<cls::log::entry> entries;
bool truncated = false;
cls_log_list(op, {}, {}, {}, 1, entries, &to_marker, &truncated);
auto r = rgw_rados_operate(&dp, ioctx, oid, &op, nullptr, null_yield);
TYPE(RGWLifecycleConfiguration)
#include "cls/log/cls_log_types.h"
-TYPE(cls_log_entry)
+TYPE(cls::log::entry)
#include "cls/log/cls_log_ops.h"
-TYPE(cls_log_add_op)
+TYPE(cls::log::ops::add_op)
#include "cls/rgw/cls_rgw_types.h"
TYPE(rgw_bucket_pending_info)