]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: rgw_zone api adjustments
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 6 Sep 2018 13:42:42 +0000 (06:42 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 8 Nov 2018 17:19:29 +0000 (09:19 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
17 files changed:
src/rgw/CMakeLists.txt
src/rgw/rgw_lib.h
src/rgw/rgw_log.cc
src/rgw/rgw_main.cc
src/rgw/rgw_period_pusher.cc
src/rgw/rgw_process.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_realm_reloader.cc
src/rgw/rgw_realm_watcher.cc
src/rgw/rgw_rest_config.cc
src/rgw/rgw_rest_swift.cc
src/rgw/rgw_zone.cc
src/rgw/rgw_zone.h
src/rgw/services/svc_sys_obj.cc
src/rgw/services/svc_sys_obj.h
src/rgw/services/svc_sys_obj_core.h
src/rgw/services/svc_zone.cc

index 55e7aada6a6556790f5d295cc2d39db2b75868bb..9711f45e2aec947a3f08ed60f1f594488b0078e9 100644 (file)
@@ -122,6 +122,7 @@ set(librgw_common_srcs
   rgw_crypt_sanitize.cc
   rgw_iam_policy.cc
   rgw_rest_user_policy.cc
+  rgw_zone.cc
   rgw_sts.cc
   rgw_rest_sts.cc)
 
index 94b51ac4f10c2e6d44d5e426f2d834232b240f05..24d273e3cfa64d9b3a144b1294f1f77acc572530 100644 (file)
@@ -14,6 +14,7 @@
 #include "rgw_process.h"
 #include "rgw_rest_s3.h" // RGW_Auth_S3
 #include "rgw_ldap.h"
+#include "services/svc_zone_utils.h"
 #include "include/ceph_assert.h"
 
 class OpsLogSocket;
@@ -158,8 +159,8 @@ namespace rgw {
       RGWHandler::init(rados_ctx->store, _s, io);
 
       get_state()->obj_ctx = rados_ctx;
-      get_state()->req_id = store->unique_id(id);
-      get_state()->trans_id = store->unique_trans_id(id);
+      get_state()->req_id = store->svc.zone_utils->unique_id(id);
+      get_state()->trans_id = store->svc.zone_utils->unique_trans_id(id);
 
       ldpp_dout(_s, 2) << "initializing for trans_id = "
          << get_state()->trans_id.c_str() << dendl;
@@ -194,8 +195,8 @@ namespace rgw {
        RGWHandler::init(rados_ctx.store, &rstate, &io_ctx);
 
        get_state()->obj_ctx = &rados_ctx;
-       get_state()->req_id = store->unique_id(id);
-       get_state()->trans_id = store->unique_trans_id(id);
+       get_state()->req_id = store->svc.zone_utils->unique_id(id);
+       get_state()->trans_id = store->svc.zone_utils->unique_trans_id(id);
 
        ldpp_dout(get_state(), 2) << "initializing for trans_id = "
            << get_state()->trans_id.c_str() << dendl;
index 11f856c9d54aabf2e3a14dc40aa638e92dc3f832..158843ca0a9dc4a3d237e0264b136fd2b98ea9cf 100644 (file)
@@ -14,6 +14,8 @@
 #include "rgw_client_io.h"
 #include "rgw_rest.h"
 
+#include "services/svc_zone.h"
+
 #define dout_subsys ceph_subsys_rgw
 
 static void set_param_str(struct req_state *s, const char *name, string& str)
@@ -440,11 +442,11 @@ int rgw_log_op(RGWRados *store, RGWREST* const rest, struct req_state *s,
     string oid = render_log_object_name(s->cct->_conf->rgw_log_object_name, &bdt,
                                        s->bucket.bucket_id, entry.bucket);
 
-    rgw_raw_obj obj(store->get_zone_params().log_pool, oid);
+    rgw_raw_obj obj(store->svc.zone->get_zone_params().log_pool, oid);
 
     ret = store->append_async(obj, bl.length(), bl);
     if (ret == -ENOENT) {
-      ret = store->create_pool(store->get_zone_params().log_pool);
+      ret = store->create_pool(store->svc.zone->get_zone_params().log_pool);
       if (ret < 0)
         goto done;
       // retry
index fd7e3c005a4b88b0ce8eafc54c522a88a88b0b39..3aa9cd8bf3c50e3c7e01a6010304de13c541e907 100644 (file)
@@ -40,6 +40,8 @@
 #include "rgw_asio_frontend.h"
 #endif /* WITH_RADOSGW_BEAST_FRONTEND */
 
+#include "services/svc_zone.h"
+
 #ifdef HAVE_SYS_PRCTL_H
 #include <sys/prctl.h>
 #endif
@@ -314,7 +316,7 @@ int main(int argc, const char **argv)
     return -r;
   }
 
-  rgw_rest_init(g_ceph_context, store, store->get_zonegroup());
+  rgw_rest_init(g_ceph_context, store, store->svc.zone->get_zonegroup());
 
   mutex.Lock();
   init_timer.cancel_all_events();
@@ -378,7 +380,7 @@ int main(int argc, const char **argv)
                           set_logging(rest_filter(store, RGW_REST_SWIFT,
                                                   swift_resource)));
     } else {
-      if (store->get_zonegroup().zones.size() > 1) {
+      if (store->svc.zone->get_zonegroup().zones.size() > 1) {
         derr << "Placing Swift API in the root of URL hierarchy while running"
              << " multi-site configuration requires another instance of RadosGW"
              << " with S3 API enabled!" << dendl;
@@ -522,7 +524,7 @@ int main(int argc, const char **argv)
   RGWFrontendPauser pauser(fes, &pusher);
   RGWRealmReloader reloader(store, service_map_meta, &pauser);
 
-  RGWRealmWatcher realm_watcher(g_ceph_context, store->realm);
+  RGWRealmWatcher realm_watcher(g_ceph_context, store->svc.zone->get_realm());
   realm_watcher.add_watcher(RGWRealmNotify::Reload, reloader);
   realm_watcher.add_watcher(RGWRealmNotify::ZonesNeedPeriod, pusher);
 
index df5d3aea25dabb0b58d827694be16c7507f6a044..e44dd7a3de693f776b518c72491475ffccd0dece 100644 (file)
@@ -6,7 +6,12 @@
 
 #include "rgw_period_pusher.h"
 #include "rgw_cr_rest.h"
+#include "rgw_zone.h"
+
+#include "services/svc_zone.h"
+
 #include "common/errno.h"
+
 #include <boost/asio/yield.hpp>
 
 #define dout_subsys ceph_subsys_rgw
@@ -154,14 +159,14 @@ class RGWPeriodPusher::CRThread {
 RGWPeriodPusher::RGWPeriodPusher(RGWRados* store)
   : cct(store->ctx()), store(store)
 {
-  const auto& realm = store->realm;
+  const auto& realm = store->svc.zone->get_realm();
   auto& realm_id = realm.get_id();
   if (realm_id.empty()) // no realm configuration
     return;
 
   // always send out the current period on startup
   RGWPeriod period;
-  int r = period.init(cct, store, realm_id, realm.get_name());
+  int r = period.init(cct, store->svc.sysobj, realm_id, realm.get_name());
   if (r < 0) {
     lderr(cct) << "failed to load period for realm " << realm_id << dendl;
     return;
@@ -216,7 +221,7 @@ void RGWPeriodPusher::handle_notify(RGWZonesNeedPeriod&& period)
 
   // find our zonegroup in the new period
   auto& zonegroups = period.get_map().zonegroups;
-  auto i = zonegroups.find(store->get_zonegroup().get_id());
+  auto i = zonegroups.find(store->svc.zone->get_zonegroup().get_id());
   if (i == zonegroups.end()) {
     lderr(cct) << "The new period does not contain my zonegroup!" << dendl;
     return;
@@ -224,7 +229,7 @@ void RGWPeriodPusher::handle_notify(RGWZonesNeedPeriod&& period)
   auto& my_zonegroup = i->second;
 
   // if we're not a master zone, we're not responsible for pushing any updates
-  if (my_zonegroup.master_zone != store->get_zone_params().get_id())
+  if (my_zonegroup.master_zone != store->svc.zone->get_zone_params().get_id())
     return;
 
   // construct a map of the zones that need this period. the map uses the same
@@ -233,11 +238,11 @@ void RGWPeriodPusher::handle_notify(RGWZonesNeedPeriod&& period)
   auto hint = conns.end();
 
   // are we the master zonegroup in this period?
-  if (period.get_map().master_zonegroup == store->get_zonegroup().get_id()) {
+  if (period.get_map().master_zonegroup == store->svc.zone->get_zonegroup().get_id()) {
     // update other zonegroup endpoints
     for (auto& zg : zonegroups) {
       auto& zonegroup = zg.second;
-      if (zonegroup.get_id() == store->get_zonegroup().get_id())
+      if (zonegroup.get_id() == store->svc.zone->get_zonegroup().get_id())
         continue;
       if (zonegroup.endpoints.empty())
         continue;
@@ -245,14 +250,14 @@ void RGWPeriodPusher::handle_notify(RGWZonesNeedPeriod&& period)
       hint = conns.emplace_hint(
           hint, std::piecewise_construct,
           std::forward_as_tuple(zonegroup.get_id()),
-          std::forward_as_tuple(cct, store, zonegroup.get_id(), zonegroup.endpoints, RGWAccessKey()));
+          std::forward_as_tuple(cct, store->svc.zone, zonegroup.get_id(), zonegroup.endpoints, RGWAccessKey()));
     }
   }
 
   // update other zone endpoints
   for (auto& z : my_zonegroup.zones) {
     auto& zone = z.second;
-    if (zone.id == store->get_zone_params().get_id())
+    if (zone.id == store->svc.zone->get_zone_params().get_id())
       continue;
     if (zone.endpoints.empty())
       continue;
@@ -260,7 +265,7 @@ void RGWPeriodPusher::handle_notify(RGWZonesNeedPeriod&& period)
     hint = conns.emplace_hint(
         hint, std::piecewise_construct,
         std::forward_as_tuple(zone.id),
-        std::forward_as_tuple(cct, store, zone.id, zone.endpoints));
+        std::forward_as_tuple(cct, store->svc.zone, zone.id, zone.endpoints));
   }
 
   if (conns.empty()) {
index c21a98b60c85185ca1764dc4f51c5150bdac70ec..39a5f9ff5049bccb3497239d5ddf106b205b2425 100644 (file)
@@ -14,6 +14,8 @@
 #include "rgw_client_io.h"
 #include "rgw_opa.h"
 
+#include "services/svc_zone_utils.h"
+
 #define dout_subsys ceph_subsys_rgw
 
 void RGWProcess::RGWWQ::_dump_queue()
@@ -149,8 +151,8 @@ int process_request(RGWRados* const store,
     return ret;
   }
 
-  s->req_id = store->unique_id(req->id);
-  s->trans_id = store->unique_trans_id(req->id);
+  s->req_id = store->svc.zone_utils->unique_id(req->id);
+  s->trans_id = store->svc.zone_utils->unique_trans_id(req->id);
   s->host_id = store->host_id;
 
   ldpp_dout(s, 2) << "initializing for trans_id = " << s->trans_id << dendl;
index db43e307d14a7a4cecc63ddffdc0de9d725d24b2..a367a9963ed615adf553393041fc0cccb1e9e1fa 100644 (file)
@@ -101,7 +101,6 @@ static string default_storage_extra_pool_suffix = "rgw.buckets.non-ec";
 static string log_lock_name = "rgw_log_lock";
 static RGWObjCategory main_category = RGW_OBJ_CATEGORY_MAIN;
 #define RGW_USAGE_OBJ_PREFIX "usage."
-#define FIRST_EPOCH 1
 
 
 #define dout_subsys ceph_subsys_rgw
index 3a91e552484aff9d405c1f94bf64368ac2bd9272..e269ba138b12f0350ca2b0b537e5b00770c5f214 100644 (file)
@@ -9,6 +9,8 @@
 #include "rgw_rest.h"
 #include "rgw_user.h"
 
+#include "services/svc_zone.h"
+
 #include "common/errno.h"
 
 #define dout_subsys ceph_subsys_rgw
@@ -160,7 +162,7 @@ void RGWRealmReloader::reload()
   ldout(cct, 1) << "Finishing initialization of new store" << dendl;
   // finish initializing the new store
   ldout(cct, 1) << " - REST subsystem init" << dendl;
-  rgw_rest_init(cct, store, store->get_zonegroup());
+  rgw_rest_init(cct, store, store->svc.zone->get_zonegroup());
   ldout(cct, 1) << " - user subsystem init" << dendl;
   rgw_user_init(store);
   ldout(cct, 1) << " - user subsystem init" << dendl;
index 57cdc85a9f9bb264931561b725ed36197f64ef5e..8ea58571c3db1aea7ea4f5d7617bf9f8b6ae001f 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "rgw_realm_watcher.h"
 #include "rgw_rados.h"
+#include "rgw_zone.h"
 
 #define dout_subsys ceph_subsys_rgw
 
index 5b6a1cbd38b17bc3143fe51b09d7621f9aff941e..ef184776b198b6330318961481da707068e0eae2 100644 (file)
 #include "common/errno.h"
 #include "include/ceph_assert.h"
 
+#include "services/svc_zone.h"
+
 #define dout_context g_ceph_context
 #define dout_subsys ceph_subsys_rgw
 
 void RGWOp_ZoneGroupMap_Get::execute() {
-  http_ret = zonegroup_map.read(g_ceph_context, store);
+  http_ret = zonegroup_map.read(g_ceph_context, store->svc.sysobj);
   if (http_ret < 0) {
     dout(5) << "failed to read zone_group map" << dendl;
   }
@@ -54,7 +56,7 @@ void RGWOp_ZoneGroupMap_Get::send_response() {
 }
 
 void RGWOp_ZoneConfig_Get::send_response() {
-  const RGWZoneParams& zone_params = store->get_zone_params();
+  const RGWZoneParams& zone_params = store->svc.zone->get_zone_params();
 
   set_req_state_err(s, http_ret);
   dump_errno(s);
index 903d3cbf49a3528e083f041938880b9105df8d7e..f65e4c9fea86c2b136cd23bbe9a6e726c08b5d60 100644 (file)
 #include "rgw_request.h"
 #include "rgw_process.h"
 
+#include "rgw_zone.h"
+
+#include "services/svc_zone.h"
+
 #include <array>
 #include <sstream>
 #include <memory>
@@ -703,7 +707,7 @@ int RGWCreateBucket_ObjStore_SWIFT::get_params()
     policy.create_default(s->user->user_id, s->user->display_name);
   }
 
-  location_constraint = store->get_zonegroup().api_name;
+  location_constraint = store->svc.zone->get_zonegroup().api_name;
   get_rmattrs_from_headers(s, CONT_PUT_ATTR_PREFIX,
                            CONT_REMOVE_ATTR_PREFIX, rmattr_names);
   placement_rule = s->info.env->get("HTTP_X_STORAGE_POLICY", "");
@@ -1898,7 +1902,7 @@ void RGWInfo_ObjStore_SWIFT::list_swift_data(Formatter& formatter,
   }
 
   formatter.open_array_section("policies");
-  RGWZoneGroup& zonegroup = store.get_zonegroup();
+  RGWZoneGroup& zonegroup = store.svc.zone->get_zonegroup();
 
   for (const auto& placement_targets : zonegroup.placement_targets) {
     formatter.open_object_section("policy");
index 54a906892073d4b8bcc7b43d15bd4148e7570d56..7a7061fef4da38327a9320b37036c64079c71e0f 100644 (file)
@@ -1,7 +1,46 @@
+#include "common/errno.h"
+
 #include "rgw_zone.h"
+#include "rgw_realm_watcher.h"
+#include "rgw_meta_sync_status.h"
 
+#include "services/svc_zone.h"
 #include "services/svc_sys_obj.h"
 
+#define dout_subsys ceph_subsys_rgw
+
+namespace rgw_zone_defaults {
+
+std::string zone_info_oid_prefix = "zone_info.";
+std::string zone_names_oid_prefix = "zone_names.";
+std::string region_info_oid_prefix = "region_info.";
+std::string realm_names_oid_prefix = "realms_names.";
+std::string zone_group_info_oid_prefix = "zonegroup_info.";
+std::string realm_info_oid_prefix = "realms.";
+std::string default_region_info_oid = "default.region";
+std::string default_zone_group_info_oid = "default.zonegroup";
+std::string period_info_oid_prefix = "periods.";
+std::string period_latest_epoch_info_oid = ".latest_epoch";
+std::string region_map_oid = "region_map";
+std::string default_realm_info_oid = "default.realm";
+std::string default_zonegroup_name = "default";
+std::string default_zone_name = "default";
+std::string zonegroup_names_oid_prefix = "zonegroups_names.";
+std::string RGW_DEFAULT_ZONE_ROOT_POOL = "rgw.root";
+std::string RGW_DEFAULT_ZONEGROUP_ROOT_POOL = "rgw.root";
+std::string RGW_DEFAULT_REALM_ROOT_POOL = "rgw.root";
+std::string RGW_DEFAULT_PERIOD_ROOT_POOL = "rgw.root";
+std::string default_bucket_index_pool_suffix = "rgw.buckets.index";
+std::string default_storage_extra_pool_suffix = "rgw.buckets.non-ec";
+std::string avail_pools = ".pools.avail";
+std::string default_storage_pool_suffix = "rgw.buckets.data";
+
+}
+
+using namespace rgw_zone_defaults;
+
+#define FIRST_EPOCH 1
+
 void RGWDefaultZoneGroupInfo::dump(Formatter *f) const {
   encode_json("default_zonegroup", default_zonegroup, f);
 }
@@ -37,7 +76,7 @@ int RGWZoneGroup::create_default(bool old_format)
 
   RGWZoneParams zone_params(default_zone_name);
 
-  int r = zone_params.init(cct, zone_svc, false);
+  int r = zone_params.init(cct, sysobj_svc, false);
   if (r < 0) {
     ldout(cct, 0) << "create_default: error initializing zone params: " << cpp_strerror(-r) << dendl;
     return r;
@@ -50,7 +89,7 @@ int RGWZoneGroup::create_default(bool old_format)
   } else if (r == -EEXIST) {
     ldout(cct, 10) << "zone_params::create_default() returned -EEXIST, we raced with another default zone_params creation" << dendl;
     zone_params.clear_id();
-    r = zone_params.init(cct, zone_svc);
+    r = zone_params.init(cct, sysobj_svc);
     if (r < 0) {
       ldout(cct, 0) << "create_default: error in init existing zone params: " << cpp_strerror(-r) << dendl;
       return r;
@@ -73,7 +112,7 @@ int RGWZoneGroup::create_default(bool old_format)
   if (r == -EEXIST) {
     ldout(cct, 10) << "create_default() returned -EEXIST, we raced with another zonegroup creation" << dendl;
     id.clear();
-    r = init(cct, zone_svc);
+    r = init(cct, sysobj_svc);
     if (r < 0) {
       return r;
     }
@@ -181,9 +220,9 @@ int RGWZoneGroup::add_zone(const RGWZoneParams& zone_params, bool *is_master, bo
                     << ",  valid sync modules: " 
                     << store->get_sync_modules_manager()->get_registered_module_names()
                     << dendl;
-#endif
       return -ENOENT;
     }
+#endif
   }
 
   if (psync_from_all) {
@@ -232,7 +271,7 @@ void RGWZoneGroup::post_process_params()
     zone.log_data = log_data;
 
     RGWZoneParams zone_params(zone.id, zone.name);
-    int ret = zone_params.init(cct, zone_svc);
+    int ret = zone_params.init(cct, sysobj_svc);
     if (ret < 0) {
       ldout(cct, 0) << "WARNING: could not read zone params for zone id=" << zone.id << " name=" << zone.name << dendl;
       continue;
@@ -275,7 +314,7 @@ int RGWZoneGroup::read_default_id(string& default_id, bool old_format)
   if (realm_id.empty()) {
     /* try using default realm */
     RGWRealm realm;
-    int ret = realm.init(cct, zone_svc);
+    int ret = realm.init(cct, sysobj_svc);
     // no default realm exist
     if (ret < 0) {
       return read_id(default_zonegroup_name, default_id);
@@ -291,7 +330,7 @@ int RGWZoneGroup::set_as_default(bool exclusive)
   if (realm_id.empty()) {
     /* try using default realm */
     RGWRealm realm;
-    int ret = realm.init(cct, zone_svc);
+    int ret = realm.init(cct, sysobj_svc);
     if (ret < 0) {
       ldout(cct, 10) << "could not read realm id: " << cpp_strerror(-ret) << dendl;
       return -EINVAL;
@@ -302,10 +341,16 @@ int RGWZoneGroup::set_as_default(bool exclusive)
   return RGWSystemMetaObj::set_as_default(exclusive);
 }
 
-int RGWSystemMetaObj::init(CephContext *_cct, RGWSI_Zone *_zone_svc, bool setup_obj, bool old_format)
+void RGWSystemMetaObj::reinit_instance(CephContext *_cct, RGWSI_SysObj *_sysobj_svc)
 {
   cct = _cct;
-  zone_svc = _zone_svc;
+  sysobj_svc = _sysobj_svc;
+  zone_svc = _sysobj_svc->get_zone_svc();
+}
+
+int RGWSystemMetaObj::init(CephContext *_cct, RGWSI_SysObj *_sysobj_svc, bool setup_obj, bool old_format)
+{
+  reinit_instance(_cct, _sysobj_svc);
 
   if (!setup_obj)
     return 0;
@@ -343,9 +388,10 @@ int RGWSystemMetaObj::read_default(RGWDefaultSystemMetaObjInfo& default_info, co
   using ceph::decode;
   auto pool = get_pool(cct);
   bufferlist bl;
-  RGWSysObjectCtx obj_ctx = sysobj_svc->get_obj_ctx();
 
-  int ret = rgw_get_system_obj(store, obj_ctx, pool, oid, bl, NULL, NULL);
+  auto obj_ctx = sysobj_svc->init_obj_ctx();
+  auto sysobj = sysobj_svc->get_obj(obj_ctx, rgw_raw_obj(pool, oid));
+  int ret = sysobj.rop().read(&bl);
   if (ret < 0)
     return ret;
 
@@ -392,8 +438,11 @@ int RGWSystemMetaObj::set_as_default(bool exclusive)
 
   encode(default_info, bl);
 
-  int ret = rgw_put_system_obj(store, pool, oid, bl,
-                               exclusive, NULL, real_time(), NULL);
+  auto obj_ctx = sysobj_svc->init_obj_ctx();
+  auto sysobj = sysobj_svc->get_obj(obj_ctx, rgw_raw_obj(pool, oid));
+  int ret = sysobj.wop()
+                  .set_exclusive(exclusive)
+                 .write(bl);
   if (ret < 0)
     return ret;
 
@@ -408,9 +457,9 @@ int RGWSystemMetaObj::read_id(const string& obj_name, string& object_id)
 
   string oid = get_names_oid_prefix() + obj_name;
 
-  RGWSysObjectCtx obj_ctx = sysobj_svc->get_obj_ctx();
-
-  int ret = rgw_get_system_obj(store, obj_ctx, pool, oid, bl, NULL, NULL);
+  auto obj_ctx = sysobj_svc->init_obj_ctx();
+  auto sysobj = sysobj_svc->get_obj(obj_ctx, rgw_raw_obj(pool, oid));
+  int ret = sysobj.rop().read(&bl);
   if (ret < 0) {
     return ret;
   }
@@ -431,6 +480,8 @@ int RGWSystemMetaObj::delete_obj(bool old_format)
 {
   rgw_pool pool(get_pool(cct));
 
+  auto obj_ctx = sysobj_svc->init_obj_ctx();
+
   /* check to see if obj is the default */
   RGWDefaultSystemMetaObjInfo default_info;
   int ret = read_default(default_info, get_default_oid(old_format));
@@ -439,7 +490,8 @@ int RGWSystemMetaObj::delete_obj(bool old_format)
   if (default_info.default_id == id || (old_format && default_info.default_id == name)) {
     string oid = get_default_oid(old_format);
     rgw_raw_obj default_named_obj(pool, oid);
-    ret = store->delete_system_obj(default_named_obj);
+    auto sysobj = sysobj_svc->get_obj(obj_ctx, default_named_obj);
+    ret = sysobj.wop().remove();
     if (ret < 0) {
       ldout(cct, 0) << "Error delete default obj name  " << name << ": " << cpp_strerror(-ret) << dendl;
       return ret;
@@ -448,7 +500,8 @@ int RGWSystemMetaObj::delete_obj(bool old_format)
   if (!old_format) {
     string oid  = get_names_oid_prefix() + name;
     rgw_raw_obj object_name(pool, oid);
-    ret = store->delete_system_obj(object_name);
+    auto sysobj = sysobj_svc->get_obj(obj_ctx, object_name);
+    ret = sysobj.wop().remove();
     if (ret < 0) {
       ldout(cct, 0) << "Error delete obj name  " << name << ": " << cpp_strerror(-ret) << dendl;
       return ret;
@@ -463,7 +516,8 @@ int RGWSystemMetaObj::delete_obj(bool old_format)
   }
 
   rgw_raw_obj object_id(pool, oid);
-  ret = store->delete_system_obj(object_id);
+  auto sysobj = sysobj_svc->get_obj(obj_ctx, object_id);
+  ret = sysobj.wop().remove();
   if (ret < 0) {
     ldout(cct, 0) << "Error delete object id " << id << ": " << cpp_strerror(-ret) << dendl;
   }
@@ -482,7 +536,11 @@ int RGWSystemMetaObj::store_name(bool exclusive)
   bufferlist bl;
   using ceph::encode;
   encode(nameToId, bl);
-  return rgw_put_system_obj(store, pool, oid, bl, exclusive, NULL, real_time(), NULL);
+  auto obj_ctx = sysobj_svc->init_obj_ctx();
+  auto sysobj = sysobj_svc->get_obj(obj_ctx, rgw_raw_obj(pool, oid));
+  return sysobj.wop()
+               .set_exclusive(exclusive)
+              .write(bl);
 }
 
 int RGWSystemMetaObj::rename(const string& new_name)
@@ -512,7 +570,9 @@ int RGWSystemMetaObj::rename(const string& new_name)
   rgw_pool pool(get_pool(cct));
   string oid = get_names_oid_prefix() + old_name;
   rgw_raw_obj old_name_obj(pool, oid);
-  ret = store->delete_system_obj(old_name_obj);
+  auto obj_ctx = sysobj_svc->init_obj_ctx();
+  auto sysobj = sysobj_svc->get_obj(obj_ctx, old_name_obj);
+  ret = sysobj.wop().remove();
   if (ret < 0) {
     ldout(cct, 0) << "Error delete old obj name  " << old_name << ": " << cpp_strerror(-ret) << dendl;
     return ret;
@@ -529,9 +589,9 @@ int RGWSystemMetaObj::read_info(const string& obj_id, bool old_format)
 
   string oid = get_info_oid_prefix(old_format) + obj_id;
 
-  RGWSysObjectCtx obj_ctx = sysobj_svc->get_obj_ctx();
-
-  int ret = rgw_get_system_obj(store, obj_ctx, pool, oid, bl, NULL, NULL);
+  auto obj_ctx = sysobj_svc->init_obj_ctx();
+  auto sysobj = sysobj_svc->get_obj(obj_ctx, rgw_raw_obj{pool, oid});
+  int ret = sysobj.rop().read(&bl);
   if (ret < 0) {
     ldout(cct, 0) << "failed reading obj info from " << pool << ":" << oid << ": " << cpp_strerror(-ret) << dendl;
     return ret;
@@ -600,7 +660,11 @@ int RGWSystemMetaObj::store_info(bool exclusive)
   bufferlist bl;
   using ceph::encode;
   encode(*this, bl);
-  return rgw_put_system_obj(store, pool, oid, bl, exclusive, NULL, real_time(), NULL);
+  auto obj_ctx = sysobj_svc->init_obj_ctx();
+  auto sysobj = sysobj_svc->get_obj(obj_ctx, rgw_raw_obj{pool, oid});
+  return sysobj.wop()
+               .set_exclusive(exclusive)
+              .write(bl);
 }
 
 int RGWSystemMetaObj::write(bool exclusive)
@@ -639,7 +703,7 @@ int RGWRealm::create(bool exclusive)
   RGWPeriod period;
   if (current_period.empty()) {
     /* create new period for the realm */
-    ret = period.init(cct, store, id, name, false);
+    ret = period.init(cct, sysobj_svc, id, name, false);
     if (ret < 0 ) {
       return ret;
     }
@@ -650,7 +714,7 @@ int RGWRealm::create(bool exclusive)
     }
   } else {
     period = RGWPeriod(current_period, 0);
-    int ret = period.init(cct, store, id, name);
+    int ret = period.init(cct, sysobj_svc, id, name);
     if (ret < 0) {
       ldout(cct, 0) << "ERROR: failed to init period " << current_period << dendl;
       return ret;
@@ -685,15 +749,20 @@ int RGWRealm::create_control(bool exclusive)
   auto pool = rgw_pool{get_pool(cct)};
   auto oid = get_control_oid();
   bufferlist bl;
-  return rgw_put_system_obj(store, pool, oid, bl, exclusive,
-                            nullptr, real_time(), nullptr);
+  auto obj_ctx = sysobj_svc->init_obj_ctx();
+  auto sysobj = sysobj_svc->get_obj(obj_ctx, rgw_raw_obj{pool, oid});
+  return sysobj.wop()
+               .set_exclusive(exclusive)
+              .write(bl);
 }
 
 int RGWRealm::delete_control()
 {
   auto pool = rgw_pool{get_pool(cct)};
   auto obj = rgw_raw_obj{pool, get_control_oid()};
-  return store->delete_system_obj(obj);
+  auto obj_ctx = sysobj_svc->init_obj_ctx();
+  auto sysobj = sysobj_svc->get_obj(obj_ctx, obj);
+  return sysobj.wop().remove();
 }
 
 rgw_pool RGWRealm::get_pool(CephContext *cct)
@@ -809,15 +878,15 @@ rgw_pool RGWPeriodConfig::get_pool(CephContext *cct)
   return {pool_name};
 }
 
-int RGWPeriodConfig::read(RGWRados *store, const std::string& realm_id)
+int RGWPeriodConfig::read(RGWSI_SysObj *sysobj_svc, const std::string& realm_id)
 {
-  RGWSysObjectCtx obj_ctx = sysobj_svc->get_obj_ctx();
-
-  const auto& pool = get_pool(store->ctx());
+  const auto& pool = get_pool(sysobj_svc->ctx());
   const auto& oid = get_oid(realm_id);
   bufferlist bl;
 
-  int ret = rgw_get_system_obj(store, obj_ctx, pool, oid, bl, nullptr, nullptr);
+  auto obj_ctx = sysobj_svc->init_obj_ctx();
+  auto sysobj = sysobj_svc->get_obj(obj_ctx, rgw_raw_obj{pool, oid});
+  int ret = sysobj.rop().read(&bl);
   if (ret < 0) {
     return ret;
   }
@@ -831,43 +900,47 @@ int RGWPeriodConfig::read(RGWRados *store, const std::string& realm_id)
   return 0;
 }
 
-int RGWPeriodConfig::write(RGWRados *store, const std::string& realm_id)
+int RGWPeriodConfig::write(RGWSI_SysObj *sysobj_svc, const std::string& realm_id)
 {
-  const auto& pool = get_pool(store->ctx());
+  const auto& pool = get_pool(sysobj_svc->ctx());
   const auto& oid = get_oid(realm_id);
   bufferlist bl;
   using ceph::encode;
   encode(*this, bl);
-  return rgw_put_system_obj(store, pool, oid, bl,
-                            false, nullptr, real_time(), nullptr);
+  auto obj_ctx = sysobj_svc->init_obj_ctx();
+  auto sysobj = sysobj_svc->get_obj(obj_ctx, rgw_raw_obj{pool, oid});
+  return sysobj.wop()
+               .set_exclusive(false)
+              .write(bl);
 }
 
-int RGWPeriod::init(CephContext *_cct, RGWRados *_store, const string& period_realm_id,
+int RGWPeriod::init(CephContext *_cct, RGWSI_SysObj *_sysobj_svc, const string& period_realm_id,
                    const string& period_realm_name, bool setup_obj)
 {
   cct = _cct;
-  store = _store;
+  sysobj_svc = _sysobj_svc;
+
   realm_id = period_realm_id;
   realm_name = period_realm_name;
 
   if (!setup_obj)
     return 0;
 
-  return init(_cct, _store, setup_obj);
+  return init(_cct, _sysobj_svc, setup_obj);
 }
 
 
-int RGWPeriod::init(CephContext *_cct, RGWRados *_store, bool setup_obj)
+int RGWPeriod::init(CephContext *_cct, RGWSI_SysObj *_sysobj_svc, bool setup_obj)
 {
   cct = _cct;
-  store = _store;
+  sysobj_svc = _sysobj_svc;
 
   if (!setup_obj)
     return 0;
 
   if (id.empty()) {
     RGWRealm realm(realm_id, realm_name);
-    int ret = realm.init(cct, store);
+    int ret = realm.init(cct, sysobj_svc);
     if (ret < 0) {
       ldout(cct, 0) << "RGWPeriod::init failed to init realm " << realm_name  << " id " << realm_id << " : " <<
        cpp_strerror(-ret) << dendl;
@@ -905,29 +978,6 @@ int RGWPeriod::get_zonegroup(RGWZoneGroup& zonegroup, const string& zonegroup_id
   return -ENOENT;
 }
 
-bool RGWRados::get_redirect_zone_endpoint(string *endpoint)
-{
-  if (zone_public_config.redirect_zone.empty()) {
-    return false;
-  }
-
-  auto iter = zone_conn_map.find(zone_public_config.redirect_zone);
-  if (iter == zone_conn_map.end()) {
-    ldout(cct, 0) << "ERROR: cannot find entry for redirect zone: " << zone_public_config.redirect_zone << dendl;
-    return false;
-  }
-
-  RGWRESTConn *conn = iter->second;
-
-  int ret = conn->get_url(*endpoint);
-  if (ret < 0) {
-    ldout(cct, 0) << "ERROR: redirect zone, conn->get_endpoint() returned ret=" << ret << dendl;
-    return false;
-  }
-
-  return true;
-}
-
 const string& RGWPeriod::get_latest_epoch_oid()
 {
   if (cct->_conf->rgw_period_latest_epoch_info_oid.empty()) {
@@ -963,9 +1013,9 @@ int RGWPeriod::read_latest_epoch(RGWPeriodLatestEpochInfo& info,
 
   rgw_pool pool(get_pool(cct));
   bufferlist bl;
-  RGWSysObjectCtx obj_ctx = sysobj_svc->get_obj_ctx();
-
-  int ret = rgw_get_system_obj(store, obj_ctx, pool, oid, bl, objv, nullptr);
+  auto obj_ctx = sysobj_svc->init_obj_ctx();
+  auto sysobj = sysobj_svc->get_obj(obj_ctx, rgw_raw_obj{pool, oid});
+  int ret = sysobj.rop().read(&bl);
   if (ret < 0) {
     ldout(cct, 1) << "error read_lastest_epoch " << pool << ":" << oid << dendl;
     return ret;
@@ -1023,8 +1073,11 @@ int RGWPeriod::set_latest_epoch(epoch_t epoch, bool exclusive,
   using ceph::encode;
   encode(info, bl);
 
-  return rgw_put_system_obj(store, pool, oid, bl,
-                            exclusive, objv, real_time(), nullptr);
+  auto obj_ctx = sysobj_svc->init_obj_ctx();
+  auto sysobj = sysobj_svc->get_obj(obj_ctx, rgw_raw_obj(pool, oid));
+  return sysobj.wop()
+               .set_exclusive(exclusive)
+               .write(bl);
 }
 
 int RGWPeriod::update_latest_epoch(epoch_t epoch)
@@ -1080,7 +1133,9 @@ int RGWPeriod::delete_obj()
   for (epoch_t e = 1; e <= epoch; e++) {
     RGWPeriod p{get_id(), e};
     rgw_raw_obj oid{pool, p.get_period_oid()};
-    int ret = store->delete_system_obj(oid);
+    auto obj_ctx = sysobj_svc->init_obj_ctx();
+    auto sysobj = sysobj_svc->get_obj(obj_ctx, oid);
+    int ret = sysobj.wop().remove();
     if (ret < 0) {
       ldout(cct, 0) << "WARNING: failed to delete period object " << oid
           << ": " << cpp_strerror(-ret) << dendl;
@@ -1089,7 +1144,9 @@ int RGWPeriod::delete_obj()
 
   // delete the .latest_epoch object
   rgw_raw_obj oid{pool, get_period_oid_prefix() + get_latest_epoch_oid()};
-  int ret = store->delete_system_obj(oid);
+  auto obj_ctx = sysobj_svc->init_obj_ctx();
+  auto sysobj = sysobj_svc->get_obj(obj_ctx, oid);
+  int ret = sysobj.wop().remove();
   if (ret < 0) {
     ldout(cct, 0) << "WARNING: failed to delete period object " << oid
         << ": " << cpp_strerror(-ret) << dendl;
@@ -1103,10 +1160,9 @@ int RGWPeriod::read_info()
 
   bufferlist bl;
 
-  RGWSysObjectCtx obj_ctx = sysobj_svc->get_obj_ctx();
-
-
-  int ret = rgw_get_system_obj(store, obj_ctx, pool, get_period_oid(), bl, NULL, NULL);
+  auto obj_ctx = sysobj_svc->init_obj_ctx();
+  auto sysobj = sysobj_svc->get_obj(obj_ctx, rgw_raw_obj{pool, get_period_oid()});
+  int ret = sysobj.rop().read(&bl);
   if (ret < 0) {
     ldout(cct, 0) << "failed reading obj info from " << pool << ":" << get_period_oid() << ": " << cpp_strerror(-ret) << dendl;
     return ret;
@@ -1162,8 +1218,11 @@ int RGWPeriod::store_info(bool exclusive)
   using ceph::encode;
   encode(*this, bl);
 
-  return rgw_put_system_obj(store, pool, oid, bl,
-                            exclusive, NULL, real_time(), NULL);
+  auto obj_ctx = sysobj_svc->init_obj_ctx();
+  auto sysobj = sysobj_svc->get_obj(obj_ctx, rgw_raw_obj(pool, oid));
+  return sysobj.wop()
+               .set_exclusive(exclusive)
+               .write(bl);
 }
 
 rgw_pool RGWPeriod::get_pool(CephContext *cct)
@@ -1190,9 +1249,10 @@ int RGWPeriod::add_zonegroup(const RGWZoneGroup& zonegroup)
 
 int RGWPeriod::update()
 {
+  auto zone_svc = sysobj_svc->get_zone_svc();
   ldout(cct, 20) << __func__ << " realm " << realm_id << " period " << get_id() << dendl;
   list<string> zonegroups;
-  int ret = store->list_zonegroups(zonegroups);
+  int ret = zone_svc->list_zonegroups(zonegroups);
   if (ret < 0) {
     ldout(cct, 0) << "ERROR: failed to list zonegroups: " << cpp_strerror(-ret) << dendl;
     return ret;
@@ -1204,7 +1264,7 @@ int RGWPeriod::update()
 
   for (auto& iter : zonegroups) {
     RGWZoneGroup zg(string(), iter);
-    ret = zg.init(cct, store);
+    ret = zg.init(cct, sysobj_svc);
     if (ret < 0) {
       ldout(cct, 0) << "WARNING: zg.init() failed: " << cpp_strerror(-ret) << dendl;
       continue;
@@ -1231,7 +1291,7 @@ int RGWPeriod::update()
     }
   }
 
-  ret = period_config.read(store, realm_id);
+  ret = period_config.read(sysobj_svc, realm_id);
   if (ret < 0 && ret != -ENOENT) {
     ldout(cct, 0) << "ERROR: failed to read period config: "
         << cpp_strerror(ret) << dendl;
@@ -1244,7 +1304,7 @@ int RGWPeriod::reflect()
 {
   for (auto& iter : period_map.zonegroups) {
     RGWZoneGroup& zg = iter.second;
-    zg.reinit_instance(cct, store);
+    zg.reinit_instance(cct, sysobj_svc);
     int r = zg.write(false);
     if (r < 0) {
       ldout(cct, 0) << "ERROR: failed to store zonegroup info for zonegroup=" << iter.first << ": " << cpp_strerror(-r) << dendl;
@@ -1260,7 +1320,7 @@ int RGWPeriod::reflect()
     }
   }
 
-  int r = period_config.write(store, realm_id);
+  int r = period_config.write(sysobj_svc, realm_id);
   if (r < 0) {
     ldout(cct, 0) << "ERROR: failed to store period config: "
         << cpp_strerror(-r) << dendl;
@@ -1343,11 +1403,12 @@ int RGWPeriod::update_sync_status(const RGWPeriod &current_period,
 int RGWPeriod::commit(RGWRealm& realm, const RGWPeriod& current_period,
                       std::ostream& error_stream, bool force_if_stale)
 {
+  auto zone_svc = sysobj_svc->get_zone_svc();
   ldout(cct, 20) << __func__ << " realm " << realm.get_id() << " period " << current_period.get_id() << dendl;
   // gateway must be in the master zone to commit
-  if (master_zone != store->get_zone_params().get_id()) {
+  if (master_zone != zone_svc->get_zone_params().get_id()) {
     error_stream << "Cannot commit period on zone "
-        << store->get_zone_params().get_id() << ", it must be sent to "
+        << zone_svc->get_zone_params().get_id() << ", it must be sent to "
         "the period's master zone " << master_zone << '.' << std::endl;
     return -EINVAL;
   }
@@ -1453,14 +1514,14 @@ int RGWZoneParams::create_default(bool old_format)
 
 
 int get_zones_pool_set(CephContext* cct,
-                       RGWRados* store,
+                       RGWSI_SysObj* sysobj_svc,
                        const list<string>& zones,
                        const string& my_zone_id,
                        set<rgw_pool>& pool_names)
 {
   for(auto const& iter : zones) {
     RGWZoneParams zone(iter);
-    int r = zone.init(cct, store);
+    int r = zone.init(cct, sysobj_svc);
     if (r < 0) {
       ldout(cct, 0) << "Error: init zone " << iter << ":" << cpp_strerror(-r) << dendl;
       return r;
@@ -1523,13 +1584,13 @@ int RGWZoneParams::fix_pool_names()
 {
 
   list<string> zones;
-  int r = store->list_zones(zones);
+  int r = zone_svc->list_zones(zones);
   if (r < 0) {
     ldout(cct, 10) << "WARNING: store->list_zones() returned r=" << r << dendl;
   }
 
   set<rgw_pool> pools;
-  r = get_zones_pool_set(cct, store, zones, id, pools);
+  r = get_zones_pool_set(cct, zone_svc, zones, id, pools);
   if (r < 0) {
     ldout(cct, 0) << "Error: get_zones_pool_names" << r << dendl;
     return r;
@@ -1569,9 +1630,11 @@ int RGWZoneParams::create(bool exclusive)
 {
   /* check for old pools config */
   rgw_raw_obj obj(domain_root, avail_pools);
-  int r = store->raw_obj_stat(obj, NULL, NULL, NULL, NULL, NULL, NULL);
+  auto obj_ctx = sysobj_svc->init_obj_ctx();
+  auto sysobj = sysobj_svc->get_obj(obj_ctx, obj);
+  int r = sysobj.rop().stat();
   if (r < 0) {
-    ldout(store->ctx(), 10) << "couldn't find old data placement pools config, setting up new ones for the zone" << dendl;
+    ldout(cct, 10) << "couldn't find old data placement pools config, setting up new ones for the zone" << dendl;
     /* a new system, let's set new placement info */
     RGWZonePlacementInfo default_placement;
     default_placement.index_pool = name + "." + default_bucket_index_pool_suffix;
@@ -1633,13 +1696,13 @@ const string& RGWZoneParams::get_predefined_name(CephContext *cct) {
   return cct->_conf->rgw_zone;
 }
 
-int RGWZoneParams::init(CephContext *cct, RGWRados *store, bool setup_obj, bool old_format)
+int RGWZoneParams::init(CephContext *cct, RGWSI_SysObj *sysobj_svc, bool setup_obj, bool old_format)
 {
   if (name.empty()) {
     name = cct->_conf->rgw_zone;
   }
 
-  return RGWSystemMetaObj::init(cct, store, setup_obj, old_format);
+  return RGWSystemMetaObj::init(cct, sysobj_svc, setup_obj, old_format);
 }
 
 int RGWZoneParams::read_default_id(string& default_id, bool old_format)
@@ -1647,7 +1710,7 @@ int RGWZoneParams::read_default_id(string& default_id, bool old_format)
   if (realm_id.empty()) {
     /* try using default realm */
     RGWRealm realm;
-    int ret = realm.init(cct, store);
+    int ret = realm.init(cct, sysobj_svc);
     //no default realm exist
     if (ret < 0) {
       return read_id(default_zone_name, default_id);
@@ -1664,7 +1727,7 @@ int RGWZoneParams::set_as_default(bool exclusive)
   if (realm_id.empty()) {
     /* try using default realm */
     RGWRealm realm;
-    int ret = realm.init(cct, store);
+    int ret = realm.init(cct, sysobj_svc);
     if (ret < 0) {
       ldout(cct, 10) << "could not read realm id: " << cpp_strerror(-ret) << dendl;
       return -EINVAL;
@@ -1788,11 +1851,11 @@ uint32_t RGWPeriodMap::get_zone_short_id(const string& zone_id) const
   return i->second;
 }
 
-int RGWZoneGroupMap::read(CephContext *cct, RGWRados *store)
+int RGWZoneGroupMap::read(CephContext *cct, RGWSI_SysObj *sysobj_svc)
 {
 
   RGWPeriod period;
-  int ret = period.init(cct, store);
+  int ret = period.init(cct, sysobj_svc);
   if (ret < 0) {
     cerr << "failed to read current period info: " << cpp_strerror(ret);
     return ret;
index 48ada717e4ca488c80858e203fe473f6b4812266..7622e9befd261dd4d8162f79c15ec29deff3b7f7 100644 (file)
@@ -1,8 +1,35 @@
 #ifndef CEPH_RGW_ZONE_H
 #define CEPH_RGW_ZONE_H
 
+#include "rgw_common.h"
+
+namespace rgw_zone_defaults {
+
+extern std::string zone_names_oid_prefix;
+extern std::string region_info_oid_prefix;
+extern std::string realm_names_oid_prefix;
+extern std::string zone_group_info_oid_prefix;
+extern std::string realm_info_oid_prefix;
+extern std::string default_region_info_oid;
+extern std::string default_zone_group_info_oid;
+extern std::string region_map_oid;
+extern std::string default_realm_info_oid;
+extern std::string default_zonegroup_name;
+extern std::string default_zone_name;
+extern std::string zonegroup_names_oid_prefix;
+extern std::string RGW_DEFAULT_ZONE_ROOT_POOL;
+extern std::string RGW_DEFAULT_ZONEGROUP_ROOT_POOL;
+extern std::string RGW_DEFAULT_REALM_ROOT_POOL;
+extern std::string RGW_DEFAULT_PERIOD_ROOT_POOL;
+extern std::string avail_pools;
+extern std::string default_storage_pool_suffix;
+
+}
+
+class JSONObj;
+
 struct RGWNameToId {
-  string obj_id;
+  std::string obj_id;
 
   void encode(bufferlist& bl) const {
     ENCODE_START(1, 1, bl);
@@ -22,7 +49,7 @@ struct RGWNameToId {
 WRITE_CLASS_ENCODER(RGWNameToId)
 
 struct RGWDefaultSystemMetaObjInfo {
-  string default_id;
+  std::string default_id;
 
   void encode(bufferlist& bl) const {
     ENCODE_START(1, 1, bl);
@@ -42,36 +69,42 @@ struct RGWDefaultSystemMetaObjInfo {
 WRITE_CLASS_ENCODER(RGWDefaultSystemMetaObjInfo)
 
 class RGWSI_SysObj;
+class RGWSI_Zone;
 
 class RGWSystemMetaObj {
 protected:
-  string id;
-  string name;
+  std::string id;
+  std::string name;
 
   CephContext *cct{nullptr};
   RGWSI_SysObj *sysobj_svc{nullptr};
+  RGWSI_Zone *zone_svc{nullptr};
 
   int store_name(bool exclusive);
   int store_info(bool exclusive);
-  int read_info(const string& obj_id, bool old_format = false);
-  int read_id(const string& obj_name, string& obj_id);
+  int read_info(const std::string& obj_id, bool old_format = false);
+  int read_id(const std::string& obj_name, std::string& obj_id);
   int read_default(RGWDefaultSystemMetaObjInfo& default_info,
-                  const string& oid);
+                  const std::string& oid);
   /* read and use default id */
   int use_default(bool old_format = false);
 
 public:
   RGWSystemMetaObj() {}
-  RGWSystemMetaObj(const string& _name): name(_name) {}
-  RGWSystemMetaObj(const string& _id, const string& _name) : id(_id), name(_name) {}
-  RGWSystemMetaObj(CephContext *_cct, RGWSI_SysObj *_sysobj_svc): cct(_cct), sysobj_svc(_sysobj_svc){}
-  RGWSystemMetaObj(const string& _name, CephContext *_cct, RGWSI_SysObj *_sysobj_svc): name(_name), cct(_cct), sysobj_svc(_sysobj_svc){}
+  RGWSystemMetaObj(const std::string& _name): name(_name) {}
+  RGWSystemMetaObj(const std::string& _id, const std::string& _name) : id(_id), name(_name) {}
+  RGWSystemMetaObj(CephContext *_cct, RGWSI_SysObj *_sysobj_svc) {
+    reinit_instance(_cct, _sysobj_svc);
+  }
+  RGWSystemMetaObj(const std::string& _name, CephContext *_cct, RGWSI_SysObj *_sysobj_svc): name(_name) {
+    reinit_instance(_cct, _sysobj_svc);
+  }
 
-  const string& get_name() const { return name; }
-  const string& get_id() const { return id; }
+  const std::string& get_name() const { return name; }
+  const std::string& get_id() const { return id; }
 
-  void set_name(const string& _name) { name = _name;}
-  void set_id(const string& _id) { id = _id;}
+  void set_name(const std::string& _name) { name = _name;}
+  void set_id(const std::string& _id) { id = _id;}
   void clear_id() { id.clear(); }
 
   virtual ~RGWSystemMetaObj() {}
@@ -90,27 +123,24 @@ public:
     DECODE_FINISH(bl);
   }
 
-  void reinit_instance(CephContext *_cct, RGWSI_SysObj *_sysobj_svc) {
-    cct = _cct;
-    sysobj_svc = _sysobj_svc;
-  }
+  void reinit_instance(CephContext *_cct, RGWSI_SysObj *_sysobj_svc);
   int init(CephContext *_cct, RGWSI_SysObj *_sysobj_svc, bool setup_obj = true, bool old_format = false);
-  virtual int read_default_id(string& default_id, bool old_format = false);
+  virtual int read_default_id(std::string& default_id, bool old_format = false);
   virtual int set_as_default(bool exclusive = false);
   int delete_default();
   virtual int create(bool exclusive = true);
   int delete_obj(bool old_format = false);
-  int rename(const string& new_name);
+  int rename(const std::string& new_name);
   int update() { return store_info(false);}
   int update_name() { return store_name(false);}
   int read();
   int write(bool exclusive);
 
   virtual rgw_pool get_pool(CephContext *cct) = 0;
-  virtual const string get_default_oid(bool old_format = false) = 0;
-  virtual const string& get_names_oid_prefix() = 0;
-  virtual const string& get_info_oid_prefix(bool old_format = false) = 0;
-  virtual const string& get_predefined_name(CephContext *cct) = 0;
+  virtual const std::string get_default_oid(bool old_format = false) = 0;
+  virtual const std::string& get_names_oid_prefix() = 0;
+  virtual const std::string& get_info_oid_prefix(bool old_format = false) = 0;
+  virtual const std::string& get_predefined_name(CephContext *cct) = 0;
 
   void dump(Formatter *f) const;
   void decode_json(JSONObj *obj);
@@ -138,14 +168,14 @@ struct RGWZonePlacementInfo {
 
   void decode(bufferlist::const_iterator& bl) {
     DECODE_START(6, bl);
-    string index_pool_str;
-    string data_pool_str;
+    std::string index_pool_str;
+    std::string data_pool_str;
     decode(index_pool_str, bl);
     index_pool = rgw_pool(index_pool_str);
     decode(data_pool_str, bl);
     data_pool = rgw_pool(data_pool_str);
     if (struct_v >= 4) {
-      string data_extra_pool_str;
+      std::string data_extra_pool_str;
       decode(data_extra_pool_str, bl);
       data_extra_pool = rgw_pool(data_extra_pool_str);
     }
@@ -190,34 +220,34 @@ struct RGWZoneParams : RGWSystemMetaObj {
 
   RGWAccessKey system_key;
 
-  map<string, RGWZonePlacementInfo> placement_pools;
+  map<std::string, RGWZonePlacementInfo> placement_pools;
 
-  string realm_id;
+  std::string realm_id;
 
   JSONFormattable tier_config;
 
   RGWZoneParams() : RGWSystemMetaObj() {}
-  explicit RGWZoneParams(const string& name) : RGWSystemMetaObj(name){}
-  RGWZoneParams(const string& id, const string& name) : RGWSystemMetaObj(id, name) {}
-  RGWZoneParams(const string& id, const string& name, const string& _realm_id)
+  explicit RGWZoneParams(const std::string& name) : RGWSystemMetaObj(name){}
+  RGWZoneParams(const std::string& id, const std::string& name) : RGWSystemMetaObj(id, name) {}
+  RGWZoneParams(const std::string& id, const std::string& name, const std::string& _realm_id)
     : RGWSystemMetaObj(id, name), realm_id(_realm_id) {}
 
   rgw_pool get_pool(CephContext *cct) override;
-  const string get_default_oid(bool old_format = false) override;
-  const string& get_names_oid_prefix() override;
-  const string& get_info_oid_prefix(bool old_format = false) override;
-  const string& get_predefined_name(CephContext *cct) override;
+  const std::string get_default_oid(bool old_format = false) override;
+  const std::string& get_names_oid_prefix() override;
+  const std::string& get_info_oid_prefix(bool old_format = false) override;
+  const std::string& get_predefined_name(CephContext *cct) override;
 
   int init(CephContext *_cct, RGWSI_SysObj *_sysobj_svc, bool setup_obj = true,
           bool old_format = false);
   using RGWSystemMetaObj::init;
-  int read_default_id(string& default_id, bool old_format = false) override;
+  int read_default_id(std::string& default_id, bool old_format = false) override;
   int set_as_default(bool exclusive = false) override;
   int create_default(bool old_format = false);
   int create(bool exclusive = true) override;
   int fix_pool_names();
 
-  const string& get_compression_type(const string& placement_rule) const;
+  const std::string& get_compression_type(const std::string& placement_rule) const;
   
   void encode(bufferlist& bl) const override {
     ENCODE_START(12, 1, bl);
@@ -237,7 +267,7 @@ struct RGWZoneParams : RGWSystemMetaObj {
     encode(metadata_heap, bl);
     encode(realm_id, bl);
     encode(lc_pool, bl);
-    map<string, string, ltstr_nocase> old_tier_config;
+    map<std::string, std::string, ltstr_nocase> old_tier_config;
     encode(old_tier_config, bl);
     encode(roles_pool, bl);
     encode(reshard_pool, bl);
@@ -278,7 +308,7 @@ struct RGWZoneParams : RGWSystemMetaObj {
     } else {
       lc_pool = log_pool.name + ":lc";
     }
-    map<string, string, ltstr_nocase> old_tier_config;
+    map<std::string, std::string, ltstr_nocase> old_tier_config;
     if (struct_v >= 8) {
       decode(old_tier_config, bl);
     }
@@ -310,7 +340,7 @@ struct RGWZoneParams : RGWSystemMetaObj {
   void decode_json(JSONObj *obj);
   static void generate_test_instances(list<RGWZoneParams*>& o);
 
-  bool get_placement(const string& placement_id, RGWZonePlacementInfo *placement) const {
+  bool get_placement(const std::string& placement_id, RGWZonePlacementInfo *placement) const {
     auto iter = placement_pools.find(placement_id);
     if (iter == placement_pools.end()) {
       return false;
@@ -322,7 +352,7 @@ struct RGWZoneParams : RGWSystemMetaObj {
   /*
    * return data pool of the head object
    */
-  bool get_head_data_pool(const string& placement_id, const rgw_obj& obj, rgw_pool *pool) const {
+  bool get_head_data_pool(const std::string& placement_id, const rgw_obj& obj, rgw_pool *pool) const {
     const rgw_data_placement_target& explicit_placement = obj.bucket.explicit_placement;
     if (!explicit_placement.data_pool.empty()) {
       if (!obj.in_extra_data) {
@@ -350,15 +380,15 @@ struct RGWZoneParams : RGWSystemMetaObj {
 WRITE_CLASS_ENCODER(RGWZoneParams)
 
 struct RGWZone {
-  string id;
-  string name;
-  list<string> endpoints;
+  std::string id;
+  std::string name;
+  list<std::string> endpoints;
   bool log_meta;
   bool log_data;
   bool read_only;
-  string tier_type;
+  std::string tier_type;
 
-  string redirect_zone;
+  std::string redirect_zone;
 
 /**
  * Represents the number of shards for the bucket index object, a value of zero
@@ -370,7 +400,7 @@ struct RGWZone {
   uint32_t bucket_index_max_shards;
 
   bool sync_from_all;
-  set<string> sync_from; /* list of zones to sync from */
+  set<std::string> sync_from; /* list of zones to sync from */
 
   RGWZone() : log_meta(false), log_data(false), read_only(false), bucket_index_max_shards(0),
               sync_from_all(true) {}
@@ -427,14 +457,14 @@ struct RGWZone {
 
   bool is_read_only() { return read_only; }
 
-  bool syncs_from(const string& zone_id) const {
+  bool syncs_from(const std::string& zone_id) const {
     return (sync_from_all || sync_from.find(zone_id) != sync_from.end());
   }
 };
 WRITE_CLASS_ENCODER(RGWZone)
 
 struct RGWDefaultZoneGroupInfo {
-  string default_zonegroup;
+  std::string default_zonegroup;
 
   void encode(bufferlist& bl) const {
     ENCODE_START(1, 1, bl);
@@ -454,10 +484,10 @@ struct RGWDefaultZoneGroupInfo {
 WRITE_CLASS_ENCODER(RGWDefaultZoneGroupInfo)
 
 struct RGWZoneGroupPlacementTarget {
-  string name;
-  set<string> tags;
+  std::string name;
+  set<std::string> tags;
 
-  bool user_permitted(list<string>& user_tags) const {
+  bool user_permitted(list<std::string>& user_tags) const {
     if (tags.empty()) {
       return true;
     }
@@ -489,25 +519,25 @@ WRITE_CLASS_ENCODER(RGWZoneGroupPlacementTarget)
 
 
 struct RGWZoneGroup : public RGWSystemMetaObj {
-  string api_name;
-  list<string> endpoints;
+  std::string api_name;
+  list<std::string> endpoints;
   bool is_master = false;
 
-  string master_zone;
-  map<string, RGWZone> zones;
+  std::string master_zone;
+  map<std::string, RGWZone> zones;
 
-  map<string, RGWZoneGroupPlacementTarget> placement_targets;
-  string default_placement;
+  map<std::string, RGWZoneGroupPlacementTarget> placement_targets;
+  std::string default_placement;
 
-  list<string> hostnames;
-  list<string> hostnames_s3website;
-  // TODO: Maybe convert hostnames to a map<string,list<string>> for
+  list<std::string> hostnames;
+  list<std::string> hostnames_s3website;
+  // TODO: Maybe convert hostnames to a map<std::string,list<std::string>> for
   // endpoint_type->hostnames
 /*
 20:05 < _robbat21irssi> maybe I do someting like: if (hostname_map.empty()) { populate all map keys from hostnames; };
 20:05 < _robbat21irssi> but that's a later compatability migration planning bit
 20:06 < yehudasa> more like if (!hostnames.empty()) {
-20:06 < yehudasa> for (list<string>::iterator iter = hostnames.begin(); iter != hostnames.end(); ++iter) {
+20:06 < yehudasa> for (list<std::string>::iterator iter = hostnames.begin(); iter != hostnames.end(); ++iter) {
 20:06 < yehudasa> hostname_map["s3"].append(iter->second);
 20:07 < yehudasa> hostname_map["s3website"].append(iter->second);
 20:07 < yehudasa> s/append/push_back/g
@@ -515,16 +545,16 @@ struct RGWZoneGroup : public RGWSystemMetaObj {
 20:08 < yehudasa> yeah, probably
 20:08 < _robbat21irssi> s3, s3website, swift, swith_auth, swift_website
 */
-  map<string, list<string> > api_hostname_map;
-  map<string, list<string> > api_endpoints_map;
+  map<std::string, list<std::string> > api_hostname_map;
+  map<std::string, list<std::string> > api_endpoints_map;
 
-  string realm_id;
+  std::string realm_id;
 
   RGWZoneGroup(): is_master(false){}
   RGWZoneGroup(const std::string &id, const std::string &name):RGWSystemMetaObj(id, name) {}
   explicit RGWZoneGroup(const std::string &_name):RGWSystemMetaObj(_name) {}
   RGWZoneGroup(const std::string &_name, bool _is_master, CephContext *cct, RGWSI_SysObj* sysobj_svc,
-              const string& _realm_id, const list<string>& _endpoints)
+              const std::string& _realm_id, const list<std::string>& _endpoints)
     : RGWSystemMetaObj(_name, cct , sysobj_svc), endpoints(_endpoints), is_master(_is_master),
       realm_id(_realm_id) {}
 
@@ -577,21 +607,21 @@ struct RGWZoneGroup : public RGWSystemMetaObj {
     DECODE_FINISH(bl);
   }
 
-  int read_default_id(string& default_id, bool old_format = false) override;
+  int read_default_id(std::string& default_id, bool old_format = false) override;
   int set_as_default(bool exclusive = false) override;
   int create_default(bool old_format = false);
-  int equals(const string& other_zonegroup) const;
+  int equals(const std::string& other_zonegroup) const;
   int add_zone(const RGWZoneParams& zone_params, bool *is_master, bool *read_only,
-               const list<string>& endpoints, const string *ptier_type,
-               bool *psync_from_all, list<string>& sync_from, list<string>& sync_from_rm,
-               string *predirect_zone);
+               const list<std::string>& endpoints, const std::string *ptier_type,
+               bool *psync_from_all, list<std::string>& sync_from, list<std::string>& sync_from_rm,
+               std::string *predirect_zone);
   int remove_zone(const std::string& zone_id);
   int rename_zone(const RGWZoneParams& zone_params);
   rgw_pool get_pool(CephContext *cct) override;
-  const string get_default_oid(bool old_region_format = false) override;
-  const string& get_info_oid_prefix(bool old_region_format = false) override;
-  const string& get_names_oid_prefix() override;
-  const string& get_predefined_name(CephContext *cct) override;
+  const std::string get_default_oid(bool old_region_format = false) override;
+  const std::string& get_info_oid_prefix(bool old_region_format = false) override;
+  const std::string& get_names_oid_prefix() override;
+  const std::string& get_predefined_name(CephContext *cct) override;
 
   void dump(Formatter *f) const;
   void decode_json(JSONObj *obj);
@@ -601,12 +631,12 @@ WRITE_CLASS_ENCODER(RGWZoneGroup)
 
 struct RGWPeriodMap
 {
-  string id;
-  map<string, RGWZoneGroup> zonegroups;
-  map<string, RGWZoneGroup> zonegroups_by_api;
-  map<string, uint32_t> short_zone_ids;
+  std::string id;
+  map<std::string, RGWZoneGroup> zonegroups;
+  map<std::string, RGWZoneGroup> zonegroups_by_api;
+  map<std::string, uint32_t> short_zone_ids;
 
-  string master_zonegroup;
+  std::string master_zonegroup;
 
   void encode(bufferlist& bl) const;
   void decode(bufferlist::const_iterator& bl);
@@ -622,7 +652,7 @@ struct RGWPeriodMap
     master_zonegroup.clear();
   }
 
-  uint32_t get_zone_short_id(const string& zone_id) const;
+  uint32_t get_zone_short_id(const std::string& zone_id) const;
 };
 WRITE_CLASS_ENCODER(RGWPeriodMap)
 
@@ -662,9 +692,9 @@ WRITE_CLASS_ENCODER(RGWPeriodConfig)
 /* for backward comaptability */
 struct RGWRegionMap {
 
-  map<string, RGWZoneGroup> regions;
+  map<std::string, RGWZoneGroup> regions;
 
-  string master_region;
+  std::string master_region;
 
   RGWQuotaInfo bucket_quota;
   RGWQuotaInfo user_quota;
@@ -679,10 +709,10 @@ WRITE_CLASS_ENCODER(RGWRegionMap)
 
 struct RGWZoneGroupMap {
 
-  map<string, RGWZoneGroup> zonegroups;
-  map<string, RGWZoneGroup> zonegroups_by_api;
+  map<std::string, RGWZoneGroup> zonegroups;
+  map<std::string, RGWZoneGroup> zonegroups_by_api;
 
-  string master_zonegroup;
+  std::string master_zonegroup;
 
   RGWQuotaInfo bucket_quota;
   RGWQuotaInfo user_quota;
@@ -703,16 +733,16 @@ class RGWPeriod;
 
 class RGWRealm : public RGWSystemMetaObj
 {
-  string current_period;
+  std::string current_period;
   epoch_t epoch{0}; //< realm epoch, incremented for each new period
 
   int create_control(bool exclusive);
   int delete_control();
 public:
   RGWRealm() {}
-  RGWRealm(const string& _id, const string& _name = "") : RGWSystemMetaObj(_id, _name) {}
+  RGWRealm(const std::string& _id, const std::string& _name = "") : RGWSystemMetaObj(_id, _name) {}
   RGWRealm(CephContext *_cct, RGWSI_SysObj *_sysobj_svc): RGWSystemMetaObj(_cct, _sysobj_svc) {}
-  RGWRealm(const string& _name, CephContext *_cct, RGWSI_SysObj *_sysobj_svc): RGWSystemMetaObj(_name, _cct, _sysobj_svc){}
+  RGWRealm(const std::string& _name, CephContext *_cct, RGWSI_SysObj *_sysobj_svc): RGWSystemMetaObj(_name, _cct, _sysobj_svc){}
 
   void encode(bufferlist& bl) const override {
     ENCODE_START(1, 1, bl);
@@ -733,17 +763,17 @@ public:
   int create(bool exclusive = true) override;
   int delete_obj();
   rgw_pool get_pool(CephContext *cct) override;
-  const string get_default_oid(bool old_format = false) override;
-  const string& get_names_oid_prefix() override;
-  const string& get_info_oid_prefix(bool old_format = false) override;
-  const string& get_predefined_name(CephContext *cct) override;
+  const std::string get_default_oid(bool old_format = false) override;
+  const std::string& get_names_oid_prefix() override;
+  const std::string& get_info_oid_prefix(bool old_format = false) override;
+  const std::string& get_predefined_name(CephContext *cct) override;
 
   using RGWSystemMetaObj::read_id; // expose as public for radosgw-admin
 
   void dump(Formatter *f) const;
   void decode_json(JSONObj *obj);
 
-  const string& get_current_period() const {
+  const std::string& get_current_period() const {
     return current_period;
   }
   int set_current_period(RGWPeriod& period);
@@ -753,7 +783,7 @@ public:
   }
   epoch_t get_epoch() const { return epoch; }
 
-  string get_control_oid();
+  std::string get_control_oid();
   /// send a notify on the realm control object
   int notify_zone(bufferlist& bl);
   /// notify the zone of a new period
@@ -783,17 +813,17 @@ WRITE_CLASS_ENCODER(RGWPeriodLatestEpochInfo)
 
 class RGWPeriod
 {
-  string id;
+  std::string id;
   epoch_t epoch{0};
-  string predecessor_uuid;
+  std::string predecessor_uuid;
   std::vector<std::string> sync_status;
   RGWPeriodMap period_map;
   RGWPeriodConfig period_config;
-  string master_zonegroup;
-  string master_zone;
+  std::string master_zonegroup;
+  std::string master_zone;
 
-  string realm_id;
-  string realm_name;
+  std::string realm_id;
+  std::string realm_name;
   epoch_t realm_epoch{1}; //< realm epoch when period was made current
 
   CephContext *cct{nullptr};
@@ -805,8 +835,8 @@ class RGWPeriod
   int use_latest_epoch();
   int use_current_period();
 
-  const string get_period_oid();
-  const string get_period_oid_prefix();
+  const std::string get_period_oid();
+  const std::string get_period_oid_prefix();
 
   // gather the metadata sync status for each shard; only for use on master zone
   int update_sync_status(const RGWPeriod &current_period,
@@ -815,23 +845,23 @@ class RGWPeriod
 public:
   RGWPeriod() {}
 
-  RGWPeriod(const string& period_id, epoch_t _epoch = 0)
+  RGWPeriod(const std::string& period_id, epoch_t _epoch = 0)
     : id(period_id), epoch(_epoch) {}
 
-  const string& get_id() const { return id; }
+  const std::string& get_id() const { return id; }
   epoch_t get_epoch() const { return epoch; }
   epoch_t get_realm_epoch() const { return realm_epoch; }
-  const string& get_predecessor() const { return predecessor_uuid; }
-  const string& get_master_zone() const { return master_zone; }
-  const string& get_master_zonegroup() const { return master_zonegroup; }
-  const string& get_realm() const { return realm_id; }
+  const std::string& get_predecessor() const { return predecessor_uuid; }
+  const std::string& get_master_zone() const { return master_zone; }
+  const std::string& get_master_zonegroup() const { return master_zonegroup; }
+  const std::string& get_realm() const { return realm_id; }
   const RGWPeriodMap& get_map() const { return period_map; }
   RGWPeriodConfig& get_config() { return period_config; }
   const RGWPeriodConfig& get_config() const { return period_config; }
   const std::vector<std::string>& get_sync_status() const { return sync_status; }
   rgw_pool get_pool(CephContext *cct);
-  const string& get_latest_epoch_oid();
-  const string& get_info_oid_prefix();
+  const std::string& get_latest_epoch_oid();
+  const std::string& get_info_oid_prefix();
 
   void set_user_quota(RGWQuotaInfo& user_quota) {
     period_config.user_quota = user_quota;
@@ -841,26 +871,26 @@ public:
     period_config.bucket_quota = bucket_quota;
   }
 
-  void set_id(const string& id) {
+  void set_id(const std::string& id) {
     this->id = id;
     period_map.id = id;
   }
   void set_epoch(epoch_t epoch) { this->epoch = epoch; }
   void set_realm_epoch(epoch_t epoch) { realm_epoch = epoch; }
 
-  void set_predecessor(const string& predecessor)
+  void set_predecessor(const std::string& predecessor)
   {
     predecessor_uuid = predecessor;
   }
 
-  void set_realm_id(const string& _realm_id) {
+  void set_realm_id(const std::string& _realm_id) {
     realm_id = _realm_id;
   }
 
   int reflect();
 
   int get_zonegroup(RGWZoneGroup& zonegroup,
-                   const string& zonegroup_id);
+                   const std::string& zonegroup_id);
 
   bool is_single_zonegroup() const
   {
@@ -889,7 +919,7 @@ public:
   // update latest_epoch if the given epoch is higher, else return -EEXIST
   int update_latest_epoch(epoch_t epoch);
 
-  int init(CephContext *_cct, RGWSI_SysObj *_sysobj_svc, const string &period_realm_id, const string &period_realm_name = "",
+  int init(CephContext *_cct, RGWSI_SysObj *_sysobj_svc, const std::string &period_realm_id, const std::string &period_realm_name = "",
           bool setup_obj = true);
   int init(CephContext *_cct, RGWSI_SysObj *_sysobj_svc, bool setup_obj = true);  
 
@@ -939,7 +969,7 @@ public:
   void dump(Formatter *f) const;
   void decode_json(JSONObj *obj);
 
-  static string get_staging_id(const string& realm_id) {
+  static std::string get_staging_id(const std::string& realm_id) {
     return realm_id + ":staging";
   }
 };
index e0b54fb508e21ee9fcbef14d694e7d0adc6272b2..8b4aa6e0093c97b7cebe2a3193421d8789de9f1f 100644 (file)
@@ -190,3 +190,8 @@ int RGWSI_SysObj::Obj::OmapOp::del(const std::string& key)
 
   return svc->omap_del(obj, key);
 }
+
+RGWSI_Zone *RGWSI_SysObj::get_zone_svc()
+{
+  return core_svc->get_zone_svc();
+}
index 2a7432da33b849f928b69516e59473c74914383d..f7429534905be25fdeb1bd50cb0aa2ecce352e18 100644 (file)
@@ -223,6 +223,7 @@ public:
     return Pool(core_svc.get(), pool);
   }
 
+  RGWSI_Zone *get_zone_svc();
 };
 
 using RGWSysObj = RGWSI_SysObj::Obj;
index d296909a524ea39a196710d9e1a5e4488f6dfa30..c330a865145265d0fe794c8a3ad569e32f38616c 100644 (file)
@@ -195,6 +195,9 @@ protected:
 public:
   RGWSI_SysObj_Core(RGWService *svc, CephContext *cct): RGWServiceInstance(svc, cct) {}
 
+  RGWSI_Zone *get_zone_svc() {
+    return zone_svc.get();
+  }
 };
 
 #endif
index 69e857c5bbbdb272670249eed80c53114ceba634..2c455acdd5daff4bfe69bf057e5e7dd7f69656a7 100644 (file)
 
 #define dout_subsys ceph_subsys_rgw
 
-static string zone_names_oid_prefix = "zone_names.";
-static string region_info_oid_prefix = "region_info.";
-static string realm_names_oid_prefix = "realms_names.";
-static string default_region_info_oid = "default.region";
-static string region_map_oid = "region_map";
-const string default_zonegroup_name = "default";
-const string default_zone_name = "default";
-static string zonegroup_names_oid_prefix = "zonegroups_names.";
-static string RGW_DEFAULT_ZONE_ROOT_POOL = "rgw.root";
-static string RGW_DEFAULT_ZONEGROUP_ROOT_POOL = "rgw.root";
-static string RGW_DEFAULT_REALM_ROOT_POOL = "rgw.root";
-static string RGW_DEFAULT_PERIOD_ROOT_POOL = "rgw.root";
-static string avail_pools = ".pools.avail";
-static string default_storage_pool_suffix = "rgw.buckets.data";
+using namespace rgw_zone_defaults;
 
 int RGWS_Zone::create_instance(const string& conf, RGWServiceInstanceRef *instance)
 {
@@ -1207,3 +1194,26 @@ int RGWSI_Zone::list_placement_set(set<rgw_pool>& names)
   return names.size();
 }
 
+bool RGWSI_Zone::get_redirect_zone_endpoint(string *endpoint)
+{
+  if (zone_public_config->redirect_zone.empty()) {
+    return false;
+  }
+
+  auto iter = zone_conn_map.find(zone_public_config->redirect_zone);
+  if (iter == zone_conn_map.end()) {
+    ldout(cct, 0) << "ERROR: cannot find entry for redirect zone: " << zone_public_config->redirect_zone << dendl;
+    return false;
+  }
+
+  RGWRESTConn *conn = iter->second;
+
+  int ret = conn->get_url(*endpoint);
+  if (ret < 0) {
+    ldout(cct, 0) << "ERROR: redirect zone, conn->get_endpoint() returned ret=" << ret << dendl;
+    return false;
+  }
+
+  return true;
+}
+