]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add json decoders for data sync status
authorCasey Bodley <cbodley@redhat.com>
Mon, 6 Jun 2016 18:43:09 +0000 (14:43 -0400)
committerCasey Bodley <cbodley@redhat.com>
Fri, 22 Jul 2016 02:14:20 +0000 (22:14 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_data_sync.h

index f3fc2f2a28367f448dcc63dfedf15f00ecdac107..0bdb151128578e8e6fb9aca227e80700698a7c31 100644 (file)
@@ -6,6 +6,7 @@
 #include "rgw_bucket.h"
 
 #include "common/RWLock.h"
+#include "common/ceph_json.h"
 
 
 struct rgw_datalog_info {
@@ -59,6 +60,18 @@ struct rgw_data_sync_info {
     encode_json("status", s, f);
     encode_json("num_shards", num_shards, f);
   }
+  void decode_json(JSONObj *obj) {
+    std::string s;
+    JSONDecoder::decode_json("status", s, obj);
+    if (s == "building-full-sync-maps") {
+      state = StateBuildingFullSyncMaps;
+    } else if (s == "sync") {
+      state = StateSync;
+    } else {
+      state = StateInit;
+    }
+    JSONDecoder::decode_json("num_shards", num_shards, obj);
+  }
 
   rgw_data_sync_info() : state((int)StateInit), num_shards(0) {}
 };
@@ -108,6 +121,18 @@ struct rgw_data_sync_marker {
     encode_json("pos", pos, f);
     encode_json("timestamp", utime_t(timestamp), f);
   }
+  void decode_json(JSONObj *obj) {
+    int s;
+    JSONDecoder::decode_json("state", s, obj);
+    state = s;
+    JSONDecoder::decode_json("marker", marker, obj);
+    JSONDecoder::decode_json("next_step_marker", next_step_marker, obj);
+    JSONDecoder::decode_json("total_entries", total_entries, obj);
+    JSONDecoder::decode_json("pos", pos, obj);
+    utime_t t;
+    JSONDecoder::decode_json("timestamp", t, obj);
+    timestamp = t.to_real_time();
+  }
 };
 WRITE_CLASS_ENCODER(rgw_data_sync_marker)
 
@@ -135,6 +160,10 @@ struct rgw_data_sync_status {
     encode_json("info", sync_info, f);
     encode_json("markers", sync_markers, f);
   }
+  void decode_json(JSONObj *obj) {
+    JSONDecoder::decode_json("info", sync_info, obj);
+    JSONDecoder::decode_json("markers", sync_markers, obj);
+  }
 };
 WRITE_CLASS_ENCODER(rgw_data_sync_status)