]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cls_rgw; fix json decoding and encoding of certain type
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 23 Jan 2015 02:24:10 +0000 (18:24 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 23 Jan 2015 02:26:00 +0000 (18:26 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/cls/rgw/cls_rgw_types.cc
src/cls/rgw/cls_rgw_types.h

index c830991cab21cf2887c6df5d62272a669ed4493c..89c8476d71d29ac21e2d8afe17fd0803e4d5630c 100644 (file)
@@ -169,7 +169,7 @@ static void dump_bi_entry(bufferlist bl, BIIndexType index_type, Formatter *form
   }
 }
 
-void rgw_cls_bi_entry::decode_json(JSONObj *obj) {
+void rgw_cls_bi_entry::decode_json(JSONObj *obj, cls_rgw_obj_key *effective_key) {
   JSONDecoder::decode_json("idx", idx, obj);
   string s;
   JSONDecoder::decode_json("type", s, obj);
@@ -189,13 +189,21 @@ void rgw_cls_bi_entry::decode_json(JSONObj *obj) {
         rgw_bucket_dir_entry entry;
         JSONDecoder::decode_json("entry", entry, obj);
         ::encode(entry, data);
+
+        if (effective_key) {
+          *effective_key = entry.key;
+        }
       }
       break;
     case OLHIdx:
       {
-        rgw_bucket_dir_entry entry;
+        rgw_bucket_olh_entry entry;
         JSONDecoder::decode_json("entry", entry, obj);
         ::encode(entry, data);
+
+        if (effective_key) {
+          *effective_key = entry.key;
+        }
       }
       break;
     default:
@@ -235,6 +243,17 @@ void rgw_bucket_olh_entry::dump(Formatter *f) const
   encode_json("pending_removal", pending_removal, f);
 }
 
+void rgw_bucket_olh_entry::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("key", key, obj);
+  JSONDecoder::decode_json("delete_marker", delete_marker, obj);
+  JSONDecoder::decode_json("epoch", epoch, obj);
+  JSONDecoder::decode_json("pending_log", pending_log, obj);
+  JSONDecoder::decode_json("tag", tag, obj);
+  JSONDecoder::decode_json("exists", exists, obj);
+  JSONDecoder::decode_json("pending_removal", pending_removal, obj);
+}
+
 void rgw_bucket_olh_log_entry::generate_test_instances(list<rgw_bucket_olh_log_entry*>& o)
 {
   rgw_bucket_olh_log_entry *entry = new rgw_bucket_olh_log_entry;
@@ -270,6 +289,24 @@ void rgw_bucket_olh_log_entry::dump(Formatter *f) const
   encode_json("delete_marker", delete_marker, f);
 }
 
+void rgw_bucket_olh_log_entry::decode_json(JSONObj *obj)
+{
+  JSONDecoder::decode_json("epoch", epoch, obj);
+  string op_str;
+  JSONDecoder::decode_json("op", op_str, obj);
+  if (op_str == "link_olh") {
+    op = CLS_RGW_OLH_OP_LINK_OLH;
+  } else if (op_str == "unlink_olh") {
+    op = CLS_RGW_OLH_OP_UNLINK_OLH;
+  } else if (op_str == "remove_instance") {
+    op = CLS_RGW_OLH_OP_REMOVE_INSTANCE;
+  } else {
+    op = CLS_RGW_OLH_OP_UNKNOWN;
+  }
+  JSONDecoder::decode_json("op_tag", op_tag, obj);
+  JSONDecoder::decode_json("key", key, obj);
+  JSONDecoder::decode_json("delete_marker", delete_marker, obj);
+}
 void rgw_bi_log_entry::dump(Formatter *f) const
 {
   f->dump_string("op_id", id);
index 2799de5d5e3eaf54429abe7fcee2e61934f8f998..237c45277eac922ee716678fdcaccf2990a989af 100644 (file)
@@ -374,11 +374,12 @@ struct rgw_cls_bi_entry {
   }
 
   void dump(Formatter *f) const;
-  void decode_json(JSONObj *obj);
+  void decode_json(JSONObj *obj, cls_rgw_obj_key *effective_key = NULL);
 };
 WRITE_CLASS_ENCODER(rgw_cls_bi_entry)
 
 enum OLHLogOp {
+  CLS_RGW_OLH_OP_UNKNOWN         = 0,
   CLS_RGW_OLH_OP_LINK_OLH        = 1,
   CLS_RGW_OLH_OP_UNLINK_OLH      = 2, /* object does not exist */
   CLS_RGW_OLH_OP_REMOVE_INSTANCE = 3,
@@ -391,7 +392,7 @@ struct rgw_bucket_olh_log_entry {
   cls_rgw_obj_key key;
   bool delete_marker;
 
-  rgw_bucket_olh_log_entry() : delete_marker(false) {}
+  rgw_bucket_olh_log_entry() : op(CLS_RGW_OLH_OP_UNKNOWN), delete_marker(false) {}
 
 
   void encode(bufferlist &bl) const {
@@ -416,6 +417,7 @@ struct rgw_bucket_olh_log_entry {
   }
   static void generate_test_instances(list<rgw_bucket_olh_log_entry*>& o);
   void dump(Formatter *f) const;
+  void decode_json(JSONObj *obj);
 };
 WRITE_CLASS_ENCODER(rgw_bucket_olh_log_entry)
 
@@ -453,6 +455,7 @@ struct rgw_bucket_olh_entry {
     DECODE_FINISH(bl);
   }
   void dump(Formatter *f) const;
+  void decode_json(JSONObj *obj);
 };
 WRITE_CLASS_ENCODER(rgw_bucket_olh_entry)