}
int DB::get_entry(const std::string& oid, const std::string& marker,
- std::unique_ptr<rgw::sal::Lifecycle::LCEntry>* entry)
+ rgw::sal::LCEntry& entry)
{
int ret = 0;
const DoutPrefixProvider *dpp = get_def_dpp();
InitializeParams(dpp, ¶ms);
params.op.lc_entry.index = oid;
- params.op.lc_entry.entry.set_bucket(marker);
+ params.op.lc_entry.entry.bucket = marker;
params.op.query_str = "get_entry";
ret = ProcessOp(dpp, "GetLCEntry", ¶ms);
goto out;
}
- if (!params.op.lc_entry.entry.get_start_time() == 0) { //ensure entry found
- rgw::sal::Lifecycle::LCEntry* e;
- e = new rgw::sal::StoreLifecycle::StoreLCEntry(params.op.lc_entry.entry);
- if (!e) {
- ret = -ENOMEM;
- goto out;
- }
- entry->reset(e);
+ if (params.op.lc_entry.entry.start_time != 0) { //ensure entry found
+ entry = std::move(params.op.lc_entry.entry);
}
out:
}
int DB::get_next_entry(const std::string& oid, const std::string& marker,
- std::unique_ptr<rgw::sal::Lifecycle::LCEntry>* entry)
+ rgw::sal::LCEntry& entry)
{
int ret = 0;
const DoutPrefixProvider *dpp = get_def_dpp();
InitializeParams(dpp, ¶ms);
params.op.lc_entry.index = oid;
- params.op.lc_entry.entry.set_bucket(marker);
+ params.op.lc_entry.entry.bucket = marker;
params.op.query_str = "get_next_entry";
ret = ProcessOp(dpp, "GetLCEntry", ¶ms);
goto out;
}
- if (!params.op.lc_entry.entry.get_start_time() == 0) { //ensure entry found
- rgw::sal::Lifecycle::LCEntry* e;
- e = new rgw::sal::StoreLifecycle::StoreLCEntry(params.op.lc_entry.entry);
- if (!e) {
- ret = -ENOMEM;
- goto out;
- }
- entry->reset(e);
+ if (params.op.lc_entry.entry.start_time != 0) { //ensure entry found
+ entry = std::move(params.op.lc_entry.entry);
}
out:
return ret;
}
-int DB::set_entry(const std::string& oid, rgw::sal::Lifecycle::LCEntry& entry)
+int DB::set_entry(const std::string& oid, const rgw::sal::LCEntry& entry)
{
int ret = 0;
const DoutPrefixProvider *dpp = get_def_dpp();
}
int DB::list_entries(const std::string& oid, const std::string& marker,
- uint32_t max_entries, std::vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>>& entries)
+ uint32_t max_entries, std::vector<rgw::sal::LCEntry>& entries)
{
int ret = 0;
const DoutPrefixProvider *dpp = get_def_dpp();
}
for (auto& entry : params.op.lc_entry.list_entries) {
- entries.push_back(std::make_unique<rgw::sal::StoreLifecycle::StoreLCEntry>(std::move(entry)));
+ entries.push_back(std::move(entry));
}
out:
return ret;
}
-int DB::rm_entry(const std::string& oid, rgw::sal::Lifecycle::LCEntry& entry)
+int DB::rm_entry(const std::string& oid, const rgw::sal::LCEntry& entry)
{
int ret = 0;
const DoutPrefixProvider *dpp = get_def_dpp();
return ret;
}
-int DB::get_head(const std::string& oid, std::unique_ptr<rgw::sal::Lifecycle::LCHead>* head)
+int DB::get_head(const std::string& oid, rgw::sal::LCHead& head)
{
int ret = 0;
const DoutPrefixProvider *dpp = get_def_dpp();
goto out;
}
- *head = std::make_unique<rgw::sal::StoreLifecycle::StoreLCHead>(params.op.lc_head.head);
+ head = std::move(params.op.lc_head.head);
out:
return ret;
}
-int DB::put_head(const std::string& oid, rgw::sal::Lifecycle::LCHead& head)
+int DB::put_head(const std::string& oid, const rgw::sal::LCHead& head)
{
int ret = 0;
const DoutPrefixProvider *dpp = get_def_dpp();
struct DBOpLCHeadInfo {
std::string index;
- rgw::sal::StoreLifecycle::StoreLCHead head;
+ rgw::sal::LCHead head;
};
struct DBOpLCEntryInfo {
std::string index;
- rgw::sal::StoreLifecycle::StoreLCEntry entry;
+ rgw::sal::LCEntry entry;
// used for list query
std::string min_marker;
- std::list<rgw::sal::StoreLifecycle::StoreLCEntry> list_entries;
+ std::list<rgw::sal::LCEntry> list_entries;
};
struct DBOpInfo {
RGWObjState *astate, void *arg);
int get_entry(const std::string& oid, const std::string& marker,
- std::unique_ptr<rgw::sal::Lifecycle::LCEntry>* entry);
+ rgw::sal::LCEntry& entry);
int get_next_entry(const std::string& oid, const std::string& marker,
- std::unique_ptr<rgw::sal::Lifecycle::LCEntry>* entry);
- int set_entry(const std::string& oid, rgw::sal::Lifecycle::LCEntry& entry);
+ rgw::sal::LCEntry& entry);
+ int set_entry(const std::string& oid, const rgw::sal::LCEntry& entry);
int list_entries(const std::string& oid, const std::string& marker,
- uint32_t max_entries, std::vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>>& entries);
- int rm_entry(const std::string& oid, rgw::sal::Lifecycle::LCEntry& entry);
- int get_head(const std::string& oid, std::unique_ptr<rgw::sal::Lifecycle::LCHead>* head);
- int put_head(const std::string& oid, rgw::sal::Lifecycle::LCHead& head);
+ uint32_t max_entries, std::vector<rgw::sal::LCEntry>& entries);
+ int rm_entry(const std::string& oid, const rgw::sal::LCEntry& entry);
+ int get_head(const std::string& oid, rgw::sal::LCHead& head);
+ int put_head(const std::string& oid, const rgw::sal::LCHead& head);
int delete_stale_objs(const DoutPrefixProvider *dpp, const std::string& bucket,
uint32_t min_wait);
int createGC(const DoutPrefixProvider *_dpp);
return -1;
op.lc_entry.index = (const char*)sqlite3_column_text(stmt, LCEntryIndex);
- op.lc_entry.entry.set_bucket((const char*)sqlite3_column_text(stmt, LCEntryBucketName));
- op.lc_entry.entry.set_start_time(sqlite3_column_int(stmt, LCEntryStartTime));
- op.lc_entry.entry.set_status(sqlite3_column_int(stmt, LCEntryStatus));
+ op.lc_entry.entry.bucket = (const char*)sqlite3_column_text(stmt, LCEntryBucketName);
+ op.lc_entry.entry.start_time = sqlite3_column_int(stmt, LCEntryStartTime);
+ op.lc_entry.entry.status = sqlite3_column_int(stmt, LCEntryStatus);
op.lc_entry.list_entries.push_back(op.lc_entry.entry);
int64_t start_date;
op.lc_head.index = (const char*)sqlite3_column_text(stmt, LCHeadIndex);
- op.lc_head.head.set_marker((const char*)sqlite3_column_text(stmt, LCHeadMarker));
+ op.lc_head.head.marker = (const char*)sqlite3_column_text(stmt, LCHeadMarker);
SQL_DECODE_BLOB_PARAM(dpp, stmt, LCHeadStartDate, start_date, sdb);
- op.lc_head.head.get_start_date() = start_date;
+ op.lc_head.head.start_date = start_date;
return 0;
}
SQL_BIND_TEXT(dpp, stmt, index, params->op.lc_entry.index.c_str(), sdb);
SQL_BIND_INDEX(dpp, stmt, index, p_params.op.lc_entry.bucket_name, sdb);
- SQL_BIND_TEXT(dpp, stmt, index, params->op.lc_entry.entry.get_bucket().c_str(), sdb);
+ SQL_BIND_TEXT(dpp, stmt, index, params->op.lc_entry.entry.bucket.c_str(), sdb);
SQL_BIND_INDEX(dpp, stmt, index, p_params.op.lc_entry.status, sdb);
- SQL_BIND_INT(dpp, stmt, index, params->op.lc_entry.entry.get_status(), sdb);
+ SQL_BIND_INT(dpp, stmt, index, params->op.lc_entry.entry.status, sdb);
SQL_BIND_INDEX(dpp, stmt, index, p_params.op.lc_entry.start_time, sdb);
- SQL_BIND_INT(dpp, stmt, index, params->op.lc_entry.entry.get_start_time(), sdb);
+ SQL_BIND_INT(dpp, stmt, index, params->op.lc_entry.entry.start_time, sdb);
out:
return rc;
SQL_BIND_TEXT(dpp, stmt, index, params->op.lc_entry.index.c_str(), sdb);
SQL_BIND_INDEX(dpp, stmt, index, p_params.op.lc_entry.bucket_name, sdb);
- SQL_BIND_TEXT(dpp, stmt, index, params->op.lc_entry.entry.get_bucket().c_str(), sdb);
+ SQL_BIND_TEXT(dpp, stmt, index, params->op.lc_entry.entry.bucket.c_str(), sdb);
out:
return rc;
SQL_BIND_TEXT(dpp, *pstmt, index, params->op.lc_entry.index.c_str(), sdb);
SQL_BIND_INDEX(dpp, *pstmt, index, p_params.op.lc_entry.bucket_name, sdb);
- SQL_BIND_TEXT(dpp, *pstmt, index, params->op.lc_entry.entry.get_bucket().c_str(), sdb);
+ SQL_BIND_TEXT(dpp, *pstmt, index, params->op.lc_entry.entry.bucket.c_str(), sdb);
out:
return rc;
SQL_BIND_TEXT(dpp, stmt, index, params->op.lc_head.index.c_str(), sdb);
SQL_BIND_INDEX(dpp, stmt, index, p_params.op.lc_head.marker, sdb);
- SQL_BIND_TEXT(dpp, stmt, index, params->op.lc_head.head.get_marker().c_str(), sdb);
+ SQL_BIND_TEXT(dpp, stmt, index, params->op.lc_head.head.marker.c_str(), sdb);
SQL_BIND_INDEX(dpp, stmt, index, p_params.op.lc_head.start_date, sdb);
SQL_ENCODE_BLOB_PARAM(dpp, stmt, index, static_cast<int64_t>(params->op.lc_head.head.start_date), sdb);
std::string index1 = "bucket1";
std::string index2 = "bucket2";
time_t lc_time = ceph_clock_now();
- std::unique_ptr<rgw::sal::Lifecycle::LCHead> head;
- std::string ents[] = {"entry1", "entry2", "entry3"};
- rgw::sal::StoreLifecycle::StoreLCHead head1(lc_time, 0, ents[0]);
- rgw::sal::StoreLifecycle::StoreLCHead head2(lc_time, 0, ents[1]);
- rgw::sal::StoreLifecycle::StoreLCHead head3(lc_time, 0, ents[2]);
+ rgw::sal::LCHead head;
+ rgw::sal::LCHead head1{lc_time, "entry1"};
+ rgw::sal::LCHead head2{lc_time, "entry2"};
+ rgw::sal::LCHead head3{lc_time, "entry3"};
ret = db->put_head(index1, head1);
ASSERT_EQ(ret, 0);
ret = db->put_head(index2, head2);
ASSERT_EQ(ret, 0);
- ret = db->get_head(index1, &head);
+ ret = db->get_head(index1, head);
ASSERT_EQ(ret, 0);
- ASSERT_EQ(head->get_marker(), "entry1");
+ ASSERT_EQ(head.marker, "entry1");
- ret = db->get_head(index2, &head);
+ ret = db->get_head(index2, head);
ASSERT_EQ(ret, 0);
- ASSERT_EQ(head->get_marker(), "entry2");
+ ASSERT_EQ(head.marker, "entry2");
// update index1
ret = db->put_head(index1, head3);
ASSERT_EQ(ret, 0);
- ret = db->get_head(index1, &head);
+ ret = db->get_head(index1, head);
ASSERT_EQ(ret, 0);
- ASSERT_EQ(head->get_marker(), "entry3");
+ ASSERT_EQ(head.marker, "entry3");
}
TEST_F(DBStoreTest, LCEntry) {
std::string index2 = "lcindex2";
typedef enum {lc_uninitial = 1, lc_complete} status;
std::string ents[] = {"bucket1", "bucket2", "bucket3", "bucket4"};
- std::unique_ptr<rgw::sal::Lifecycle::LCEntry> entry;
- rgw::sal::StoreLifecycle::StoreLCEntry entry1(ents[0], lc_time, lc_uninitial);
- rgw::sal::StoreLifecycle::StoreLCEntry entry2(ents[1], lc_time, lc_uninitial);
- rgw::sal::StoreLifecycle::StoreLCEntry entry3(ents[2], lc_time, lc_uninitial);
- rgw::sal::StoreLifecycle::StoreLCEntry entry4(ents[3], lc_time, lc_uninitial);
+ rgw::sal::LCEntry entry;
+ rgw::sal::LCEntry entry1{ents[0], lc_time, lc_uninitial};
+ rgw::sal::LCEntry entry2{ents[1], lc_time, lc_uninitial};
+ rgw::sal::LCEntry entry3{ents[2], lc_time, lc_uninitial};
+ rgw::sal::LCEntry entry4{ents[3], lc_time, lc_uninitial};
- vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>> lc_entries;
+ vector<rgw::sal::LCEntry> lc_entries;
ret = db->set_entry(index1, entry1);
ASSERT_EQ(ret, 0);
ASSERT_EQ(ret, 0);
// get entry index1, entry1
- ret = db->get_entry(index1, ents[0], &entry);
+ ret = db->get_entry(index1, ents[0], entry);
ASSERT_EQ(ret, 0);
- ASSERT_EQ(entry->get_status(), lc_uninitial);
- ASSERT_EQ(entry->get_start_time(), lc_time);
+ ASSERT_EQ(entry.status, lc_uninitial);
+ ASSERT_EQ(entry.start_time, lc_time);
// get next entry index1, entry2
- ret = db->get_next_entry(index1, ents[1], &entry);
+ ret = db->get_next_entry(index1, ents[1], entry);
ASSERT_EQ(ret, 0);
- ASSERT_EQ(entry->get_bucket(), ents[2]);
- ASSERT_EQ(entry->get_status(), lc_uninitial);
- ASSERT_EQ(entry->get_start_time(), lc_time);
+ ASSERT_EQ(entry.bucket, ents[2]);
+ ASSERT_EQ(entry.status, lc_uninitial);
+ ASSERT_EQ(entry.start_time, lc_time);
// update entry4 to entry5
entry4.status = lc_complete;
ret = db->set_entry(index2, entry4);
ASSERT_EQ(ret, 0);
- ret = db->get_entry(index2, ents[3], &entry);
+ ret = db->get_entry(index2, ents[3], entry);
ASSERT_EQ(ret, 0);
- ASSERT_EQ(entry->get_status(), lc_complete);
+ ASSERT_EQ(entry.status, lc_complete);
// list entries
ret = db->list_entries(index1, "", 5, lc_entries);
ASSERT_EQ(ret, 0);
for (const auto& ent: lc_entries) {
cout << "###################### \n";
- cout << "lc entry.bucket : " << ent->get_bucket() << "\n";
- cout << "lc entry.status : " << ent->get_status() << "\n";
+ cout << "lc entry.bucket : " << ent.bucket << "\n";
+ cout << "lc entry.status : " << ent.status << "\n";
}
// remove index1, entry3
ret = db->rm_entry(index1, entry3);
ASSERT_EQ(ret, 0);
- // get next entry index1, entry2.. should be null
- entry.release();
- ret = db->get_next_entry(index1, ents[1], &entry);
+ // get next entry index1, entry2.. should be empty
+ entry = rgw::sal::LCEntry{};
+ ret = db->get_next_entry(index1, ents[1], entry);
ASSERT_EQ(ret, 0);
- ASSERT_EQ(entry.get(), nullptr);
+ ASSERT_TRUE(entry.bucket.empty());
}
TEST_F(DBStoreTest, RemoveBucket) {
int RadosLifecycle::get_entry(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, const std::string& marker,
- std::unique_ptr<LCEntry>* entry)
+ LCEntry& entry)
{
librados::ObjectReadOperation op;
bufferlist bl;
return ret;
}
- *entry = std::make_unique<StoreLCEntry>(cls_entry.bucket, cls_entry.start_time, cls_entry.status);
+ entry.bucket = std::move(cls_entry.bucket);
+ entry.start_time = cls_entry.start_time;
+ entry.status = cls_entry.status;
return 0;
}
int RadosLifecycle::get_next_entry(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, const std::string& marker,
- std::unique_ptr<LCEntry>* entry)
+ LCEntry& entry)
{
librados::ObjectReadOperation op;
bufferlist bl;
return ret;
}
- *entry = std::make_unique<StoreLCEntry>(cls_entry.bucket, cls_entry.start_time, cls_entry.status);
+ entry.bucket = std::move(cls_entry.bucket);
+ entry.start_time = cls_entry.start_time;
+ entry.status = cls_entry.status;
return 0;
}
int RadosLifecycle::set_entry(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, LCEntry& entry)
+ const std::string& oid, const LCEntry& entry)
{
cls_rgw_lc_entry cls_entry;
- cls_entry.bucket = entry.get_bucket();
- cls_entry.start_time = entry.get_start_time();
- cls_entry.status = entry.get_status();
+ cls_entry.bucket = entry.bucket;
+ cls_entry.start_time = entry.start_time;
+ cls_entry.status = entry.status;
librados::ObjectWriteOperation op;
cls_rgw_lc_set_entry(op, cls_entry);
int RadosLifecycle::list_entries(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, const std::string& marker,
- uint32_t max_entries, std::vector<std::unique_ptr<LCEntry>>& entries)
+ uint32_t max_entries, std::vector<LCEntry>& entries)
{
entries.clear();
}
for (auto& entry : cls_entries) {
- entries.push_back(std::make_unique<StoreLCEntry>(entry.bucket, oid,
- entry.start_time, entry.status));
+ entries.push_back(LCEntry{entry.bucket, entry.start_time, entry.status});
}
return ret;
}
int RadosLifecycle::rm_entry(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, LCEntry& entry)
+ const std::string& oid, const LCEntry& entry)
{
cls_rgw_lc_entry cls_entry;
- cls_entry.bucket = entry.get_bucket();
- cls_entry.start_time = entry.get_start_time();
- cls_entry.status = entry.get_status();
+ cls_entry.bucket = entry.bucket;
+ cls_entry.start_time = entry.start_time;
+ cls_entry.status = entry.status;
librados::ObjectWriteOperation op;
cls_rgw_lc_rm_entry(op, cls_entry);
}
int RadosLifecycle::get_head(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, std::unique_ptr<LCHead>* head)
+ const std::string& oid, LCHead& head)
{
librados::ObjectReadOperation op;
bufferlist bl;
return ret;
}
- *head = std::make_unique<StoreLCHead>(cls_head.start_date, cls_head.shard_rollover_date, cls_head.marker);
+ head.start_date = cls_head.start_date;
+ head.shard_rollover_date = cls_head.shard_rollover_date;
+ head.marker = std::move(cls_head.marker);
return 0;
}
int RadosLifecycle::put_head(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, LCHead& head)
+ const std::string& oid, const LCHead& head)
{
cls_rgw_lc_obj_head cls_head;
- cls_head.marker = head.get_marker();
- cls_head.start_date = head.get_start_date();
- cls_head.shard_rollover_date = head.get_shard_rollover_date();
+ cls_head.marker = head.marker;
+ cls_head.start_date = head.start_date;
+ cls_head.shard_rollover_date = head.shard_rollover_date;
librados::ObjectWriteOperation op;
cls_rgw_lc_put_head(op, cls_head);
}
};
-class RadosLifecycle : public StoreLifecycle {
+class RadosLifecycle : public Lifecycle {
RadosStore* store;
public:
RadosLifecycle(RadosStore* _st) : store(_st) {}
- using StoreLifecycle::get_entry;
virtual int get_entry(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, const std::string& marker,
- std::unique_ptr<LCEntry>* entry) override;
+ LCEntry& entry) override;
virtual int get_next_entry(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, const std::string& marker,
- std::unique_ptr<LCEntry>* entry) override;
+ LCEntry& entry) override;
virtual int set_entry(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, LCEntry& entry) override;
+ const std::string& oid, const LCEntry& entry) override;
virtual int list_entries(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, const std::string& marker,
uint32_t max_entries,
- std::vector<std::unique_ptr<LCEntry>>& entries) override;
+ std::vector<LCEntry>& entries) override;
virtual int rm_entry(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, LCEntry& entry) override;
+ const std::string& oid, const LCEntry& entry) override;
virtual int get_head(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, std::unique_ptr<LCHead>* head) override;
- virtual int put_head(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, LCHead& head) override;
+ virtual int put_head(const DoutPrefixProvider* dpp, optional_yield y,
+ const std::string& oid, const LCHead& head) override;
virtual std::unique_ptr<LCSerializer> get_serializer(const std::string& lock_name,
const std::string& oid,
const std::string& cookie) override;
if (opt_cmd == OPT::LC_LIST) {
formatter->open_array_section("lifecycle_list");
- vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>> bucket_lc_map;
+ vector<rgw::sal::LCEntry> bucket_lc_map;
string marker;
int index{0};
#define MAX_LC_LIST_ENTRIES 100
}
for (const auto& entry : bucket_lc_map) {
formatter->open_object_section("bucket_lc_info");
- formatter->dump_string("bucket", entry->get_bucket());
- formatter->dump_string("shard", entry->get_oid());
+ formatter->dump_string("bucket", entry.bucket);
char exp_buf[100];
- time_t t{time_t(entry->get_start_time())};
+ time_t t = entry.start_time;
if (std::strftime(
exp_buf, sizeof(exp_buf),
"%a, %d %b %Y %T %Z", std::gmtime(&t))) {
formatter->dump_string("started", exp_buf);
}
- string lc_status = LC_STATUS[entry->get_status()];
- formatter->dump_string("status", lc_status);
+ formatter->dump_string("status", LC_STATUS[entry.status]);
formatter->close_section(); // objs
formatter->flush(cout);
}
delete[] obj_names;
}
-static inline std::ostream& operator<<(std::ostream &os, rgw::sal::Lifecycle::LCEntry& ent) {
+static inline std::ostream& operator<<(std::ostream &os, rgw::sal::LCEntry& ent) {
os << "<ent: bucket=";
- os << ent.get_bucket();
+ os << ent.bucket;
os << "; start_time=";
- os << rgw_to_asctime(utime_t(time_t(ent.get_start_time()), 0));
+ os << rgw_to_asctime(utime_t(ent.start_time, 0));
os << "; status=";
- os << LC_STATUS[ent.get_status()];
+ os << LC_STATUS[ent.status];
os << ">";
return os;
}
};
int RGWLC::bucket_lc_post(int index, int max_lock_sec,
- rgw::sal::Lifecycle::LCEntry& entry, int& result,
+ rgw::sal::LCEntry& entry, int& result,
LCWorker* worker)
{
utime_t lock_duration(cct->_conf->rgw_lc_lock_max_time, 0);
}
goto clean;
} else if (result < 0) {
- entry.set_status(lc_failed);
+ entry.status = lc_failed;
} else {
- entry.set_status(lc_complete);
+ entry.status = lc_complete;
}
ret = sal_lc->set_entry(this, null_yield, obj_names[index], entry);
} /* RGWLC::bucket_lc_post */
int RGWLC::list_lc_progress(string& marker, uint32_t max_entries,
- vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>>& progress_map,
+ vector<rgw::sal::LCEntry>& progress_map,
int& index)
{
progress_map.clear();
for(; index < max_objs; index++, marker="") {
- vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>> entries;
+ vector<rgw::sal::LCEntry> entries;
int ret = sal_lc->list_entries(this, null_yield, obj_names[index],
marker, max_entries, entries);
if (ret < 0) {
/* update index, marker tuple */
if (progress_map.size() > 0)
- marker = progress_map.back()->get_bucket();
+ marker = progress_map.back().bucket;
if (progress_map.size() >= max_entries)
break;
std::unique_ptr<rgw::sal::LCSerializer> serializer =
sal_lc->get_serializer(lc_index_lock_name, obj_names[index],
worker->thr_name());
- std::unique_ptr<rgw::sal::Lifecycle::LCEntry> entry;
if (max_lock_secs <= 0) {
return -EAGAIN;
}
std::unique_lock<rgw::sal::LCSerializer> lock(
*(serializer.get()), std::adopt_lock);
+ rgw::sal::LCEntry entry;
ret = sal_lc->get_entry(this, null_yield, obj_names[index],
- bucket_entry_marker, &entry);
+ bucket_entry_marker, entry);
if (ret >= 0) {
- if (entry->get_status() == lc_processing) {
- if (expired_session(entry->get_start_time())) {
+ if (entry.status == lc_processing) {
+ if (expired_session(entry.start_time)) {
ldpp_dout(this, 5) << "RGWLC::process_bucket(): STALE lc session found for: " << entry
<< " index: " << index << " worker ix: " << worker->ix
<< " (clearing)"
}
/* do nothing if no bucket */
- if ((! entry) || entry->get_bucket().empty()) {
+ if ((ret < 0) || entry.bucket.empty()) {
return ret;
}
<< " index: " << index << " worker ix: " << worker->ix
<< dendl;
- entry->set_status(lc_processing);
- ret = sal_lc->set_entry(this, null_yield, obj_names[index], *entry);
+ entry.status = lc_processing;
+ ret = sal_lc->set_entry(this, null_yield, obj_names[index], entry);
if (ret < 0) {
ldpp_dout(this, 0) << "RGWLC::process_bucket() failed to set obj entry "
- << obj_names[index] << entry->get_bucket() << entry->get_status()
+ << obj_names[index] << entry.bucket << entry.status
<< dendl;
return ret;
}
<< dendl;
lock.unlock();
- ret = bucket_lc_process(entry->get_bucket(), worker, thread_stop_at(), once);
+ ret = bucket_lc_process(entry.bucket, worker, thread_stop_at(), once);
ldpp_dout(this, 5) << "RGWLC::process_bucket(): END entry 2: " << entry
<< " index: " << index << " worker ix: " << worker->ix << " ret: " << ret << dendl;
- bucket_lc_post(index, max_lock_secs, *entry, ret, worker);
+ bucket_lc_post(index, max_lock_secs, entry, ret, worker);
return ret;
} /* RGWLC::process_bucket */
} /* already_run_today */
inline int RGWLC::advance_head(const std::string& lc_shard,
- rgw::sal::Lifecycle::LCHead& head,
- rgw::sal::Lifecycle::LCEntry& entry,
+ rgw::sal::LCHead& head,
+ const rgw::sal::LCEntry& entry,
time_t start_date)
{
int ret{0};
- std::unique_ptr<rgw::sal::Lifecycle::LCEntry> next_entry;
+ rgw::sal::LCEntry next_entry;
ret = sal_lc->get_next_entry(this, null_yield, lc_shard,
- entry.get_bucket(), &next_entry);
+ entry.bucket, next_entry);
if (ret < 0) {
ldpp_dout(this, 0) << "RGWLC::process() failed to get obj entry "
<< lc_shard << dendl;
}
/* save the next position */
- head.set_marker(next_entry->get_bucket());
- head.set_start_date(start_date);
+ head.marker = next_entry.bucket;
+ head.start_date = start_date;
ret = sal_lc->put_head(this, null_yield, lc_shard, head);
if (ret < 0) {
} /* advance head */
inline int RGWLC::check_if_shard_done(const std::string& lc_shard,
- rgw::sal::Lifecycle::LCHead& head, int worker_ix)
+ rgw::sal::LCHead& head, int worker_ix)
{
int ret{0};
- if (head.get_marker().empty()) {
+ if (head.marker.empty()) {
/* done with this shard */
ldpp_dout(this, 5) <<
"RGWLC::process() next_entry not found. cycle finished lc_shard="
<< lc_shard << " worker=" << worker_ix
<< dendl;
- head.set_shard_rollover_date(ceph_clock_now());
+ head.shard_rollover_date = ceph_clock_now();
ret = sal_lc->put_head(this, null_yield, lc_shard, head);
if (ret < 0) {
ldpp_dout(this, 0) << "RGWLC::process() failed to put head "
}
inline int RGWLC::update_head(const std::string& lc_shard,
- rgw::sal::Lifecycle::LCHead& head,
- rgw::sal::Lifecycle::LCEntry& entry,
+ rgw::sal::LCHead& head,
+ rgw::sal::LCEntry& entry,
time_t start_date, int worker_ix)
{
int ret{0};
int ret{0};
const auto& lc_shard = obj_names[index];
- std::unique_ptr<rgw::sal::Lifecycle::LCHead> head;
- std::unique_ptr<rgw::sal::Lifecycle::LCEntry> entry; //string = bucket_name:bucket_id, start_time, int = LC_BUCKET_STATUS
+ rgw::sal::LCHead head;
+ rgw::sal::LCEntry entry; //string = bucket_name:bucket_id, start_time, int = LC_BUCKET_STATUS
ldpp_dout(this, 5) << "RGWLC::process(): ENTER: "
<< "index: " << index << " worker ix: " << worker->ix
utime_t now = ceph_clock_now();
/* preamble: find an inital bucket/marker */
- ret = sal_lc->get_head(this, null_yield, lc_shard, &head);
+ ret = sal_lc->get_head(this, null_yield, lc_shard, head);
if (ret < 0) {
ldpp_dout(this, 0) << "RGWLC::process() failed to get obj head "
<< lc_shard << ", ret=" << ret << dendl;
/* if there is nothing at head, try to reinitialize head.marker with the
* first entry in the queue */
- if (head->get_marker().empty() &&
- allow_shard_rollover(cct, now, head->get_shard_rollover_date()) /* prevent multiple passes by diff.
+ if (head.marker.empty() &&
+ allow_shard_rollover(cct, now, head.shard_rollover_date) /* prevent multiple passes by diff.
* rgws,in same cycle */) {
ldpp_dout(this, 5) << "RGWLC::process() process shard rollover lc_shard=" << lc_shard
- << " head.marker=" << head->get_marker()
- << " head.shard_rollover_date=" << head->get_shard_rollover_date()
+ << " head.marker=" << head.marker
+ << " head.shard_rollover_date=" << head.shard_rollover_date
<< dendl;
- vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>> entries;
+ vector<rgw::sal::LCEntry> entries;
int ret = sal_lc->list_entries(this, null_yield, lc_shard,
- head->get_marker(), 1, entries);
+ head.marker, 1, entries);
if (ret < 0) {
ldpp_dout(this, 0) << "RGWLC::process() sal_lc->list_entries(lc_shard, head.marker, 1, "
<< "entries) returned error ret==" << ret << dendl;
}
if (entries.size() > 0) {
entry = std::move(entries.front());
- head->set_marker(entry->get_bucket());
- head->set_start_date(now);
- head->set_shard_rollover_date(0);
+ head.marker = entry.bucket;
+ head.start_date= now;
+ head.shard_rollover_date = 0;
}
} else {
ldpp_dout(this, 0) << "RGWLC::process() head.marker !empty() at START for shard=="
<< lc_shard << " head last stored at "
- << rgw_to_asctime(utime_t(time_t(head->get_start_date()), 0))
+ << rgw_to_asctime(utime_t(head.start_date, 0))
<< dendl;
/* fetches the entry pointed to by head.bucket */
ret = sal_lc->get_entry(this, null_yield, lc_shard,
- head->get_marker(), &entry);
+ head.marker, entry);
if (ret == -ENOENT) {
/* skip to next entry */
- std::unique_ptr<rgw::sal::Lifecycle::LCEntry> tmp_entry = sal_lc->get_entry();
- tmp_entry->set_bucket(head->get_marker());
+ rgw::sal::LCEntry tmp_entry;
+ tmp_entry.bucket = head.marker;
- if (update_head(lc_shard, *head.get(), *tmp_entry.get(), now, worker->ix) != 0) {
- goto exit;
- }
+ if (update_head(lc_shard, head, tmp_entry, now, worker->ix) != 0) {
+ goto exit;
+ }
continue;
}
if (ret < 0) {
}
}
- if (entry && !entry->get_bucket().empty()) {
- if (entry->get_status() == lc_processing) {
- if (expired_session(entry->get_start_time())) {
+ if (!entry.bucket.empty()) {
+ if (entry.status == lc_processing) {
+ if (expired_session(entry.start_time)) {
ldpp_dout(this, 5)
<< "RGWLC::process(): STALE lc session found for: " << entry
<< " index: " << index << " worker ix: " << worker->ix
<< "RGWLC::process(): ACTIVE entry: " << entry
<< " index: " << index << " worker ix: " << worker->ix << dendl;
/* skip to next entry */
- if (update_head(lc_shard, *head.get(), *entry.get(), now, worker->ix) != 0) {
+ if (update_head(lc_shard, head, entry, now, worker->ix) != 0) {
goto exit;
}
continue;
}
} else {
- if ((entry->get_status() == lc_complete) &&
- already_run_today(cct, entry->get_start_time())) {
+ if ((entry.status == lc_complete) &&
+ already_run_today(cct, entry.start_time)) {
ldpp_dout(this, 5) << "RGWLC::process() worker ix: " << worker->ix
- << " SKIP processing for already-processed bucket " << entry->get_bucket()
+ << " SKIP processing for already-processed bucket " << entry.bucket
<< dendl;
/* skip to next entry */
- if (update_head(lc_shard, *head.get(), *entry.get(), now, worker->ix) != 0) {
+ if (update_head(lc_shard, head, entry, now, worker->ix) != 0) {
goto exit;
}
continue;
<< " index: " << index << " worker ix: " << worker->ix
<< dendl;
- entry->set_status(lc_processing);
- entry->set_start_time(now);
+ entry.status = lc_processing;
+ entry.start_time = now;
- ret = sal_lc->set_entry(this, null_yield, lc_shard, *entry);
+ ret = sal_lc->set_entry(this, null_yield, lc_shard, entry);
if (ret < 0) {
ldpp_dout(this, 0) << "RGWLC::process() failed to set obj entry "
- << lc_shard << entry->get_bucket() << entry->get_status() << dendl;
+ << lc_shard << entry.bucket << entry.status << dendl;
goto exit;
}
/* advance head for next waiter, then process */
- if (advance_head(lc_shard, *head.get(), *entry.get(), now) < 0) {
+ if (advance_head(lc_shard, head, entry, now) < 0) {
goto exit;
}
/* drop lock so other instances can make progress while this
* bucket is being processed */
lock->unlock();
- ret = bucket_lc_process(entry->get_bucket(), worker, thread_stop_at(), once);
+ ret = bucket_lc_process(entry.bucket, worker, thread_stop_at(), once);
ldpp_dout(this, 5) << "RGWLC::process(): END entry 2: " << entry
<< " index: " << index << " worker ix: " << worker->ix << " ret: " << ret << dendl;
/* XXXX are we SURE the only way result could == ENOENT is when
* there is no such bucket? It is currently the value returned
* from bucket_lc_process(...) */
- ret = sal_lc->rm_entry(this, null_yield, lc_shard, *entry);
+ ret = sal_lc->rm_entry(this, null_yield, lc_shard, entry);
if (ret < 0) {
ldpp_dout(this, 0) << "RGWLC::process() failed to remove entry "
<< lc_shard << " (nonfatal)"
}
} else {
if (ret < 0) {
- entry->set_status(lc_failed);
+ entry.status = lc_failed;
} else {
- entry->set_status(lc_complete);
+ entry.status = lc_complete;
}
- ret = sal_lc->set_entry(this, null_yield, lc_shard, *entry);
+ ret = sal_lc->set_entry(this, null_yield, lc_shard, entry);
if (ret < 0) {
ldpp_dout(this, 0) << "RGWLC::process() failed to set entry on lc_shard="
<< lc_shard << " entry=" << entry
}
}
- if (check_if_shard_done(lc_shard, *head.get(), worker->ix) != 0 ) {
+ if (check_if_shard_done(lc_shard, head, worker->ix) != 0 ) {
goto exit;
}
} while(1 && !once && !going_down());
get_lc_oid(cct, bucket_lc_key, &oid);
/* XXX it makes sense to take shard_id for a bucket_id? */
- std::unique_ptr<rgw::sal::Lifecycle::LCEntry> entry = sal_lc->get_entry();
- entry->set_bucket(bucket_lc_key);
- entry->set_status(lc_uninitial);
+ rgw::sal::LCEntry entry;
+ entry.bucket = bucket_lc_key;
+ entry.status = lc_uninitial;
int max_lock_secs = cct->_conf->rgw_lc_lock_max_time;
std::unique_ptr<rgw::sal::LCSerializer> lock =
<< oid << ", ret=" << ret << dendl;
break;
}
- ret = f(sal_lc, oid, *entry.get());
+ ret = f(sal_lc, oid, entry);
if (ret < 0) {
ldpp_dout(dpp, 0) << "RGWLC::RGWPutLC() failed to set entry on "
<< oid << ", ret=" << ret << dendl;
ret = guard_lc_modify(dpp, driver, sal_lc.get(), b, cookie,
[&](rgw::sal::Lifecycle* sal_lc, const string& oid,
- rgw::sal::Lifecycle::LCEntry& entry) {
+ rgw::sal::LCEntry& entry) {
return sal_lc->set_entry(dpp, y, oid, entry);
});
ret = guard_lc_modify(dpp, driver, sal_lc.get(), b, cookie,
[&](rgw::sal::Lifecycle* sal_lc, const string& oid,
- rgw::sal::Lifecycle::LCEntry& entry) {
+ rgw::sal::LCEntry& entry) {
return sal_lc->rm_entry(dpp, y, oid, entry);
});
std::string lc_oid;
get_lc_oid(driver->ctx(), bucket_lc_key, &lc_oid);
- std::unique_ptr<rgw::sal::Lifecycle::LCEntry> entry;
+ rgw::sal::LCEntry entry;
// There are multiple cases we need to encounter here
// 1. entry exists and is already set to marker, happens in plain buckets & newly resharded buckets
// 2. entry doesn't exist, which usually happens when reshard has happened prior to update and next LC process has already dropped the update
// 3. entry exists matching the current bucket id which was after a reshard (needs to be updated to the marker)
// We are not dropping the old marker here as that would be caught by the next LC process update
- int ret = sal_lc->get_entry(dpp, null_yield, lc_oid, bucket_lc_key, &entry);
+ int ret = sal_lc->get_entry(dpp, null_yield, lc_oid, bucket_lc_key, entry);
if (ret == 0) {
ldpp_dout(dpp, 5) << "Entry already exists, nothing to do" << dendl;
return ret; // entry is already existing correctly set to marker
driver, sal_lc, bucket->get_key(), cookie,
[dpp, &lc_oid](rgw::sal::Lifecycle* slc,
const string& oid,
- rgw::sal::Lifecycle::LCEntry& entry) {
+ rgw::sal::LCEntry& entry) {
return slc->set_entry(dpp, null_yield, lc_oid, entry);
});
const std::unique_ptr<rgw::sal::Bucket>& optional_bucket,
bool once);
int advance_head(const std::string& lc_shard,
- rgw::sal::Lifecycle::LCHead& head,
- rgw::sal::Lifecycle::LCEntry& entry,
+ rgw::sal::LCHead& head,
+ const rgw::sal::LCEntry& entry,
time_t start_date);
int check_if_shard_done(const std::string& lc_shard,
- rgw::sal::Lifecycle::LCHead& head,
+ rgw::sal::LCHead& head,
int worker_ix);
int update_head(const std::string& lc_shard,
- rgw::sal::Lifecycle::LCHead& head,
- rgw::sal::Lifecycle::LCEntry& entry,
+ rgw::sal::LCHead& head,
+ rgw::sal::LCEntry& entry,
time_t start_date, int worker_ix);
int process(int index, int max_lock_secs, LCWorker* worker, bool once);
int process_bucket(int index, int max_lock_secs, LCWorker* worker,
bool expired_session(time_t started);
time_t thread_stop_at();
int list_lc_progress(std::string& marker, uint32_t max_entries,
- std::vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>>&,
+ std::vector<rgw::sal::LCEntry>&,
int& index);
int bucket_lc_process(std::string& shard_id, LCWorker* worker, time_t stop_at,
bool once);
int bucket_lc_post(int index, int max_lock_sec,
- rgw::sal::Lifecycle::LCEntry& entry, int& result, LCWorker* worker);
+ rgw::sal::LCEntry& entry, int& result, LCWorker* worker);
bool going_down();
void start_processor();
void stop_processor();
virtual ~LCSerializer() = default;
};
+/** Head of a lifecycle run. Used for tracking parallel lifecycle runs. */
+struct LCHead {
+ time_t start_date = 0;
+ std::string marker;
+ time_t shard_rollover_date = 0;
+};
+
+/** Single entry in a lifecycle run. Multiple entries can exist processing different
+ * buckets. */
+struct LCEntry {
+ std::string bucket;
+ uint64_t start_time = 0;
+ uint32_t status = 0;
+};
+
/**
* @brief Abstraction for lifecycle processing
*
*/
class Lifecycle {
public:
- /** Head of a lifecycle run. Used for tracking parallel lifecycle runs. */
- struct LCHead {
- LCHead() = default;
- virtual ~LCHead() = default;
-
- virtual time_t& get_start_date() = 0;
- virtual void set_start_date(time_t) = 0;
- virtual std::string& get_marker() = 0;
- virtual void set_marker(const std::string&) = 0;
- virtual time_t& get_shard_rollover_date() = 0;
- virtual void set_shard_rollover_date(time_t) = 0;
- };
-
- /** Single entry in a lifecycle run. Multiple entries can exist processing different
- * buckets. */
- struct LCEntry {
- LCEntry() = default;
- virtual ~LCEntry() = default;
-
- virtual std::string& get_bucket() = 0;
- virtual void set_bucket(const std::string&) = 0;
- virtual std::string& get_oid() = 0;
- virtual void set_oid(const std::string&) = 0;
- virtual uint64_t get_start_time() = 0;
- virtual void set_start_time(uint64_t) = 0;
- virtual uint32_t get_status() = 0;
- virtual void set_status(uint32_t) = 0;
-
- /** Print the entry to @a out */
- virtual void print(std::ostream& out) const = 0;
-
- friend inline std::ostream& operator<<(std::ostream& out, const LCEntry& e) {
- e.print(out);
- return out;
- }
- friend inline std::ostream& operator<<(std::ostream& out, const LCEntry* e) {
- if (!e)
- out << "<NULL>";
- else
- e->print(out);
- return out;
- }
- friend inline std::ostream& operator<<(std::ostream& out, const std::unique_ptr<LCEntry>& p) {
- out << p.get();
- return out;
- }
- };
-
Lifecycle() = default;
virtual ~Lifecycle() = default;
- /** Get an empty entry */
- virtual std::unique_ptr<LCEntry> get_entry() = 0;
/** Get an entry matching the given marker */
virtual int get_entry(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, const std::string& marker,
- std::unique_ptr<LCEntry>* entry) = 0;
+ LCEntry& entry) = 0;
/** Get the entry following the given marker */
virtual int get_next_entry(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, const std::string& marker,
- std::unique_ptr<LCEntry>* entry) = 0;
+ LCEntry& entry) = 0;
/** Store a modified entry in then backing store */
virtual int set_entry(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, LCEntry& entry) = 0;
+ const std::string& oid, const LCEntry& entry) = 0;
/** List all known entries */
virtual int list_entries(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, const std::string& marker,
uint32_t max_entries,
- std::vector<std::unique_ptr<LCEntry>>& entries) = 0;
+ std::vector<LCEntry>& entries) = 0;
/** Remove an entry from the backing store */
virtual int rm_entry(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, LCEntry& entry) = 0;
+ const std::string& oid, const LCEntry& entry) = 0;
/** Get a head */
virtual int get_head(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, std::unique_ptr<LCHead>* head) = 0;
+ const std::string& oid, LCHead& head) = 0;
/** Store a modified head to the backing store */
virtual int put_head(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, LCHead& head) = 0;
+ const std::string& oid, const LCHead& head) = 0;
/** Get a serializer for lifecycle */
virtual std::unique_ptr<LCSerializer> get_serializer(const std::string& lock_name,
int DBLifecycle::get_entry(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, const std::string& marker,
- std::unique_ptr<LCEntry>* entry)
+ LCEntry& entry)
{
return store->getDB()->get_entry(oid, marker, entry);
}
int DBLifecycle::get_next_entry(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, const std::string& marker,
- std::unique_ptr<LCEntry>* entry)
+ LCEntry& entry)
{
return store->getDB()->get_next_entry(oid, marker, entry);
}
int DBLifecycle::set_entry(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, LCEntry& entry)
+ const std::string& oid, const LCEntry& entry)
{
return store->getDB()->set_entry(oid, entry);
}
int DBLifecycle::list_entries(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, const std::string& marker,
- uint32_t max_entries, vector<std::unique_ptr<LCEntry>>& entries)
+ uint32_t max_entries, vector<LCEntry>& entries)
{
return store->getDB()->list_entries(oid, marker, max_entries, entries);
}
int DBLifecycle::rm_entry(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, LCEntry& entry)
+ const std::string& oid, const LCEntry& entry)
{
return store->getDB()->rm_entry(oid, entry);
}
int DBLifecycle::get_head(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, std::unique_ptr<LCHead>* head)
+ const std::string& oid, LCHead& head)
{
return store->getDB()->get_head(oid, head);
}
int DBLifecycle::put_head(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, LCHead& head)
+ const std::string& oid, const LCHead& head)
{
return store->getDB()->put_head(oid, head);
}
}
};
-class DBLifecycle : public StoreLifecycle {
+class DBLifecycle : public Lifecycle {
DBStore* store;
public:
DBLifecycle(DBStore* _st) : store(_st) {}
- using StoreLifecycle::get_entry;
virtual int get_entry(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, const std::string& marker,
- std::unique_ptr<LCEntry>* entry) override;
+ LCEntry& entry) override;
virtual int get_next_entry(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, const std::string& marker,
- std::unique_ptr<LCEntry>* entry) override;
+ LCEntry& entry) override;
virtual int set_entry(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, LCEntry& entry) override;
+ const std::string& oid, const LCEntry& entry) override;
virtual int list_entries(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, const std::string& marker,
uint32_t max_entries,
- std::vector<std::unique_ptr<LCEntry>>& entries) override;
+ std::vector<LCEntry>& entries) override;
virtual int rm_entry(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, LCEntry& entry) override;
+ const std::string& oid, const LCEntry& entry) override;
virtual int get_head(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, std::unique_ptr<LCHead>* head) override;
- virtual int put_head(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, LCHead& head) override;
+ virtual int put_head(const DoutPrefixProvider* dpp, optional_yield y,
+ const std::string& oid, const LCHead& head) override;
virtual std::unique_ptr<LCSerializer> get_serializer(const std::string& lock_name,
const std::string& oid,
const std::string& cookie) override;
return next->try_lock(dpp, dur, y);
}
-std::unique_ptr<Lifecycle::LCEntry> FilterLifecycle::get_entry()
-{
- std::unique_ptr<Lifecycle::LCEntry> e = next->get_entry();
- return std::make_unique<FilterLCEntry>(std::move(e));
-}
-
int FilterLifecycle::get_entry(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, const std::string& marker,
- std::unique_ptr<LCEntry>* entry)
+ LCEntry& entry)
{
- std::unique_ptr<LCEntry> ne;
- int ret = next->get_entry(dpp, y, oid, marker, &ne);
- if (ret < 0)
- return ret;
-
- *entry = std::make_unique<FilterLCEntry>(std::move(ne));
- return 0;
+ return next->get_entry(dpp, y, oid, marker, entry);
}
int FilterLifecycle::get_next_entry(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, const std::string& marker,
- std::unique_ptr<LCEntry>* entry)
+ LCEntry& entry)
{
- std::unique_ptr<LCEntry> ne;
- int ret = next->get_next_entry(dpp, y, oid, marker, &ne);
- if (ret < 0)
- return ret;
-
- *entry = std::make_unique<FilterLCEntry>(std::move(ne));
- return 0;
+ return next->get_next_entry(dpp, y, oid, marker, entry);
}
int FilterLifecycle::set_entry(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, LCEntry& entry)
+ const std::string& oid, const LCEntry& entry)
{
return next->set_entry(dpp, y, oid, entry);
}
int FilterLifecycle::list_entries(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, const std::string& marker,
uint32_t max_entries,
- std::vector<std::unique_ptr<LCEntry>>& entries)
+ std::vector<LCEntry>& entries)
{
- std::vector<std::unique_ptr<LCEntry>> ne;
- int ret = next->list_entries(dpp, y, oid, marker, max_entries, ne);
- if (ret < 0)
- return ret;
-
- for (auto& ent : ne) {
- entries.emplace_back(std::make_unique<FilterLCEntry>(std::move(ent)));
- }
-
- return 0;
+ return next->list_entries(dpp, y, oid, marker, max_entries, entries);
}
int FilterLifecycle::rm_entry(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, LCEntry& entry)
+ const std::string& oid, const LCEntry& entry)
{
return next->rm_entry(dpp, y, oid, entry);
}
int FilterLifecycle::get_head(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, std::unique_ptr<LCHead>* head)
+ const std::string& oid, LCHead& head)
{
- std::unique_ptr<LCHead> nh;
- int ret = next->get_head(dpp, y, oid, &nh);
- if (ret < 0)
- return ret;
-
- *head = std::make_unique<FilterLCHead>(std::move(nh));
- return 0;
+ return next->get_head(dpp, y, oid, head);
}
int FilterLifecycle::put_head(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, LCHead& head)
+ const std::string& oid, const LCHead& head)
{
- return next->put_head(dpp, y, oid, *(dynamic_cast<FilterLCHead&>(head).next.get()));
+ return next->put_head(dpp, y, oid, head);
}
std::unique_ptr<LCSerializer> FilterLifecycle::get_serializer(
std::unique_ptr<Lifecycle> next;
public:
- struct FilterLCHead : LCHead {
- std::unique_ptr<LCHead> next;
-
- FilterLCHead(std::unique_ptr<LCHead> _next) : next(std::move(_next)) {}
- virtual ~FilterLCHead() = default;
-
- virtual time_t& get_start_date() override { return next->get_start_date(); }
- virtual void set_start_date(time_t t) override { next->set_start_date(t); }
- virtual std::string& get_marker() override { return next->get_marker(); }
- virtual void set_marker(const std::string& m) override { next->set_marker(m); }
- virtual time_t& get_shard_rollover_date() override { return next->get_shard_rollover_date(); }
- virtual void set_shard_rollover_date(time_t t) override { next->set_shard_rollover_date(t); }
- };
-
- struct FilterLCEntry : LCEntry {
- std::unique_ptr<LCEntry> next;
-
- FilterLCEntry(std::unique_ptr<LCEntry> _next) : next(std::move(_next)) {}
- virtual ~FilterLCEntry() = default;
-
- virtual std::string& get_bucket() override { return next->get_bucket(); }
- virtual void set_bucket(const std::string& b) override { next->set_bucket(b); }
- virtual std::string& get_oid() override { return next->get_oid(); }
- virtual void set_oid(const std::string& o) override { next->set_oid(o); }
- virtual uint64_t get_start_time() override { return next->get_start_time(); }
- virtual void set_start_time(uint64_t t) override { next->set_start_time(t); }
- virtual uint32_t get_status() override { return next->get_status(); }
- virtual void set_status(uint32_t s) override { next->set_status(s); }
- virtual void print(std::ostream& out) const override { return next->print(out); }
- };
FilterLifecycle(std::unique_ptr<Lifecycle> _next) : next(std::move(_next)) {}
virtual ~FilterLifecycle() = default;
- virtual std::unique_ptr<LCEntry> get_entry() override;
virtual int get_entry(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, const std::string& marker,
- std::unique_ptr<LCEntry>* entry) override;
+ LCEntry& entry) override;
virtual int get_next_entry(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, const std::string& marker,
- std::unique_ptr<LCEntry>* entry) override;
+ LCEntry& entry) override;
virtual int set_entry(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, LCEntry& entry) override;
+ const std::string& oid, const LCEntry& entry) override;
virtual int list_entries(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, const std::string& marker,
uint32_t max_entries,
- std::vector<std::unique_ptr<LCEntry>>& entries) override;
+ std::vector<LCEntry>& entries) override;
virtual int rm_entry(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, LCEntry& entry) override;
+ const std::string& oid, const LCEntry& entry) override;
virtual int get_head(const DoutPrefixProvider* dpp, optional_yield y,
- const std::string& oid, std::unique_ptr<LCHead>* head) override;
- virtual int put_head(const DoutPrefixProvider* dpp, optional_yield y,
const std::string& oid, LCHead& head) override;
+ virtual int put_head(const DoutPrefixProvider* dpp, optional_yield y,
+ const std::string& oid, const LCHead& head) override;
virtual std::unique_ptr<LCSerializer> get_serializer(const std::string& lock_name,
const std::string& oid,
const std::string& cookie) override;
virtual void print(std::ostream& out) const override { out << oid; }
};
-class StoreLifecycle : public Lifecycle {
-public:
- struct StoreLCHead : LCHead {
- time_t start_date{0};
- time_t shard_rollover_date{0};
- std::string marker;
-
- StoreLCHead() = default;
- StoreLCHead(time_t _start_date, time_t _rollover_date, std::string& _marker) : start_date(_start_date), shard_rollover_date(_rollover_date), marker(_marker) {}
-
- StoreLCHead& operator=(LCHead& _h) {
- start_date = _h.get_start_date();
- shard_rollover_date = _h.get_shard_rollover_date();
- marker = _h.get_marker();
-
- return *this;
- }
-
- virtual time_t& get_start_date() override { return start_date; }
- virtual void set_start_date(time_t _date) override { start_date = _date; }
- virtual std::string& get_marker() override { return marker; }
- virtual void set_marker(const std::string& _marker) override { marker = _marker; }
- virtual time_t& get_shard_rollover_date() override { return shard_rollover_date; }
- virtual void set_shard_rollover_date(time_t _date) override { shard_rollover_date = _date; }
- };
-
- struct StoreLCEntry : LCEntry {
- std::string bucket;
- std::string oid;
- uint64_t start_time{0};
- uint32_t status{0};
-
- StoreLCEntry() = default;
- StoreLCEntry(std::string& _bucket, uint64_t _time, uint32_t _status) : bucket(_bucket), start_time(_time), status(_status) {}
- StoreLCEntry(std::string& _bucket, std::string _oid, uint64_t _time, uint32_t _status) : bucket(_bucket), oid(_oid), start_time(_time), status(_status) {}
- StoreLCEntry(const StoreLCEntry& _e) = default;
-
- StoreLCEntry& operator=(LCEntry& _e) {
- bucket = _e.get_bucket();
- oid = _e.get_oid();
- start_time = _e.get_start_time();
- status = _e.get_status();
-
- return *this;
- }
-
- virtual std::string& get_bucket() override { return bucket; }
- virtual void set_bucket(const std::string& _bucket) override { bucket = _bucket; }
- virtual std::string& get_oid() override { return oid; }
- virtual void set_oid(const std::string& _oid) override { oid = _oid; }
- virtual uint64_t get_start_time() override { return start_time; }
- virtual void set_start_time(uint64_t _time) override { start_time = _time; }
- virtual uint32_t get_status() override { return status; }
- virtual void set_status(uint32_t _status) override { status = _status; }
- virtual void print(std::ostream& out) const override {
- out << bucket << ":" << oid << ":" << start_time << ":" << status;
- }
- };
-
- StoreLifecycle() = default;
- virtual ~StoreLifecycle() = default;
-
- virtual std::unique_ptr<LCEntry> get_entry() override {
- return std::make_unique<StoreLCEntry>();
- }
- using Lifecycle::get_entry;
-};
-
class StoreNotification : public Notification {
protected:
Object* obj;