return 0;
}
-
-static int rgw_reshard_get_head(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
-{
- bufferlist bl;
- int ret = cls_cxx_map_read_header(hctx, &bl);
- if (ret < 0)
- return ret;
- cls_rgw_reshard_entry entry;
- if (bl.length() != 0) {
- bufferlist::iterator iter = bl.begin();
- try {
- ::decode(entry, iter);
- } catch (buffer::error& err) {
- CLS_LOG(0, "ERROR: rgw_reshard_get_head(): failed to decode entry %s\n",err.what());
- return -EINVAL;
- }
- }
-
- cls_rgw_reshard_get_head_ret op_ret;
- op_ret.entry = entry;
- ::encode(op_ret, *out);
- return 0;
-}
-
static int rgw_reshard_get(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
{
bufferlist::iterator in_iter = in->begin();
cls_method_handle_t h_rgw_reshard_add;
cls_method_handle_t h_rgw_reshard_list;
cls_method_handle_t h_rgw_reshard_get;
- cls_method_handle_t h_rgw_reshard_get_head;
cls_method_handle_t h_rgw_reshard_remove;
cls_method_handle_t h_rgw_set_bucket_resharding;
cls_method_handle_t h_rgw_clear_bucket_resharding;
cls_register_cxx_method(h_class, "reshard_add", CLS_METHOD_RD | CLS_METHOD_WR, rgw_reshard_add, &h_rgw_reshard_add);
cls_register_cxx_method(h_class, "reshard_list", CLS_METHOD_RD, rgw_reshard_list, &h_rgw_reshard_list);
cls_register_cxx_method(h_class, "reshard_get", CLS_METHOD_RD,rgw_reshard_get, &h_rgw_reshard_get);
- cls_register_cxx_method(h_class, "reshard_get_head", CLS_METHOD_RD, rgw_reshard_get_head, &h_rgw_reshard_get_head);
cls_register_cxx_method(h_class, "reshard_remove", CLS_METHOD_RD | CLS_METHOD_WR, rgw_reshard_remove, &h_rgw_reshard_remove);
cls_register_cxx_method(h_class, "set_bucket_resharding", CLS_METHOD_RD | CLS_METHOD_WR,
rgw_set_bucket_resharding, &h_rgw_set_bucket_resharding);
return 0;
}
-int cls_rgw_reshard_get_head(librados::IoCtx& io_ctx, const string& oid, cls_rgw_reshard_entry& entry)
-{
- bufferlist in, out;
- struct cls_rgw_reshard_get_head_op call;
- ::encode(call, in);
- int r = io_ctx.exec(oid, "rgw", "reshard_get_head", in, out);
- if (r < 0)
- return r;
-
- struct cls_rgw_reshard_get_head_ret op_ret;
- bufferlist::iterator iter = out.begin();
- try {
- ::decode(op_ret, iter);
- } catch (buffer::error& err) {
- return -EIO;
- }
-
- entry = op_ret.entry;
-
- return 0;
-}
-
void cls_rgw_reshard_remove(librados::ObjectWriteOperation& op, const cls_rgw_reshard_entry& entry)
{
bufferlist in;
::encode_json("entry", entry, f);
}
-void cls_rgw_reshard_get_head_op::generate_test_instances(list<cls_rgw_reshard_get_head_op*>& ls)
-{
- ls.push_back(new cls_rgw_reshard_get_head_op);
- ls.push_back(new cls_rgw_reshard_get_head_op);
-}
-
-void cls_rgw_reshard_get_head_op::dump(Formatter *f) const
-{
-}
-
-void cls_rgw_reshard_get_head_ret::generate_test_instances(list<cls_rgw_reshard_get_head_ret*>& ls)
-{
- ls.push_back(new cls_rgw_reshard_get_head_ret);
- ls.push_back(new cls_rgw_reshard_get_head_ret);
-}
-
-void cls_rgw_reshard_get_head_ret::dump(Formatter *f) const
-{
- ::encode_json("entry", entry, f);
-}
-
void cls_rgw_reshard_remove_op::generate_test_instances(list<cls_rgw_reshard_remove_op*>& ls)
{
ls.push_back(new cls_rgw_reshard_remove_op);
};
WRITE_CLASS_ENCODER(cls_rgw_reshard_get_ret)
-struct cls_rgw_reshard_get_head_op {
-
- cls_rgw_reshard_get_head_op() {}
-
- void encode(bufferlist& bl) const {
- ENCODE_START(1, 1, bl);
- ENCODE_FINISH(bl);
- }
-
- void decode(bufferlist::iterator& bl) {
- DECODE_START(1, bl);
- DECODE_FINISH(bl);
- }
- static void generate_test_instances(list<cls_rgw_reshard_get_head_op*>& o);
- void dump(Formatter *f) const;
-};
-WRITE_CLASS_ENCODER(cls_rgw_reshard_get_head_op)
-
-struct cls_rgw_reshard_get_head_ret {
- cls_rgw_reshard_entry entry;
-
- cls_rgw_reshard_get_head_ret() {}
-
- 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_reshard_get_head_ret*>& o);
- void dump(Formatter *f) const;
-};
-WRITE_CLASS_ENCODER(cls_rgw_reshard_get_head_ret)
-
struct cls_rgw_reshard_remove_op {
string bucket_name;
string bucket_id;
TYPE(cls_rgw_reshard_list_ret)
TYPE(cls_rgw_reshard_get_op)
TYPE(cls_rgw_reshard_get_ret)
-TYPE(cls_rgw_reshard_get_head_op)
-TYPE(cls_rgw_reshard_get_head_ret)
TYPE(cls_rgw_reshard_remove_op)
TYPE(cls_rgw_set_bucket_resharding_op)
TYPE(cls_rgw_clear_bucket_resharding_op)