From ae7f8042c7b001c5988933282dc99f7aac1a825b Mon Sep 17 00:00:00 2001 From: Orit Wasserman Date: Mon, 21 Sep 2015 17:32:06 +0200 Subject: [PATCH] rgw: add zonegroup_map period update Signed-off-by: Orit Wasserman --- src/rgw/rgw_admin.cc | 36 +++++++++++++++++++----------------- src/rgw/rgw_rados.cc | 17 +++++++++++++++++ src/rgw/rgw_rados.h | 5 ++++- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 0dcb0e255f00b..82e231d0481c5 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -2192,23 +2192,6 @@ int main(int argc, char **argv) return -ret; } - list realms; - ret = store->list_realms(realms); - if (ret < 0) { - cerr << "failed to list realms: " << cpp_strerror(-ret) << std::endl; - return -ret; - } - for (list::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 zonegroups; ret = store->list_zonegroups(zonegroups); if (ret < 0) { @@ -2321,6 +2304,25 @@ int main(int argc, char **argv) zonegroupmap.clear_zonegroups(); } + list realms; + ret = store->list_realms(realms); + if (ret < 0) { + cerr << "failed to list realms: " << cpp_strerror(-ret) << std::endl; + return -ret; + } + + for (list::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 zonegroups; ret = store->list_zonegroups(zonegroups); if (ret < 0) { diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 52c8106612fda..31429371ee9e6 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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) { diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 3db003e719123..2fe29a15b44cf 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -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 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(); -- 2.39.5