}
-void cls_rgw_bucket_instance_entry::generate_test_instances(list<cls_rgw_bucket_instance_entry*>& ls)
+void cls_rgw_bucket_instance_entry::generate_test_instances(
+ list<cls_rgw_bucket_instance_entry*>& ls)
{
ls.push_back(new cls_rgw_bucket_instance_entry);
ls.push_back(new cls_rgw_bucket_instance_entry);
- ls.back()->reshard_status = CLS_RGW_RESHARD_IN_PROGRESS;
+ ls.back()->reshard_status = RESHARD_STATUS::IN_PROGRESS;
ls.back()->new_bucket_instance_id = "new_instance_id";
}
};
WRITE_CLASS_ENCODER(rgw_bucket_category_stats)
-enum cls_rgw_reshard_status {
- CLS_RGW_RESHARD_NOT_RESHARDING = 0,
- CLS_RGW_RESHARD_IN_PROGRESS = 1,
- CLS_RGW_RESHARD_DONE = 2,
+enum class cls_rgw_reshard_status : uint8_t {
+ NOT_RESHARDING = 0,
+ IN_PROGRESS = 1,
+ DONE = 2
};
-static inline std::string to_string(const enum cls_rgw_reshard_status status)
+static inline std::string to_string(const cls_rgw_reshard_status status)
{
switch (status) {
- case CLS_RGW_RESHARD_NOT_RESHARDING:
+ case cls_rgw_reshard_status::NOT_RESHARDING:
return "not-resharding";
break;
- case CLS_RGW_RESHARD_IN_PROGRESS:
+ case cls_rgw_reshard_status::IN_PROGRESS:
return "in-progress";
break;
- case CLS_RGW_RESHARD_DONE:
+ case cls_rgw_reshard_status::DONE:
return "done";
break;
- default:
- break;
};
return "Unknown reshard status";
}
struct cls_rgw_bucket_instance_entry {
- cls_rgw_reshard_status reshard_status{CLS_RGW_RESHARD_NOT_RESHARDING};
+ using RESHARD_STATUS = cls_rgw_reshard_status;
+
+ cls_rgw_reshard_status reshard_status{RESHARD_STATUS::NOT_RESHARDING};
string new_bucket_instance_id;
int32_t num_shards{-1};
static void generate_test_instances(list<cls_rgw_bucket_instance_entry*>& o);
void clear() {
- reshard_status = CLS_RGW_RESHARD_NOT_RESHARDING;
+ reshard_status = RESHARD_STATUS::NOT_RESHARDING;
new_bucket_instance_id.clear();
}
- void set_status(const string& new_instance_id, int32_t new_num_shards, cls_rgw_reshard_status s) {
+ void set_status(const string& new_instance_id,
+ int32_t new_num_shards,
+ cls_rgw_reshard_status s) {
reshard_status = s;
new_bucket_instance_id = new_instance_id;
num_shards = new_num_shards;
}
bool resharding() const {
- return reshard_status != CLS_RGW_RESHARD_NOT_RESHARDING;
+ return reshard_status != RESHARD_STATUS::NOT_RESHARDING;
}
bool resharding_in_progress() const {
- return reshard_status == CLS_RGW_RESHARD_IN_PROGRESS;
+ return reshard_status == RESHARD_STATUS::IN_PROGRESS;
}
};
WRITE_CLASS_ENCODER(cls_rgw_bucket_instance_entry)
return ret;
}
- if (bucket_info.reshard_status != CLS_RGW_RESHARD_NOT_RESHARDING) {
+ if (bucket_info.reshard_status != cls_rgw_reshard_status::NOT_RESHARDING) {
// if in_progress or done then we have an old BucketInfo
cerr << "ERROR: the bucket is currently undergoing resharding and "
"cannot be added to the reshard list at this time" << std::endl;
<< cpp_strerror(-r) << dendl;
continue;
}
- if (binfo.reshard_status == CLS_RGW_RESHARD_DONE)
+ if (binfo.reshard_status == cls_rgw_reshard_status::DONE)
stale_instances.emplace_back(std::move(binfo));
else {
other_instances.emplace_back(std::move(binfo));
}
// Don't process further in this round if bucket is resharding
- if (cur_bucket_info.reshard_status == CLS_RGW_RESHARD_IN_PROGRESS)
+ if (cur_bucket_info.reshard_status == cls_rgw_reshard_status::IN_PROGRESS)
return;
other_instances.erase(std::remove_if(other_instances.begin(), other_instances.end(),
RGWQuotaInfo quota;
// Represents the number of bucket index object shards:
- // - value of 0 indicates there is no sharding (this is by default before this
- // feature is implemented).
+ // - value of 0 indicates there is no sharding (this is by default
+ // before this feature is implemented).
// - value of UINT32_T::MAX indicates this is a blind bucket.
uint32_t num_shards{0};
map<string, uint32_t> mdsearch_config;
-
-
- /* resharding */
- uint8_t reshard_status{0};
+ // resharding
+ cls_rgw_reshard_status reshard_status{cls_rgw_reshard_status::NOT_RESHARDING};
string new_bucket_instance_id;
RGWObjectLock obj_lock;
return 0;
}
- if (cur_bucket_info.reshard_status == CLS_RGW_RESHARD_IN_PROGRESS) {
+ if (cur_bucket_info.reshard_status == cls_rgw_reshard_status::IN_PROGRESS) {
ldout(store->ctx(), 0) << __func__ << ": reshard in progress. Skipping "
<< orphan_bucket.name << ": "
<< orphan_bucket.bucket_id << dendl;
int ret = set_resharding_status(store, bucket_info,
bucket_info.bucket.bucket_id,
(num_shards < 1 ? 1 : num_shards),
- CLS_RGW_RESHARD_NOT_RESHARDING);
+ cls_rgw_reshard_status::NOT_RESHARDING);
if (ret < 0) {
ldout(store->ctx(), 0) << "RGWBucketReshard::" << __func__ <<
" ERROR: error clearing reshard status from index shard " <<
new_bucket_info.objv_tracker.clear();
new_bucket_info.new_bucket_instance_id.clear();
- new_bucket_info.reshard_status = 0;
+ new_bucket_info.reshard_status = cls_rgw_reshard_status::NOT_RESHARDING;
int ret = store->svc()->bi->init_index(new_bucket_info);
if (ret < 0) {
" clear_index_shard_status returned " << ret << dendl;
}
bucket_info.new_bucket_instance_id.clear();
- set_status(CLS_RGW_RESHARD_NOT_RESHARDING); // clears new_bucket_instance as well
+
+ // clears new_bucket_instance as well
+ set_status(cls_rgw_reshard_status::NOT_RESHARDING);
}
}
int start() {
- int ret = set_status(CLS_RGW_RESHARD_IN_PROGRESS);
+ int ret = set_status(cls_rgw_reshard_status::IN_PROGRESS);
if (ret < 0) {
return ret;
}
}
int complete() {
- int ret = set_status(CLS_RGW_RESHARD_DONE);
+ int ret = set_status(cls_rgw_reshard_status::DONE);
if (ret < 0) {
return ret;
}
// set resharding status of current bucket_info & shards with
// information about planned resharding
ret = set_resharding_status(new_bucket_info.bucket.bucket_id,
- num_shards, CLS_RGW_RESHARD_IN_PROGRESS);
+ num_shards, cls_rgw_reshard_status::IN_PROGRESS);
if (ret < 0) {
goto error_out;
}