From 1150047309f71582469a1b831c6c0eb8b6e53286 Mon Sep 17 00:00:00 2001 From: Orit Wasserman Date: Mon, 21 Sep 2015 17:28:25 +0200 Subject: [PATCH] rgw: add zonegroupmap realm update Signed-off-by: Orit Wasserman --- src/rgw/rgw_admin.cc | 17 +++++++++++++++++ src/rgw/rgw_rados.cc | 7 +++++++ src/rgw/rgw_rados.h | 6 +++--- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 9c6f85818db3a..0dcb0e255f00b 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -2192,6 +2192,23 @@ 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) { diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 4024f9cf5ad82..52c8106612fda 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1120,6 +1120,13 @@ int RGWZoneGroupMap::update(RGWZoneGroup& zonegroup) return 0; } +int RGWZoneGroupMap::update(RGWRealm& realm) +{ + Mutex::Locker l(lock); + realms[realm.get_id()] = realm; + 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 b0a75a2bcd86a..3db003e719123 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1148,7 +1148,6 @@ struct RGWPeriodMap WRITE_CLASS_ENCODER(RGWPeriodMap) class RGWRealm; - struct RGWZoneGroupMap { Mutex lock; @@ -1174,7 +1173,8 @@ struct RGWZoneGroupMap { int store(CephContext *cct, RGWRados *store); int update(RGWZoneGroup& zonegroup); - + int update(RGWRealm& realm); + int get_master_zonegroup(const string& current_period, RGWZoneGroup& master_zonegroup); @@ -1235,7 +1235,7 @@ class RGWRealm : public RGWSystemMetaObj public: RGWRealm() {} - RGWRealm(const string& _id, const string& _name) : RGWSystemMetaObj(_id, _name) {} + RGWRealm(const string& _id, const string& _name = "") : RGWSystemMetaObj(_id, _name) {} RGWRealm(CephContext *_cct, RGWRados *_store): RGWSystemMetaObj(_cct, _store) {} RGWRealm(const string& _name, CephContext *_cct, RGWRados *_store): RGWSystemMetaObj(_name, _cct, _store){} -- 2.39.5