]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: store latest sync status when activating a period
authorOrit Wasserman <owasserm@redhat.com>
Tue, 13 Oct 2015 11:36:25 +0000 (13:36 +0200)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 12 Feb 2016 00:13:08 +0000 (16:13 -0800)
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index fda454fdb8780a5240b3603bbf5991ede5f01958..5fe417fecd39654ae94939da2ca4f7402a7142d6 100644 (file)
@@ -1903,7 +1903,22 @@ int main(int argc, char **argv)
          cerr << "Error initing realm " << cpp_strerror(-ret) << std::endl;
          return ret;
        }
-       ret = realm.set_current_period(period_id);
+       /* read latest sync data */
+       RGWMetaSyncStatusManager sync(store);
+
+       ret = sync.init();
+       if (ret < 0) {
+         cerr << "ERROR: sync.init() returned ret=" << ret << std::endl;
+         return -ret;
+       }
+
+       ret = sync.read_sync_status();
+       if (ret < 0) {
+         cerr << "ERROR: sync.read_sync_status() returned ret=" << ret << std::endl;
+         return -ret;
+       }
+
+       ret = realm.set_current_period(period_id, &sync.get_sync_status());
        if (ret < 0 ) {
          cerr << "Error setting current period " << period_id << ":" << cpp_strerror(-ret) << std::endl;
          return ret;
index d447563b243570ed02cc3f9fd6f59f6e293e5cbb..9bf293e42e78f70244bf9621fa0dfe66dfd496b5 100644 (file)
@@ -604,7 +604,7 @@ const string& RGWRealm::get_info_oid_prefix(bool old_format)
   return realm_info_oid_prefix;
 }
 
-int RGWRealm::set_current_period(const string& period_id) {
+int RGWRealm::set_current_period(const string& period_id, const rgw_meta_sync_status* sync_status) {
   /* check to see period id is valid */
   RGWPeriod new_current(period_id);
   int ret = new_current.init(cct, store, id, name);
@@ -613,6 +613,10 @@ int RGWRealm::set_current_period(const string& period_id) {
     return ret;
   }
   new_current.set_predecessor(current_period);
+  if (sync_status) {
+    new_current.set_sync_status(*sync_status);
+  }
+
   ret = new_current.store_info(false);
   if (ret < 0) {
     return ret;
index 5665627b655faf5d71e1f63a16fdaa8a218a2e87..1993cf215f9ddaf939783ab16a7b7d896e77d1e7 100644 (file)
@@ -16,6 +16,7 @@
 #include "cls/timeindex/cls_timeindex_types.h"
 #include "rgw_log.h"
 #include "rgw_metadata.h"
+#include "rgw_meta_sync_status.h"
 
 class RGWWatcher;
 class SafeTimer;
@@ -1301,7 +1302,7 @@ public:
   const string& get_current_period() const {
     return current_period;
   }
-  int set_current_period(const string& period_id);  
+  int set_current_period(const string& period_id, const rgw_meta_sync_status* sync_status = NULL);
 };
 WRITE_CLASS_ENCODER(RGWRealm)
 
@@ -1330,7 +1331,7 @@ class RGWPeriod
   string id;
   epoch_t epoch;
   string predecessor_uuid;
-  map<int, version_t> versions;
+  rgw_meta_sync_status sync_status;
   RGWPeriodMap period_map;
   string master_zone;
 
@@ -1361,6 +1362,7 @@ public:
   const string& get_master_zone() { return master_zone;}
   const string& get_realm() { return realm_id;}
   const RGWPeriodMap& get_map() { return period_map;}
+  const rgw_meta_sync_status& get_sync_status() { return sync_status;}
   const string& get_pool_name(CephContext *cct);
   const string& get_latest_epoch_oid();
   const string& get_info_oid_prefix();
@@ -1373,6 +1375,11 @@ public:
   void set_realm_id(const string& _realm_id) {
     realm_id = _realm_id;
   }
+
+  void set_sync_status(const rgw_meta_sync_status& _sync_status) {
+    sync_status = _sync_status;
+  }
+
   int get_latest_epoch(epoch_t& epoch);
   int init(CephContext *_cct, RGWRados *_store, const string &period_realm_id, const string &period_realm_name = "",
           bool setup_obj = true);
@@ -1389,7 +1396,7 @@ public:
     ::encode(id, bl);
     ::encode(epoch, bl);
     ::encode(predecessor_uuid, bl);
-    ::encode(versions, bl);
+    ::encode(sync_status, bl);
     ::encode(period_map, bl);
     ::encode(master_zone, bl);
     ENCODE_FINISH(bl);
@@ -1400,7 +1407,7 @@ public:
     ::decode(id, bl);
     ::decode(epoch, bl);
     ::decode(predecessor_uuid, bl);
-    ::decode(versions, bl);
+    ::decode(sync_status, bl);
     ::decode(period_map, bl);
     ::decode(master_zone, bl);
     DECODE_FINISH(bl);