return 0;
}
+static int rgw_get_bucket_resharding(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
+{
+ cls_rgw_get_bucket_resharding_op op;
+
+ bufferlist::iterator in_iter = in->begin();
+ try {
+ ::decode(op, in_iter);
+ } catch (buffer::error& err) {
+ CLS_LOG(1, "ERROR: cls_rgw_clear_bucket_resharding: failed to decode entry\n");
+ return -EINVAL;
+ }
+
+ bufferlist bl;
+ int ret = cls_cxx_getxattr(hctx, resharding_attr.c_str(), &bl);
+ if (ret < 0) {
+ CLS_LOG(0, "ERROR: %s(): cls_cxx_getxattr (attr=%s) returned %d", __func__, resharding_attr.c_str(), ret);
+ return ret;
+ }
+
+ cls_rgw_get_bucket_resharding_ret op_ret;
+ try {
+ ::decode(op_ret.resharding, bl);
+ } catch (buffer::error& err) {
+ CLS_LOG(1, "ERROR: cls_rgw_get_bucket_resharding: failed to decode entry\n");
+ return -EINVAL;
+ }
+
+ ::encode(op_ret, *out);
+
+ return 0;
+}
+
CLS_INIT(rgw)
{
CLS_LOG(1, "Loaded rgw class!");
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_method_handle_t h_rgw_get_bucket_resharding;
cls_register(RGW_CLASS, &h_class);
rgw_set_bucket_resharding, &h_rgw_set_bucket_resharding);
cls_register_cxx_method(h_class, "clear_bucket_resharding", CLS_METHOD_RD | CLS_METHOD_WR,
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", "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)
+{
+ 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 r;
+
+ struct cls_rgw_get_bucket_resharding_ret op_ret;
+ bufferlist::iterator iter = out.begin();
+ try {
+ ::decode(op_ret, iter);
+ } catch (buffer::error& err) {
+ return -EIO;
+ }
+
+ resharding = op_ret.resharding;
+
+ return 0;
+}
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_get_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
+ const cls_rgw_bucket_instance_entry& entry, bool& resharding);
#endif
::encode_json("entry", entry, f);
}
+void cls_rgw_get_bucket_resharding_op::generate_test_instances(
+ list<cls_rgw_get_bucket_resharding_op*>& ls)
+{
+ ls.push_back(new cls_rgw_get_bucket_resharding_op);
+ ls.push_back(new cls_rgw_get_bucket_resharding_op);
+}
+
+void cls_rgw_get_bucket_resharding_op::dump(Formatter *f) const
+{
+ ::encode_json("entry", entry, f);
+}
+
+
};
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);
+ }
+
+ static void generate_test_instances(list<cls_rgw_get_bucket_resharding_op*>& o);
+ void dump(Formatter *f) const;
+};
+WRITE_CLASS_ENCODER(cls_rgw_get_bucket_resharding_op)
+
+struct cls_rgw_get_bucket_resharding_ret {
+ bool resharding;
+
+ void encode(bufferlist& bl) const {
+ ENCODE_START(1, 1, bl);
+ ::encode(resharding, bl);
+ ENCODE_FINISH(bl);
+ }
+
+ void decode(bufferlist::iterator& bl) {
+ DECODE_START(1, bl);
+ ::decode(resharding, bl);
+ DECODE_FINISH(bl);
+ }
+
+ static void generate_test_instances(list<cls_rgw_get_bucket_resharding_ret*>& o);
+ void dump(Formatter *f) const;
+};
+WRITE_CLASS_ENCODER(cls_rgw_get_bucket_resharding_ret)
+
#endif /* CEPH_CLS_RGW_OPS_H */