]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: zone service only provides const access to its data 25412/head
authorCasey Bodley <cbodley@redhat.com>
Tue, 4 Dec 2018 21:38:10 +0000 (16:38 -0500)
committerCasey Bodley <cbodley@redhat.com>
Wed, 5 Dec 2018 19:02:11 +0000 (14:02 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
17 files changed:
src/rgw/rgw_admin.cc
src/rgw/rgw_data_sync.cc
src/rgw/rgw_orphan.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_realm_watcher.cc
src/rgw/rgw_realm_watcher.h
src/rgw/rgw_rest.cc
src/rgw/rgw_rest.h
src/rgw/rgw_rest_swift.cc
src/rgw/rgw_sync_module_aws.cc
src/rgw/rgw_sync_module_es.cc
src/rgw/rgw_user.cc
src/rgw/rgw_zone.cc
src/rgw/rgw_zone.h
src/rgw/services/svc_zone.cc
src/rgw/services/svc_zone.h

index 80ec4908bf43d550afbca1554381d20479857324..205754ac486c8d6bd81f00bb890a8dca8888d49a 100644 (file)
@@ -2253,9 +2253,9 @@ static void tab_dump(const string& header, int width, const list<string>& entrie
 
 static void sync_status(Formatter *formatter)
 {
-  RGWRealm& realm = store->svc.zone->get_realm();
-  RGWZoneGroup& zonegroup = store->svc.zone->get_zonegroup();
-  RGWZone& zone = store->svc.zone->get_zone();
+  const RGWRealm& realm = store->svc.zone->get_realm();
+  const RGWZoneGroup& zonegroup = store->svc.zone->get_zonegroup();
+  const RGWZone& zone = store->svc.zone->get_zone();
 
   int width = 15;
 
@@ -2399,9 +2399,9 @@ static int bucket_sync_status(RGWRados *store, const RGWBucketInfo& info,
                               const std::string& source_zone_id,
                               std::ostream& out)
 {
-  RGWRealm& realm = store->svc.zone->get_realm();
-  RGWZoneGroup& zonegroup = store->svc.zone->get_zonegroup();
-  RGWZone& zone = store->svc.zone->get_zone();
+  const RGWRealm& realm = store->svc.zone->get_realm();
+  const RGWZoneGroup& zonegroup = store->svc.zone->get_zonegroup();
+  const RGWZone& zone = store->svc.zone->get_zone();
   constexpr int width = 15;
 
   out << indented{width, "realm"} << realm.get_id() << " (" << realm.get_name() << ")\n";
index d742daa738348e576c814cba13ea5e62d67a288c..2f2e992022381aace3a0717b93041fcd07628662 100644 (file)
@@ -1471,7 +1471,7 @@ class RGWDataSyncShardControlCR : public RGWBackoffControlCR {
 
   RGWSyncTraceNodeRef tn;
 public:
-  RGWDataSyncShardControlCR(RGWDataSyncEnv *_sync_env, rgw_pool& _pool,
+  RGWDataSyncShardControlCR(RGWDataSyncEnv *_sync_env, const rgw_pool& _pool,
                     uint32_t _shard_id, rgw_data_sync_marker& _marker,
                      RGWSyncTraceNodeRef& _tn_parent) : RGWBackoffControlCR(_sync_env->cct, false),
                                                       sync_env(_sync_env),
@@ -1764,7 +1764,7 @@ int RGWDataSyncStatusManager::init()
     return -ENOTSUP;
   }
 
-  RGWZoneParams& zone_params = store->svc.zone->get_zone_params();
+  const RGWZoneParams& zone_params = store->svc.zone->get_zone_params();
 
   if (sync_module == nullptr) { 
     sync_module = store->get_sync_module();
index 87e3e8e4f9752119e47288880a79b6be62a6613e..930bbb04895865963df4bafc8d78c1b4fbb2d30b 100644 (file)
@@ -145,7 +145,7 @@ int RGWOrphanStore::list_jobs(map <string,RGWOrphanSearchState>& job_list)
 
 int RGWOrphanStore::init()
 {
-  rgw_pool& log_pool = store->svc.zone->get_zone_params().log_pool;
+  const rgw_pool& log_pool = store->svc.zone->get_zone_params().log_pool;
   int r = rgw_init_ioctx(store->get_rados_handle(), log_pool, ioctx);
   if (r < 0) {
     cerr << "ERROR: failed to open log pool (" << log_pool << " ret=" << r << std::endl;
index 93ce2247ee4358b668d3a87d413c5cc8b270df05..eafc712d49642511e29b5d8bd290e75ab95f8ca9 100644 (file)
@@ -403,7 +403,8 @@ RGWObjManifest::obj_iterator RGWObjManifest::obj_find(uint64_t ofs)
   return iter;
 }
 
-int RGWObjManifest::append(RGWObjManifest& m, RGWZoneGroup& zonegroup, RGWZoneParams& zone_params)
+int RGWObjManifest::append(RGWObjManifest& m, const RGWZoneGroup& zonegroup,
+                           const RGWZoneParams& zone_params)
 {
   if (explicit_objs || m.explicit_objs) {
     return append_explicit(m, zonegroup, zone_params);
@@ -2305,7 +2306,7 @@ int RGWRados::objexp_hint_trim(const string& oid,
   return 0;
 }
 
-int RGWRados::lock_exclusive(rgw_pool& pool, const string& oid, timespan& duration, 
+int RGWRados::lock_exclusive(const rgw_pool& pool, const string& oid, timespan& duration,
                              string& zone_id, string& owner_id) {
   librados::IoCtx io_ctx;
 
@@ -2325,7 +2326,7 @@ int RGWRados::lock_exclusive(rgw_pool& pool, const string& oid, timespan& durati
   return l.lock_exclusive(&io_ctx, oid);
 }
 
-int RGWRados::unlock(rgw_pool& pool, const string& oid, string& zone_id, string& owner_id) {
+int RGWRados::unlock(const rgw_pool& pool, const string& oid, string& zone_id, string& owner_id) {
   librados::IoCtx io_ctx;
 
   int r = rgw_init_ioctx(get_rados_handle(), pool, io_ctx);
index 5a9c142cfd05a5c7a341e64319f51f536a75a410..89a5d120426a2c9d4468389b77ade4d422391996 100644 (file)
@@ -576,7 +576,8 @@ public:
   void dump(Formatter *f) const;
   static void generate_test_instances(list<RGWObjManifest*>& o);
 
-  int append(RGWObjManifest& m, RGWZoneGroup& zonegroup, RGWZoneParams& zone_params);
+  int append(RGWObjManifest& m, const RGWZoneGroup& zonegroup,
+             const RGWZoneParams& zone_params);
   int append(RGWObjManifest& m, RGWSI_Zone *zone_svc);
 
   bool get_rule(uint64_t ofs, RGWObjManifestRule *rule);
@@ -2260,8 +2261,8 @@ public:
                        const string& from_marker = std::string(),
                        const string& to_marker   = std::string());
 
-  int lock_exclusive(rgw_pool& pool, const string& oid, ceph::timespan& duration, string& zone_id, string& owner_id);
-  int unlock(rgw_pool& pool, const string& oid, string& zone_id, string& owner_id);
+  int lock_exclusive(const rgw_pool& pool, const string& oid, ceph::timespan& duration, string& zone_id, string& owner_id);
+  int unlock(const rgw_pool& pool, const string& oid, string& zone_id, string& owner_id);
 
   void update_gc_chain(rgw_obj& head_obj, RGWObjManifest& manifest, cls_rgw_obj_chain *chain);
   int send_chain_to_gc(cls_rgw_obj_chain& chain, const string& tag, bool sync);
index 8ea58571c3db1aea7ea4f5d7617bf9f8b6ae001f..6ad38c6e40ac0582c0b7b33f6eb57dd105c128b6 100644 (file)
@@ -13,7 +13,7 @@
 #define dout_prefix (*_dout << "rgw realm watcher: ")
 
 
-RGWRealmWatcher::RGWRealmWatcher(CephContext* cct, RGWRealm& realm)
+RGWRealmWatcher::RGWRealmWatcher(CephContext* cct, const RGWRealm& realm)
   : cct(cct)
 {
   // no default realm, nothing to watch
@@ -80,7 +80,7 @@ void RGWRealmWatcher::handle_error(uint64_t cookie, int err)
   }
 }
 
-int RGWRealmWatcher::watch_start(RGWRealm& realm)
+int RGWRealmWatcher::watch_start(const RGWRealm& realm)
 {
   // initialize a Rados client
   int r = rados.init_with_context(cct);
index 1df4f04fc8e17dfb631df817d803d8efcc936b74..03d7e939b281b0915c7952cfb956b2ebf32e4ab6 100644 (file)
@@ -36,7 +36,7 @@ class RGWRealmWatcher : public librados::WatchCtx2 {
                                bufferlist::const_iterator& p) = 0;
   };
 
-  RGWRealmWatcher(CephContext* cct, RGWRealm& realm);
+  RGWRealmWatcher(CephContext* cct, const RGWRealm& realm);
   ~RGWRealmWatcher() override;
 
   /// register a watcher for the given notification type
@@ -59,7 +59,7 @@ class RGWRealmWatcher : public librados::WatchCtx2 {
   uint64_t watch_handle = 0;
   std::string watch_oid;
 
-  int watch_start(RGWRealm& realm);
+  int watch_start(const RGWRealm& realm);
   int watch_restart();
   void watch_stop();
 
index 324d28d49998cddf0febe35d67b30ca937e713ad..4e87b14787845cf505fae6f40e09ae6c99ff92dc 100644 (file)
@@ -170,7 +170,7 @@ string uppercase_underscore_http_attr(const string& orig)
 static set<string> hostnames_set;
 static set<string> hostnames_s3website_set;
 
-void rgw_rest_init(CephContext *cct, RGWRados *store, RGWZoneGroup& zone_group)
+void rgw_rest_init(CephContext *cct, RGWRados *store, const RGWZoneGroup& zone_group)
 {
   for (const auto& rgw2http : base_rgw_to_http_attrs)  {
     rgw_to_http_attrs[rgw2http.rgw_attr] = rgw2http.http_attr;
index defbed1d4b5a207eb64b3ca7a8eae8a03167b450..e6493bc9d3c8f3bd6a8de1cf813f560453802b16 100644 (file)
@@ -17,7 +17,7 @@
 
 extern std::map<std::string, std::string> rgw_to_http_attrs;
 
-extern void rgw_rest_init(CephContext *cct, RGWRados *store, RGWZoneGroup& zone_group);
+extern void rgw_rest_init(CephContext *cct, RGWRados *store, const RGWZoneGroup& zone_group);
 
 extern void rgw_flush_formatter_and_reset(struct req_state *s,
                                         ceph::Formatter *formatter);
index 40a1ebe7e23cb226b97d3135ede0c9bd1949ce68..1fcbc801ec9b6623f938a481c944e05c54c7e983 100644 (file)
@@ -1902,7 +1902,7 @@ void RGWInfo_ObjStore_SWIFT::list_swift_data(Formatter& formatter,
   }
 
   formatter.open_array_section("policies");
-  RGWZoneGroup& zonegroup = store.svc.zone->get_zonegroup();
+  const RGWZoneGroup& zonegroup = store.svc.zone->get_zonegroup();
 
   for (const auto& placement_targets : zonegroup.placement_targets) {
     formatter.open_object_section("policy");
index a9c0d5d9ee325181bca1330d199aa8069ce24366..a8c77191c02a84ada75428269fed8a0dcf008242 100644 (file)
@@ -560,11 +560,11 @@ struct AWSSyncConfig {
   void expand_target(RGWDataSyncEnv *sync_env, const string& sid, const string& path, string *dest) {
       apply_meta_param(path, "sid", sid, dest);
 
-      RGWZoneGroup& zg = sync_env->store->svc.zone->get_zonegroup();
+      const RGWZoneGroup& zg = sync_env->store->svc.zone->get_zonegroup();
       apply_meta_param(path, "zonegroup", zg.get_name(), dest);
       apply_meta_param(path, "zonegroup_id", zg.get_id(), dest);
 
-      RGWZone& zone = sync_env->store->svc.zone->get_zone();
+      const RGWZone& zone = sync_env->store->svc.zone->get_zone();
       apply_meta_param(path, "zone", zone.name, dest);
       apply_meta_param(path, "zone_id", zone.id, dest);
   }
index ddbf40beae21875b3d0429e1671573146b458b03..818111a1cc1516f5d14b42bceacf44b766bde5d9 100644 (file)
@@ -134,7 +134,7 @@ struct ElasticConfig {
     num_replicas = config["num_replicas"](ES_NUM_REPLICAS_DEFAULT);
   }
 
-  void init_instance(RGWRealm& realm, uint64_t instance_id) {
+  void init_instance(const RGWRealm& realm, uint64_t instance_id) {
     sync_instance = instance_id;
 
     if (!override_index_path.empty()) {
index 95df6a48d5c17c0bdc9ca1f0397332af0fb01994..9fd576e6f6b9234b80135c638b1fde0aebfc9f90 100644 (file)
@@ -261,7 +261,7 @@ static RGWChainedCacheImpl<user_info_entry> uinfo_cache;
 
 int rgw_get_user_info_from_index(RGWRados * const store,
                                  const string& key,
-                                 rgw_pool& pool,
+                                 const rgw_pool& pool,
                                  RGWUserInfo& info,
                                  RGWObjVersionTracker * const objv_tracker,
                                  real_time * const pmtime)
index 5366ebdb0feed69d122e58bb7aace32b54a748d2..0038d60eb3c617285b3835dcc84dc1191b7d35f7 100644 (file)
@@ -55,7 +55,7 @@ void RGWDefaultZoneGroupInfo::decode_json(JSONObj *obj) {
   }
 }
 
-rgw_pool RGWZoneGroup::get_pool(CephContext *cct_)
+rgw_pool RGWZoneGroup::get_pool(CephContext *cct_) const
 {
   if (cct_->_conf->rgw_zonegroup_root_pool.empty()) {
     return rgw_pool(RGW_DEFAULT_ZONEGROUP_ROOT_POOL);
@@ -128,7 +128,7 @@ int RGWZoneGroup::create_default(bool old_format)
   return 0;
 }
 
-const string RGWZoneGroup::get_default_oid(bool old_region_format)
+const string RGWZoneGroup::get_default_oid(bool old_region_format) const
 {
   if (old_region_format) {
     if (cct->_conf->rgw_default_region_info_oid.empty()) {
@@ -148,7 +148,7 @@ const string RGWZoneGroup::get_default_oid(bool old_region_format)
   return default_oid;
 }
 
-const string& RGWZoneGroup::get_info_oid_prefix(bool old_region_format)
+const string& RGWZoneGroup::get_info_oid_prefix(bool old_region_format) const
 {
   if (old_region_format) {
     return region_info_oid_prefix;
@@ -156,12 +156,12 @@ const string& RGWZoneGroup::get_info_oid_prefix(bool old_region_format)
   return zone_group_info_oid_prefix;
 }
 
-const string& RGWZoneGroup::get_names_oid_prefix()
+const string& RGWZoneGroup::get_names_oid_prefix() const
 {
   return zonegroup_names_oid_prefix;
 }
 
-const string& RGWZoneGroup::get_predefined_name(CephContext *cct) {
+const string& RGWZoneGroup::get_predefined_name(CephContext *cct) const {
   return cct->_conf->rgw_zonegroup;
 }
 
@@ -681,7 +681,7 @@ int RGWSystemMetaObj::write(bool exclusive)
 }
 
 
-const string& RGWRealm::get_predefined_name(CephContext *cct) {
+const string& RGWRealm::get_predefined_name(CephContext *cct) const {
   return cct->_conf->rgw_realm;
 }
 
@@ -763,7 +763,7 @@ int RGWRealm::delete_control()
   return sysobj.wop().remove();
 }
 
-rgw_pool RGWRealm::get_pool(CephContext *cct)
+rgw_pool RGWRealm::get_pool(CephContext *cct) const
 {
   if (cct->_conf->rgw_realm_root_pool.empty()) {
     return rgw_pool(RGW_DEFAULT_REALM_ROOT_POOL);
@@ -771,7 +771,7 @@ rgw_pool RGWRealm::get_pool(CephContext *cct)
   return rgw_pool(cct->_conf->rgw_realm_root_pool);
 }
 
-const string RGWRealm::get_default_oid(bool old_format)
+const string RGWRealm::get_default_oid(bool old_format) const
 {
   if (cct->_conf->rgw_default_realm_info_oid.empty()) {
     return default_realm_info_oid;
@@ -779,12 +779,12 @@ const string RGWRealm::get_default_oid(bool old_format)
   return cct->_conf->rgw_default_realm_info_oid;
 }
 
-const string& RGWRealm::get_names_oid_prefix()
+const string& RGWRealm::get_names_oid_prefix() const
 {
   return realm_names_oid_prefix;
 }
 
-const string& RGWRealm::get_info_oid_prefix(bool old_format)
+const string& RGWRealm::get_info_oid_prefix(bool old_format) const
 {
   return realm_info_oid_prefix;
 }
@@ -822,7 +822,7 @@ int RGWRealm::set_current_period(RGWPeriod& period)
   return 0;
 }
 
-string RGWRealm::get_control_oid()
+string RGWRealm::get_control_oid() const
 {
   return get_info_oid_prefix() + id + ".control";
 }
@@ -954,7 +954,9 @@ int RGWPeriod::init(CephContext *_cct, RGWSI_SysObj *_sysobj_svc, bool setup_obj
 }
 
 
-int RGWPeriod::get_zonegroup(RGWZoneGroup& zonegroup, const string& zonegroup_id) {
+int RGWPeriod::get_zonegroup(RGWZoneGroup& zonegroup,
+                             const string& zonegroup_id) const
+{
   map<string, RGWZoneGroup>::const_iterator iter;
   if (!zonegroup_id.empty()) {
     iter = period_map.zonegroups.find(zonegroup_id);
@@ -969,7 +971,7 @@ int RGWPeriod::get_zonegroup(RGWZoneGroup& zonegroup, const string& zonegroup_id
   return -ENOENT;
 }
 
-const string& RGWPeriod::get_latest_epoch_oid()
+const string& RGWPeriod::get_latest_epoch_oid() const
 {
   if (cct->_conf->rgw_period_latest_epoch_info_oid.empty()) {
     return period_latest_epoch_info_oid;
@@ -977,17 +979,17 @@ const string& RGWPeriod::get_latest_epoch_oid()
   return cct->_conf->rgw_period_latest_epoch_info_oid;
 }
 
-const string& RGWPeriod::get_info_oid_prefix()
+const string& RGWPeriod::get_info_oid_prefix() const
 {
   return period_info_oid_prefix;
 }
 
-const string RGWPeriod::get_period_oid_prefix()
+const string RGWPeriod::get_period_oid_prefix() const
 {
   return get_info_oid_prefix() + id;
 }
 
-const string RGWPeriod::get_period_oid()
+const string RGWPeriod::get_period_oid() const
 {
   std::ostringstream oss;
   oss << get_period_oid_prefix();
@@ -1216,7 +1218,7 @@ int RGWPeriod::store_info(bool exclusive)
                .write(bl);
 }
 
-rgw_pool RGWPeriod::get_pool(CephContext *cct)
+rgw_pool RGWPeriod::get_pool(CephContext *cct) const
 {
   if (cct->_conf->rgw_period_root_pool.empty()) {
     return rgw_pool(RGW_DEFAULT_PERIOD_ROOT_POOL);
@@ -1663,7 +1665,7 @@ int RGWZoneParams::create(bool exclusive)
   return 0;
 }
 
-rgw_pool RGWZoneParams::get_pool(CephContext *cct)
+rgw_pool RGWZoneParams::get_pool(CephContext *cct) const
 {
   if (cct->_conf->rgw_zone_root_pool.empty()) {
     return rgw_pool(RGW_DEFAULT_ZONE_ROOT_POOL);
@@ -1672,7 +1674,7 @@ rgw_pool RGWZoneParams::get_pool(CephContext *cct)
   return rgw_pool(cct->_conf->rgw_zone_root_pool);
 }
 
-const string RGWZoneParams::get_default_oid(bool old_format)
+const string RGWZoneParams::get_default_oid(bool old_format) const
 {
   if (old_format) {
     return cct->_conf->rgw_default_zone_info_oid;
@@ -1681,17 +1683,17 @@ const string RGWZoneParams::get_default_oid(bool old_format)
   return cct->_conf->rgw_default_zone_info_oid + "." + realm_id;
 }
 
-const string& RGWZoneParams::get_names_oid_prefix()
+const string& RGWZoneParams::get_names_oid_prefix() const
 {
   return zone_names_oid_prefix;
 }
 
-const string& RGWZoneParams::get_info_oid_prefix(bool old_format)
+const string& RGWZoneParams::get_info_oid_prefix(bool old_format) const
 {
   return zone_info_oid_prefix;
 }
 
-const string& RGWZoneParams::get_predefined_name(CephContext *cct) {
+const string& RGWZoneParams::get_predefined_name(CephContext *cct) const {
   return cct->_conf->rgw_zone;
 }
 
index f982915382ceb099cfc61dc1d294608ecf90141b..6632349dbec6ed4e8f1b4ba68362e8506f38e5e0 100644 (file)
@@ -137,11 +137,11 @@ public:
   int read();
   int write(bool exclusive);
 
-  virtual rgw_pool get_pool(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;
+  virtual rgw_pool get_pool(CephContext *cct) const = 0;
+  virtual const std::string get_default_oid(bool old_format = false) const = 0;
+  virtual const std::string& get_names_oid_prefix() const = 0;
+  virtual const std::string& get_info_oid_prefix(bool old_format = false) const = 0;
+  virtual const std::string& get_predefined_name(CephContext *cct) const = 0;
 
   void dump(Formatter *f) const;
   void decode_json(JSONObj *obj);
@@ -233,11 +233,11 @@ struct RGWZoneParams : RGWSystemMetaObj {
   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 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;
+  rgw_pool get_pool(CephContext *cct) const override;
+  const std::string get_default_oid(bool old_format = false) const override;
+  const std::string& get_names_oid_prefix() const override;
+  const std::string& get_info_oid_prefix(bool old_format = false) const override;
+  const std::string& get_predefined_name(CephContext *cct) const override;
 
   int init(CephContext *_cct, RGWSI_SysObj *_sysobj_svc, bool setup_obj = true,
           bool old_format = false);
@@ -456,7 +456,7 @@ struct RGWZone {
   void decode_json(JSONObj *obj);
   static void generate_test_instances(list<RGWZone*>& o);
 
-  bool is_read_only() { return read_only; }
+  bool is_read_only() const { return read_only; }
 
   bool syncs_from(const std::string& zone_id) const {
     return (sync_from_all || sync_from.find(zone_id) != sync_from.end());
@@ -618,11 +618,11 @@ struct RGWZoneGroup : public RGWSystemMetaObj {
                std::string *predirect_zone, RGWSyncModulesManager *sync_mgr);
   int remove_zone(const std::string& zone_id);
   int rename_zone(const RGWZoneParams& zone_params);
-  rgw_pool get_pool(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;
+  rgw_pool get_pool(CephContext *cct) const override;
+  const std::string get_default_oid(bool old_region_format = false) const override;
+  const std::string& get_info_oid_prefix(bool old_region_format = false) const override;
+  const std::string& get_names_oid_prefix() const override;
+  const std::string& get_predefined_name(CephContext *cct) const override;
 
   void dump(Formatter *f) const;
   void decode_json(JSONObj *obj);
@@ -763,11 +763,11 @@ public:
 
   int create(bool exclusive = true) override;
   int delete_obj();
-  rgw_pool get_pool(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;
+  rgw_pool get_pool(CephContext *cct) const override;
+  const std::string get_default_oid(bool old_format = false) const override;
+  const std::string& get_names_oid_prefix() const override;
+  const std::string& get_info_oid_prefix(bool old_format = false) const override;
+  const std::string& get_predefined_name(CephContext *cct) const override;
 
   using RGWSystemMetaObj::read_id; // expose as public for radosgw-admin
 
@@ -785,7 +785,7 @@ public:
   }
   epoch_t get_epoch() const { return epoch; }
 
-  std::string get_control_oid();
+  std::string get_control_oid() const;
   /// send a notify on the realm control object
   int notify_zone(bufferlist& bl);
   /// notify the zone of a new period
@@ -837,8 +837,8 @@ class RGWPeriod
   int use_latest_epoch();
   int use_current_period();
 
-  const std::string get_period_oid();
-  const std::string get_period_oid_prefix();
+  const std::string get_period_oid() const;
+  const std::string get_period_oid_prefix() const;
 
   // gather the metadata sync status for each shard; only for use on master zone
   int update_sync_status(RGWRados *store,
@@ -862,9 +862,9 @@ public:
   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 std::string& get_latest_epoch_oid();
-  const std::string& get_info_oid_prefix();
+  rgw_pool get_pool(CephContext *cct) const;
+  const std::string& get_latest_epoch_oid() const;
+  const std::string& get_info_oid_prefix() const;
 
   void set_user_quota(RGWQuotaInfo& user_quota) {
     period_config.user_quota = user_quota;
@@ -893,7 +893,7 @@ public:
   int reflect();
 
   int get_zonegroup(RGWZoneGroup& zonegroup,
-                   const std::string& zonegroup_id);
+                   const std::string& zonegroup_id) const;
 
   bool is_single_zonegroup() const
   {
@@ -903,7 +903,7 @@ public:
   /*
     returns true if there are several zone groups with a least one zone
    */
-  bool is_multi_zonegroups_with_zones()
+  bool is_multi_zonegroups_with_zones() const
   {
     int count = 0;
     for (const auto& zg:  period_map.zonegroups) {
index 2dc123262dd88b3b9acd94a82835b5410c6baae6..eeaffc23a18785a8e7d2adf205a2808cc2abe560 100644 (file)
@@ -41,7 +41,7 @@ RGWSI_Zone::~RGWSI_Zone()
   delete current_period;
 }
 
-bool RGWSI_Zone::zone_syncs_from(RGWZone& target_zone, RGWZone& source_zone)
+bool RGWSI_Zone::zone_syncs_from(const RGWZone& target_zone, const RGWZone& source_zone) const
 {
   return target_zone.syncs_from(source_zone.name) &&
          sync_modules_svc->get_manager()->supports_data_export(source_zone.tier_type);
@@ -128,8 +128,8 @@ int RGWSI_Zone::do_start()
     lderr(cct) << "failed reading zone info: ret "<< ret << " " << cpp_strerror(-ret) << dendl;
     return ret;
   }
-  map<string, RGWZone>::iterator zone_iter = get_zonegroup().zones.find(zone_params->get_id());
-  if (zone_iter == get_zonegroup().zones.end()) {
+  auto zone_iter = zonegroup->zones.find(zone_params->get_id());
+  if (zone_iter == zonegroup->zones.end()) {
     if (using_local) {
       lderr(cct) << "Cannot find zone id=" << zone_params->get_id() << " (name=" << zone_params->get_name() << ")" << dendl;
       return -EINVAL;
@@ -139,9 +139,9 @@ int RGWSI_Zone::do_start()
     if (ret < 0) {
       return ret;
     }
-    zone_iter = get_zonegroup().zones.find(zone_params->get_id());
+    zone_iter = zonegroup->zones.find(zone_params->get_id());
   }
-  if (zone_iter != get_zonegroup().zones.end()) {
+  if (zone_iter != zonegroup->zones.end()) {
     *zone_public_config = zone_iter->second;
     ldout(cct, 20) << "zone " << zone_params->get_name() << dendl;
   } else {
@@ -165,7 +165,7 @@ int RGWSI_Zone::do_start()
     ldout(cct, 0) << "WARNING: could not find zone config in zonegroup for local zone (" << zone_id() << "), will use defaults" << dendl;
   }
   *zone_public_config = zone_by_id[zone_id()];
-  for (auto ziter : get_zonegroup().zones) {
+  for (auto ziter : zonegroup->zones) {
     const string& id = ziter.first;
     RGWZone& z = ziter.second;
     if (id == zone_id()) {
@@ -769,38 +769,38 @@ int RGWSI_Zone::convert_regionmap()
   return 0;
 }
 
-RGWZoneParams& RGWSI_Zone::get_zone_params()
+const RGWZoneParams& RGWSI_Zone::get_zone_params() const
 {
   return *zone_params;
 }
 
-RGWZone& RGWSI_Zone::get_zone()
+const RGWZone& RGWSI_Zone::get_zone() const
 {
   return *zone_public_config;
 }
 
-RGWZoneGroup& RGWSI_Zone::get_zonegroup()
+const RGWZoneGroup& RGWSI_Zone::get_zonegroup() const
 {
   return *zonegroup;
 }
 
-int RGWSI_Zone::get_zonegroup(const string& id, RGWZoneGroup& zonegroup)
+int RGWSI_Zone::get_zonegroup(const string& id, RGWZoneGroup& zg) const
 {
   int ret = 0;
-  if (id == get_zonegroup().get_id()) {
-    zonegroup = get_zonegroup();
+  if (id == zonegroup->get_id()) {
+    zg = *zonegroup;
   } else if (!current_period->get_id().empty()) {
-    ret = current_period->get_zonegroup(zonegroup, id);
+    ret = current_period->get_zonegroup(zg, id);
   }
   return ret;
 }
 
-RGWRealm& RGWSI_Zone::get_realm()
+const RGWRealm& RGWSI_Zone::get_realm() const
 {
   return *realm;
 }
 
-RGWPeriod& RGWSI_Zone::get_current_period()
+const RGWPeriod& RGWSI_Zone::get_current_period() const
 {
   return *current_period;
 }
@@ -1010,8 +1010,8 @@ int RGWSI_Zone::select_bucket_location_by_rule(const string& location_rule, RGWZ
    * checking it for the local zone, because that's where this bucket object is going to
    * reside.
    */
-  map<string, RGWZonePlacementInfo>::iterator piter = get_zone_params().placement_pools.find(location_rule);
-  if (piter == get_zone_params().placement_pools.end()) {
+  auto piter = zone_params->placement_pools.find(location_rule);
+  if (piter == zone_params->placement_pools.end()) {
     /* couldn't find, means we cannot really place data for this bucket in this zone */
     ldout(cct, 0) << "ERROR: This zone does not contain placement rule "
                   << location_rule << " present in the zonegroup!" << dendl;
@@ -1030,7 +1030,7 @@ int RGWSI_Zone::select_bucket_location_by_rule(const string& location_rule, RGWZ
 int RGWSI_Zone::select_bucket_placement(RGWUserInfo& user_info, const string& zonegroup_id, const string& placement_rule,
                                       string *pselected_rule_name, RGWZonePlacementInfo *rule_info)
 {
-  if (!get_zone_params().placement_pools.empty()) {
+  if (!zone_params->placement_pools.empty()) {
     return select_new_bucket_location(user_info, zonegroup_id, placement_rule,
                                       pselected_rule_name, rule_info);
   }
@@ -1053,7 +1053,7 @@ int RGWSI_Zone::select_legacy_bucket_placement(RGWZonePlacementInfo *rule_info)
   string pool_name;
   bool write_map = false;
 
-  rgw_raw_obj obj(get_zone_params().domain_root, avail_pools);
+  rgw_raw_obj obj(zone_params->domain_root, avail_pools);
 
   auto obj_ctx = sysobj_svc->init_obj_ctx();
   auto sysobj = obj_ctx.get_obj(obj);
index fd9ec109b91aa696ee67525aedd5b5c21172db35..940cb78f85d33064b2659d59b27b232be23c5f55 100644 (file)
@@ -59,12 +59,12 @@ public:
   RGWSI_Zone(CephContext *cct);
   ~RGWSI_Zone();
 
-  RGWZoneParams& get_zone_params();
-  RGWPeriod& get_current_period();
-  RGWRealm& get_realm();
-  RGWZoneGroup& get_zonegroup();
-  int get_zonegroup(const string& id, RGWZoneGroup& zonegroup);
-  RGWZone& get_zone();
+  const RGWZoneParams& get_zone_params() const;
+  const RGWPeriod& get_current_period() const;
+  const RGWRealm& get_realm() const;
+  const RGWZoneGroup& get_zonegroup() const;
+  int get_zonegroup(const string& id, RGWZoneGroup& zonegroup) const;
+  const RGWZone& get_zone() const;
 
   const string& zone_name();
   const string& zone_id();
@@ -74,7 +74,7 @@ public:
   bool has_zonegroup_api(const std::string& api) const;
 
   bool zone_is_writeable();
-  bool zone_syncs_from(RGWZone& target_zone, RGWZone& source_zone);
+  bool zone_syncs_from(const RGWZone& target_zone, const RGWZone& source_zone) const;
   bool get_redirect_zone_endpoint(string *endpoint);
 
   RGWRESTConn *get_master_conn() {