return r;
}
-int cls_rgw_lc_get_next_entry(IoCtx& io_ctx, const string& oid, string& marker,
+int cls_rgw_lc_get_next_entry(IoCtx& io_ctx, const string& oid, const string& marker,
cls_rgw_lc_entry& entry)
{
bufferlist in, out;
#ifndef CLS_CLIENT_HIDE_IOCTX
int cls_rgw_lc_get_head(librados::IoCtx& io_ctx, const std::string& oid, cls_rgw_lc_obj_head& head);
int cls_rgw_lc_put_head(librados::IoCtx& io_ctx, const std::string& oid, cls_rgw_lc_obj_head& head);
-int cls_rgw_lc_get_next_entry(librados::IoCtx& io_ctx, const std::string& oid, std::string& marker, cls_rgw_lc_entry& entry);
+int cls_rgw_lc_get_next_entry(librados::IoCtx& io_ctx, const std::string& oid, const std::string& marker, cls_rgw_lc_entry& entry);
int cls_rgw_lc_rm_entry(librados::IoCtx& io_ctx, const std::string& oid, const cls_rgw_lc_entry& entry);
int cls_rgw_lc_set_entry(librados::IoCtx& io_ctx, const std::string& oid, const cls_rgw_lc_entry& entry);
int cls_rgw_lc_get_entry(librados::IoCtx& io_ctx, const std::string& oid, const std::string& marker, cls_rgw_lc_entry& entry);
if (opt_cmd == OPT::LC_LIST) {
formatter->open_array_section("lifecycle_list");
- vector<rgw::sal::Lifecycle::LCEntry> bucket_lc_map;
+ vector<std::unique_ptr<rgw::sal::Lifecycle::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.bucket);
- formatter->dump_string("shard", entry.oid);
+ formatter->dump_string("bucket", entry->get_bucket());
+ formatter->dump_string("shard", entry->get_oid());
char exp_buf[100];
- time_t t{time_t(entry.start_time)};
+ time_t t{time_t(entry->get_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.status];
+ string lc_status = LC_STATUS[entry->get_status()];
formatter->dump_string("status", lc_status);
formatter->close_section(); // objs
formatter->flush(cout);
static inline std::ostream& operator<<(std::ostream &os, rgw::sal::Lifecycle::LCEntry& ent) {
os << "<ent: bucket=";
- os << ent.bucket;
+ os << ent.get_bucket();
os << "; start_time=";
- os << rgw_to_asctime(utime_t(time_t(ent.start_time), 0));
+ os << rgw_to_asctime(utime_t(time_t(ent.get_start_time()), 0));
os << "; status=";
- os << LC_STATUS[ent.status];
+ os << LC_STATUS[ent.get_status()];
os << ">";
return os;
}
}
goto clean;
} else if (result < 0) {
- entry.status = lc_failed;
+ entry.set_status(lc_failed);
} else {
- entry.status = lc_complete;
+ entry.set_status(lc_complete);
}
ret = sal_lc->set_entry(obj_names[index], entry);
} /* RGWLC::bucket_lc_post */
int RGWLC::list_lc_progress(string& marker, uint32_t max_entries,
- vector<rgw::sal::Lifecycle::LCEntry>& progress_map,
+ vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>>& progress_map,
int& index)
{
progress_map.clear();
for(; index < max_objs; index++, marker="") {
- vector<rgw::sal::Lifecycle::LCEntry> entries;
+ vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>> entries;
int ret = sal_lc->list_entries(obj_names[index], marker, max_entries, entries);
if (ret < 0) {
if (ret == -ENOENT) {
}
}
progress_map.reserve(progress_map.size() + entries.size());
- progress_map.insert(progress_map.end(), entries.begin(), entries.end());
+ std::move(begin(entries), end(entries), std::back_inserter(progress_map));
+ //progress_map.insert(progress_map.end(), entries.begin(), entries.end());
/* update index, marker tuple */
if (progress_map.size() > 0)
- marker = progress_map.back().bucket;
+ marker = progress_map.back()->get_bucket();
if (progress_map.size() >= max_entries)
break;
sal_lc->get_serializer(lc_index_lock_name, obj_names[index],
std::string()));
- rgw::sal::Lifecycle::LCEntry entry;
+ 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);
- ret = sal_lc->get_entry(obj_names[index], bucket_entry_marker, entry);
+ ret = sal_lc->get_entry(obj_names[index], bucket_entry_marker, &entry);
if (ret >= 0) {
- if (entry.status == lc_processing) {
- if (expired_session(entry.start_time)) {
+ if (entry->get_status() == lc_processing) {
+ if (expired_session(entry->get_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.bucket.empty()) {
+ if (entry->get_bucket().empty()) {
return ret;
}
<< " index: " << index << " worker ix: " << worker->ix
<< dendl;
- entry.status = lc_processing;
- ret = sal_lc->set_entry(obj_names[index], entry);
+ entry->set_status(lc_processing);
+ ret = sal_lc->set_entry(obj_names[index], *entry);
if (ret < 0) {
ldpp_dout(this, 0) << "RGWLC::process_bucket() failed to set obj entry "
- << obj_names[index] << entry.bucket << entry.status
+ << obj_names[index] << entry->get_bucket() << entry->get_status()
<< dendl;
return ret;
}
<< dendl;
lock.unlock();
- ret = bucket_lc_process(entry.bucket, worker, thread_stop_at(), once);
- bucket_lc_post(index, max_lock_secs, entry, ret, worker);
+ ret = bucket_lc_process(entry->get_bucket(), worker, thread_stop_at(), once);
+ bucket_lc_post(index, max_lock_secs, *entry, ret, worker);
return ret;
} /* RGWLC::process_bucket */
time_t start_date)
{
int ret{0};
- rgw::sal::Lifecycle::LCEntry next_entry;
+ std::unique_ptr<rgw::sal::Lifecycle::LCEntry> next_entry;
- ret = sal_lc->get_next_entry(lc_shard, entry.bucket, next_entry);
+ ret = sal_lc->get_next_entry(lc_shard, entry.get_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.marker = next_entry.bucket;
- head.start_date = start_date;
+ head.set_marker(next_entry->get_bucket());
+ head.set_start_date(start_date);
ret = sal_lc->put_head(lc_shard, head);
if (ret < 0) {
int ret{0};
const auto& lc_shard = obj_names[index];
- rgw::sal::Lifecycle::LCHead head{};
- rgw::sal::Lifecycle::LCEntry entry; //string = bucket_name:bucket_id, start_time, int = LC_BUCKET_STATUS
+ 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
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(lc_shard, head);
+ ret = sal_lc->get_head(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.marker.empty() &&
- allow_shard_rollover(cct, now, head.shard_rollover_date) /* prevent multiple passes by diff.
+ if (head->get_marker().empty() &&
+ allow_shard_rollover(cct, now, head->get_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.marker
- << " head.shard_rollover_date=" << head.shard_rollover_date
+ << " head.marker=" << head->get_marker()
+ << " head.shard_rollover_date=" << head->get_shard_rollover_date()
<< dendl;
- vector<rgw::sal::Lifecycle::LCEntry> entries;
- int ret = sal_lc->list_entries(lc_shard, head.marker, 1, entries);
+ vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>> entries;
+ int ret = sal_lc->list_entries(lc_shard, head->get_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;
goto exit;
}
if (entries.size() > 0) {
- entry = entries.front();
- head.marker = entry.bucket;
- head.start_date = now;
- head.shard_rollover_date = 0;
+ entry = std::move(entries.front());
+ head->set_marker(entry->get_bucket());
+ head->set_start_date(now);
+ head->set_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.start_date), 0))
+ << rgw_to_asctime(utime_t(time_t(head->get_start_date()), 0))
<< dendl;
/* fetches the entry pointed to by head.bucket */
- ret = sal_lc->get_entry(lc_shard, head.marker, entry);
+ ret = sal_lc->get_entry(lc_shard, head->get_marker(), &entry);
if (ret < 0) {
ldpp_dout(this, 0) << "RGWLC::process() sal_lc->get_entry(lc_shard, head.marker, entry) "
<< "returned error ret==" << ret << dendl;
}
}
- if (! entry.bucket.empty()) {
- if (entry.status == lc_processing) {
- if (expired_session(entry.start_time)) {
+ if (entry && !entry->get_bucket().empty()) {
+ if (entry->get_status() == lc_processing) {
+ if (expired_session(entry->get_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 (advance_head(lc_shard, head, entry, now) < 0) {
+ if (advance_head(lc_shard, *head.get(), *entry.get(), now) < 0) {
goto exit;
}
/* done with this shard */
- if (head.marker.empty()) {
+ if (head->get_marker().empty()) {
ldpp_dout(this, 5) <<
"RGWLC::process() cycle finished lc_shard="
<< lc_shard
<< dendl;
- head.shard_rollover_date = ceph_clock_now();
- ret = sal_lc->put_head(lc_shard, head);
+ head->set_shard_rollover_date(ceph_clock_now());
+ ret = sal_lc->put_head(lc_shard, *head.get());
if (ret < 0) {
ldpp_dout(this, 0) << "RGWLC::process() failed to put head "
<< lc_shard
continue;
}
} else {
- if ((entry.status == lc_complete) &&
- already_run_today(cct, entry.start_time)) {
+ if ((entry->get_status() == lc_complete) &&
+ already_run_today(cct, entry->get_start_time())) {
/* skip to next entry */
- if (advance_head(lc_shard, head, entry, now) < 0) {
+ if (advance_head(lc_shard, *head.get(), *entry.get(), now) < 0) {
goto exit;
}
ldpp_dout(this, 5) << "RGWLC::process() worker ix; " << worker->ix
- << " SKIP processing for already-processed bucket " << entry.bucket
+ << " SKIP processing for already-processed bucket " << entry->get_bucket()
<< dendl;
/* done with this shard */
- if (head.marker.empty()) {
+ if (head->get_marker().empty()) {
ldpp_dout(this, 5) <<
"RGWLC::process() cycle finished lc_shard="
<< lc_shard
<< dendl;
- head.shard_rollover_date = ceph_clock_now();
- ret = sal_lc->put_head(lc_shard, head);
+ head->set_shard_rollover_date(ceph_clock_now());
+ ret = sal_lc->put_head(lc_shard, *head.get());
if (ret < 0) {
ldpp_dout(this, 0) << "RGWLC::process() failed to put head "
<< lc_shard
<< " index: " << index << " worker ix: " << worker->ix
<< dendl;
- entry.status = lc_processing;
- entry.start_time = now;
+ entry->set_status(lc_processing);
+ entry->set_start_time(now);
- ret = sal_lc->set_entry(lc_shard, entry);
+ ret = sal_lc->set_entry(lc_shard, *entry);
if (ret < 0) {
ldpp_dout(this, 0) << "RGWLC::process() failed to set obj entry "
- << lc_shard << entry.bucket << entry.status << dendl;
+ << lc_shard << entry->get_bucket() << entry->get_status() << dendl;
goto exit;
}
/* advance head for next waiter, then process */
- if (advance_head(lc_shard, head, entry, now) < 0) {
+ if (advance_head(lc_shard, *head.get(), *entry.get(), 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.bucket, worker, thread_stop_at(), once);
+ ret = bucket_lc_process(entry->get_bucket(), worker, thread_stop_at(), once);
/* postamble */
//bucket_lc_post(index, max_lock_secs, entry, ret, worker);
/* 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(lc_shard, entry);
+ ret = sal_lc->rm_entry(lc_shard, *entry);
if (ret < 0) {
ldpp_dout(this, 0) << "RGWLC::process() failed to remove entry "
<< lc_shard << " (nonfatal)"
/* not fatal, could result from a race */
}
} else if (ret < 0) {
- entry.status = lc_failed;
+ entry->set_status(lc_failed);
} else {
- entry.status = lc_complete;
+ entry->set_status(lc_complete);
}
- ret = sal_lc->set_entry(lc_shard, entry);
+ ret = sal_lc->set_entry(lc_shard, *entry);
if (ret < 0) {
ldpp_dout(this, 0) << "RGWLC::process() failed to set entry on "
<< lc_shard << dendl;
}
/* done with this shard */
- if (head.marker.empty()) {
+ if (head->get_marker().empty()) {
ldpp_dout(this, 5) <<
"RGWLC::process() cycle finished lc_shard="
<< lc_shard
<< dendl;
- head.shard_rollover_date = ceph_clock_now();
- ret = sal_lc->put_head(lc_shard, head);
+ head->set_shard_rollover_date(ceph_clock_now());
+ ret = sal_lc->put_head(lc_shard, *head.get());
if (ret < 0) {
ldpp_dout(this, 0) << "RGWLC::process() failed to put head "
<< lc_shard
get_lc_oid(cct, bucket_lc_key, &oid);
/* XXX it makes sense to take shard_id for a bucket_id? */
- rgw::sal::Lifecycle::LCEntry entry;
- entry.bucket = bucket_lc_key;
- entry.status = lc_uninitial;
+ std::unique_ptr<rgw::sal::Lifecycle::LCEntry> entry = sal_lc->get_entry();
+ entry->set_bucket(bucket_lc_key);
+ entry->set_status(lc_uninitial);
int max_lock_secs = cct->_conf->rgw_lc_lock_max_time;
rgw::sal::LCSerializer* lock = sal_lc->get_serializer(lc_index_lock_name,
<< oid << ", ret=" << ret << dendl;
break;
}
- ret = f(sal_lc, oid, entry);
+ ret = f(sal_lc, oid, *entry.get());
if (ret < 0) {
ldpp_dout(dpp, 0) << "RGWLC::RGWPutLC() failed to set entry on "
<< oid << ", ret=" << ret << dendl;
ret = guard_lc_modify(this, store, sal_lc.get(), b, cookie,
[&](rgw::sal::Lifecycle* sal_lc, const string& oid,
- const rgw::sal::Lifecycle::LCEntry& entry) {
+ rgw::sal::Lifecycle::LCEntry& entry) {
return sal_lc->set_entry(oid, entry);
});
ret = guard_lc_modify(this, store, sal_lc.get(), b, cookie,
[&](rgw::sal::Lifecycle* sal_lc, const string& oid,
- const rgw::sal::Lifecycle::LCEntry& entry) {
+ rgw::sal::Lifecycle::LCEntry& entry) {
return sal_lc->rm_entry(oid, entry);
});
std::string lc_oid;
get_lc_oid(store->ctx(), bucket_lc_key, &lc_oid);
- rgw::sal::Lifecycle::LCEntry entry;
+ std::unique_ptr<rgw::sal::Lifecycle::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(lc_oid, bucket_lc_key, entry);
+ int ret = sal_lc->get_entry(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
store, sal_lc, bucket->get_key(), cookie,
[&lc_oid](rgw::sal::Lifecycle* slc,
const string& oid,
- const rgw::sal::Lifecycle::LCEntry& entry) {
+ rgw::sal::Lifecycle::LCEntry& entry) {
return slc->set_entry(lc_oid, entry);
});
bool expired_session(time_t started);
time_t thread_stop_at();
int list_lc_progress(std::string& marker, uint32_t max_entries,
- std::vector<rgw::sal::Lifecycle::LCEntry>&, int& index);
+ std::vector<std::unique_ptr<rgw::sal::Lifecycle::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,
void RGWCompleteMultipart::complete()
{
/* release exclusive lock iff not already */
- if (unlikely(serializer && serializer->locked)) {
+ if (unlikely(serializer && serializer->is_locked())) {
int r = serializer->unlock();
if (r < 0) {
- ldpp_dout(this, 0) << "WARNING: failed to unlock " << serializer->oid << dendl;
+ ldpp_dout(this, 0) << "WARNING: failed to unlock " << serializer << dendl;
}
}
send_response();
}
int RGWRados::list_lc_progress(string& marker, uint32_t max_entries,
- vector<rgw::sal::Lifecycle::LCEntry>& progress_map,
+ vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>>& progress_map,
int& index)
{
return lc->list_lc_progress(marker, max_entries, progress_map, index);
int process_lc(const std::unique_ptr<rgw::sal::Bucket>& optional_bucket);
int list_lc_progress(std::string& marker, uint32_t max_entries,
- std::vector<rgw::sal::Lifecycle::LCEntry>& progress_map, int& index);
+ std::vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>>& progress_map,
+ int& index);
int bucket_check_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info,
std::map<RGWObjCategory, RGWStorageStats> *existing_stats,
#include "rgw_datalog_notify.h"
#include "include/random.h"
-class RGWGetDataCB;
class RGWAccessListFilter;
class RGWLC;
class RGWObjManifest;
using Attrs = std::map<std::string, ceph::buffer::list>;
/**
- * @brief Base singleton representing a Store or stacking layer
+ * @brief Base singleton representing a Store or Filter
*
* The Store is the base abstraction of the SAL layer. It represents a base storage
* mechanism, or a intermediate stacking layer. There is a single instance of a given
/** Enable or disable a set of bucket. e.g. if a User is suspended */
virtual int set_buckets_enabled(const DoutPrefixProvider* dpp, std::vector<rgw_bucket>& buckets, bool enabled) = 0;
/** Get a new request ID */
- virtual uint64_t get_new_req_id() {
- return ceph::util::generate_random_number<uint64_t>();
- }
+ virtual uint64_t get_new_req_id() = 0;
/** Get a handler for bucket sync policy. */
virtual int get_sync_policy_handler(const DoutPrefixProvider* dpp,
std::optional<rgw_zone_id> zone,
* attributes, and statistics (including usage) about the User.
*/
class User {
- protected:
- RGWUserInfo info;
- RGWObjVersionTracker objv_tracker;
- Attrs attrs;
-
public:
- User() : info() {}
- User(const rgw_user& _u) : info() { info.user_id = _u; }
- User(const RGWUserInfo& _i) : info(_i) {}
- User(User& _o) = default;
+ User() {}
virtual ~User() = default;
/** Clone a copy of this user. Used when modification is necessary of the copy */
optional_yield y) = 0;
/** Get the display name for this User */
- virtual std::string& get_display_name() { return info.display_name; }
+ virtual std::string& get_display_name() = 0;
/** Get the tenant name for this User */
- const std::string& get_tenant() { return info.user_id.tenant; }
+ virtual const std::string& get_tenant() = 0;
/** Set the tenant name for this User */
- void set_tenant(std::string& _t) { info.user_id.tenant = _t; }
+ virtual void set_tenant(std::string& _t) = 0;
/** Get the namespace for this User */
- const std::string& get_ns() { return info.user_id.ns; }
+ virtual const std::string& get_ns() = 0;
/** Set the namespace for this User */
- void set_ns(std::string& _ns) { info.user_id.ns = _ns; }
+ virtual void set_ns(std::string& _ns) = 0;
/** Clear the namespace for this User */
- void clear_ns() { info.user_id.ns.clear(); }
+ virtual void clear_ns() = 0;
/** Get the full ID for this User */
- const rgw_user& get_id() const { return info.user_id; }
+ virtual const rgw_user& get_id() const = 0;
/** Get the type of this User */
- uint32_t get_type() const { return info.type; }
+ virtual uint32_t get_type() const = 0;
/** Get the maximum number of buckets allowed for this User */
- int32_t get_max_buckets() const { return info.max_buckets; }
+ virtual int32_t get_max_buckets() const = 0;
/** Get the capabilities for this User */
- const RGWUserCaps& get_caps() const { return info.caps; }
+ virtual const RGWUserCaps& get_caps() const = 0;
/** Get the version tracker for this User */
- virtual RGWObjVersionTracker& get_version_tracker() { return objv_tracker; }
+ virtual RGWObjVersionTracker& get_version_tracker() = 0;
/** Get the cached attributes for this User */
- virtual Attrs& get_attrs() { return attrs; }
+ virtual Attrs& get_attrs() = 0;
/** Set the cached attributes fro this User */
- virtual void set_attrs(Attrs& _attrs) { attrs = _attrs; }
+ virtual void set_attrs(Attrs& _attrs) = 0;
+ /** Check if a User is empty */
+ virtual bool empty() = 0;
/** Check if a User pointer is empty */
- static bool empty(User* u) { return (!u || u->info.user_id.id.empty()); }
+ static bool empty(User* u) { return (!u || u->empty()); }
/** Check if a User unique_pointer is empty */
- static bool empty(std::unique_ptr<User>& u) { return (!u || u->info.user_id.id.empty()); }
+ static bool empty(std::unique_ptr<User>& u) { return (!u || u->empty()); }
/** Read the User attributes from the backing Store */
virtual int read_attrs(const DoutPrefixProvider* dpp, optional_yield y) = 0;
/** Set the attributes in attrs, leaving any other existing attrs set, and
virtual int remove_user(const DoutPrefixProvider* dpp, optional_yield y) = 0;
/* dang temporary; will be removed when User is complete */
- RGWUserInfo& get_info() { return info; }
+ virtual RGWUserInfo& get_info() = 0;
+
+ /** Print the User to @a out */
+ virtual void print(std::ostream& out) const = 0;
friend inline std::ostream& operator<<(std::ostream& out, const User& u) {
- out << u.info.user_id;
+ u.print(out);
return out;
}
if (!u)
out << "<NULL>";
else
- out << u->info.user_id;
+ u->print(out);
return out;
}
out << p.get();
return out;
}
-
- friend class Bucket;
};
/**
* can access the contents of the bucket, and in what ways.
*/
class Bucket {
- protected:
- RGWBucketEnt ent;
- RGWBucketInfo info;
- User* owner = nullptr;
- Attrs attrs;
- obj_version bucket_version;
- ceph::real_time mtime;
-
public:
/**
};
Bucket() = default;
- Bucket(User* _u) :
- owner(_u) { }
- Bucket(const rgw_bucket& _b) { ent.bucket = _b; info.bucket = _b; }
- Bucket(const RGWBucketEnt& _e) : ent(_e) {
- info.bucket = ent.bucket;
- info.placement_rule = ent.placement_rule;
- info.creation_time = ent.creation_time;
- }
- Bucket(const RGWBucketInfo& _i) : info(_i) {
- ent.bucket = info.bucket;
- ent.placement_rule = info.placement_rule;
- ent.creation_time = info.creation_time;
- }
- Bucket(const rgw_bucket& _b, User* _u) :
- owner(_u) { ent.bucket = _b; info.bucket = _b; }
- Bucket(const RGWBucketEnt& _e, User* _u) : ent(_e), owner(_u) {
- info.bucket = ent.bucket;
- info.placement_rule = ent.placement_rule;
- info.creation_time = ent.creation_time;
- }
- Bucket(const RGWBucketInfo& _i, User* _u) : info(_i), owner(_u) {
- ent.bucket = info.bucket;
- ent.placement_rule = info.placement_rule;
- ent.creation_time = info.creation_time;
- }
virtual ~Bucket() = default;
/** Get an @a Object belonging to this bucket */
/** List the contents of this bucket */
virtual int list(const DoutPrefixProvider* dpp, ListParams&, int, ListResults&, optional_yield y) = 0;
/** Get the cached attributes associated with this bucket */
- virtual Attrs& get_attrs(void) { return attrs; }
+ virtual Attrs& get_attrs(void) = 0;
/** Set the cached attributes on this bucket */
- virtual int set_attrs(Attrs a) { attrs = a; return 0; }
+ virtual int set_attrs(Attrs a) = 0;
/** Remove this bucket from the backing store */
virtual int remove_bucket(const DoutPrefixProvider* dpp, bool delete_children, bool forward_to_master, req_info* req_info, optional_yield y) = 0;
/** Remove this bucket, bypassing garbage collection. May be removed */
virtual int set_acl(const DoutPrefixProvider* dpp, RGWAccessControlPolicy& acl, optional_yield y) = 0;
// XXXX hack
- void set_owner(rgw::sal::User* _owner) {
- owner = _owner;
- }
+ virtual void set_owner(rgw::sal::User* _owner) = 0;
/** Load this bucket from the backing store. Requires the key to be set, fills other fields.
* If @a get_stats is true, then statistics on the bucket are also looked up. */
/** Check to see if the given user is the owner of this bucket */
virtual bool is_owner(User* user) = 0;
/** Get the owner of this bucket */
- virtual User* get_owner(void) { return owner; };
+ virtual User* get_owner(void) = 0;
/** Get the owner of this bucket in the form of an ACLOwner object */
- virtual ACLOwner get_acl_owner(void) { return ACLOwner(info.owner); };
+ virtual ACLOwner get_acl_owner(void) = 0;
/** Check in the backing store if this bucket is empty */
virtual int check_empty(const DoutPrefixProvider* dpp, optional_yield y) = 0;
/** Chec k if the given size fits within the quota */
virtual int purge_instance(const DoutPrefixProvider* dpp) = 0;
/** Check if this instantiation is empty */
- bool empty() const { return info.bucket.name.empty(); }
+ virtual bool empty() const = 0;
/** Get the cached name of this bucket */
- const std::string& get_name() const { return info.bucket.name; }
+ virtual const std::string& get_name() const = 0;
/** Get the cached tenant of this bucket */
- const std::string& get_tenant() const { return info.bucket.tenant; }
+ virtual const std::string& get_tenant() const = 0;
/** Get the cached marker of this bucket */
- const std::string& get_marker() const { return info.bucket.marker; }
+ virtual const std::string& get_marker() const = 0;
/** Get the cached ID of this bucket */
- const std::string& get_bucket_id() const { return info.bucket.bucket_id; }
+ virtual const std::string& get_bucket_id() const = 0;
/** Get the cached size of this bucket */
- size_t get_size() const { return ent.size; }
+ virtual size_t get_size() const = 0;
/** Get the cached rounded size of this bucket */
- size_t get_size_rounded() const { return ent.size_rounded; }
+ virtual size_t get_size_rounded() const = 0;
/** Get the cached object count of this bucket */
- uint64_t get_count() const { return ent.count; }
+ virtual uint64_t get_count() const = 0;
/** Get the cached placement rule of this bucket */
- rgw_placement_rule& get_placement_rule() { return info.placement_rule; }
+ virtual rgw_placement_rule& get_placement_rule() = 0;
/** Get the cached creation time of this bucket */
- ceph::real_time& get_creation_time() { return info.creation_time; }
+ virtual ceph::real_time& get_creation_time() = 0;
/** Get the cached modification time of this bucket */
- ceph::real_time& get_modification_time() { return mtime; }
+ virtual ceph::real_time& get_modification_time() = 0;
/** Get the cached version of this bucket */
- obj_version& get_version() { return bucket_version; }
+ virtual obj_version& get_version() = 0;
/** Set the cached version of this bucket */
- void set_version(obj_version &ver) { bucket_version = ver; }
+ virtual void set_version(obj_version &ver) = 0;
/** Check if this bucket is versioned */
- bool versioned() { return info.versioned(); }
+ virtual bool versioned() = 0;
/** Check if this bucket has versioning enabled */
- bool versioning_enabled() { return info.versioning_enabled(); }
+ virtual bool versioning_enabled() = 0;
/** Check if a Bucket pointer is empty */
static bool empty(Bucket* b) { return (!b || b->empty()); }
+ /** Check if a Bucket unique pointer is empty */
+ static bool empty(std::unique_ptr<Bucket> b) { return (!b || b->empty()); }
/** Clone a copy of this bucket. Used when modification is necessary of the copy */
virtual std::unique_ptr<Bucket> clone() = 0;
CephContext* cct) = 0;
/* dang - This is temporary, until the API is completed */
- rgw_bucket& get_key() { return info.bucket; }
- RGWBucketInfo& get_info() { return info; }
+ virtual rgw_bucket& get_key() = 0;
+ virtual RGWBucketInfo& get_info() = 0;
+
+ /** Print the User to @a out */
+ virtual void print(std::ostream& out) const = 0;
friend inline std::ostream& operator<<(std::ostream& out, const Bucket& b) {
- out << b.info.bucket;
+ b.print(out);
return out;
}
if (!b)
out << "<NULL>";
else
- out << b->info.bucket;
+ b->print(out);
return out;
}
return out;
}
- bool operator==(const Bucket& b) const {
- return (info.bucket.tenant == b.info.bucket.tenant) &&
- (info.bucket.name == b.info.bucket.name) &&
- (info.bucket.bucket_id == b.info.bucket.bucket_id);
- }
- bool operator!=(const Bucket& b) const {
- return (info.bucket.tenant != b.info.bucket.tenant) ||
- (info.bucket.name != b.info.bucket.name) ||
- (info.bucket.bucket_id != b.info.bucket.bucket_id);
- }
+ virtual bool operator==(const Bucket& b) const = 0;
+ virtual bool operator!=(const Bucket& b) const = 0;
friend class BucketList;
- protected:
- virtual void set_ent(RGWBucketEnt& _ent) { ent = _ent; info.bucket = ent.bucket; info.placement_rule = ent.placement_rule; }
};
/**
void set_truncated(bool trunc) { truncated = trunc; }
/** Add a bucket to the list. Takes ownership of the bucket */
void add(std::unique_ptr<Bucket> bucket) {
- buckets.emplace(bucket->info.bucket.name, std::move(bucket));
+ buckets.emplace(bucket->get_name(), std::move(bucket));
}
/** The number of buckets in this list */
size_t count() const { return buckets.size(); }
* is written to, it is replaced, and the old data is not accessible.
*/
class Object {
- protected:
- RGWObjState state; /**< The key and primary metadata for the object */
- Bucket* bucket; /**< @a Bucket containing this object */
- Attrs attrs; /**< Cache of attributes for this object */
- bool delete_marker{false}; /**< True if this object has a delete marker */
-
public:
/**
virtual int delete_obj(const DoutPrefixProvider* dpp, optional_yield y) = 0;
};
- Object()
- : state(),
- bucket(nullptr),
- attrs()
- {}
- Object(const rgw_obj_key& _k)
- : state(),
- bucket(),
- attrs()
- { state.obj.key = _k; }
- Object(const rgw_obj_key& _k, Bucket* _b)
- : state(),
- bucket(_b),
- attrs()
- { state.obj.init(_b->get_key(), _k); }
- Object(Object& _o) = default;
-
+ Object() {}
virtual ~Object() = default;
/** Shortcut synchronous delete call for common deletes */
/** Set the ACL for this object */
virtual int set_acl(const RGWAccessControlPolicy& acl) = 0;
/** Mark further operations on this object as being atomic */
- virtual void set_atomic() {
- state.is_atomic = true;
- }
+ virtual void set_atomic() = 0;
/** Check if this object is atomic */
- bool is_atomic() { return state.is_atomic; }
+ virtual bool is_atomic() = 0;
/** Pre-fetch data when reading */
- virtual void set_prefetch_data() {
- state.prefetch_data = true;
- }
+ virtual void set_prefetch_data() = 0;
/** Check if this object should prefetch */
- bool is_prefetch_data() { return state.prefetch_data; }
+ virtual bool is_prefetch_data() = 0;
/** Mark data as compressed */
- virtual void set_compressed() {
- state.compressed = true;
- }
+ virtual void set_compressed() = 0;
/** Check if this object is compressed */
- bool is_compressed() { return state.compressed; }
+ virtual bool is_compressed() = 0;
/** Invalidate cached info about this object, except atomic, prefetch, and
* compressed */
- virtual void invalidate() {
- rgw_obj obj = state.obj;
- bool is_atomic = state.is_atomic;
- bool prefetch_data = state.prefetch_data;
- bool compressed = state.compressed;
-
- state = RGWObjState();
- state.obj = obj;
- state.is_atomic = is_atomic;
- state.prefetch_data = prefetch_data;
- state.compressed = compressed;
- }
+ virtual void invalidate() = 0;
/** Check to see if this object has an empty key. This means it's uninitialized */
- bool empty() const { return state.obj.empty(); }
+ virtual bool empty() const = 0;
/** Get the name of this object */
- const std::string &get_name() const { return state.obj.key.name; }
+ virtual const std::string &get_name() const = 0;
/** Get the object state for this object. Will be removed in the future */
virtual int get_obj_state(const DoutPrefixProvider* dpp, RGWObjState **state, optional_yield y, bool follow_olh = true) = 0;
virtual int dump_obj_layout(const DoutPrefixProvider *dpp, optional_yield y, Formatter* f) = 0;
/** Get the cached attributes for this object */
- Attrs& get_attrs(void) { return state.attrset; }
+ virtual Attrs& get_attrs(void) = 0;
/** Get the (const) cached attributes for this object */
- const Attrs& get_attrs(void) const { return state.attrset; }
+ virtual const Attrs& get_attrs(void) const = 0;
/** Set the cached attributes for this object */
- virtual int set_attrs(Attrs a) { state.attrset = a; state.has_attrs = true; return 0; }
+ virtual int set_attrs(Attrs a) = 0;
/** Check to see if attributes are cached on this object */
- bool has_attrs(void) { return state.has_attrs; }
+ virtual bool has_attrs(void) = 0;
/** Get the cached modification time for this object */
- ceph::real_time get_mtime(void) const { return state.mtime; }
+ virtual ceph::real_time get_mtime(void) const = 0;
/** Get the cached size for this object */
- uint64_t get_obj_size(void) const { return state.size; }
+ virtual uint64_t get_obj_size(void) const = 0;
/** Get the bucket containing this object */
- Bucket* get_bucket(void) const { return bucket; }
+ virtual Bucket* get_bucket(void) const = 0;
/** Set the bucket containing this object */
- void set_bucket(Bucket* b) { bucket = b; state.obj.bucket = b->get_key(); }
+ virtual void set_bucket(Bucket* b) = 0;
/** Get the sharding hash representation of this object */
- std::string get_hash_source(void) { return state.obj.index_hash_source; }
+ virtual std::string get_hash_source(void) = 0;
/** Set the sharding hash representation of this object */
- void set_hash_source(std::string s) { state.obj.index_hash_source = s; }
+ virtual void set_hash_source(std::string s) = 0;
/** Build an Object Identifier string for this object */
- std::string get_oid(void) const { return state.obj.key.get_oid(); }
+ virtual std::string get_oid(void) const = 0;
/** True if this object is a delete marker (newest version is deleted) */
- bool get_delete_marker(void) { return delete_marker; }
+ virtual bool get_delete_marker(void) = 0;
/** True if this object is stored in the extra data pool */
- bool get_in_extra_data(void) { return state.obj.is_in_extra_data(); }
+ virtual bool get_in_extra_data(void) = 0;
/** Set the in_extra_data field */
- void set_in_extra_data(bool i) { state.obj.set_in_extra_data(i); }
+ virtual void set_in_extra_data(bool i) = 0;
/** Helper to sanitize object size, offset, and end values */
int range_to_ofs(uint64_t obj_size, int64_t &ofs, int64_t &end);
/** Set the cached size of this object */
- void set_obj_size(uint64_t s) { state.size = s; }
+ virtual void set_obj_size(uint64_t s) = 0;
/** Set the cached name of this object */
- virtual void set_name(const std::string& n) { state.obj.key = n; }
+ virtual void set_name(const std::string& n) = 0;
/** Set the cached key of this object */
- virtual void set_key(const rgw_obj_key& k) { state.obj.key = k; }
+ virtual void set_key(const rgw_obj_key& k) = 0;
/** Get an rgw_obj representing this object */
- virtual rgw_obj get_obj(void) const { return state.obj; }
+ virtual rgw_obj get_obj(void) const = 0;
/** Restore the previous swift version of this object */
virtual int swift_versioning_restore(bool& restored, /* out */
virtual int omap_set_val_by_key(const DoutPrefixProvider *dpp, const std::string& key, bufferlist& val,
bool must_exist, optional_yield y) = 0;
- /** Check to see if the give object pointer is uninitialized */
+ /** Check to see if the given object pointer is uninitialized */
static bool empty(Object* o) { return (!o || o->empty()); }
+ /** Check to see if the given object unique pointer is uninitialized */
+ static bool empty(std::unique_ptr<Object> o) { return (!o || o->empty()); }
/** Get a unique copy of this object */
virtual std::unique_ptr<Object> clone() = 0;
/* dang - This is temporary, until the API is completed */
/** Get the key for this object */
- rgw_obj_key& get_key() { return state.obj.key; }
+ virtual rgw_obj_key& get_key() = 0;
/** Set the instance for this object */
- void set_instance(const std::string &i) { state.obj.key.set_instance(i); }
+ virtual void set_instance(const std::string &i) = 0;
/** Get the instance for this object */
- const std::string &get_instance() const { return state.obj.key.instance; }
+ virtual const std::string &get_instance() const = 0;
/** Check to see if this object has an instance set */
- bool have_instance(void) { return state.obj.key.have_instance(); }
+ virtual bool have_instance(void) = 0;
/** Clear the instance on this object */
- void clear_instance() { state.obj.key.instance.clear(); }
+ virtual void clear_instance() = 0;
+
+ /** Print the User to @a out */
+ virtual void print(std::ostream& out) const = 0;
friend inline std::ostream& operator<<(std::ostream& out, const Object& o) {
- if (o.bucket)
- out << o.bucket << ":";
- out << o.state.obj.key;
+ o.print(out);
return out;
}
friend inline std::ostream& operator<<(std::ostream& out, const Object* o) {
if (!o)
out << "<NULL>";
else
- out << *o;
+ o->print(out);
return out;
}
friend inline std::ostream& operator<<(std::ostream& out, const std::unique_ptr<Object>& p) {
* @brief Abstraction of a single part of a multipart upload
*/
class MultipartPart {
-protected:
- std::string oid;
-
public:
MultipartPart() = default;
virtual ~MultipartPart() = default;
* set of upload parts.
*/
class MultipartUpload {
-protected:
- Bucket* bucket;
- std::map<uint32_t, std::unique_ptr<MultipartPart>> parts;
- jspan_context trace_ctx{false, false};
public:
- MultipartUpload(Bucket* _bucket) : bucket(_bucket) {}
+ MultipartUpload() = default;
virtual ~MultipartUpload() = default;
/** Get the name of the object representing this upload in the backing store */
virtual ceph::real_time& get_mtime() = 0;
/** Get all the cached parts that make up this upload */
- std::map<uint32_t, std::unique_ptr<MultipartPart>>& get_parts() { return parts; }
+ virtual std::map<uint32_t, std::unique_ptr<MultipartPart>>& get_parts() = 0;
/** Get the trace context of this upload */
- const jspan_context& get_trace() { return trace_ctx; }
+ virtual const jspan_context& get_trace() = 0;
/** Get the Object that represents this upload */
virtual std::unique_ptr<rgw::sal::Object> get_meta_obj() = 0;
uint64_t part_num,
const std::string& part_num_str) = 0;
+ /** Print the Upload to @a out */
+ virtual void print(std::ostream& out) const = 0;
+
friend inline std::ostream& operator<<(std::ostream& out, const MultipartUpload& u) {
- out << u.get_meta();
- if (!u.get_upload_id().empty())
- out << ":" << u.get_upload_id();
+ u.print(out);
return out;
}
friend inline std::ostream& operator<<(std::ostream& out, const MultipartUpload* u) {
if (!u)
out << "<NULL>";
else
- out << *u;
+ u->print(out);
return out;
}
friend inline std::ostream& operator<<(std::ostream& out, const
/**
* @brief Interface of a lock/serialization
*/
-struct Serializer {
+class Serializer {
+public:
Serializer() = default;
virtual ~Serializer() = default;
virtual int try_lock(const DoutPrefixProvider *dpp, utime_t dur, optional_yield y) = 0;
/** Unlock the lock */
virtual int unlock() = 0;
+
+ /** Print the Serializer to @a out */
+ virtual void print(std::ostream& out) const = 0;
+
+ friend inline std::ostream& operator<<(std::ostream& out, const Serializer& s) {
+ s.print(out);
+ return out;
+ }
+ friend inline std::ostream& operator<<(std::ostream& out, const Serializer* s) {
+ if (!s)
+ out << "<NULL>";
+ else
+ s->print(out);
+ return out;
+ }
};
/** @brief Abstraction of a serializer for multipart uploads
*/
-struct MPSerializer : Serializer {
- bool locked;
- std::string oid;
- MPSerializer() : locked(false) {}
+class MPSerializer : public Serializer {
+public:
+ MPSerializer() = default;
virtual ~MPSerializer() = default;
- void clear_locked() {
- locked = false;
- }
+ virtual void clear_locked() = 0;
+ /** Check to see if locked */
+ virtual bool is_locked() = 0;
};
/** @brief Abstraction of a serializer for Lifecycle
*/
-struct LCSerializer : Serializer {
+class LCSerializer : public Serializer {
+public:
LCSerializer() {}
virtual ~LCSerializer() = default;
};
public:
/** 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};
-
LCHead() = default;
- LCHead(time_t _date, std::string& _marker) : start_date(_date), marker(_marker) {}
+ 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 {
- std::string bucket;
- std::string oid;
- uint64_t start_time{0};
- uint32_t status{0};
-
LCEntry() = default;
- LCEntry(std::string& _bucket, uint64_t _time, uint32_t _status) : bucket(_bucket), start_time(_time), status(_status) {}
- LCEntry(std::string& _bucket, std::string _oid, uint64_t _time, uint32_t _status) : bucket(_bucket), oid(_oid), start_time(_time), status(_status) {}
+ 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 std::string& oid, const std::string& marker, LCEntry& entry) = 0;
+ virtual int get_entry(const std::string& oid, const std::string& marker, std::unique_ptr<LCEntry>* entry) = 0;
/** Get the entry following the given marker */
- virtual int get_next_entry(const std::string& oid, std::string& marker, LCEntry& entry) = 0;
+ virtual int get_next_entry(const std::string& oid, const std::string& marker, std::unique_ptr<LCEntry>* entry) = 0;
/** Store a modified entry in then backing store */
- virtual int set_entry(const std::string& oid, const LCEntry& entry) = 0;
+ virtual int set_entry(const std::string& oid, LCEntry& entry) = 0;
/** List all known entries */
virtual int list_entries(const std::string& oid, const std::string& marker,
- uint32_t max_entries, std::vector<LCEntry>& entries) = 0;
+ uint32_t max_entries,
+ std::vector<std::unique_ptr<LCEntry>>& entries) = 0;
/** Remove an entry from the backing store */
- virtual int rm_entry(const std::string& oid, const LCEntry& entry) = 0;
+ virtual int rm_entry(const std::string& oid, LCEntry& entry) = 0;
/** Get a head */
- virtual int get_head(const std::string& oid, LCHead& head) = 0;
+ virtual int get_head(const std::string& oid, std::unique_ptr<LCHead>* head) = 0;
/** Store a modified head to the backing store */
- virtual int put_head(const std::string& oid, const LCHead& head) = 0;
+ virtual int put_head(const std::string& oid, LCHead& head) = 0;
/** Get a serializer for lifecycle */
virtual LCSerializer* get_serializer(const std::string& lock_name, const std::string& oid, const std::string& cookie) = 0;
*/
class Notification {
protected:
- Object* obj;
- Object* src_obj;
- rgw::notify::EventType event_type;
-
public:
- Notification(Object* _obj, Object* _src_obj, rgw::notify::EventType _type)
- : obj(_obj), src_obj(_src_obj), event_type(_type)
- {}
+ Notification() {}
virtual ~Notification() = default;
* those filters.
*/
class Writer : public ObjectProcessor {
-protected:
- const DoutPrefixProvider* dpp;
-
public:
- Writer(const DoutPrefixProvider *_dpp, optional_yield y) : dpp(_dpp) {}
+ Writer() {}
virtual ~Writer() = default;
/** prepare to start processing object data */
optional_yield y) = 0;
};
+
+/**
+ * @brief Abstraction of a placement tier
+ *
+ * This abstraction allows access to information about placement tiers,
+ * including storage class.
+ */
class PlacementTier {
public:
virtual ~PlacementTier() = default;
/** Get the placement rule associated with this tier */
};
+/**
+ * @brief Abstraction of a zone group
+ *
+ * This class allows access to information about a zonegroup. It may be the
+ * group containing the current zone, or another group.
+ */
class ZoneGroup {
public:
virtual ~ZoneGroup() = default;
+ /** Get the ID of this zonegroup */
virtual const std::string& get_id() const = 0;
+ /** Get the name of this zonegroup */
virtual const std::string& get_name() const = 0;
+ /** Determine if two zonegroups are the same */
virtual int equals(const std::string& other_zonegroup) const = 0;
/** Get the endpoint from zonegroup, or from master zone if not set */
virtual const std::string& get_endpoint() const = 0;
+ /** Check if a placement target (by name) exists in this zonegroup */
virtual bool placement_target_exists(std::string& target) const = 0;
+ /** Check if this is the master zonegroup */
virtual bool is_master_zonegroup() const = 0;
+ /** Get the API name of this zonegroup */
virtual const std::string& get_api_name() const = 0;
+ /** Get the list of placement target names for this zone */
virtual int get_placement_target_names(std::set<std::string>& names) const = 0;
+ /** Get the name of the default placement target for this zone */
virtual const std::string& get_default_placement_name() const = 0;
+ /** Get the list of hostnames from this zone */
virtual int get_hostnames(std::list<std::string>& names) const = 0;
+ /** Get the list of hostnames that host s3 websites from this zone */
virtual int get_s3website_hostnames(std::list<std::string>& names) const = 0;
/** Get the number of zones in this zonegroup */
virtual int get_zone_count() const = 0;
const rgw_user& _owner,
const rgw_placement_rule *_ptail_placement_rule,
uint64_t _part_num, const std::string& _part_num_str):
- Writer(dpp, y),
+ StoreWriter(dpp, y),
store(_store),
owner(_owner),
ptail_placement_rule(_ptail_placement_rule),
const rgw_placement_rule *_ptail_placement_rule,
uint64_t _olh_epoch,
const std::string& _unique_tag) :
- Writer(dpp, y),
+ StoreWriter(dpp, y),
store(_store),
owner(_owner),
ptail_placement_rule(_ptail_placement_rule),
}
int DBLifecycle::get_entry(const std::string& oid, const std::string& marker,
- LCEntry& entry)
+ std::unique_ptr<LCEntry>* entry)
{
return store->getDB()->get_entry(oid, marker, entry);
}
- int DBLifecycle::get_next_entry(const std::string& oid, std::string& marker,
- LCEntry& entry)
+ int DBLifecycle::get_next_entry(const std::string& oid, const std::string& marker,
+ std::unique_ptr<LCEntry>* entry)
{
return store->getDB()->get_next_entry(oid, marker, entry);
}
- int DBLifecycle::set_entry(const std::string& oid, const LCEntry& entry)
+ int DBLifecycle::set_entry(const std::string& oid, LCEntry& entry)
{
return store->getDB()->set_entry(oid, entry);
}
int DBLifecycle::list_entries(const std::string& oid, const std::string& marker,
- uint32_t max_entries, vector<LCEntry>& entries)
+ uint32_t max_entries, vector<std::unique_ptr<LCEntry>>& entries)
{
return store->getDB()->list_entries(oid, marker, max_entries, entries);
}
- int DBLifecycle::rm_entry(const std::string& oid, const LCEntry& entry)
+ int DBLifecycle::rm_entry(const std::string& oid, LCEntry& entry)
{
return store->getDB()->rm_entry(oid, entry);
}
- int DBLifecycle::get_head(const std::string& oid, LCHead& head)
+ int DBLifecycle::get_head(const std::string& oid, std::unique_ptr<LCHead>* head)
{
return store->getDB()->get_head(oid, head);
}
- int DBLifecycle::put_head(const std::string& oid, const LCHead& head)
+ int DBLifecycle::put_head(const std::string& oid, LCHead& head)
{
return store->getDB()->put_head(oid, head);
}
#pragma once
-#include "rgw_sal.h"
+#include "rgw_sal_store.h"
#include "rgw_oidc_provider.h"
#include "rgw_role.h"
#include "rgw_lc.h"
class DBStore;
-class LCDBSerializer : public LCSerializer {
- const std::string oid;
+class LCDBSerializer : public StoreLCSerializer {
public:
LCDBSerializer(DBStore* store, const std::string& oid, const std::string& lock_name, const std::string& cookie) {}
}
};
-class DBLifecycle : public Lifecycle {
+class DBLifecycle : public StoreLifecycle {
DBStore* store;
public:
DBLifecycle(DBStore* _st) : store(_st) {}
- virtual int get_entry(const std::string& oid, const std::string& marker, LCEntry& entry) override;
- virtual int get_next_entry(const std::string& oid, std::string& marker, LCEntry& entry) override;
- virtual int set_entry(const std::string& oid, const LCEntry& entry) override;
+ using StoreLifecycle::get_entry;
+ virtual int get_entry(const std::string& oid, const std::string& marker, std::unique_ptr<LCEntry>* entry) override;
+ virtual int get_next_entry(const std::string& oid, const std::string& marker, std::unique_ptr<LCEntry>* entry) override;
+ virtual int set_entry(const std::string& oid, LCEntry& entry) override;
virtual int list_entries(const std::string& oid, const std::string& marker,
- uint32_t max_entries, std::vector<LCEntry>& entries) override;
- virtual int rm_entry(const std::string& oid, const LCEntry& entry) override;
- virtual int get_head(const std::string& oid, LCHead& head) override;
- virtual int put_head(const std::string& oid, const LCHead& head) override;
+ uint32_t max_entries,
+ std::vector<std::unique_ptr<LCEntry>>& entries) override;
+ virtual int rm_entry(const std::string& oid, LCEntry& entry) override;
+ virtual int get_head(const std::string& oid, std::unique_ptr<LCHead>* head) override;
+ virtual int put_head(const std::string& oid, LCHead& head) override;
virtual LCSerializer* get_serializer(const std::string& lock_name, const std::string& oid, const std::string& cookie) override;
};
-class DBNotification : public Notification {
+class DBNotification : public StoreNotification {
protected:
public:
DBNotification(Object* _obj, Object* _src_obj, rgw::notify::EventType _type)
- : Notification(_obj, _src_obj, _type) {}
+ : StoreNotification(_obj, _src_obj, _type) {}
~DBNotification() = default;
virtual int publish_reserve(const DoutPrefixProvider *dpp, RGWObjTags* obj_tags = nullptr) override { return 0;}
const ceph::real_time& mtime, const std::string& etag, const std::string& version) override { return 0; }
};
- class DBUser : public User {
+ class DBUser : public StoreUser {
private:
DBStore *store;
public:
- DBUser(DBStore *_st, const rgw_user& _u) : User(_u), store(_st) { }
- DBUser(DBStore *_st, const RGWUserInfo& _i) : User(_i), store(_st) { }
+ DBUser(DBStore *_st, const rgw_user& _u) : StoreUser(_u), store(_st) { }
+ DBUser(DBStore *_st, const RGWUserInfo& _i) : StoreUser(_i), store(_st) { }
DBUser(DBStore *_st) : store(_st) { }
DBUser(DBUser& _o) = default;
DBUser() {}
friend class DBBucket;
};
- class DBBucket : public Bucket {
+ class DBBucket : public StoreBucket {
private:
DBStore *store;
RGWAccessControlPolicy acls;
}
DBBucket(DBStore *_st, User* _u)
- : Bucket(_u),
+ : StoreBucket(_u),
store(_st),
acls() {
}
DBBucket(DBStore *_st, const rgw_bucket& _b)
- : Bucket(_b),
+ : StoreBucket(_b),
store(_st),
acls() {
}
DBBucket(DBStore *_st, const RGWBucketEnt& _e)
- : Bucket(_e),
+ : StoreBucket(_e),
store(_st),
acls() {
}
DBBucket(DBStore *_st, const RGWBucketInfo& _i)
- : Bucket(_i),
+ : StoreBucket(_i),
store(_st),
acls() {
}
DBBucket(DBStore *_st, const rgw_bucket& _b, User* _u)
- : Bucket(_b, _u),
+ : StoreBucket(_b, _u),
store(_st),
acls() {
}
DBBucket(DBStore *_st, const RGWBucketEnt& _e, User* _u)
- : Bucket(_e, _u),
+ : StoreBucket(_e, _u),
store(_st),
acls() {
}
DBBucket(DBStore *_st, const RGWBucketInfo& _i, User* _u)
- : Bucket(_i, _u),
+ : StoreBucket(_i, _u),
store(_st),
acls() {
}
friend class DBStore;
};
- class DBPlacementTier: public PlacementTier {
+ class DBPlacementTier: public StorePlacementTier {
DBStore* store;
RGWZoneGroupPlacementTier tier;
public:
RGWZoneGroupPlacementTier& get_rt() { return tier; }
};
- class DBZoneGroup : public ZoneGroup {
+ class DBZoneGroup : public StoreZoneGroup {
DBStore* store;
std::unique_ptr<RGWZoneGroup> group;
std::string empty;
}
};
- class DBZone : public Zone {
+ class DBZone : public StoreZone {
protected:
DBStore* store;
RGWRealm *realm{nullptr};
virtual const std::string& get_realm_id() override;
};
- class DBLuaScriptManager : public LuaScriptManager {
+ class DBLuaScriptManager : public StoreLuaScriptManager {
DBStore* store;
public:
* rename all data/tail objects to orig object name and update
* metadata of the orig object.
*/
- class DBMultipartPart : public MultipartPart {
+ class DBMultipartPart : public StoreMultipartPart {
protected:
RGWUploadPartInfo info; /* XXX: info contains manifest also which is not needed */
}
};
- class DBMultipartUpload : public MultipartUpload {
+ class DBMultipartUpload : public StoreMultipartUpload {
DBStore* store;
DBMPObj mp_obj;
ACLOwner owner;
rgw_placement_rule placement;
public:
- DBMultipartUpload(DBStore* _store, Bucket* _bucket, const std::string& oid, std::optional<std::string> upload_id, ACLOwner _owner, ceph::real_time _mtime) : MultipartUpload(_bucket), store(_store), mp_obj(oid, upload_id), owner(_owner), mtime(_mtime) {}
+ DBMultipartUpload(DBStore* _store, Bucket* _bucket, const std::string& oid, std::optional<std::string> upload_id, ACLOwner _owner, ceph::real_time _mtime) : StoreMultipartUpload(_bucket), store(_store), mp_obj(oid, upload_id), owner(_owner), mtime(_mtime) {}
virtual ~DBMultipartUpload() = default;
virtual const std::string& get_meta() const { return mp_obj.get_meta(); }
const std::string& part_num_str) override;
};
- class DBObject : public Object {
+ class DBObject : public StoreObject {
private:
DBStore* store;
RGWAccessControlPolicy acls;
DBObject() = default;
DBObject(DBStore *_st, const rgw_obj_key& _k)
- : Object(_k),
+ : StoreObject(_k),
store(_st),
acls() {}
DBObject(DBStore *_st, const rgw_obj_key& _k, Bucket* _b)
- : Object(_k, _b),
+ : StoreObject(_k, _b),
store(_st),
acls() {}
int read_attrs(const DoutPrefixProvider* dpp, DB::Object::Read &read_op, optional_yield y, rgw_obj* target_obj = nullptr);
};
- class MPDBSerializer : public MPSerializer {
+ class MPDBSerializer : public StoreMPSerializer {
public:
MPDBSerializer(const DoutPrefixProvider *dpp, DBStore* store, DBObject* obj, const std::string& lock_name) {}
virtual int unlock() override { return 0;}
};
- class DBAtomicWriter : public Writer {
+ class DBAtomicWriter : public StoreWriter {
protected:
rgw::sal::DBStore* store;
const rgw_user& owner;
optional_yield y) override;
};
- class DBMultipartWriter : public Writer {
+ class DBMultipartWriter : public StoreWriter {
protected:
rgw::sal::DBStore* store;
const rgw_user& owner;
optional_yield y) override;
};
- class DBStore : public Store {
+ class DBStore : public StoreStore {
private:
/* DBStoreManager is used in case multiple
* connections are needed one for each tenant.
--- /dev/null
+// -*- 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) 2022 Red Hat, Inc.
+ *
+ * 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_sal.h"
+
+namespace rgw { namespace sal {
+
+class FilterStore : public Store {
+ public:
+ FilterStore() {}
+ virtual ~FilterStore() = default;
+
+ virtual int initialize(CephContext *cct, const DoutPrefixProvider *dpp) = 0;
+ virtual const std::string get_name() const = 0;
+ virtual std::string get_cluster_id(const DoutPrefixProvider* dpp, optional_yield y) = 0;
+ virtual std::unique_ptr<User> get_user(const rgw_user& u) = 0;
+ virtual int get_user_by_access_key(const DoutPrefixProvider* dpp, const std::string& key, optional_yield y, std::unique_ptr<User>* user) = 0;
+ virtual int get_user_by_email(const DoutPrefixProvider* dpp, const std::string& email, optional_yield y, std::unique_ptr<User>* user) = 0;
+ virtual int get_user_by_swift(const DoutPrefixProvider* dpp, const std::string& user_str, optional_yield y, std::unique_ptr<User>* user) = 0;
+ virtual std::unique_ptr<Object> get_object(const rgw_obj_key& k) = 0;
+ virtual int get_bucket(User* u, const RGWBucketInfo& i, std::unique_ptr<Bucket>* bucket) = 0;
+ virtual int get_bucket(const DoutPrefixProvider* dpp, User* u, const rgw_bucket& b, std::unique_ptr<Bucket>* bucket, optional_yield y) = 0;
+ virtual int get_bucket(const DoutPrefixProvider* dpp, User* u, const std::string& tenant, const std::string& name, std::unique_ptr<Bucket>* bucket, optional_yield y) = 0;
+ virtual bool is_meta_master() = 0;
+ virtual int forward_request_to_master(const DoutPrefixProvider *dpp, User* user, obj_version* objv,
+ bufferlist& in_data, JSONParser* jp, req_info& info,
+ optional_yield y) = 0;
+ virtual Zone* get_zone() = 0;
+ virtual std::string zone_unique_id(uint64_t unique_num) = 0;
+ virtual std::string zone_unique_trans_id(const uint64_t unique_num) = 0;
+ virtual int cluster_stat(RGWClusterStat& stats) = 0;
+ virtual std::unique_ptr<Lifecycle> get_lifecycle(void) = 0;
+ virtual std::unique_ptr<Completions> get_completions(void) = 0;
+
+ virtual std::unique_ptr<Notification> get_notification(rgw::sal::Object* obj, rgw::sal::Object* src_obj, struct req_state* s,
+ rgw::notify::EventType event_type, const std::string* object_name=nullptr) = 0;
+ virtual std::unique_ptr<Notification> get_notification(
+ const DoutPrefixProvider* dpp, rgw::sal::Object* obj, rgw::sal::Object* src_obj,
+ rgw::notify::EventType event_type, rgw::sal::Bucket* _bucket, std::string& _user_id, std::string& _user_tenant,
+ std::string& _req_id, optional_yield y) = 0;
+
+ virtual RGWLC* get_rgwlc(void) = 0;
+ virtual RGWCoroutinesManagerRegistry* get_cr_registry() = 0;
+
+ virtual int log_usage(const DoutPrefixProvider *dpp, std::map<rgw_user_bucket, RGWUsageBatch>& usage_info) = 0;
+ virtual int log_op(const DoutPrefixProvider *dpp, std::string& oid, bufferlist& bl) = 0;
+ virtual int register_to_service_map(const DoutPrefixProvider *dpp, const std::string& daemon_type,
+ const std::map<std::string, std::string>& meta) = 0;
+ virtual void get_quota(RGWQuota& quota) = 0;
+ virtual void get_ratelimit(RGWRateLimitInfo& bucket_ratelimit, RGWRateLimitInfo& user_ratelimit, RGWRateLimitInfo& anon_ratelimit) = 0;
+ virtual int set_buckets_enabled(const DoutPrefixProvider* dpp, std::vector<rgw_bucket>& buckets, bool enabled) = 0;
+ virtual uint64_t get_new_req_id() = 0;
+ virtual int get_sync_policy_handler(const DoutPrefixProvider* dpp,
+ std::optional<rgw_zone_id> zone,
+ std::optional<rgw_bucket> bucket,
+ RGWBucketSyncPolicyHandlerRef* phandler,
+ optional_yield y) = 0;
+ virtual RGWDataSyncStatusManager* get_data_sync_manager(const rgw_zone_id& source_zone) = 0;
+ virtual void wakeup_meta_sync_shards(std::set<int>& shard_ids) = 0;
+ virtual void wakeup_data_sync_shards(const DoutPrefixProvider *dpp, const rgw_zone_id& source_zone, boost::container::flat_map<int, boost::container::flat_set<rgw_data_notify_entry>>& shard_ids) = 0;
+ virtual int clear_usage(const DoutPrefixProvider *dpp) = 0;
+ virtual int read_all_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch,
+ uint32_t max_entries, bool* is_truncated,
+ RGWUsageIter& usage_iter,
+ std::map<rgw_user_bucket, rgw_usage_log_entry>& usage) = 0;
+ virtual int trim_all_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch) = 0;
+ virtual int get_config_key_val(std::string name, bufferlist* bl) = 0;
+ virtual int meta_list_keys_init(const DoutPrefixProvider *dpp, const std::string& section, const std::string& marker, void** phandle) = 0;
+ virtual int meta_list_keys_next(const DoutPrefixProvider *dpp, void* handle, int max, std::list<std::string>& keys, bool* truncated) = 0;
+ virtual void meta_list_keys_complete(void* handle) = 0;
+ virtual std::string meta_get_marker(void* handle) = 0;
+ virtual int meta_remove(const DoutPrefixProvider* dpp, std::string& metadata_key, optional_yield y) = 0;
+ virtual const RGWSyncModuleInstanceRef& get_sync_module() = 0;
+ virtual std::string get_host_id() = 0;
+ virtual std::unique_ptr<LuaScriptManager> get_lua_script_manager() = 0;
+ virtual std::unique_ptr<RGWRole> get_role(std::string name,
+ std::string tenant,
+ std::string path="",
+ std::string trust_policy="",
+ std::string max_session_duration_str="",
+ std::multimap<std::string,std::string> tags={}) = 0;
+ virtual std::unique_ptr<RGWRole> get_role(std::string id) = 0;
+ virtual std::unique_ptr<RGWRole> get_role(const RGWRoleInfo& info) = 0;
+ virtual int get_roles(const DoutPrefixProvider *dpp,
+ optional_yield y,
+ const std::string& path_prefix,
+ const std::string& tenant,
+ std::vector<std::unique_ptr<RGWRole>>& roles) = 0;
+ virtual std::unique_ptr<RGWOIDCProvider> get_oidc_provider() = 0;
+ virtual int get_oidc_providers(const DoutPrefixProvider *dpp,
+ const std::string& tenant,
+ std::vector<std::unique_ptr<RGWOIDCProvider>>& providers) = 0;
+ virtual std::unique_ptr<Writer> get_append_writer(const DoutPrefixProvider *dpp,
+ optional_yield y,
+ std::unique_ptr<rgw::sal::Object> _head_obj,
+ const rgw_user& owner,
+ const rgw_placement_rule *ptail_placement_rule,
+ const std::string& unique_tag,
+ uint64_t position,
+ uint64_t *cur_accounted_size) = 0;
+ virtual std::unique_ptr<Writer> get_atomic_writer(const DoutPrefixProvider *dpp,
+ optional_yield y,
+ std::unique_ptr<rgw::sal::Object> _head_obj,
+ const rgw_user& owner,
+ const rgw_placement_rule *ptail_placement_rule,
+ uint64_t olh_epoch,
+ const std::string& unique_tag) = 0;
+
+ virtual const std::string& get_compression_type(const rgw_placement_rule& rule) = 0;
+ virtual bool valid_placement(const rgw_placement_rule& rule) = 0;
+
+ virtual void finalize(void) = 0;
+
+ virtual CephContext* ctx(void) = 0;
+
+ virtual const std::string& get_luarocks_path() const = 0;
+ virtual void set_luarocks_path(const std::string& path) = 0;
+};
+
+class FilterUser : public User {
+ public:
+ FilterUser() {}
+ virtual ~FilterUser() = default;
+
+ virtual std::unique_ptr<User> clone() = 0;
+ virtual int list_buckets(const DoutPrefixProvider* dpp,
+ const std::string& marker, const std::string& end_marker,
+ uint64_t max, bool need_stats, BucketList& buckets,
+ optional_yield y) = 0;
+ virtual int create_bucket(const DoutPrefixProvider* dpp,
+ const rgw_bucket& b,
+ const std::string& zonegroup_id,
+ rgw_placement_rule& placement_rule,
+ std::string& swift_ver_location,
+ const RGWQuotaInfo* pquota_info,
+ const RGWAccessControlPolicy& policy,
+ Attrs& attrs,
+ RGWBucketInfo& info,
+ obj_version& ep_objv,
+ bool exclusive,
+ bool obj_lock_enabled,
+ bool* existed,
+ req_info& req_info,
+ std::unique_ptr<Bucket>* bucket,
+ optional_yield y) = 0;
+
+ virtual std::string& get_display_name() = 0;
+ virtual const std::string& get_tenant() = 0;
+ virtual void set_tenant(std::string& _t) = 0;
+ virtual const std::string& get_ns() = 0;
+ virtual void set_ns(std::string& _ns) = 0;
+ virtual void clear_ns() = 0;
+ virtual const rgw_user& get_id() const = 0;
+ virtual uint32_t get_type() const = 0;
+ virtual int32_t get_max_buckets() const = 0;
+ virtual const RGWUserCaps& get_caps() const = 0;
+ virtual RGWObjVersionTracker& get_version_tracker() = 0;
+ virtual Attrs& get_attrs() = 0;
+ virtual void set_attrs(Attrs& _attrs) = 0;
+ virtual bool empty() = 0;
+ virtual int read_attrs(const DoutPrefixProvider* dpp, optional_yield y) = 0;
+ virtual int merge_and_store_attrs(const DoutPrefixProvider* dpp, Attrs& new_attrs, optional_yield y) = 0;
+ virtual int read_stats(const DoutPrefixProvider *dpp,
+ const bucket_index_layout_generation& idx_layout,
+ int shard_id, std::string* bucket_ver, std::string* master_ver,
+ std::map<RGWObjCategory, RGWStorageStats>& stats,
+ std::string* max_marker = nullptr,
+ bool* syncstopped = nullptr) = 0;
+ virtual int read_stats_async(const DoutPrefixProvider *dpp,
+ const bucket_index_layout_generation& idx_layout,
+ int shard_id, RGWGetBucketStats_CB* ctx) = 0;
+ virtual int complete_flush_stats(const DoutPrefixProvider *dpp, optional_yield y) = 0;
+ virtual int read_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch,
+ uint64_t end_epoch, uint32_t max_entries,
+ bool* is_truncated, RGWUsageIter& usage_iter,
+ std::map<rgw_user_bucket, rgw_usage_log_entry>& usage) = 0;
+ virtual int trim_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch) = 0;
+
+ virtual int load_user(const DoutPrefixProvider* dpp, optional_yield y) = 0;
+ virtual int store_user(const DoutPrefixProvider* dpp, optional_yield y, bool exclusive, RGWUserInfo* old_info = nullptr) = 0;
+ virtual int remove_user(const DoutPrefixProvider* dpp, optional_yield y) = 0;
+
+ RGWUserInfo& get_info() = 0;
+ virtual void print(std::ostream& out) const = 0;
+};
+
+class FilterBucket : public Bucket {
+ public:
+
+ Bucket() = default;
+ virtual ~Bucket() = default;
+
+ virtual std::unique_ptr<Object> get_object(const rgw_obj_key& key) = 0;
+ virtual int list(const DoutPrefixProvider* dpp, ListParams&, int, ListResults&, optional_yield y) = 0;
+ virtual Attrs& get_attrs(void) = 0;
+ virtual int set_attrs(Attrs a) = 0;
+ virtual int remove_bucket(const DoutPrefixProvider* dpp, bool delete_children, bool forward_to_master, req_info* req_info, optional_yield y) = 0;
+ virtual int remove_bucket_bypass_gc(int concurrent_max, bool
+ keep_index_consistent,
+ optional_yield y, const
+ DoutPrefixProvider *dpp) = 0;
+ virtual RGWAccessControlPolicy& get_acl(void) = 0;
+ virtual int set_acl(const DoutPrefixProvider* dpp, RGWAccessControlPolicy& acl, optional_yield y) = 0;
+
+ virtual void set_owner(rgw::sal::User* _owner) = 0;
+ virtual int load_bucket(const DoutPrefixProvider* dpp, optional_yield y, bool get_stats = false) = 0;
+ virtual int read_stats(const DoutPrefixProvider *dpp, int shard_id,
+ std::string* bucket_ver, std::string* master_ver,
+ std::map<RGWObjCategory, RGWStorageStats>& stats,
+ std::string* max_marker = nullptr,
+ bool* syncstopped = nullptr) = 0;
+ virtual int read_stats_async(const DoutPrefixProvider *dpp, int shard_id, RGWGetBucketStats_CB* ctx) = 0;
+ virtual int sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y) = 0;
+ virtual int update_container_stats(const DoutPrefixProvider* dpp) = 0;
+ virtual int check_bucket_shards(const DoutPrefixProvider* dpp) = 0;
+ virtual int chown(const DoutPrefixProvider* dpp, User* new_user, User* old_user, optional_yield y, const std::string* marker = nullptr) = 0;
+ virtual int put_info(const DoutPrefixProvider* dpp, bool exclusive, ceph::real_time mtime) = 0;
+ virtual bool is_owner(User* user) = 0;
+ virtual User* get_owner(void) = 0;
+ virtual ACLOwner get_acl_owner(void) = 0;
+ virtual int check_empty(const DoutPrefixProvider* dpp, optional_yield y) = 0;
+ virtual int check_quota(const DoutPrefixProvider *dpp, RGWQuota& quota, uint64_t obj_size, optional_yield y, bool check_size_only = false) = 0;
+ virtual int merge_and_store_attrs(const DoutPrefixProvider* dpp, Attrs& new_attrs, optional_yield y) = 0;
+ virtual int try_refresh_info(const DoutPrefixProvider* dpp, ceph::real_time* pmtime) = 0;
+ virtual int read_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries,
+ bool* is_truncated, RGWUsageIter& usage_iter,
+ std::map<rgw_user_bucket, rgw_usage_log_entry>& usage) = 0;
+ virtual int trim_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch) = 0;
+ virtual int remove_objs_from_index(const DoutPrefixProvider *dpp, std::list<rgw_obj_index_key>& objs_to_unlink) = 0;
+ virtual int check_index(const DoutPrefixProvider *dpp, std::map<RGWObjCategory, RGWStorageStats>& existing_stats, std::map<RGWObjCategory, RGWStorageStats>& calculated_stats) = 0;
+ virtual int rebuild_index(const DoutPrefixProvider *dpp) = 0;
+ virtual int set_tag_timeout(const DoutPrefixProvider *dpp, uint64_t timeout) = 0;
+ virtual int purge_instance(const DoutPrefixProvider* dpp) = 0;
+ virtual bool empty() const = 0;
+ virtual const std::string& get_name() const = 0;
+ virtual const std::string& get_tenant() const = 0;
+ virtual const std::string& get_marker() const = 0;
+ virtual const std::string& get_bucket_id() const = 0;
+ virtual size_t get_size() const = 0;
+ virtual size_t get_size_rounded() const = 0;
+ virtual uint64_t get_count() const = 0;
+ virtual rgw_placement_rule& get_placement_rule() = 0;
+ virtual ceph::real_time& get_creation_time() = 0;
+ virtual ceph::real_time& get_modification_time() = 0;
+ virtual obj_version& get_version() = 0;
+ virtual void set_version(obj_version &ver) = 0;
+ virtual bool versioned() = 0;
+ virtual bool versioning_enabled() = 0;
+
+ virtual std::unique_ptr<Bucket> clone() = 0;
+
+ virtual std::unique_ptr<MultipartUpload> get_multipart_upload(
+ const std::string& oid,
+ std::optional<std::string> upload_id=std::nullopt,
+ ACLOwner owner={}, ceph::real_time mtime=real_clock::now()) = 0;
+ virtual int list_multiparts(const DoutPrefixProvider *dpp,
+ const std::string& prefix,
+ std::string& marker,
+ const std::string& delim,
+ const int& max_uploads,
+ std::vector<std::unique_ptr<MultipartUpload>>& uploads,
+ std::map<std::string, bool> *common_prefixes,
+ bool *is_truncated) = 0;
+ virtual int abort_multiparts(const DoutPrefixProvider* dpp,
+ CephContext* cct) = 0;
+
+ virtual rgw_bucket& get_key() = 0;
+ virtual RGWBucketInfo& get_info() = 0;
+
+ virtual void print(std::ostream& out) const = 0;
+
+ virtual bool operator==(const Bucket& b) const = 0;
+ virtual bool operator!=(const Bucket& b) const = 0;
+
+ friend class BucketList;
+};
+
+class FilterObject : public Object {
+ public:
+
+ struct FilterOp : ReadOp {
+ virtual ~FilterOp() = default;
+
+ virtual int prepare(optional_yield y, const DoutPrefixProvider* dpp) = 0;
+ virtual int read(int64_t ofs, int64_t end, bufferlist& bl, optional_yield y, const DoutPrefixProvider* dpp) = 0;
+ virtual int iterate(const DoutPrefixProvider* dpp, int64_t ofs, int64_t end, RGWGetDataCB* cb, optional_yield y) = 0;
+ virtual int get_attr(const DoutPrefixProvider* dpp, const char* name, bufferlist& dest, optional_yield y) = 0;
+ };
+
+ struct FilterOp : DeleteOp {
+ virtual ~FilterOp() = default;
+
+ virtual int delete_obj(const DoutPrefixProvider* dpp, optional_yield y) = 0;
+ };
+
+ FilterObject() {}
+ virtual ~FilterObject() = default;
+
+ virtual int delete_object(const DoutPrefixProvider* dpp,
+ optional_yield y,
+ bool prevent_versioning = false) = 0;
+ virtual int delete_obj_aio(const DoutPrefixProvider* dpp, RGWObjState* astate, Completions* aio,
+ bool keep_index_consistent, optional_yield y) = 0;
+ virtual int copy_object(User* user,
+ req_info* info, const rgw_zone_id& source_zone,
+ rgw::sal::Object* dest_object, rgw::sal::Bucket* dest_bucket,
+ rgw::sal::Bucket* src_bucket,
+ const rgw_placement_rule& dest_placement,
+ ceph::real_time* src_mtime, ceph::real_time* mtime,
+ const ceph::real_time* mod_ptr, const ceph::real_time* unmod_ptr,
+ bool high_precision_time,
+ const char* if_match, const char* if_nomatch,
+ AttrsMod attrs_mod, bool copy_if_newer, Attrs& attrs,
+ RGWObjCategory category, uint64_t olh_epoch,
+ boost::optional<ceph::real_time> delete_at,
+ std::string* version_id, std::string* tag, std::string* etag,
+ void (*progress_cb)(off_t, void *), void* progress_data,
+ const DoutPrefixProvider* dpp, optional_yield y) = 0;
+ virtual RGWAccessControlPolicy& get_acl(void) = 0;
+ virtual int set_acl(const RGWAccessControlPolicy& acl) = 0;
+ virtual void set_atomic() = 0;
+ virtual bool is_atomic() = 0;
+ virtual void set_prefetch_data() = 0;
+ virtual bool is_prefetch_data() = 0;
+ virtual void set_compressed() = 0;
+ virtual bool is_compressed() = 0;
+ virtual void invalidate() = 0;
+ virtual bool empty() const = 0;
+ virtual const std::string &get_name() const = 0;
+
+ virtual int get_obj_state(const DoutPrefixProvider* dpp, RGWObjState **state, optional_yield y, bool follow_olh = true) = 0;
+ virtual int set_obj_attrs(const DoutPrefixProvider* dpp, Attrs* setattrs, Attrs* delattrs, optional_yield y) = 0;
+ virtual int get_obj_attrs(optional_yield y, const DoutPrefixProvider* dpp, rgw_obj* target_obj = NULL) = 0;
+ virtual int modify_obj_attrs(const char* attr_name, bufferlist& attr_val, optional_yield y, const DoutPrefixProvider* dpp) = 0;
+ virtual int delete_obj_attrs(const DoutPrefixProvider* dpp, const char* attr_name, optional_yield y) = 0;
+ virtual bool is_expired() = 0;
+ virtual void gen_rand_obj_instance_name() = 0;
+ virtual MPSerializer* get_serializer(const DoutPrefixProvider *dpp, const std::string& lock_name) = 0;
+ virtual int transition(Bucket* bucket,
+ const rgw_placement_rule& placement_rule,
+ const real_time& mtime,
+ uint64_t olh_epoch,
+ const DoutPrefixProvider* dpp,
+ optional_yield y) = 0;
+ virtual int transition_to_cloud(Bucket* bucket,
+ rgw::sal::PlacementTier* tier,
+ rgw_bucket_dir_entry& o,
+ std::set<std::string>& cloud_targets,
+ CephContext* cct,
+ bool update_object,
+ const DoutPrefixProvider* dpp,
+ optional_yield y) = 0;
+ virtual bool placement_rules_match(rgw_placement_rule& r1, rgw_placement_rule& r2) = 0;
+ virtual int dump_obj_layout(const DoutPrefixProvider *dpp, optional_yield y, Formatter* f) = 0;
+
+ virtual Attrs& get_attrs(void) = 0;
+ virtual const Attrs& get_attrs(void) const = 0;
+ virtual int set_attrs(Attrs a) = 0;
+ virtual bool has_attrs(void) = 0;
+ virtual ceph::real_time get_mtime(void) const = 0;
+ virtual uint64_t get_obj_size(void) const = 0;
+ virtual Bucket* get_bucket(void) const = 0;
+ virtual void set_bucket(Bucket* b) = 0;
+ virtual std::string get_hash_source(void) = 0;
+ virtual void set_hash_source(std::string s) = 0;
+ virtual std::string get_oid(void) const = 0;
+ virtual bool get_delete_marker(void) = 0;
+ virtual bool get_in_extra_data(void) = 0;
+ virtual void set_in_extra_data(bool i) = 0;
+ int range_to_ofs(uint64_t obj_size, int64_t &ofs, int64_t &end);
+ virtual void set_obj_size(uint64_t s) = 0;
+ virtual void set_name(const std::string& n) = 0;
+ virtual void set_key(const rgw_obj_key& k) = 0;
+ virtual rgw_obj get_obj(void) const = 0;
+
+ virtual int swift_versioning_restore(bool& restored, /* out */
+ const DoutPrefixProvider* dpp) = 0;
+ virtual int swift_versioning_copy(const DoutPrefixProvider* dpp,
+ optional_yield y) = 0;
+
+ virtual std::unique_ptr<ReadOp> get_read_op() = 0;
+ virtual std::unique_ptr<DeleteOp> get_delete_op() = 0;
+
+ virtual int omap_get_vals(const DoutPrefixProvider *dpp, const std::string& marker, uint64_t count,
+ std::map<std::string, bufferlist>* m,
+ bool* pmore, optional_yield y) = 0;
+ virtual int omap_get_all(const DoutPrefixProvider *dpp, std::map<std::string, bufferlist>* m,
+ optional_yield y) = 0;
+ virtual int omap_get_vals_by_keys(const DoutPrefixProvider *dpp, const std::string& oid,
+ const std::set<std::string>& keys,
+ Attrs* vals) = 0;
+ virtual int omap_set_val_by_key(const DoutPrefixProvider *dpp, const std::string& key, bufferlist& val,
+ bool must_exist, optional_yield y) = 0;
+
+ virtual std::unique_ptr<Object> clone() = 0;
+
+ virtual rgw_obj_key& get_key() = 0;
+ virtual void set_instance(const std::string &i) = 0;
+ virtual const std::string &get_instance() const = 0;
+ virtual bool have_instance(void) = 0;
+ virtual void clear_instance() = 0;
+
+ virtual void print(std::ostream& out) const = 0;
+};
+
+class FilterMultipartPart : public MultipartPart {
+public:
+ FilterMultipartPart() = default;
+ virtual ~FilterMultipartPart() = default;
+
+ virtual uint32_t get_num() = 0;
+ virtual uint64_t get_size() = 0;
+ virtual const std::string& get_etag() = 0;
+ virtual ceph::real_time& get_mtime() = 0;
+};
+
+class FilterMultipartUpload : public MultipartUpload {
+public:
+ FilterMultipartUpload() = default;
+ virtual ~FilterMultipartUpload() = default;
+
+ virtual const std::string& get_meta() const = 0;
+ virtual const std::string& get_key() const = 0;
+ virtual const std::string& get_upload_id() const = 0;
+ virtual const ACLOwner& get_owner() const = 0;
+ virtual ceph::real_time& get_mtime() = 0;
+
+ virtual std::map<uint32_t, std::unique_ptr<MultipartPart>>& get_parts() = 0;
+
+ virtual const jspan_context& get_trace() = 0;
+
+ virtual std::unique_ptr<rgw::sal::Object> get_meta_obj() = 0;
+
+ virtual int init(const DoutPrefixProvider* dpp, optional_yield y, ACLOwner& owner, rgw_placement_rule& dest_placement, rgw::sal::Attrs& attrs) = 0;
+ virtual int list_parts(const DoutPrefixProvider* dpp, CephContext* cct,
+ int num_parts, int marker,
+ int* next_marker, bool* truncated,
+ bool assume_unsorted = false) = 0;
+ virtual int abort(const DoutPrefixProvider* dpp, CephContext* cct) = 0;
+ virtual int complete(const DoutPrefixProvider* dpp,
+ optional_yield y, CephContext* cct,
+ std::map<int, std::string>& part_etags,
+ std::list<rgw_obj_index_key>& remove_objs,
+ uint64_t& accounted_size, bool& compressed,
+ RGWCompressionInfo& cs_info, off_t& ofs,
+ std::string& tag, ACLOwner& owner,
+ uint64_t olh_epoch,
+ rgw::sal::Object* target_obj) = 0;
+
+ virtual int get_info(const DoutPrefixProvider *dpp, optional_yield y, rgw_placement_rule** rule, rgw::sal::Attrs* attrs = nullptr) = 0;
+
+ virtual std::unique_ptr<Writer> get_writer(const DoutPrefixProvider *dpp,
+ optional_yield y,
+ std::unique_ptr<rgw::sal::Object> _head_obj,
+ const rgw_user& owner,
+ const rgw_placement_rule *ptail_placement_rule,
+ uint64_t part_num,
+ const std::string& part_num_str) = 0;
+ virtual void print(std::ostream& out) const = 0;
+};
+
+class FilterMPSerializer : public MPSerializer {
+public:
+ FilterMPSerializer() = default;
+ virtual ~FilterMPSerializer() = default;
+
+ virtual void clear_locked() = 0;
+};
+
+class FilterLCSerializer : public LCSerializer {
+public:
+ FilterLCSerializer() {}
+ virtual ~FilterLCSerializer() = default;
+};
+
+class FilterLifecycle : public Lifecycle {
+public:
+ struct FilterLCHead : LCHead {
+ FilterLCHead() = default;
+ virtual ~FilterLCHead() = 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;
+ };
+
+ struct FilterLCEntry : LCEntry {
+ FilterLCEntry() = default;
+ virtual ~FilterLCEntry() = 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;
+ };
+
+ FilterLifecycle() = default;
+ virtual ~FilterLifecycle() = default;
+
+ virtual std::unique_ptr<LCEntry> get_entry() = 0;
+ virtual int get_entry(const std::string& oid, const std::string& marker, std::unique_ptr<LCEntry>* entry) = 0;
+ virtual int get_next_entry(const std::string& oid, const std::string& marker, std::unique_ptr<LCEntry>* entry) = 0;
+ virtual int set_entry(const std::string& oid, LCEntry& entry) = 0;
+ virtual int list_entries(const std::string& oid, const std::string& marker,
+ uint32_t max_entries,
+ std::vector<std::unique_ptr<LCEntry>>& entries) = 0;
+ virtual int rm_entry(const std::string& oid, LCEntry& entry) = 0;
+ virtual int get_head(const std::string& oid, std::unique_ptr<LCHead>* head) = 0;
+ virtual int put_head(const std::string& oid, LCHead& head) = 0;
+ virtual LCSerializer* get_serializer(const std::string& lock_name, const std::string& oid, const std::string& cookie) = 0;
+};
+
+class FilterNotification : public Notification {
+protected:
+ Object* obj;
+ Object* src_obj;
+ rgw::notify::EventType event_type;
+
+ public:
+ FilterNotification(Object* _obj, Object* _src_obj, rgw::notify::EventType _type)
+ : obj(_obj), src_obj(_src_obj), event_type(_type)
+ {}
+
+ virtual ~FilterNotification() = default;
+
+ virtual int publish_reserve(const DoutPrefixProvider *dpp, RGWObjTags* obj_tags = nullptr) = 0;
+ virtual int publish_commit(const DoutPrefixProvider* dpp, uint64_t size,
+ const ceph::real_time& mtime, const std::string& etag, const std::string& version) = 0;
+};
+
+class FilterWriter : public Writer {
+public:
+ FilterWriter() {}
+ virtual ~FilterWriter() = default;
+
+ virtual int prepare(optional_yield y) = 0;
+ virtual int process(bufferlist&& data, uint64_t offset) = 0;
+ virtual int complete(size_t accounted_size, const std::string& etag,
+ ceph::real_time *mtime, ceph::real_time set_mtime,
+ std::map<std::string, bufferlist>& attrs,
+ ceph::real_time delete_at,
+ const char *if_match, const char *if_nomatch,
+ const std::string *user_data,
+ rgw_zone_set *zones_trace, bool *canceled,
+ optional_yield y) = 0;
+};
+
+class FilterPlacementTier : public PlacementTier {
+public:
+ virtual ~FilterPlacementTier() = default;
+
+ virtual const std::string& get_tier_type() = 0;
+ virtual const std::string& get_storage_class() = 0;
+ virtual bool retain_head_object() = 0;
+};
+
+class FilterZoneGroup : public ZoneGroup {
+public:
+ virtual ~FilterZoneGroup() = default;
+ virtual const std::string& get_id() const = 0;
+ virtual const std::string& get_name() const = 0;
+ virtual int equals(const std::string& other_zonegroup) const = 0;
+ virtual const std::string& get_endpoint() const = 0;
+ virtual bool placement_target_exists(std::string& target) const = 0;
+ virtual bool is_master_zonegroup() const = 0;
+ virtual const std::string& get_api_name() const = 0;
+ virtual int get_placement_target_names(std::set<std::string>& names) const = 0;
+ virtual const std::string& get_default_placement_name() const = 0;
+ virtual int get_hostnames(std::list<std::string>& names) const = 0;
+ virtual int get_s3website_hostnames(std::list<std::string>& names) const = 0;
+ virtual int get_zone_count() const = 0;
+ virtual int get_placement_tier(const rgw_placement_rule& rule, std::unique_ptr<PlacementTier>* tier) = 0;
+};
+
+class FilterZone : public Zone {
+ public:
+ virtual ~FilterZone() = default;
+
+ virtual ZoneGroup& get_zonegroup() = 0;
+ virtual int get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>* zonegroup) = 0;
+ virtual const rgw_zone_id& get_id() = 0;
+ virtual const std::string& get_name() const = 0;
+ virtual bool is_writeable() = 0;
+ virtual bool get_redirect_endpoint(std::string* endpoint) = 0;
+ virtual bool has_zonegroup_api(const std::string& api) const = 0;
+ virtual const std::string& get_current_period_id() = 0;
+ virtual const RGWAccessKey& get_system_key() = 0;
+ virtual const std::string& get_realm_name() = 0;
+ virtual const std::string& get_realm_id() = 0;
+};
+
+class FilterLuaScriptManager : public LuaScriptManager {
+public:
+ virtual ~FilterLuaScriptManager() = default;
+
+ virtual int get(const DoutPrefixProvider* dpp, optional_yield y, const std::string& key, std::string& script) = 0;
+ virtual int put(const DoutPrefixProvider* dpp, optional_yield y, const std::string& key, const std::string& script) = 0;
+ virtual int del(const DoutPrefixProvider* dpp, optional_yield y, const std::string& key) = 0;
+};
+
+} } // namespace rgw::sal
const rgw_placement_rule *_ptail_placement_rule,
uint64_t _olh_epoch,
const std::string& _unique_tag) :
- Writer(dpp, y),
+ StoreWriter(dpp, y),
store(_store),
owner(_owner),
ptail_placement_rule(_ptail_placement_rule),
#pragma clang diagnostic pop
}
-#include "rgw_sal.h"
+#include "rgw_sal_store.h"
#include "rgw_rados.h"
#include "rgw_notify.h"
#include "rgw_oidc_provider.h"
};
WRITE_CLASS_ENCODER(MotrUserInfo);
-class MotrNotification : public Notification {
+class MotrNotification : public StoreNotification {
public:
MotrNotification(Object* _obj, Object* _src_obj, rgw::notify::EventType _type) :
- Notification(_obj, _src_obj, _type) {}
+ StoreNotification(_obj, _src_obj, _type) {}
~MotrNotification() = default;
virtual int publish_reserve(const DoutPrefixProvider *dpp, RGWObjTags* obj_tags = nullptr) override { return 0;}
const ceph::real_time& mtime, const std::string& etag, const std::string& version) override { return 0; }
};
-class MotrUser : public User {
+class MotrUser : public StoreUser {
private:
MotrStore *store;
struct m0_uint128 idxID = {0xe5ecb53640d4ecce, 0x6a156cd5a74aa3b8}; // MD5 of “motr.rgw.users“
struct m0_idx idx;
public:
- MotrUser(MotrStore *_st, const rgw_user& _u) : User(_u), store(_st) { }
- MotrUser(MotrStore *_st, const RGWUserInfo& _i) : User(_i), store(_st) { }
+ MotrUser(MotrStore *_st, const rgw_user& _u) : StoreUser(_u), store(_st) { }
+ MotrUser(MotrStore *_st, const RGWUserInfo& _i) : StoreUser(_i), store(_st) { }
MotrUser(MotrStore *_st) : store(_st) { }
MotrUser(MotrUser& _o) = default;
MotrUser() {}
friend class MotrBucket;
};
-class MotrBucket : public Bucket {
+class MotrBucket : public StoreBucket {
private:
MotrStore *store;
RGWAccessControlPolicy acls;
}
MotrBucket(MotrStore *_st, User* _u)
- : Bucket(_u),
+ : StoreBucket(_u),
store(_st),
acls() {
}
MotrBucket(MotrStore *_st, const rgw_bucket& _b)
- : Bucket(_b),
+ : StoreBucket(_b),
store(_st),
acls() {
}
MotrBucket(MotrStore *_st, const RGWBucketEnt& _e)
- : Bucket(_e),
+ : StoreBucket(_e),
store(_st),
acls() {
}
MotrBucket(MotrStore *_st, const RGWBucketInfo& _i)
- : Bucket(_i),
+ : StoreBucket(_i),
store(_st),
acls() {
}
MotrBucket(MotrStore *_st, const rgw_bucket& _b, User* _u)
- : Bucket(_b, _u),
+ : StoreBucket(_b, _u),
store(_st),
acls() {
}
MotrBucket(MotrStore *_st, const RGWBucketEnt& _e, User* _u)
- : Bucket(_e, _u),
+ : StoreBucket(_e, _u),
store(_st),
acls() {
}
MotrBucket(MotrStore *_st, const RGWBucketInfo& _i, User* _u)
- : Bucket(_i, _u),
+ : StoreBucket(_i, _u),
store(_st),
acls() {
}
friend class MotrStore;
};
-class MotrPlacementTier: public PlacementTier {
+class MotrPlacementTier: public StorePlacementTier {
MotrStore* store;
RGWZoneGroupPlacementTier tier;
public:
RGWZoneGroupPlacementTier& get_rt() { return tier; }
};
-class MotrZoneGroup : public ZoneGroup {
+class MotrZoneGroup : public StoreZoneGroup {
MotrStore* store;
const RGWZoneGroup group;
std::string empty;
const RGWZoneGroup& get_group() { return group; }
};
-class MotrZone : public Zone {
+class MotrZone : public StoreZone {
protected:
MotrStore* store;
RGWRealm *realm{nullptr};
friend class MotrStore;
};
-class MotrLuaScriptManager : public LuaScriptManager {
+class MotrLuaScriptManager : public StoreLuaScriptManager {
MotrStore* store;
public:
}
};
-class MotrObject : public Object {
+class MotrObject : public StoreObject {
private:
MotrStore *store;
RGWAccessControlPolicy acls;
MotrObject() = default;
MotrObject(MotrStore *_st, const rgw_obj_key& _k)
- : Object(_k), store(_st), acls() {}
+ : StoreObject(_k), store(_st), acls() {}
MotrObject(MotrStore *_st, const rgw_obj_key& _k, Bucket* _b)
- : Object(_k, _b), store(_st), acls() {}
+ : StoreObject(_k, _b), store(_st), acls() {}
MotrObject(MotrObject& _o) = default;
// A placeholder locking class for multipart upload.
// TODO: implement it using Motr object locks.
-class MPMotrSerializer : public MPSerializer {
+class MPMotrSerializer : public StoreMPSerializer {
public:
MPMotrSerializer(const DoutPrefixProvider *dpp, MotrStore* store, MotrObject* obj, const std::string& lock_name) {}
virtual int unlock() override { return 0;}
};
-class MotrAtomicWriter : public Writer {
+class MotrAtomicWriter : public StoreWriter {
protected:
rgw::sal::MotrStore* store;
const rgw_user& owner;
void cleanup();
};
-class MotrMultipartWriter : public Writer {
+class MotrMultipartWriter : public StoreWriter {
protected:
rgw::sal::MotrStore* store;
const rgw_user& owner,
const rgw_placement_rule *ptail_placement_rule,
uint64_t _part_num, const std::string& part_num_str) :
- Writer(dpp, y), store(_store), head_obj(std::move(_head_obj)),
+ StoreWriter(dpp, y), store(_store), head_obj(std::move(_head_obj)),
part_num(_part_num), part_num_str(part_num_str)
{
}
//
//
-class MotrMultipartPart : public MultipartPart {
+class MotrMultipartPart : public StoreMultipartPart {
protected:
RGWUploadPartInfo info;
friend class MotrMultipartUpload;
};
-class MotrMultipartUpload : public MultipartUpload {
+class MotrMultipartUpload : public StoreMultipartUpload {
MotrStore* store;
RGWMPObj mp_obj;
ACLOwner owner;
public:
MotrMultipartUpload(MotrStore* _store, Bucket* _bucket, const std::string& oid,
std::optional<std::string> upload_id, ACLOwner _owner, ceph::real_time _mtime) :
- MultipartUpload(_bucket), store(_store), mp_obj(oid, upload_id), owner(_owner), mtime(_mtime) {}
+ StoreMultipartUpload(_bucket), store(_store), mp_obj(oid, upload_id), owner(_owner), mtime(_mtime) {}
virtual ~MotrMultipartUpload() = default;
virtual const std::string& get_meta() const { return mp_obj.get_meta(); }
int delete_parts(const DoutPrefixProvider *dpp);
};
-class MotrStore : public Store {
+class MotrStore : public StoreStore {
private:
std::string luarocks_path;
MotrZone zone;
}
LCRadosSerializer::LCRadosSerializer(RadosStore* store, const std::string& _oid, const std::string& lock_name, const std::string& cookie) :
- lock(lock_name), oid(_oid)
+ StoreLCSerializer(_oid),
+ lock(lock_name)
{
ioctx = &store->getRados()->lc_pool_ctx;
lock.set_cookie(cookie);
}
int RadosLifecycle::get_entry(const std::string& oid, const std::string& marker,
- LCEntry& entry)
+ std::unique_ptr<LCEntry>* entry)
{
cls_rgw_lc_entry cls_entry;
int ret = cls_rgw_lc_get_entry(*store->getRados()->get_lc_pool_ctx(), oid, marker, cls_entry);
+ if (ret)
+ return ret;
- entry.bucket = cls_entry.bucket;
- entry.start_time = cls_entry.start_time;
- entry.status = cls_entry.status;
+ LCEntry* e;
+ e = new StoreLCEntry(cls_entry.bucket, cls_entry.start_time, cls_entry.status);
+ if (!e)
+ return -ENOMEM;
- return ret;
+ entry->reset(e);
+ return 0;
}
-int RadosLifecycle::get_next_entry(const std::string& oid, std::string& marker,
- LCEntry& entry)
+int RadosLifecycle::get_next_entry(const std::string& oid, const std::string& marker,
+ std::unique_ptr<LCEntry>* entry)
{
cls_rgw_lc_entry cls_entry;
int ret = cls_rgw_lc_get_next_entry(*store->getRados()->get_lc_pool_ctx(), oid, marker,
cls_entry);
- entry.bucket = cls_entry.bucket;
- entry.start_time = cls_entry.start_time;
- entry.status = cls_entry.status;
+ if (ret)
+ return ret;
- return ret;
+ LCEntry* e;
+ e = new StoreLCEntry(cls_entry.bucket, cls_entry.start_time, cls_entry.status);
+ if (!e)
+ return -ENOMEM;
+
+ entry->reset(e);
+ return 0;
}
-int RadosLifecycle::set_entry(const std::string& oid, const LCEntry& entry)
+int RadosLifecycle::set_entry(const std::string& oid, LCEntry& entry)
{
cls_rgw_lc_entry cls_entry;
- cls_entry.bucket = entry.bucket;
- cls_entry.start_time = entry.start_time;
- cls_entry.status = entry.status;
+ cls_entry.bucket = entry.get_bucket();
+ cls_entry.start_time = entry.get_start_time();
+ cls_entry.status = entry.get_status();
return cls_rgw_lc_set_entry(*store->getRados()->get_lc_pool_ctx(), oid, cls_entry);
}
int RadosLifecycle::list_entries(const std::string& oid, const std::string& marker,
- uint32_t max_entries, vector<LCEntry>& entries)
+ uint32_t max_entries, std::vector<std::unique_ptr<LCEntry>>& entries)
{
entries.clear();
return ret;
for (auto& entry : cls_entries) {
- entries.push_back(LCEntry(entry.bucket, oid, entry.start_time,
- entry.status));
+ entries.push_back(std::make_unique<StoreLCEntry>(entry.bucket, oid,
+ entry.start_time, entry.status));
}
return ret;
}
-int RadosLifecycle::rm_entry(const std::string& oid, const LCEntry& entry)
+int RadosLifecycle::rm_entry(const std::string& oid, LCEntry& entry)
{
cls_rgw_lc_entry cls_entry;
- cls_entry.bucket = entry.bucket;
- cls_entry.start_time = entry.start_time;
- cls_entry.status = entry.status;
+ cls_entry.bucket = entry.get_bucket();
+ cls_entry.start_time = entry.get_start_time();
+ cls_entry.status = entry.get_status();
return cls_rgw_lc_rm_entry(*store->getRados()->get_lc_pool_ctx(), oid, cls_entry);
}
-int RadosLifecycle::get_head(const std::string& oid, LCHead& head)
+int RadosLifecycle::get_head(const std::string& oid, std::unique_ptr<LCHead>* head)
{
cls_rgw_lc_obj_head cls_head;
int ret = cls_rgw_lc_get_head(*store->getRados()->get_lc_pool_ctx(), oid, cls_head);
+ if (ret)
+ return ret;
- head.marker = cls_head.marker;
- head.start_date = cls_head.start_date;
- head.shard_rollover_date = cls_head.shard_rollover_date;
+ LCHead* h;
+ h = new StoreLCHead(cls_head.start_date, cls_head.shard_rollover_date, cls_head.marker);
+ if (!h)
+ return -ENOMEM;
- return ret;
+ head->reset(h);
+ return 0;
}
-int RadosLifecycle::put_head(const std::string& oid, const LCHead& head)
+int RadosLifecycle::put_head(const std::string& oid, LCHead& head)
{
cls_rgw_lc_obj_head cls_head;
- cls_head.marker = head.marker;
- cls_head.start_date = head.start_date;
- cls_head.shard_rollover_date = head.shard_rollover_date;
+ cls_head.marker = head.get_marker();
+ cls_head.start_date = head.get_start_date();
+ cls_head.shard_rollover_date = head.get_shard_rollover_date();
return cls_rgw_lc_put_head(*store->getRados()->get_lc_pool_ctx(), oid, cls_head);
}
#pragma once
-#include "rgw_sal.h"
+#include "rgw_sal_store.h"
#include "rgw_rados.h"
#include "rgw_notify.h"
#include "rgw_oidc_provider.h"
virtual int drain() override;
};
-class RadosPlacementTier: public PlacementTier {
+class RadosPlacementTier: public StorePlacementTier {
RadosStore* store;
RGWZoneGroupPlacementTier tier;
public:
RGWZoneGroupPlacementTier& get_rt() { return tier; }
};
-class RadosZoneGroup : public ZoneGroup {
+class RadosZoneGroup : public StoreZoneGroup {
RadosStore* store;
const RGWZoneGroup group;
std::string empty;
const RGWZoneGroup& get_group() const { return group; }
};
-class RadosZone : public Zone {
+class RadosZone : public StoreZone {
protected:
RadosStore* store;
RadosZoneGroup group;
virtual const std::string& get_realm_id() override;
};
-class RadosStore : public Store {
+class RadosStore : public StoreStore {
private:
RGWRados* rados;
RGWUserCtl* user_ctl;
void setUserCtl(RGWUserCtl *_ctl) { user_ctl = _ctl; }
};
-class RadosUser : public User {
+class RadosUser : public StoreUser {
private:
RadosStore* store;
public:
- RadosUser(RadosStore *_st, const rgw_user& _u) : User(_u), store(_st) { }
- RadosUser(RadosStore *_st, const RGWUserInfo& _i) : User(_i), store(_st) { }
+ RadosUser(RadosStore *_st, const rgw_user& _u) : StoreUser(_u), store(_st) { }
+ RadosUser(RadosStore *_st, const RGWUserInfo& _i) : StoreUser(_i), store(_st) { }
RadosUser(RadosStore *_st) : store(_st) { }
RadosUser(RadosUser& _o) = default;
RadosUser() {}
friend class RadosBucket;
};
-class RadosObject : public Object {
+class RadosObject : public StoreObject {
private:
RadosStore* store;
RGWAccessControlPolicy acls;
RadosObject() = default;
RadosObject(RadosStore *_st, const rgw_obj_key& _k)
- : Object(_k),
+ : StoreObject(_k),
store(_st),
acls(),
rados_ctx(new RGWObjectCtx(dynamic_cast<Store*>(store))),
rados_ctx_owned(true) {
}
RadosObject(RadosStore *_st, const rgw_obj_key& _k, Bucket* _b)
- : Object(_k, _b),
+ : StoreObject(_k, _b),
store(_st),
acls(),
rados_ctx(new RGWObjectCtx(dynamic_cast<Store*>(store))) ,
rados_ctx_owned(true) {
}
- RadosObject(RadosObject& _o) : Object(_o) {
+ RadosObject(RadosObject& _o) : StoreObject(_o) {
store = _o.store;
acls = _o.acls;
manifest = _o.manifest;
virtual int set_acl(const RGWAccessControlPolicy& acl) override { acls = acl; return 0; }
virtual void set_atomic() override {
rados_ctx->set_atomic(state.obj);
- Object::set_atomic();
+ StoreObject::set_atomic();
}
virtual void set_prefetch_data() override {
rados_ctx->set_prefetch_data(state.obj);
- Object::set_prefetch_data();
+ StoreObject::set_prefetch_data();
}
virtual void set_compressed() override {
rados_ctx->set_compressed(state.obj);
- Object::set_compressed();
+ StoreObject::set_compressed();
}
virtual int get_obj_state(const DoutPrefixProvider* dpp, RGWObjState **state, optional_yield y, bool follow_olh = true) override;
int read_attrs(const DoutPrefixProvider* dpp, RGWRados::Object::Read &read_op, optional_yield y, rgw_obj* target_obj = nullptr);
};
-class RadosBucket : public Bucket {
+class RadosBucket : public StoreBucket {
private:
RadosStore* store;
RGWAccessControlPolicy acls;
}
RadosBucket(RadosStore *_st, User* _u)
- : Bucket(_u),
+ : StoreBucket(_u),
store(_st),
acls() {
}
RadosBucket(RadosStore *_st, const rgw_bucket& _b)
- : Bucket(_b),
+ : StoreBucket(_b),
store(_st),
acls() {
}
RadosBucket(RadosStore *_st, const RGWBucketEnt& _e)
- : Bucket(_e),
+ : StoreBucket(_e),
store(_st),
acls() {
}
RadosBucket(RadosStore *_st, const RGWBucketInfo& _i)
- : Bucket(_i),
+ : StoreBucket(_i),
store(_st),
acls() {
}
RadosBucket(RadosStore *_st, const rgw_bucket& _b, User* _u)
- : Bucket(_b, _u),
+ : StoreBucket(_b, _u),
store(_st),
acls() {
}
RadosBucket(RadosStore *_st, const RGWBucketEnt& _e, User* _u)
- : Bucket(_e, _u),
+ : StoreBucket(_e, _u),
store(_st),
acls() {
}
RadosBucket(RadosStore *_st, const RGWBucketInfo& _i, User* _u)
- : Bucket(_i, _u),
+ : StoreBucket(_i, _u),
store(_st),
acls() {
}
friend class RadosUser;
};
-class RadosMultipartPart : public MultipartPart {
+class RadosMultipartPart : public StoreMultipartPart {
protected:
RGWUploadPartInfo info;
friend class RadosMultipartUpload;
};
-class RadosMultipartUpload : public MultipartUpload {
+class RadosMultipartUpload : public StoreMultipartUpload {
RadosStore* store;
RGWMPObj mp_obj;
ACLOwner owner;
RadosMultipartUpload(RadosStore* _store, Bucket* _bucket, const std::string& oid,
std::optional<std::string> upload_id, ACLOwner owner,
ceph::real_time _mtime)
- : MultipartUpload(_bucket), store(_store), mp_obj(oid, upload_id),
+ : StoreMultipartUpload(_bucket), store(_store), mp_obj(oid, upload_id),
owner(owner), mtime(_mtime) {}
virtual ~RadosMultipartUpload() = default;
const std::string& part_num_str) override;
};
-class MPRadosSerializer : public MPSerializer {
+class MPRadosSerializer : public StoreMPSerializer {
librados::IoCtx ioctx;
rados::cls::lock::Lock lock;
librados::ObjectWriteOperation op;
}
};
-class LCRadosSerializer : public LCSerializer {
+class LCRadosSerializer : public StoreLCSerializer {
librados::IoCtx* ioctx;
rados::cls::lock::Lock lock;
- const std::string oid;
public:
LCRadosSerializer(RadosStore* store, const std::string& oid, const std::string& lock_name, const std::string& cookie);
}
};
-class RadosLifecycle : public Lifecycle {
+class RadosLifecycle : public StoreLifecycle {
RadosStore* store;
public:
RadosLifecycle(RadosStore* _st) : store(_st) {}
- virtual int get_entry(const std::string& oid, const std::string& marker, LCEntry& entry) override;
- virtual int get_next_entry(const std::string& oid, std::string& marker, LCEntry& entry) override;
- virtual int set_entry(const std::string& oid, const LCEntry& entry) override;
+ using StoreLifecycle::get_entry;
+ virtual int get_entry(const std::string& oid, const std::string& marker, std::unique_ptr<LCEntry>* entry) override;
+ virtual int get_next_entry(const std::string& oid, const std::string& marker, std::unique_ptr<LCEntry>* entry) override;
+ virtual int set_entry(const std::string& oid, LCEntry& entry) override;
virtual int list_entries(const std::string& oid, const std::string& marker,
- uint32_t max_entries, std::vector<LCEntry>& entries) override;
- virtual int rm_entry(const std::string& oid, const LCEntry& entry) override;
- virtual int get_head(const std::string& oid, LCHead& head) override;
- virtual int put_head(const std::string& oid, const LCHead& head) override;
+ uint32_t max_entries,
+ std::vector<std::unique_ptr<LCEntry>>& entries) override;
+ virtual int rm_entry(const std::string& oid, LCEntry& entry) override;
+ virtual int get_head(const std::string& oid, std::unique_ptr<LCHead>* head) override;
+ virtual int put_head(const std::string& oid, LCHead& head) override;
virtual LCSerializer* get_serializer(const std::string& lock_name, const std::string& oid, const std::string& cookie) override;
};
-class RadosNotification : public Notification {
+class RadosNotification : public StoreNotification {
RadosStore* store;
/* XXX it feels incorrect to me that rgw::notify::reservation_t is
* currently RADOS-specific; instead, I think notification types such as
public:
RadosNotification(const DoutPrefixProvider* _dpp, RadosStore* _store, Object* _obj, Object* _src_obj, req_state* _s, rgw::notify::EventType _type, const std::string* object_name=nullptr) :
- Notification(_obj, _src_obj, _type), store(_store), res(_dpp, _store, _s, _obj, _src_obj, object_name) { }
+ StoreNotification(_obj, _src_obj, _type), store(_store), res(_dpp, _store, _s, _obj, _src_obj, object_name) { }
RadosNotification(const DoutPrefixProvider* _dpp, RadosStore* _store, Object* _obj, Object* _src_obj, rgw::notify::EventType _type, rgw::sal::Bucket* _bucket, std::string& _user_id, std::string& _user_tenant, std::string& _req_id, optional_yield y) :
- Notification(_obj, _src_obj, _type), store(_store), res(_dpp, _store, _obj, _src_obj, _bucket, _user_id, _user_tenant, _req_id, y) {}
+ StoreNotification(_obj, _src_obj, _type), store(_store), res(_dpp, _store, _obj, _src_obj, _bucket, _user_id, _user_tenant, _req_id, y) {}
~RadosNotification() = default;
const ceph::real_time& mtime, const std::string& etag, const std::string& version) override;
};
-class RadosAtomicWriter : public Writer {
+class RadosAtomicWriter : public StoreWriter {
protected:
rgw::sal::RadosStore* store;
std::unique_ptr<Aio> aio;
const rgw_placement_rule *ptail_placement_rule,
uint64_t olh_epoch,
const std::string& unique_tag) :
- Writer(dpp, y),
+ StoreWriter(dpp, y),
store(_store),
aio(std::move(_aio)),
obj_ctx(&dynamic_cast<RadosObject*>(_head_obj.get())->get_ctx()),
optional_yield y) override;
};
-class RadosAppendWriter : public Writer {
+class RadosAppendWriter : public StoreWriter {
protected:
rgw::sal::RadosStore* store;
std::unique_ptr<Aio> aio;
const std::string& unique_tag,
uint64_t position,
uint64_t *cur_accounted_size) :
- Writer(dpp, y),
+ StoreWriter(dpp, y),
store(_store),
aio(std::move(_aio)),
obj_ctx(&dynamic_cast<RadosObject*>(_head_obj.get())->get_ctx()),
optional_yield y) override;
};
-class RadosMultipartWriter : public Writer {
+class RadosMultipartWriter : public StoreWriter {
protected:
rgw::sal::RadosStore* store;
std::unique_ptr<Aio> aio;
const rgw_user& owner,
const rgw_placement_rule *ptail_placement_rule,
uint64_t part_num, const std::string& part_num_str) :
- Writer(dpp, y),
+ StoreWriter(dpp, y),
store(_store),
aio(std::move(_aio)),
obj_ctx(&dynamic_cast<RadosObject*>(_head_obj.get())->get_ctx()),
optional_yield y) override;
};
-class RadosLuaScriptManager : public LuaScriptManager {
+class RadosLuaScriptManager : public StoreLuaScriptManager {
RadosStore* store;
rgw_pool pool;
--- /dev/null
+// -*- 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) 2022 Red Hat, Inc.
+ *
+ * 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_sal.h"
+
+namespace rgw { namespace sal {
+
+class StoreStore : public Store {
+ public:
+ StoreStore() {}
+ virtual ~StoreStore() = default;
+
+ virtual uint64_t get_new_req_id() override {
+ return ceph::util::generate_random_number<uint64_t>();
+ }
+};
+
+class StoreUser : public User {
+ protected:
+ RGWUserInfo info;
+ RGWObjVersionTracker objv_tracker;
+ Attrs attrs;
+
+ public:
+ StoreUser() : info() {}
+ StoreUser(const rgw_user& _u) : info() { info.user_id = _u; }
+ StoreUser(const RGWUserInfo& _i) : info(_i) {}
+ StoreUser(StoreUser& _o) = default;
+ virtual ~StoreUser() = default;
+
+ virtual std::string& get_display_name() override { return info.display_name; }
+ virtual const std::string& get_tenant() override { return info.user_id.tenant; }
+ virtual void set_tenant(std::string& _t) override { info.user_id.tenant = _t; }
+ virtual const std::string& get_ns() override { return info.user_id.ns; }
+ virtual void set_ns(std::string& _ns) override { info.user_id.ns = _ns; }
+ virtual void clear_ns() override { info.user_id.ns.clear(); }
+ virtual const rgw_user& get_id() const override { return info.user_id; }
+ virtual uint32_t get_type() const override { return info.type; }
+ virtual int32_t get_max_buckets() const override { return info.max_buckets; }
+ virtual const RGWUserCaps& get_caps() const override { return info.caps; }
+ virtual RGWObjVersionTracker& get_version_tracker() override { return objv_tracker; }
+ virtual Attrs& get_attrs() override { return attrs; }
+ virtual void set_attrs(Attrs& _attrs) override { attrs = _attrs; }
+ virtual bool empty() override { return info.user_id.id.empty(); }
+ virtual RGWUserInfo& get_info() override { return info; }
+ virtual void print(std::ostream& out) const override { out << info.user_id; }
+
+ friend class StoreBucket;
+};
+
+class StoreBucket : public Bucket {
+ protected:
+ RGWBucketEnt ent;
+ RGWBucketInfo info;
+ User* owner = nullptr;
+ Attrs attrs;
+ obj_version bucket_version;
+ ceph::real_time mtime;
+
+ public:
+
+ StoreBucket() = default;
+ StoreBucket(User* _u) :
+ owner(_u) { }
+ StoreBucket(const rgw_bucket& _b) { ent.bucket = _b; info.bucket = _b; }
+ StoreBucket(const RGWBucketEnt& _e) : ent(_e) {
+ info.bucket = ent.bucket;
+ info.placement_rule = ent.placement_rule;
+ info.creation_time = ent.creation_time;
+ }
+ StoreBucket(const RGWBucketInfo& _i) : info(_i) {
+ ent.bucket = info.bucket;
+ ent.placement_rule = info.placement_rule;
+ ent.creation_time = info.creation_time;
+ }
+ StoreBucket(const rgw_bucket& _b, User* _u) :
+ owner(_u) { ent.bucket = _b; info.bucket = _b; }
+ StoreBucket(const RGWBucketEnt& _e, User* _u) : ent(_e), owner(_u) {
+ info.bucket = ent.bucket;
+ info.placement_rule = ent.placement_rule;
+ info.creation_time = ent.creation_time;
+ }
+ StoreBucket(const RGWBucketInfo& _i, User* _u) : info(_i), owner(_u) {
+ ent.bucket = info.bucket;
+ ent.placement_rule = info.placement_rule;
+ ent.creation_time = info.creation_time;
+ }
+ virtual ~StoreBucket() = default;
+
+ virtual Attrs& get_attrs(void) override { return attrs; }
+ virtual int set_attrs(Attrs a) override { attrs = a; return 0; }
+ virtual void set_owner(rgw::sal::User* _owner) override {
+ owner = _owner;
+ }
+ virtual User* get_owner(void) override { return owner; };
+ virtual ACLOwner get_acl_owner(void) override { return ACLOwner(info.owner); };
+ virtual bool empty() const override { return info.bucket.name.empty(); }
+ virtual const std::string& get_name() const override { return info.bucket.name; }
+ virtual const std::string& get_tenant() const override { return info.bucket.tenant; }
+ virtual const std::string& get_marker() const override { return info.bucket.marker; }
+ virtual const std::string& get_bucket_id() const override { return info.bucket.bucket_id; }
+ virtual size_t get_size() const override { return ent.size; }
+ virtual size_t get_size_rounded() const override { return ent.size_rounded; }
+ virtual uint64_t get_count() const override { return ent.count; }
+ virtual rgw_placement_rule& get_placement_rule() override { return info.placement_rule; }
+ virtual ceph::real_time& get_creation_time() override { return info.creation_time; }
+ virtual ceph::real_time& get_modification_time() override { return mtime; }
+ virtual obj_version& get_version() override { return bucket_version; }
+ virtual void set_version(obj_version &ver) override { bucket_version = ver; }
+ virtual bool versioned() override { return info.versioned(); }
+ virtual bool versioning_enabled() override { return info.versioning_enabled(); }
+ virtual rgw_bucket& get_key() override { return info.bucket; }
+ virtual RGWBucketInfo& get_info() override { return info; }
+ virtual void print(std::ostream& out) const override { out << info.bucket; }
+ virtual bool operator==(const Bucket& b) const override {
+ if (typeid(*this) != typeid(b)) {
+ return false;
+ }
+ const StoreBucket& sb = dynamic_cast<const StoreBucket&>(b);
+
+ return (info.bucket.tenant == sb.info.bucket.tenant) &&
+ (info.bucket.name == sb.info.bucket.name) &&
+ (info.bucket.bucket_id == sb.info.bucket.bucket_id);
+ }
+ virtual bool operator!=(const Bucket& b) const override {
+ if (typeid(*this) != typeid(b)) {
+ return false;
+ }
+ const StoreBucket& sb = dynamic_cast<const StoreBucket&>(b);
+
+ return (info.bucket.tenant != sb.info.bucket.tenant) ||
+ (info.bucket.name != sb.info.bucket.name) ||
+ (info.bucket.bucket_id != sb.info.bucket.bucket_id);
+ }
+
+ friend class BucketList;
+ protected:
+ virtual void set_ent(RGWBucketEnt& _ent) { ent = _ent; info.bucket = ent.bucket; info.placement_rule = ent.placement_rule; }
+};
+
+class StoreObject : public Object {
+ protected:
+ RGWObjState state;
+ Bucket* bucket;
+ Attrs attrs;
+ bool delete_marker{false};
+
+ public:
+
+ struct StoreReadOp : ReadOp {
+ virtual ~StoreReadOp() = default;
+ };
+
+ struct StoreDeleteOp : DeleteOp {
+ virtual ~StoreDeleteOp() = default;
+ };
+
+ StoreObject()
+ : state(),
+ bucket(nullptr),
+ attrs()
+ {}
+ StoreObject(const rgw_obj_key& _k)
+ : state(),
+ bucket(),
+ attrs()
+ { state.obj.key = _k; }
+ StoreObject(const rgw_obj_key& _k, Bucket* _b)
+ : state(),
+ bucket(_b),
+ attrs()
+ { state.obj.init(_b->get_key(), _k); }
+ StoreObject(StoreObject& _o) = default;
+
+ virtual ~StoreObject() = default;
+
+ virtual void set_atomic() override { state.is_atomic = true; }
+ virtual bool is_atomic() override { return state.is_atomic; }
+ virtual void set_prefetch_data() override { state.prefetch_data = true; }
+ virtual bool is_prefetch_data() override { return state.prefetch_data; }
+ virtual void set_compressed() override { state.compressed = true; }
+ virtual bool is_compressed() override { return state.compressed; }
+ virtual void invalidate() override {
+ rgw_obj obj = state.obj;
+ bool is_atomic = state.is_atomic;
+ bool prefetch_data = state.prefetch_data;
+ bool compressed = state.compressed;
+
+ state = RGWObjState();
+ state.obj = obj;
+ state.is_atomic = is_atomic;
+ state.prefetch_data = prefetch_data;
+ state.compressed = compressed;
+ }
+
+ virtual bool empty() const override { return state.obj.empty(); }
+ virtual const std::string &get_name() const override { return state.obj.key.name; }
+ virtual Attrs& get_attrs(void) override { return state.attrset; }
+ virtual const Attrs& get_attrs(void) const override { return state.attrset; }
+ virtual int set_attrs(Attrs a) override { state.attrset = a; state.has_attrs = true; return 0; }
+ virtual bool has_attrs(void) override { return state.has_attrs; }
+ virtual ceph::real_time get_mtime(void) const override { return state.mtime; }
+ virtual uint64_t get_obj_size(void) const override { return state.size; }
+ virtual Bucket* get_bucket(void) const override { return bucket; }
+ virtual void set_bucket(Bucket* b) override { bucket = b; state.obj.bucket = b->get_key(); }
+ virtual std::string get_hash_source(void) override { return state.obj.index_hash_source; }
+ virtual void set_hash_source(std::string s) override { state.obj.index_hash_source = s; }
+ virtual std::string get_oid(void) const override { return state.obj.key.get_oid(); }
+ virtual bool get_delete_marker(void) override { return delete_marker; }
+ virtual bool get_in_extra_data(void) override { return state.obj.is_in_extra_data(); }
+ virtual void set_in_extra_data(bool i) override { state.obj.set_in_extra_data(i); }
+ int range_to_ofs(uint64_t obj_size, int64_t &ofs, int64_t &end);
+ virtual void set_obj_size(uint64_t s) override { state.size = s; }
+ virtual void set_name(const std::string& n) override { state.obj.key = n; }
+ virtual void set_key(const rgw_obj_key& k) override { state.obj.key = k; }
+ virtual rgw_obj get_obj(void) const override { return state.obj; }
+ virtual rgw_obj_key& get_key() override { return state.obj.key; }
+ virtual void set_instance(const std::string &i) override { state.obj.key.set_instance(i); }
+ virtual const std::string &get_instance() const override { return state.obj.key.instance; }
+ virtual bool have_instance(void) override { return state.obj.key.have_instance(); }
+ virtual void clear_instance() override { state.obj.key.instance.clear(); }
+
+ virtual void print(std::ostream& out) const override {
+ if (bucket)
+ out << bucket << ":";
+ out << state.obj.key;
+ }
+};
+
+class StoreMultipartPart : public MultipartPart {
+ protected:
+ std::string oid;
+public:
+ StoreMultipartPart() = default;
+ virtual ~StoreMultipartPart() = default;
+};
+
+class StoreMultipartUpload : public MultipartUpload {
+protected:
+ Bucket* bucket;
+ std::map<uint32_t, std::unique_ptr<MultipartPart>> parts;
+ jspan_context trace_ctx{false, false};
+public:
+ StoreMultipartUpload(Bucket* _bucket) : bucket(_bucket) {}
+ virtual ~StoreMultipartUpload() = default;
+
+ virtual std::map<uint32_t, std::unique_ptr<MultipartPart>>& get_parts() override { return parts; }
+
+ virtual const jspan_context& get_trace() override { return trace_ctx; }
+
+ virtual void print(std::ostream& out) const override {
+ out << get_meta();
+ if (!get_upload_id().empty())
+ out << ":" << get_upload_id();
+ }
+};
+
+class StoreMPSerializer : public MPSerializer {
+protected:
+ bool locked;
+ std::string oid;
+public:
+ StoreMPSerializer() : locked(false) {}
+ StoreMPSerializer(std::string _oid) : locked(false), oid(_oid) {}
+ virtual ~StoreMPSerializer() = default;
+
+ virtual void clear_locked() override {
+ locked = false;
+ }
+ virtual bool is_locked() override { return locked; }
+
+ virtual void print(std::ostream& out) const override { out << oid; }
+};
+
+class StoreLCSerializer : public LCSerializer {
+protected:
+ std::string oid;
+public:
+ StoreLCSerializer() {}
+ StoreLCSerializer(std::string _oid) : oid(_oid) {}
+ virtual ~StoreLCSerializer() = default;
+
+ 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;
+ Object* src_obj;
+ rgw::notify::EventType event_type;
+
+ public:
+ StoreNotification(Object* _obj, Object* _src_obj, rgw::notify::EventType _type)
+ : obj(_obj), src_obj(_src_obj), event_type(_type)
+ {}
+
+ virtual ~StoreNotification() = default;
+};
+
+class StoreWriter : public Writer {
+protected:
+ const DoutPrefixProvider* dpp;
+
+public:
+ StoreWriter(const DoutPrefixProvider *_dpp, optional_yield y) : dpp(_dpp) {}
+ virtual ~StoreWriter() = default;
+
+};
+
+class StorePlacementTier : public PlacementTier {
+public:
+ virtual ~StorePlacementTier() = default;
+};
+
+class StoreZoneGroup : public ZoneGroup {
+public:
+ virtual ~StoreZoneGroup() = default;
+};
+
+class StoreZone : public Zone {
+ public:
+ virtual ~StoreZone() = default;
+};
+
+class StoreLuaScriptManager : public LuaScriptManager {
+public:
+ virtual ~StoreLuaScriptManager() = default;
+};
+
+} } // namespace rgw::sal
}
int DB::get_entry(const std::string& oid, const std::string& marker,
- rgw::sal::Lifecycle::LCEntry& entry)
+ std::unique_ptr<rgw::sal::Lifecycle::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.bucket = marker;
+ params.op.lc_entry.entry.set_bucket(marker);
params.op.query_str = "get_entry";
ret = ProcessOp(dpp, "GetLCEntry", ¶ms);
goto out;
}
- if (!params.op.lc_entry.entry.start_time == 0) { //ensure entry found
- entry = params.op.lc_entry.entry;
+ 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);
}
out:
return ret;
}
-int DB::get_next_entry(const std::string& oid, std::string& marker,
- rgw::sal::Lifecycle::LCEntry& entry)
+int DB::get_next_entry(const std::string& oid, const std::string& marker,
+ std::unique_ptr<rgw::sal::Lifecycle::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.bucket = marker;
+ params.op.lc_entry.entry.set_bucket(marker);
params.op.query_str = "get_next_entry";
ret = ProcessOp(dpp, "GetLCEntry", ¶ms);
goto out;
}
- if (!params.op.lc_entry.entry.start_time == 0) { //ensure entry found
- entry = params.op.lc_entry.entry;
+ 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);
}
out:
return ret;
}
-int DB::set_entry(const std::string& oid, const rgw::sal::Lifecycle::LCEntry& entry)
+int DB::set_entry(const std::string& oid, rgw::sal::Lifecycle::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, vector<rgw::sal::Lifecycle::LCEntry>& entries)
+ uint32_t max_entries, std::vector<std::unique_ptr<rgw::sal::Lifecycle::LCEntry>>& entries)
{
int ret = 0;
const DoutPrefixProvider *dpp = get_def_dpp();
}
for (auto& entry : params.op.lc_entry.list_entries) {
- entries.push_back(std::move(entry));
+ entries.push_back(std::make_unique<rgw::sal::StoreLifecycle::StoreLCEntry>(std::move(entry)));
}
out:
return ret;
}
-int DB::rm_entry(const std::string& oid, const rgw::sal::Lifecycle::LCEntry& entry)
+int DB::rm_entry(const std::string& oid, rgw::sal::Lifecycle::LCEntry& entry)
{
int ret = 0;
const DoutPrefixProvider *dpp = get_def_dpp();
return ret;
}
-int DB::get_head(const std::string& oid, rgw::sal::Lifecycle::LCHead& head)
+int DB::get_head(const std::string& oid, std::unique_ptr<rgw::sal::Lifecycle::LCHead>* head)
{
int ret = 0;
const DoutPrefixProvider *dpp = get_def_dpp();
goto out;
}
- head = params.op.lc_head.head;
+ *head = std::make_unique<rgw::sal::StoreLifecycle::StoreLCHead>(params.op.lc_head.head);
out:
return ret;
}
-int DB::put_head(const std::string& oid, const rgw::sal::Lifecycle::LCHead& head)
+int DB::put_head(const std::string& oid, rgw::sal::Lifecycle::LCHead& head)
{
int ret = 0;
const DoutPrefixProvider *dpp = get_def_dpp();
#define FMT_HEADER_ONLY 1
#include "fmt/format.h"
#include <map>
-#include "rgw/rgw_sal.h"
+#include "rgw/rgw_sal_store.h"
#include "rgw/rgw_common.h"
#include "rgw/rgw_bucket.h"
#include "global/global_context.h"
struct DBOpLCHeadInfo {
std::string index;
- rgw::sal::Lifecycle::LCHead head;
+ rgw::sal::StoreLifecycle::StoreLCHead head;
};
struct DBOpLCEntryInfo {
std::string index;
- rgw::sal::Lifecycle::LCEntry entry;
+ rgw::sal::StoreLifecycle::StoreLCEntry entry;
// used for list query
std::string min_marker;
- std::list<rgw::sal::Lifecycle::LCEntry> list_entries;
+ std::list<rgw::sal::StoreLifecycle::StoreLCEntry> list_entries;
};
struct DBOpInfo {
RGWObjState *astate, void *arg);
int get_entry(const std::string& oid, const std::string& marker,
- rgw::sal::Lifecycle::LCEntry& entry);
- int get_next_entry(const std::string& oid, std::string& marker,
- rgw::sal::Lifecycle::LCEntry& entry);
- int set_entry(const std::string& oid, const rgw::sal::Lifecycle::LCEntry& entry);
+ std::unique_ptr<rgw::sal::Lifecycle::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);
int list_entries(const std::string& oid, const std::string& marker,
- uint32_t max_entries, std::vector<rgw::sal::Lifecycle::LCEntry>& entries);
- int rm_entry(const std::string& oid, const rgw::sal::Lifecycle::LCEntry& entry);
- int get_head(const std::string& oid, rgw::sal::Lifecycle::LCHead& head);
- int put_head(const std::string& oid, const rgw::sal::Lifecycle::LCHead& head);
+ 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);
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.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.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.list_entries.push_back(op.lc_entry.entry);
return -1;
op.lc_head.index = (const char*)sqlite3_column_text(stmt, LCHeadIndex);
- op.lc_head.head.marker = (const char*)sqlite3_column_text(stmt, LCHeadMarker);
+ op.lc_head.head.set_marker((const char*)sqlite3_column_text(stmt, LCHeadMarker));
- SQL_DECODE_BLOB_PARAM(dpp, stmt, LCHeadStartDate, op.lc_head.head.start_date, sdb);
+ SQL_DECODE_BLOB_PARAM(dpp, stmt, LCHeadStartDate, op.lc_head.head.get_start_date(), sdb);
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.bucket.c_str(), sdb);
+ SQL_BIND_TEXT(dpp, stmt, index, params->op.lc_entry.entry.get_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.status, sdb);
+ SQL_BIND_INT(dpp, stmt, index, params->op.lc_entry.entry.get_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.start_time, sdb);
+ SQL_BIND_INT(dpp, stmt, index, params->op.lc_entry.entry.get_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.bucket.c_str(), sdb);
+ SQL_BIND_TEXT(dpp, stmt, index, params->op.lc_entry.entry.get_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.bucket.c_str(), sdb);
+ SQL_BIND_TEXT(dpp, *pstmt, index, params->op.lc_entry.entry.get_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.marker.c_str(), sdb);
+ SQL_BIND_TEXT(dpp, stmt, index, params->op.lc_head.head.get_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, params->op.lc_head.head.start_date, sdb);
+ SQL_ENCODE_BLOB_PARAM(dpp, stmt, index, params->op.lc_head.head.get_start_date(), sdb);
out:
return rc;
std::string index1 = "bucket1";
std::string index2 = "bucket2";
time_t lc_time = ceph_clock_now();
- rgw::sal::Lifecycle::LCHead head;
+ std::unique_ptr<rgw::sal::Lifecycle::LCHead> head;
std::string ents[] = {"entry1", "entry2", "entry3"};
- rgw::sal::Lifecycle::LCHead head1 = {lc_time, ents[0]};
- rgw::sal::Lifecycle::LCHead head2 = {lc_time, ents[1]};
- rgw::sal::Lifecycle::LCHead head3 = {lc_time, ents[2]};
+ 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]);
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.marker, "entry1");
+ ASSERT_EQ(head->get_marker(), "entry1");
- ret = db->get_head(index2, head);
+ ret = db->get_head(index2, &head);
ASSERT_EQ(ret, 0);
- ASSERT_EQ(head.marker, "entry2");
+ ASSERT_EQ(head->get_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.marker, "entry3");
+ ASSERT_EQ(head->get_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"};
- rgw::sal::Lifecycle::LCEntry entry;
- rgw::sal::Lifecycle::LCEntry entry1 = {ents[0], lc_time, lc_uninitial};
- rgw::sal::Lifecycle::LCEntry entry2 = {ents[1], lc_time, lc_uninitial};
- rgw::sal::Lifecycle::LCEntry entry3 = {ents[2], lc_time, lc_uninitial};
- rgw::sal::Lifecycle::LCEntry entry4 = {ents[3], lc_time, lc_uninitial};
+ 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);
- vector<rgw::sal::Lifecycle::LCEntry> lc_entries;
+ vector<std::unique_ptr<rgw::sal::Lifecycle::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.status, lc_uninitial);
- ASSERT_EQ(entry.start_time, lc_time);
+ ASSERT_EQ(entry->get_status(), lc_uninitial);
+ ASSERT_EQ(entry->get_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.bucket, ents[2]);
- ASSERT_EQ(entry.status, lc_uninitial);
- ASSERT_EQ(entry.start_time, lc_time);
+ ASSERT_EQ(entry->get_bucket(), ents[2]);
+ ASSERT_EQ(entry->get_status(), lc_uninitial);
+ ASSERT_EQ(entry->get_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.status, lc_complete);
+ ASSERT_EQ(entry->get_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.bucket << "\n";
- cout << "lc entry.status : " << ent.status << "\n";
+ cout << "lc entry.bucket : " << ent->get_bucket() << "\n";
+ cout << "lc entry.status : " << ent->get_status() << "\n";
}
// remove index1, entry3
ASSERT_EQ(ret, 0);
// get next entry index1, entry2.. should be null
- entry = {};
- ret = db->get_next_entry(index1, ents[1], entry);
+ entry.release();
+ ret = db->get_next_entry(index1, ents[1], &entry);
ASSERT_EQ(ret, 0);
- ASSERT_EQ(entry.start_time, 0);
+ ASSERT_EQ(entry.get(), nullptr);
}
TEST_F(DBStoreTest, RemoveBucket) {
}
};
-class TestUser : public sal::User {
+class TestUser : public sal::StoreUser {
public:
virtual std::unique_ptr<User> clone() override {
return std::unique_ptr<User>(new TestUser(*this));