return ret;
}
-const string resharding_attr = "resharding";
-
static int rgw_set_bucket_resharding(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
{
cls_rgw_set_bucket_resharding_op op;
return rc;
}
- header.is_resharding = true;
- header.new_bucket_instance_id = op.entry.new_bucket_instance_id;
+ header.new_instance.set(op.entry.new_bucket_instance_id);
return write_bucket_header(hctx, &header);
}
CLS_LOG(1, "ERROR: %s(): failed to read header\n", __func__);
return rc;
}
- header.is_resharding = false;
- header.new_bucket_instance_id.clear();
+ header.new_instance.clear();
return write_bucket_header(hctx, &header);
}
}
cls_rgw_get_bucket_resharding_ret op_ret;
- op_ret.resharding = header.is_resharding;
+ op_ret.new_instance = header.new_instance;
::encode(op_ret, *out);
rgw_clear_bucket_resharding, &h_rgw_clear_bucket_resharding);
cls_register_cxx_method(h_class, "get_bucket_resharding", CLS_METHOD_RD ,
rgw_get_bucket_resharding, &h_rgw_get_bucket_resharding);
+
return;
}
return io_ctx.exec(oid, "rgw", "set_bucket_resharding", in, out);
}
-int cls_rgw_clear_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
- const cls_rgw_bucket_instance_entry& entry)
+int cls_rgw_clear_bucket_resharding(librados::IoCtx& io_ctx, const string& oid)
{
bufferlist in, out;
struct cls_rgw_clear_bucket_resharding_op call;
- call.entry = entry;
::encode(call, in);
return io_ctx.exec(oid, "rgw", "clear_bucket_resharding", in, out);
}
int cls_rgw_get_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
- const cls_rgw_bucket_instance_entry& entry, bool& resharding)
+ cls_rgw_bucket_instance_entry *entry)
{
bufferlist in, out;
struct cls_rgw_get_bucket_resharding_op call;
- call.entry = entry;
::encode(call, in);
int r= io_ctx.exec(oid, "rgw", "get_bucket_resharding", in, out);
if (r < 0)
return -EIO;
}
- resharding = op_ret.resharding;
+ *entry = op_ret.new_instance;
return 0;
}
/* resharding attribute */
int cls_rgw_set_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
const cls_rgw_bucket_instance_entry& entry);
-int cls_rgw_clear_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
- const cls_rgw_bucket_instance_entry& entry);
+int cls_rgw_clear_bucket_resharding(librados::IoCtx& io_ctx, const string& oid);
int cls_rgw_get_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
- const cls_rgw_bucket_instance_entry& entry, bool& resharding);
+ cls_rgw_bucket_instance_entry *entry);
#endif
void cls_rgw_clear_bucket_resharding_op::dump(Formatter *f) const
{
- ::encode_json("entry", entry, f);
}
void cls_rgw_get_bucket_resharding_op::generate_test_instances(
void cls_rgw_get_bucket_resharding_op::dump(Formatter *f) const
{
- ::encode_json("entry", entry, f);
}
WRITE_CLASS_ENCODER(cls_rgw_set_bucket_resharding_op)
struct cls_rgw_clear_bucket_resharding_op {
- cls_rgw_bucket_instance_entry entry;
-
void encode(bufferlist& bl) const {
ENCODE_START(1, 1, bl);
- ::encode(entry, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator& bl) {
DECODE_START(1, bl);
- ::decode(entry, bl);
DECODE_FINISH(bl);
}
static void generate_test_instances(list<cls_rgw_clear_bucket_resharding_op*>& o);
WRITE_CLASS_ENCODER(cls_rgw_clear_bucket_resharding_op)
struct cls_rgw_get_bucket_resharding_op {
- cls_rgw_bucket_instance_entry entry;
void encode(bufferlist& bl) const {
ENCODE_START(1, 1, bl);
- ::encode(entry, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator& bl) {
DECODE_START(1, bl);
- ::decode(entry, bl);
DECODE_FINISH(bl);
}
WRITE_CLASS_ENCODER(cls_rgw_get_bucket_resharding_op)
struct cls_rgw_get_bucket_resharding_ret {
- bool resharding;
+ cls_rgw_bucket_instance_entry new_instance;
void encode(bufferlist& bl) const {
ENCODE_START(1, 1, bl);
- ::encode(resharding, bl);
+ ::encode(new_instance, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator& bl) {
DECODE_START(1, bl);
- ::decode(resharding, bl);
+ ::decode(new_instance, bl);
DECODE_FINISH(bl);
}
iter->second.dump(f);
f->close_section();
}
- f->dump_bool("is_resharding", is_resharding);
- f->dump_string("new_bucket_instance_id",new_bucket_instance_id);
+ ::encode_json("new_instance", new_instance, f);
f->close_section();
}
void cls_rgw_bucket_instance_entry::dump(Formatter *f) const
{
- encode_json("data", data, f);
encode_json("resharding", resharding, f);
encode_json("new_bucket_instance_id", new_bucket_instance_id, f);
};
WRITE_CLASS_ENCODER(rgw_bucket_category_stats)
+struct cls_rgw_bucket_instance_entry {
+ bool resharding{false};
+ string new_bucket_instance_id;
+
+ void encode(bufferlist& bl) const {
+ ENCODE_START(1, 1, bl);
+ ::encode(resharding, bl);
+ ::encode(new_bucket_instance_id, bl);
+ ENCODE_FINISH(bl);
+ }
+
+ void decode(bufferlist::iterator& bl) {
+ DECODE_START(1, bl);
+ ::decode(resharding, bl);
+ ::decode(new_bucket_instance_id, bl);
+ DECODE_FINISH(bl);
+ }
+
+ void dump(Formatter *f) const;
+ static void generate_test_instances(list<cls_rgw_bucket_instance_entry*>& o);
+
+ void clear() {
+ resharding = false;
+ new_bucket_instance_id.clear();
+ }
+
+ void set(const string& new_instance_id) {
+ resharding = true;
+ new_bucket_instance_id = new_instance_id;
+ }
+};
+WRITE_CLASS_ENCODER(cls_rgw_bucket_instance_entry)
+
struct rgw_bucket_dir_header {
map<uint8_t, rgw_bucket_category_stats> stats;
uint64_t tag_timeout;
uint64_t ver;
uint64_t master_ver;
string max_marker;
- bool is_resharding;
- string new_bucket_instance_id;
+ cls_rgw_bucket_instance_entry new_instance;
rgw_bucket_dir_header() : tag_timeout(0), ver(0), master_ver(0) {}
::encode(ver, bl);
::encode(master_ver, bl);
::encode(max_marker, bl);
- ::encode(is_resharding, bl);
- ::encode(new_bucket_instance_id, bl);
+ ::encode(new_instance, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator &bl) {
::decode(max_marker, bl);
}
if (struct_v >= 6) {
- ::decode(is_resharding, bl);
- ::decode(new_bucket_instance_id, bl);
+ ::decode(new_instance, bl);
} else {
- is_resharding = false;
+ new_instance = cls_rgw_bucket_instance_entry();
}
DECODE_FINISH(bl);
}
void dump(Formatter *f) const;
static void generate_test_instances(list<rgw_bucket_dir_header*>& o);
+
+ bool resharding() const {
+ return new_instance.resharding;
+ }
};
WRITE_CLASS_ENCODER(rgw_bucket_dir_header)
};
WRITE_CLASS_ENCODER(cls_rgw_reshard_entry)
-struct cls_rgw_bucket_instance_entry {
- bool resharding;
- string new_bucket_instance_id;
- bufferlist data;
-
- void encode(bufferlist& bl) const {
- ENCODE_START(1, 1, bl);
- ::encode(resharding, bl);
- ::encode(new_bucket_instance_id, bl);
- ::encode(data, bl);
- ENCODE_FINISH(bl);
- }
-
- void decode(bufferlist::iterator& bl) {
- DECODE_START(1, bl);
- ::decode(resharding, bl);
- ::decode(new_bucket_instance_id, bl);
- ::decode(data, bl);
- DECODE_FINISH(bl);
- }
-
- void dump(Formatter *f) const;
- static void generate_test_instances(list<cls_rgw_bucket_instance_entry*>& o);
-};
-WRITE_CLASS_ENCODER(cls_rgw_bucket_instance_entry)
-
#endif