]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add zonegroup_map period update
authorOrit Wasserman <owasserm@redhat.com>
Mon, 21 Sep 2015 15:32:06 +0000 (17:32 +0200)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 12 Feb 2016 00:13:02 +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 0dcb0e255f00bd99506190dab3613b44275cf53a..82e231d0481c5b983daa908a7a78fc1b9393abf6 100644 (file)
@@ -2192,23 +2192,6 @@ int main(int argc, char **argv)
          return -ret;
        }
 
-       list<string> realms;
-       ret = store->list_realms(realms);
-       if (ret < 0) {
-         cerr << "failed to list realms: " << cpp_strerror(-ret) << std::endl;
-         return -ret;
-       }
-       for (list<string>::iterator iter = realms.begin(); iter != realms.end(); ++iter)
-       {        
-         RGWRealm realm(*iter);
-         ret = realm.init(g_ceph_context, store);
-         if (ret < 0) {
-           cerr << "failed to init realm: " << cpp_strerror(-ret) << std::endl;
-           return -ret;
-         }
-         zonegroupmap.update(realm);
-       }
-
        list<string> zonegroups;
        ret = store->list_zonegroups(zonegroups);
        if (ret < 0) {
@@ -2321,6 +2304,25 @@ int main(int argc, char **argv)
           zonegroupmap.clear_zonegroups();
         }
 
+       list<string> realms;
+       ret = store->list_realms(realms);
+       if (ret < 0) {
+         cerr << "failed to list realms: " << cpp_strerror(-ret) << std::endl;
+         return -ret;
+       }
+
+       for (list<string>::iterator iter = realms.begin(); iter != realms.end(); ++iter)
+       {
+         RGWRealm realm(*iter);
+         ret = realm.init(g_ceph_context, store);
+         if (ret < 0) {
+           cerr << "failed to init realm: " << cpp_strerror(-ret) << std::endl;
+           return -ret;
+         }
+         zonegroupmap.update(realm);
+         zonegroupmap.update(g_ceph_context, store, realm.get_current_period());
+       }
+
        list<string> zonegroups;
        ret = store->list_zonegroups(zonegroups);
        if (ret < 0) {
index 52c8106612fdaf583c1814d9f86de55709b3e551..31429371ee9e6f9f76a4f659483a7f53d47dd991 100644 (file)
@@ -1127,6 +1127,23 @@ int RGWZoneGroupMap::update(RGWRealm& realm)
   return 0;
 }
 
+int RGWZoneGroupMap::update(CephContext *cct, RGWRados *store,
+                           const string& period_id)
+{
+  Mutex::Locker l(lock);
+  RGWPeriod period(period_id);
+
+  int ret = period.init(cct, store);
+  if (ret < 0) {
+    cerr << "failed to init period: " << cpp_strerror(-ret) << std::endl;
+    return ret;
+  }
+
+  periods[period.get_id()] = period.get_map();
+
+  return 0;
+}
+
 int RGWZoneGroupMap::get_master_zonegroup(const string& current_period,
                                          RGWZoneGroup& zonegroup)
 {
index 3db003e719123615c19220bbcf5c6496b5afcbd1..2fe29a15b44cf4157ba7c8260be642740aacef60 100644 (file)
@@ -1174,6 +1174,8 @@ struct RGWZoneGroupMap {
 
   int update(RGWZoneGroup& zonegroup);
   int update(RGWRealm& realm);
+  int update(CephContext *cct, RGWRados *store,
+            const string& period_id);
   
   int get_master_zonegroup(const string& current_period,
                           RGWZoneGroup& master_zonegroup);
@@ -1301,7 +1303,7 @@ class RGWPeriod
   epoch_t epoch;
   string predecessor_uuid;
   map<int, version_t> versions;
-
+  RGWPeriodMap period_map;
   string master_zone;
 
   string realm_id;
@@ -1330,6 +1332,7 @@ public:
   const string& get_predecessor() { return predecessor_uuid;}
   const string& get_master_zone() { return master_zone;}
   const string& get_realm() { return realm_id;}
+  const RGWPeriodMap& get_map() { return period_map;}
   const string& get_pool_name(CephContext *cct);
   const string& get_latest_epoch_oid();
   const string& get_info_oid_prefix();