]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: RGWRealm::set_current_period takes RGWPeriod
authorCasey Bodley <cbodley@redhat.com>
Fri, 4 Dec 2015 22:07:22 +0000 (17:07 -0500)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 12 Feb 2016 00:13:51 +0000 (16:13 -0800)
set_current_period() doesn't need to set the predecessor;
RGWPeriod::commit() takes care of that

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_rest_realm.cc

index 775eb2d55ca1f617182dd5130486b905982e7305..3f1d0f5311f8365c4a8f72748f23814b8679a82c 100644 (file)
@@ -716,7 +716,7 @@ int RGWRealm::create(bool exclusive)
       return ret;
     }
   }
-  ret = set_current_period(period.get_id());
+  ret = set_current_period(period);
   if (ret < 0) {
     return ret;
   }
@@ -783,28 +783,18 @@ const string& RGWRealm::get_info_oid_prefix(bool old_format)
   return realm_info_oid_prefix;
 }
 
-int RGWRealm::set_current_period(const string& period_id) {
-  /* check to see period id is valid */
-  RGWPeriod new_current(period_id);
-  int ret = new_current.init(cct, store, id, name);
-  if (ret < 0) {
-    ldout(cct, 0) << "Error init new period id " << period_id << " : " << cpp_strerror(-ret) << dendl;
-    return ret;
-  }
-  new_current.set_predecessor(current_period);
+int RGWRealm::set_current_period(RGWPeriod& period)
+{
 
-  ret = new_current.store_info(false);
-  if (ret < 0) {
-    return ret;
-  }
-  current_period = period_id;
-  ret = update();
+  current_period = period.get_id();
+
+  int ret = update();
   if (ret < 0) {
     ldout(cct, 0) << "ERROR: period update: " << cpp_strerror(-ret) << dendl;
     return ret;
   }
 
-  ret = new_current.reflect();
+  ret = period.reflect();
   if (ret < 0) {
     ldout(cct, 0) << "ERROR: period.reflect(): " << cpp_strerror(-ret) << dendl;
     return ret;
@@ -1299,7 +1289,7 @@ int RGWPeriod::commit(RGWRealm& realm, const RGWPeriod& current_period)
       return r;
     }
     // set as current period
-    r = realm.set_current_period(id);
+    r = realm.set_current_period(*this);
     if (r < 0) {
       lderr(cct) << "failed to update realm's current period: "
           << cpp_strerror(-r) << dendl;
index 8f199b737b39a6590590c2858b1b7e22ee270885..6413c7f825cdf2682e8a3d823acda10f5c513511 100644 (file)
@@ -1324,7 +1324,7 @@ public:
   const string& get_current_period() const {
     return current_period;
   }
-  int set_current_period(const string& period_id);
+  int set_current_period(RGWPeriod& period);
 
   string get_control_oid();
   /// send a notify on the realm control object
index d97671e83ca4344563d35968780f9851a5331b4a..8db20bd90b787376979d1b4e143ea226ba5594e4 100644 (file)
@@ -140,7 +140,7 @@ void RGWOp_Period_Post::execute()
       return;
     }
     // set as current period
-    http_ret = realm.set_current_period(period.get_id()); // TODO: add sync status argument
+    http_ret = realm.set_current_period(period);
     if (http_ret < 0) {
       lderr(cct) << "failed to update realm's current period" << dendl;
       return;