From: Daniel Gryniewicz Date: Thu, 21 Jan 2021 17:11:30 +0000 (-0500) Subject: RGW Zipper - Add zone abstraction X-Git-Tag: v17.1.0~2768^2~4 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=497c9dbdd6500ff288d1e0f083d12f3c596a457b;p=ceph-ci.git RGW Zipper - Add zone abstraction Signed-off-by: Daniel Gryniewicz --- diff --git a/src/rgw/librgw.cc b/src/rgw/librgw.cc index 6c215eac141..012cc54c3be 100644 --- a/src/rgw/librgw.cc +++ b/src/rgw/librgw.cc @@ -556,7 +556,7 @@ namespace rgw { r = rgw_perf_start(g_ceph_context); - rgw_rest_init(g_ceph_context, store->get_zonegroup()); + rgw_rest_init(g_ceph_context, store->get_zone()->get_zonegroup()); mutex.lock(); init_timer.cancel_all_events(); diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 07f99f873e5..c302c2fd7dd 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -1632,7 +1632,7 @@ static int commit_period(RGWRealm& realm, RGWPeriod& period, return -EINVAL; } // are we the period's master zone? - if (store->get_zone_id() == master_zone) { + if (store->get_zone()->get_id() == master_zone) { // read the current period RGWPeriod current_period; int ret = current_period.init(g_ceph_context, @@ -2178,8 +2178,8 @@ static void tab_dump(const string& header, int width, const list& entrie static void sync_status(Formatter *formatter) { - const RGWRealm& realm = store->get_realm(); - const RGWZoneGroup& zonegroup = store->get_zonegroup(); + const RGWRealm& realm = store->get_zone()->get_realm(); + const RGWZoneGroup& zonegroup = store->get_zone()->get_zonegroup(); const RGWZone& zone = static_cast(store)->svc()->zone->get_zone(); int width = 15; @@ -2374,7 +2374,7 @@ rgw_zone_id validate_zone_id(const rgw_zone_id& zone_id) static int sync_info(std::optional opt_target_zone, std::optional opt_bucket, Formatter *formatter) { - rgw_zone_id zone_id = opt_target_zone.value_or(store->get_zone_id()); + rgw_zone_id zone_id = opt_target_zone.value_or(store->get_zone()->get_id()); auto zone_policy_handler = static_cast(store)->svc()->zone->get_sync_policy_handler(zone_id); @@ -2488,8 +2488,8 @@ static int sync_info(std::optional opt_target_zone, std::optionalget_realm(); - const RGWZoneGroup& zonegroup = store->get_zonegroup(); + const RGWRealm& realm = store->get_zone()->get_realm(); + const RGWZoneGroup& zonegroup = store->get_zone()->get_zonegroup(); const RGWZone& zone = store->svc()->zone->get_zone(); constexpr int width = 15; @@ -2529,8 +2529,8 @@ static int bucket_sync_status(rgw::sal::RGWRadosStore *store, const RGWBucketInf std::optional& opt_source_bucket, std::ostream& out) { - const RGWRealm& realm = store->get_realm(); - const RGWZoneGroup& zonegroup = store->get_zonegroup(); + const RGWRealm& realm = store->get_zone()->get_realm(); + const RGWZoneGroup& zonegroup = store->get_zone()->get_zonegroup(); const RGWZone& zone = static_cast(store)->svc()->zone->get_zone(); constexpr int width = 15; @@ -5516,7 +5516,7 @@ int main(int argc, const char **argv) rgw_placement_rule target_rule; target_rule.name = placement_id; target_rule.storage_class = *opt_storage_class; - if (!store->get_zone_params().valid_placement(target_rule)) { + if (!store->get_zone()->get_params().valid_placement(target_rule)) { cerr << "NOTICE: invalid dest placement: " << target_rule.to_str() << std::endl; return EINVAL; } @@ -7874,7 +7874,7 @@ next: RGWSyncModuleInstanceRef sync_module; int ret = static_cast(store)->svc()->sync_modules->get_manager()->create_instance(g_ceph_context, static_cast(store)->svc()->zone->get_zone().tier_type, - store->get_zone_params().tier_config, &sync_module); + store->get_zone()->get_params().tier_config, &sync_module); if (ret < 0) { lderr(cct) << "ERROR: failed to init sync module instance, ret=" << ret << dendl; return ret; diff --git a/src/rgw/rgw_asio_frontend.cc b/src/rgw/rgw_asio_frontend.cc index e140c40b2de..df6f9a91acc 100644 --- a/src/rgw/rgw_asio_frontend.cc +++ b/src/rgw/rgw_asio_frontend.cc @@ -629,13 +629,13 @@ class ExpandMetaVar { map meta_map; public: - ExpandMetaVar(RGWSI_Zone *zone_svc) { + ExpandMetaVar(rgw::sal::Zone *zone_svc) { meta_map["realm"] = zone_svc->get_realm().get_name(); meta_map["realm_id"] = zone_svc->get_realm().get_id(); meta_map["zonegroup"] = zone_svc->get_zonegroup().get_name(); meta_map["zonegroup_id"] = zone_svc->get_zonegroup().get_id(); - meta_map["zone"] = zone_svc->zone_name(); - meta_map["zone_id"] = zone_svc->zone_id().id; + meta_map["zone"] = zone_svc->get_name(); + meta_map["zone_id"] = zone_svc->get_id().id; } string process_str(const string& in); @@ -815,7 +815,7 @@ int AsioFrontend::init_ssl() key_is_cert = true; } - ExpandMetaVar emv(static_cast(env.store)->svc()->zone); + ExpandMetaVar emv(env.store->get_zone()); cert = emv.process_str(*cert); key = emv.process_str(*key); diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index e46ce8adf2d..b9cd6e02cc8 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -1786,7 +1786,7 @@ namespace rgw { state->object->set_bucket(state->bucket.get()); auto compression_type = - get_store()->get_zone_params().get_compression_type( + get_store()->get_zone()->get_params().get_compression_type( state->bucket->get_placement_rule()); /* not obviously supportable */ diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index ee9f7d8de35..e1c79fa28ec 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -1256,7 +1256,7 @@ public: target_placement.inherit_from(oc.bucket->get_placement_rule()); target_placement.storage_class = transition.storage_class; - if (!oc.store->get_zone_params(). + if (!oc.store->get_zone()->get_params(). valid_placement(target_placement)) { ldpp_dout(oc.dpp, 0) << "ERROR: non existent dest placement: " << target_placement diff --git a/src/rgw/rgw_lua.cc b/src/rgw/rgw_lua.cc index 8eed171da7f..357b8444eee 100644 --- a/src/rgw/rgw_lua.cc +++ b/src/rgw/rgw_lua.cc @@ -67,7 +67,7 @@ int read_script(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* store, const { RGWObjVersionTracker objv_tracker; - rgw_raw_obj obj(store->get_zone_params().log_pool, script_oid(ctx, tenant)); + rgw_raw_obj obj(store->get_zone()->get_params().log_pool, script_oid(ctx, tenant)); bufferlist bl; @@ -100,7 +100,7 @@ int write_script(rgw::sal::RGWStore* store, const std::string& tenant, optional_ { RGWObjVersionTracker objv_tracker; - rgw_raw_obj obj(store->get_zone_params().log_pool, script_oid(ctx, tenant)); + rgw_raw_obj obj(store->get_zone()->get_params().log_pool, script_oid(ctx, tenant)); bufferlist bl; ceph::encode(script, bl); @@ -125,7 +125,7 @@ int delete_script(rgw::sal::RGWStore* store, const std::string& tenant, optional { RGWObjVersionTracker objv_tracker; - rgw_raw_obj obj(store->get_zone_params().log_pool, script_oid(ctx, tenant)); + rgw_raw_obj obj(store->get_zone()->get_params().log_pool, script_oid(ctx, tenant)); const auto rc = store->delete_system_obj( obj.pool, diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc index 36ac9f3115a..04dbdc4432b 100644 --- a/src/rgw/rgw_main.cc +++ b/src/rgw/rgw_main.cc @@ -352,7 +352,7 @@ int radosgw_Main(int argc, const char **argv) return -r; } - rgw_rest_init(g_ceph_context, store->get_zonegroup()); + rgw_rest_init(g_ceph_context, store->get_zone()->get_zonegroup()); mutex.lock(); init_timer.cancel_all_events(); @@ -449,7 +449,7 @@ int radosgw_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->get_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; @@ -632,7 +632,7 @@ int radosgw_Main(int argc, const char **argv) auto reloader = std::make_unique(store, service_map_meta, &pauser); - RGWRealmWatcher realm_watcher(g_ceph_context, store->get_realm()); + RGWRealmWatcher realm_watcher(g_ceph_context, store->get_zone()->get_realm()); realm_watcher.add_watcher(RGWRealmNotify::Reload, *reloader); realm_watcher.add_watcher(RGWRealmNotify::ZonesNeedPeriod, pusher); diff --git a/src/rgw/rgw_obj_manifest.cc b/src/rgw/rgw_obj_manifest.cc index a91c51c4658..e1fcc3af979 100644 --- a/src/rgw/rgw_obj_manifest.cc +++ b/src/rgw/rgw_obj_manifest.cc @@ -138,9 +138,9 @@ int RGWObjManifest::append(RGWObjManifest& m, const RGWZoneGroup& zonegroup, return 0; } -int RGWObjManifest::append(RGWObjManifest& m, RGWSI_Zone *zone_svc) +int RGWObjManifest::append(RGWObjManifest& m, rgw::sal::Zone* zone_svc) { - return append(m, zone_svc->get_zonegroup(), zone_svc->get_zone_params()); + return append(m, zone_svc->get_zonegroup(), zone_svc->get_params()); } void RGWObjManifest::append_rules(RGWObjManifest& m, map::iterator& miter, diff --git a/src/rgw/rgw_obj_manifest.h b/src/rgw/rgw_obj_manifest.h index 5423dea3564..36f01bc9ec6 100644 --- a/src/rgw/rgw_obj_manifest.h +++ b/src/rgw/rgw_obj_manifest.h @@ -327,7 +327,7 @@ public: int append(RGWObjManifest& m, const RGWZoneGroup& zonegroup, const RGWZoneParams& zone_params); - int append(RGWObjManifest& m, RGWSI_Zone *zone_svc); + int append(RGWObjManifest& m, rgw::sal::Zone* zone); bool get_rule(uint64_t ofs, RGWObjManifestRule *rule); diff --git a/src/rgw/rgw_object_expirer_core.cc b/src/rgw/rgw_object_expirer_core.cc index 559d1ff63b1..c7b152d4ccb 100644 --- a/src/rgw/rgw_object_expirer_core.cc +++ b/src/rgw/rgw_object_expirer_core.cc @@ -105,7 +105,7 @@ int RGWObjExpStore::objexp_hint_add(const ceph::real_time& delete_at, cls_timeindex_add(op, utime_t(delete_at), keyext, hebl); string shard_name = objexp_hint_get_shardname(objexp_key_shard(obj_key, cct->_conf->rgw_objexp_hints_num_shards)); - auto obj = rados_svc->obj(rgw_raw_obj(zone_svc->get_zone_params().log_pool, shard_name)); + auto obj = rados_svc->obj(rgw_raw_obj(zone_svc->get_params().log_pool, shard_name)); int r = obj.open(); if (r < 0) { ldout(cct, 0) << "ERROR: " << __func__ << "(): failed to open obj=" << obj << " (r=" << r << ")" << dendl; @@ -127,7 +127,7 @@ int RGWObjExpStore::objexp_hint_list(const string& oid, cls_timeindex_list(op, utime_t(start_time), utime_t(end_time), marker, max_entries, entries, out_marker, truncated); - auto obj = rados_svc->obj(rgw_raw_obj(zone_svc->get_zone_params().log_pool, oid)); + auto obj = rados_svc->obj(rgw_raw_obj(zone_svc->get_params().log_pool, oid)); int r = obj.open(); if (r < 0) { ldout(cct, 0) << "ERROR: " << __func__ << "(): failed to open obj=" << obj << " (r=" << r << ")" << dendl; @@ -174,7 +174,7 @@ int RGWObjExpStore::objexp_hint_trim(const string& oid, const string& from_marker, const string& to_marker) { - auto obj = rados_svc->obj(rgw_raw_obj(zone_svc->get_zone_params().log_pool, oid)); + auto obj = rados_svc->obj(rgw_raw_obj(zone_svc->get_params().log_pool, oid)); int r = obj.open(); if (r < 0) { ldout(cct, 0) << "ERROR: " << __func__ << "(): failed to open obj=" << obj << " (r=" << r << ")" << dendl; diff --git a/src/rgw/rgw_object_expirer_core.h b/src/rgw/rgw_object_expirer_core.h index 15c1bcaf90b..ab653a566dc 100644 --- a/src/rgw/rgw_object_expirer_core.h +++ b/src/rgw/rgw_object_expirer_core.h @@ -40,9 +40,9 @@ class cls_timeindex_entry; class RGWObjExpStore { CephContext *cct; RGWSI_RADOS *rados_svc; - RGWSI_Zone *zone_svc; + rgw::sal::Zone* zone_svc; public: - RGWObjExpStore(CephContext *_cct, RGWSI_RADOS *_rados_svc, RGWSI_Zone *_zone_svc) : cct(_cct), + RGWObjExpStore(CephContext *_cct, RGWSI_RADOS *_rados_svc, rgw::sal::Zone* _zone_svc) : cct(_cct), rados_svc(_rados_svc), zone_svc(_zone_svc) {} @@ -100,7 +100,7 @@ protected: public: explicit RGWObjectExpirer(rgw::sal::RGWStore *_store) : store(_store), - exp_store(_store->ctx(), static_cast(store)->svc()->rados, static_cast(store)->svc()->zone), + exp_store(_store->ctx(), static_cast(store)->svc()->rados, store->get_zone()), worker(NULL) { } ~RGWObjectExpirer() { diff --git a/src/rgw/rgw_oidc_provider.cc b/src/rgw/rgw_oidc_provider.cc index 7e420bbeb52..b4aa9ea4026 100644 --- a/src/rgw/rgw_oidc_provider.cc +++ b/src/rgw/rgw_oidc_provider.cc @@ -35,7 +35,7 @@ int RGWOIDCProvider::store_url(const string& url, bool exclusive, bufferlist bl; encode(*this, bl); - return store->put_system_obj(store->get_zone_params().oidc_pool, oid, + return store->put_system_obj(store->get_zone()->get_params().oidc_pool, oid, bl, exclusive, NULL, real_time(), y); } @@ -92,7 +92,7 @@ int RGWOIDCProvider::create(const DoutPrefixProvider *dpp, bool exclusive, optio sprintf(buf + strlen(buf),".%dZ",(int)tv.tv_usec/1000); creation_date.assign(buf, strlen(buf)); - auto& pool = store->get_zone_params().oidc_pool; + auto& pool = store->get_zone()->get_params().oidc_pool; ret = store_url(idp_url, exclusive, y); if (ret < 0) { ldpp_dout(dpp, 0) << "ERROR: storing role info in pool: " << pool.name << ": " @@ -105,7 +105,7 @@ int RGWOIDCProvider::create(const DoutPrefixProvider *dpp, bool exclusive, optio int RGWOIDCProvider::delete_obj(optional_yield y) { - auto& pool = store->get_zone_params().oidc_pool; + auto& pool = store->get_zone()->get_params().oidc_pool; string url, tenant; auto ret = get_tenant_url_from_arn(tenant, url); @@ -182,7 +182,7 @@ void RGWOIDCProvider::decode_json(JSONObj *obj) int RGWOIDCProvider::read_url(const DoutPrefixProvider *dpp, const string& url, const string& tenant) { - auto& pool = store->get_zone_params().oidc_pool; + auto& pool = store->get_zone()->get_params().oidc_pool; string oid = tenant + get_url_oid_prefix() + url; bufferlist bl; @@ -240,7 +240,7 @@ int RGWOIDCProvider::get_providers(const DoutPrefixProvider *dpp, const string& tenant, vector& providers) { - auto pool = store->get_zone_params().oidc_pool; + auto pool = store->get_zone()->get_params().oidc_pool; string prefix = tenant + oidc_url_oid_prefix; //Get the filtered objects diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 335399324d4..43844e59ba6 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -550,7 +550,7 @@ int rgw_build_bucket_policies(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* &src_bucket, y); if (ret == 0) { string& zonegroup = src_bucket->get_info().zonegroup; - s->local_source = store->get_zonegroup().equals(zonegroup); + s->local_source = store->get_zone()->get_zonegroup().equals(zonegroup); } } @@ -591,7 +591,7 @@ int rgw_build_bucket_policies(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* s->bucket_owner = s->bucket_acl->get_owner(); RGWZoneGroup zonegroup; - int r = store->get_zonegroup(s->bucket->get_info().zonegroup, zonegroup); + int r = store->get_zone()->get_zonegroup(s->bucket->get_info().zonegroup, zonegroup); if (!r) { if (!zonegroup.endpoints.empty()) { s->zonegroup_endpoint = zonegroup.endpoints.front(); @@ -608,14 +608,14 @@ int rgw_build_bucket_policies(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* ret = r; } - if (!store->get_zonegroup().equals(s->bucket->get_info().zonegroup)) { + if (!store->get_zone()->get_zonegroup().equals(s->bucket->get_info().zonegroup)) { ldpp_dout(dpp, 0) << "NOTICE: request for data in a different zonegroup (" << s->bucket->get_info().zonegroup << " != " - << store->get_zonegroup().get_id() << ")" << dendl; + << store->get_zone()->get_zonegroup().get_id() << ")" << dendl; /* we now need to make sure that the operation actually requires copy source, that is * it's a copy operation */ - if (store->get_zonegroup().is_master_zonegroup() && s->system_request) { + if (store->get_zone()->get_zonegroup().is_master_zonegroup() && s->system_request) { /*If this is the master, don't redirect*/ } else if (s->op_type == RGW_OP_GET_BUCKET_LOCATION ) { /* If op is get bucket location, don't redirect */ @@ -630,7 +630,7 @@ int rgw_build_bucket_policies(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* s->dest_placement.storage_class = s->info.storage_class; s->dest_placement.inherit_from(s->bucket->get_placement_rule()); - if (!store->get_zone_params().valid_placement(s->dest_placement)) { + if (!store->get_zone()->get_params().valid_placement(s->dest_placement)) { ldpp_dout(dpp, 0) << "NOTICE: invalid dest placement: " << s->dest_placement.to_str() << dendl; return -EINVAL; } @@ -696,7 +696,7 @@ int rgw_build_bucket_policies(const DoutPrefixProvider *dpp, rgw::sal::RGWStore* ret = -EACCES; } - bool success = static_cast(store)->svc()->zone->get_redirect_zone_endpoint(&s->redirect_zone_endpoint); + bool success = store->get_zone()->get_redirect_endpoint(&s->redirect_zone_endpoint); if (success) { ldpp_dout(dpp, 20) << "redirect_zone_endpoint=" << s->redirect_zone_endpoint << dendl; } @@ -943,7 +943,7 @@ int RGWOp::verify_op_mask() return -EPERM; } - if (!s->system_request && (required_mask & RGW_OP_TYPE_MODIFY) && !static_cast(store)->svc()->zone->zone_is_writeable()) { + if (!s->system_request && (required_mask & RGW_OP_TYPE_MODIFY) && !store->get_zone()->is_writeable()) { ldpp_dout(this, 5) << "NOTICE: modify request to a read-only zone by a " "non-system user, permission denied" << dendl; return -EPERM; @@ -2317,7 +2317,7 @@ void RGWListBuckets::execute(optional_yield y) /* We need to have stats for all our policies - even if a given policy * isn't actually used in a given account. In such situation its usage * stats would be simply full of zeros. */ - for (const auto& policy : store->get_zonegroup().placement_targets) { + for (const auto& policy : store->get_zone()->get_zonegroup().placement_targets) { policies_stats.emplace(policy.second.name, decltype(policies_stats)::mapped_type()); } @@ -2458,7 +2458,7 @@ void RGWStatAccount::execute(optional_yield y) /* We need to have stats for all our policies - even if a given policy * isn't actually used in a given account. In such situation its usage * stats would be simply full of zeros. */ - for (const auto& policy : store->get_zonegroup().placement_targets) { + for (const auto& policy : store->get_zone()->get_zonegroup().placement_targets) { policies_stats.emplace(policy.second.name, decltype(policies_stats)::mapped_type()); } @@ -3036,7 +3036,7 @@ void RGWCreateBucket::execute(optional_yield y) buffer::list aclbl; buffer::list corsbl; string bucket_name = rgw_make_bucket_entry_name(s->bucket_tenant, s->bucket_name); - rgw_raw_obj obj(store->get_zone_params().domain_root, bucket_name); + rgw_raw_obj obj(store->get_zone()->get_params().domain_root, bucket_name); op_ret = get_params(y); if (op_ret < 0) @@ -3044,7 +3044,7 @@ void RGWCreateBucket::execute(optional_yield y) if (!relaxed_region_enforcement && !location_constraint.empty() && - !static_cast(store)->svc()->zone->has_zonegroup_api(location_constraint)) { + !store->get_zone()->has_zonegroup_api(location_constraint)) { ldpp_dout(this, 0) << "location constraint (" << location_constraint << ")" << " can't be found." << dendl; op_ret = -ERR_INVALID_LOCATION_CONSTRAINT; @@ -3052,22 +3052,22 @@ void RGWCreateBucket::execute(optional_yield y) return; } - if (!relaxed_region_enforcement && !store->get_zonegroup().is_master_zonegroup() && !location_constraint.empty() && - store->get_zonegroup().api_name != location_constraint) { + if (!relaxed_region_enforcement && !store->get_zone()->get_zonegroup().is_master_zonegroup() && !location_constraint.empty() && + store->get_zone()->get_zonegroup().api_name != location_constraint) { ldpp_dout(this, 0) << "location constraint (" << location_constraint << ")" - << " doesn't match zonegroup" << " (" << store->get_zonegroup().api_name << ")" + << " doesn't match zonegroup" << " (" << store->get_zone()->get_zonegroup().api_name << ")" << dendl; op_ret = -ERR_INVALID_LOCATION_CONSTRAINT; s->err.message = "The specified location-constraint is not valid"; return; } - const auto& zonegroup = store->get_zonegroup(); + const auto& zonegroup = store->get_zone()->get_zonegroup(); if (!placement_rule.name.empty() && !zonegroup.placement_targets.count(placement_rule.name)) { ldpp_dout(this, 0) << "placement target (" << placement_rule.name << ")" << " doesn't exist in the placement targets of zonegroup" - << " (" << store->get_zonegroup().api_name << ")" << dendl; + << " (" << store->get_zone()->get_zonegroup().api_name << ")" << dendl; op_ret = -ERR_INVALID_LOCATION_CONSTRAINT; s->err.message = "The specified placement target does not exist"; return; @@ -3082,7 +3082,7 @@ void RGWCreateBucket::execute(optional_yield y) if (s->bucket_exists) { if (!s->system_request && - store->get_zonegroup().get_id() != s->bucket->get_info().zonegroup) { + store->get_zone()->get_zonegroup().get_id() != s->bucket->get_info().zonegroup) { op_ret = -EEXIST; return; } @@ -3098,10 +3098,10 @@ void RGWCreateBucket::execute(optional_yield y) if (s->system_request) { zonegroup_id = s->info.args.get(RGW_SYS_PARAM_PREFIX "zonegroup"); if (zonegroup_id.empty()) { - zonegroup_id = store->get_zonegroup().get_id(); + zonegroup_id = store->get_zone()->get_zonegroup().get_id(); } } else { - zonegroup_id = store->get_zonegroup().get_id(); + zonegroup_id = store->get_zone()->get_zonegroup().get_id(); } /* Encode special metadata first as we're using std::map::emplace under @@ -3870,7 +3870,7 @@ void RGWPutObj::execute(optional_yield y) // no filters by default DataProcessor *filter = processor.get(); - const auto& compression_type = store->get_zone_params().get_compression_type(*pdest_placement); + const auto& compression_type = store->get_zone()->get_params().get_compression_type(*pdest_placement); CompressorRef plugin; boost::optional compressor; @@ -4190,7 +4190,7 @@ void RGWPostObj::execute(optional_yield y) if (encrypt != nullptr) { filter = encrypt.get(); } else { - const auto& compression_type = store->get_zone_params().get_compression_type( + const auto& compression_type = store->get_zone()->get_params().get_compression_type( s->dest_placement); if (compression_type != "none") { plugin = Compressor::create(s->cct, compression_type); @@ -6020,7 +6020,7 @@ void RGWCompleteMultipart::execute(optional_yield y) op_ret = -ERR_INVALID_PART; return; } else { - manifest.append(obj_part.manifest, static_cast(store)->svc()->zone); + manifest.append(obj_part.manifest, store->get_zone()); } bool part_compressed = (obj_part.cs_info.compression_type != "none"); @@ -6825,7 +6825,7 @@ int RGWBulkUploadOp::handle_dir(const std::string_view path, optional_yield y) rgw_obj_key object_junk; std::tie(bucket_name, object_junk) = *parse_path(path); - rgw_raw_obj obj(store->get_zone_params().domain_root, + rgw_raw_obj obj(store->get_zone()->get_params().domain_root, rgw_make_bucket_entry_name(s->bucket_tenant, bucket_name)); /* we need to make sure we read bucket info, it's not read before for this @@ -6855,7 +6855,7 @@ int RGWBulkUploadOp::handle_dir(const std::string_view path, optional_yield y) forward_req_info(s->cct, info, bucket_name); op_ret = store->create_bucket(this, *s->user, new_bucket, - store->get_zonegroup().get_id(), + store->get_zone()->get_zonegroup().get_id(), placement_rule, swift_ver_location, pquota_info, policy, attrs, out_info, ep_objv, @@ -7004,7 +7004,7 @@ int RGWBulkUploadOp::handle_file(const std::string_view path, /* No filters by default. */ DataProcessor *filter = &processor; - const auto& compression_type = store->get_zone_params().get_compression_type( + const auto& compression_type = store->get_zone()->get_params().get_compression_type( dest_placement); CompressorRef plugin; boost::optional compressor; diff --git a/src/rgw/rgw_orphan.cc b/src/rgw/rgw_orphan.cc index 72e04b16606..377366b0da1 100644 --- a/src/rgw/rgw_orphan.cc +++ b/src/rgw/rgw_orphan.cc @@ -148,7 +148,7 @@ int RGWOrphanStore::list_jobs(map & job_list) int RGWOrphanStore::init() { - const rgw_pool& log_pool = store->get_zone_params().log_pool; + const rgw_pool& log_pool = store->get_zone()->get_params().log_pool; int r = rgw_init_ioctx(static_cast(store)->getRados()->get_rados_handle(), log_pool, ioctx); if (r < 0) { cerr << "ERROR: failed to open log pool (" << log_pool << " ret=" << r << std::endl; diff --git a/src/rgw/rgw_period_pusher.cc b/src/rgw/rgw_period_pusher.cc index aecb8b89ee9..9d5d3551c20 100644 --- a/src/rgw/rgw_period_pusher.cc +++ b/src/rgw/rgw_period_pusher.cc @@ -162,7 +162,7 @@ RGWPeriodPusher::RGWPeriodPusher(rgw::sal::RGWStore* store, optional_yield y) : cct(store->ctx()), store(store) { - const auto& realm = store->get_realm(); + const auto& realm = store->get_zone()->get_realm(); auto& realm_id = realm.get_id(); if (realm_id.empty()) // no realm configuration return; @@ -225,7 +225,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->get_zone()->get_zonegroup().get_id()); if (i == zonegroups.end()) { lderr(cct) << "The new period does not contain my zonegroup!" << dendl; return; @@ -233,7 +233,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->get_zone()->get_params().get_id()) return; // construct a map of the zones that need this period. the map uses the same @@ -242,11 +242,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->get_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->get_zone()->get_zonegroup().get_id()) continue; if (zonegroup.endpoints.empty()) continue; @@ -261,7 +261,7 @@ void RGWPeriodPusher::handle_notify(RGWZonesNeedPeriod&& period) // 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->get_zone()->get_params().get_id()) continue; if (zone.endpoints.empty()) continue; diff --git a/src/rgw/rgw_putobj_processor.cc b/src/rgw/rgw_putobj_processor.cc index 12773ccf7c4..0f60ab9bce8 100644 --- a/src/rgw/rgw_putobj_processor.cc +++ b/src/rgw/rgw_putobj_processor.cc @@ -504,7 +504,7 @@ int AppendObjectProcessor::complete(size_t accounted_size, const string &etag, c //For Append obj, disable versioning obj_op->params.versioning_disabled = true; if (cur_manifest) { - cur_manifest->append(manifest, static_cast(store)->svc()->zone); + cur_manifest->append(manifest, store->get_zone()); obj_op->params.manifest = cur_manifest; } else { obj_op->params.manifest = &manifest; diff --git a/src/rgw/rgw_realm_reloader.cc b/src/rgw/rgw_realm_reloader.cc index 1721036388f..41bd283b8e4 100644 --- a/src/rgw/rgw_realm_reloader.cc +++ b/src/rgw/rgw_realm_reloader.cc @@ -164,7 +164,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->get_zonegroup()); + rgw_rest_init(cct, store->get_zone()->get_zonegroup()); ldout(cct, 1) << " - usage subsystem init" << dendl; rgw_log_usage_init(cct, store); diff --git a/src/rgw/rgw_rest_config.cc b/src/rgw/rgw_rest_config.cc index 446e2792eb0..ff3237c62af 100644 --- a/src/rgw/rgw_rest_config.cc +++ b/src/rgw/rgw_rest_config.cc @@ -59,7 +59,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->get_zone()->get_params(); set_req_state_err(s, op_ret); dump_errno(s); diff --git a/src/rgw/rgw_rest_conn.cc b/src/rgw/rgw_rest_conn.cc index 82e35c2514e..285816d151f 100644 --- a/src/rgw/rgw_rest_conn.cc +++ b/src/rgw/rgw_rest_conn.cc @@ -33,8 +33,8 @@ RGWRESTConn::RGWRESTConn(CephContext *_cct, rgw::sal::RGWStore* store, remote_id(_remote_id), host_style(_host_style) { if (store) { - key = store->get_zone_params().system_key; - self_zone_group = store->get_zonegroup().get_id(); + key = store->get_zone()->get_params().system_key; + self_zone_group = store->get_zone()->get_zonegroup().get_id(); } } @@ -64,7 +64,7 @@ RGWRESTConn::RGWRESTConn(CephContext *_cct, rgw::sal::RGWStore* store, remote_id(_remote_id), host_style(_host_style) { if (store) { - self_zone_group = store->get_zonegroup().get_id(); + self_zone_group = store->get_zone()->get_zonegroup().get_id(); } } diff --git a/src/rgw/rgw_rest_log.cc b/src/rgw/rgw_rest_log.cc index bf1224cb7d6..62dab9b5d54 100644 --- a/src/rgw/rgw_rest_log.cc +++ b/src/rgw/rgw_rest_log.cc @@ -74,7 +74,7 @@ void RGWOp_MDLog_List::execute(optional_yield y) { if (period.empty()) { ldout(s->cct, 5) << "Missing period id trying to use current" << dendl; - period = static_cast(store)->svc()->zone->get_current_period_id(); + period = store->get_zone()->get_current_period_id(); if (period.empty()) { ldout(s->cct, 5) << "Missing period id" << dendl; op_ret = -EINVAL; @@ -152,7 +152,7 @@ void RGWOp_MDLog_ShardInfo::execute(optional_yield y) { if (period.empty()) { ldout(s->cct, 5) << "Missing period id trying to use current" << dendl; - period = static_cast(store)->svc()->zone->get_current_period_id(); + period = store->get_zone()->get_current_period_id(); if (period.empty()) { ldout(s->cct, 5) << "Missing period id" << dendl; @@ -218,7 +218,7 @@ void RGWOp_MDLog_Delete::execute(optional_yield y) { if (period.empty()) { ldout(s->cct, 5) << "Missing period id trying to use current" << dendl; - period = static_cast(store)->svc()->zone->get_current_period_id(); + period = store->get_zone()->get_current_period_id(); if (period.empty()) { ldout(s->cct, 5) << "Missing period id" << dendl; @@ -245,7 +245,7 @@ void RGWOp_MDLog_Lock::execute(optional_yield y) { if (period.empty()) { ldout(s->cct, 5) << "Missing period id trying to use current" << dendl; - period = static_cast(store)->svc()->zone->get_current_period_id(); + period = store->get_zone()->get_current_period_id(); } if (period.empty() || @@ -293,7 +293,7 @@ void RGWOp_MDLog_Unlock::execute(optional_yield y) { if (period.empty()) { ldout(s->cct, 5) << "Missing period id trying to use current" << dendl; - period = static_cast(store)->svc()->zone->get_current_period_id(); + period = store->get_zone()->get_current_period_id(); } if (period.empty() || @@ -847,7 +847,7 @@ void RGWOp_BILog_Status::execute(optional_yield y) } } - const auto& local_zone_id = store->get_zone_id(); + const auto& local_zone_id = store->get_zone()->get_id(); if (!merge) { rgw_sync_bucket_pipe pipe; diff --git a/src/rgw/rgw_rest_pubsub.cc b/src/rgw/rgw_rest_pubsub.cc index e05bedadf04..9c1a9a941fd 100644 --- a/src/rgw/rgw_rest_pubsub.cc +++ b/src/rgw/rgw_rest_pubsub.cc @@ -69,7 +69,7 @@ public: dest.arn_topic = topic_name; // the topic ARN will be sent in the reply const rgw::ARN arn(rgw::Partition::aws, rgw::Service::sns, - store->get_zonegroup().get_name(), + store->get_zone()->get_zonegroup().get_name(), s->user->get_tenant(), topic_name); topic_arn = arn.to_string(); return 0; diff --git a/src/rgw/rgw_rest_realm.cc b/src/rgw/rgw_rest_realm.cc index b128c9b9ac9..8c1cf57d2c7 100644 --- a/src/rgw/rgw_rest_realm.cc +++ b/src/rgw/rgw_rest_realm.cc @@ -108,9 +108,9 @@ void RGWOp_Period_Post::execute(optional_yield y) } // require period.realm_id to match our realm - if (period.get_realm() != store->get_realm().get_id()) { + if (period.get_realm() != store->get_zone()->get_realm().get_id()) { error_stream << "period with realm id " << period.get_realm() - << " doesn't match current realm " << store->get_realm().get_id() << std::endl; + << " doesn't match current realm " << store->get_zone()->get_realm().get_id() << std::endl; op_ret = -EINVAL; return; } @@ -144,7 +144,7 @@ void RGWOp_Period_Post::execute(optional_yield y) } // if it's not period commit, nobody is allowed to push to the master zone - if (period.get_master_zone() == store->get_zone_params().get_id()) { + if (period.get_master_zone() == store->get_zone()->get_params().get_id()) { ldout(cct, 10) << "master zone rejecting period id=" << period.get_id() << " epoch=" << period.get_epoch() << dendl; op_ret = -EINVAL; // XXX: error code diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 85c55ba1071..2db083463a5 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -1895,7 +1895,7 @@ void RGWGetBucketLocation_ObjStore_S3::send_response() RGWZoneGroup zonegroup; string api_name; - int ret = store->get_zonegroup(s->bucket->get_info().zonegroup, zonegroup); + int ret = store->get_zone()->get_zonegroup(s->bucket->get_info().zonegroup, zonegroup); if (ret >= 0) { api_name = zonegroup.api_name; } else { @@ -2731,7 +2731,7 @@ int RGWPostObj_ObjStore_S3::get_params(optional_yield y) if (! storage_class.empty()) { s->dest_placement.storage_class = storage_class; - if (!store->get_zone_params().valid_placement(s->dest_placement)) { + if (!store->get_zone()->get_params().valid_placement(s->dest_placement)) { ldpp_dout(this, 0) << "NOTICE: invalid dest placement: " << s->dest_placement.to_str() << dendl; err_msg = "The storage class you specified is not valid"; return -EINVAL; diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index d8b13770138..8b2280126fd 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -711,7 +711,7 @@ int RGWCreateBucket_ObjStore_SWIFT::get_params(optional_yield y) policy.create_default(s->user->get_id(), s->user->get_display_name()); } - location_constraint = store->get_zonegroup().api_name; + location_constraint = store->get_zone()->get_zonegroup().api_name; get_rmattrs_from_headers(s, CONT_PUT_ATTR_PREFIX, CONT_REMOVE_ATTR_PREFIX, rmattr_names); placement_rule.init(s->info.env->get("HTTP_X_STORAGE_POLICY", ""), s->info.storage_class); @@ -1896,7 +1896,7 @@ void RGWInfo_ObjStore_SWIFT::list_swift_data(Formatter& formatter, } formatter.open_array_section("policies"); - const RGWZoneGroup& zonegroup = store->get_zonegroup(); + const RGWZoneGroup& zonegroup = store->get_zone()->get_zonegroup(); for (const auto& placement_targets : zonegroup.placement_targets) { formatter.open_object_section("policy"); diff --git a/src/rgw/rgw_rest_user.cc b/src/rgw/rgw_rest_user.cc index a87c64992c3..a24d5c85930 100644 --- a/src/rgw/rgw_rest_user.cc +++ b/src/rgw/rgw_rest_user.cc @@ -210,7 +210,7 @@ void RGWOp_User_Create::execute(optional_yield y) if (!default_placement_str.empty()) { rgw_placement_rule target_rule; target_rule.from_str(default_placement_str); - if (!store->get_zone_params().valid_placement(target_rule)) { + if (!store->get_zone()->get_params().valid_placement(target_rule)) { ldout(s->cct, 0) << "NOTICE: invalid dest placement: " << target_rule.to_str() << dendl; op_ret = -EINVAL; return; @@ -352,7 +352,7 @@ void RGWOp_User_Modify::execute(optional_yield y) if (!default_placement_str.empty()) { rgw_placement_rule target_rule; target_rule.from_str(default_placement_str); - if (!store->get_zone_params().valid_placement(target_rule)) { + if (!store->get_zone()->get_params().valid_placement(target_rule)) { ldout(s->cct, 0) << "NOTICE: invalid dest placement: " << target_rule.to_str() << dendl; op_ret = -EINVAL; return; diff --git a/src/rgw/rgw_role.cc b/src/rgw/rgw_role.cc index c3f408c0ba0..b7f5048a197 100644 --- a/src/rgw/rgw_role.cc +++ b/src/rgw/rgw_role.cc @@ -38,7 +38,7 @@ int RGWRole::store_info(bool exclusive, optional_yield y) bufferlist bl; encode(*this, bl); - return store->put_system_obj(store->get_zone_params().roles_pool, oid, + return store->put_system_obj(store->get_zone()->get_params().roles_pool, oid, bl, exclusive, NULL, real_time(), y, NULL); } @@ -53,7 +53,7 @@ int RGWRole::store_name(bool exclusive, optional_yield y) using ceph::encode; encode(nameToId, bl); - return store->put_system_obj(store->get_zone_params().roles_pool, oid, + return store->put_system_obj(store->get_zone()->get_params().roles_pool, oid, bl, exclusive, NULL, real_time(), y, NULL); } @@ -62,7 +62,7 @@ int RGWRole::store_path(bool exclusive, optional_yield y) string oid = tenant + get_path_oid_prefix() + path + get_info_oid_prefix() + id; bufferlist bl; - return store->put_system_obj(store->get_zone_params().roles_pool, oid, + return store->put_system_obj(store->get_zone()->get_params().roles_pool, oid, bl, exclusive, NULL, real_time(), y, NULL); } @@ -109,7 +109,7 @@ int RGWRole::create(const DoutPrefixProvider *dpp, bool exclusive, optional_yiel sprintf(buf + strlen(buf),".%dZ",(int)tv.tv_usec/1000); creation_date.assign(buf, strlen(buf)); - auto& pool = store->get_zone_params().roles_pool; + auto& pool = store->get_zone()->get_params().roles_pool; ret = store_info(exclusive, y); if (ret < 0) { ldpp_dout(dpp, 0) << "ERROR: storing role info in pool: " << pool.name << ": " @@ -157,7 +157,7 @@ int RGWRole::create(const DoutPrefixProvider *dpp, bool exclusive, optional_yiel int RGWRole::delete_obj(const DoutPrefixProvider *dpp, optional_yield y) { - auto& pool = store->get_zone_params().roles_pool; + auto& pool = store->get_zone()->get_params().roles_pool; int ret = read_name(dpp, y); if (ret < 0) { @@ -226,7 +226,7 @@ int RGWRole::get_by_id(const DoutPrefixProvider *dpp, optional_yield y) int RGWRole::update(optional_yield y) { - auto& pool = store->get_zone_params().roles_pool; + auto& pool = store->get_zone()->get_params().roles_pool; int ret = store_info(false, y); if (ret < 0) { @@ -302,7 +302,7 @@ void RGWRole::decode_json(JSONObj *obj) int RGWRole::read_id(const DoutPrefixProvider *dpp, const string& role_name, const string& tenant, string& role_id, optional_yield y) { - auto& pool = store->get_zone_params().roles_pool; + auto& pool = store->get_zone()->get_params().roles_pool; string oid = tenant + get_names_oid_prefix() + role_name; bufferlist bl; @@ -327,7 +327,7 @@ int RGWRole::read_id(const DoutPrefixProvider *dpp, const string& role_name, con int RGWRole::read_info(const DoutPrefixProvider *dpp, optional_yield y) { - auto& pool = store->get_zone_params().roles_pool; + auto& pool = store->get_zone()->get_params().roles_pool; string oid = get_info_oid_prefix() + id; bufferlist bl; @@ -353,7 +353,7 @@ int RGWRole::read_info(const DoutPrefixProvider *dpp, optional_yield y) int RGWRole::read_name(const DoutPrefixProvider *dpp, optional_yield y) { - auto& pool = store->get_zone_params().roles_pool; + auto& pool = store->get_zone()->get_params().roles_pool; string oid = tenant + get_names_oid_prefix() + name; bufferlist bl; @@ -432,7 +432,7 @@ int RGWRole::get_roles_by_path_prefix(const DoutPrefixProvider *dpp, vector& roles, optional_yield y) { - auto pool = store->get_zone_params().roles_pool; + auto pool = store->get_zone()->get_params().roles_pool; string prefix; // List all roles if path prefix is empty diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index 4a244e0bbd9..9077043c78a 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -104,6 +104,7 @@ class Lifecycle; class Notification; class GCChain; class Writer; +class Zone; enum AttrsMod { ATTRSMOD_NONE = 0, @@ -160,11 +161,7 @@ class RGWStore { optional_yield y) = 0; virtual int defer_gc(const DoutPrefixProvider *dpp, RGWObjectCtx *rctx, RGWBucket* bucket, RGWObject* obj, optional_yield y) = 0; - virtual const RGWZoneGroup& get_zonegroup() = 0; - virtual int get_zonegroup(const string& id, RGWZoneGroup& zonegroup) = 0; - virtual const RGWZoneParams& get_zone_params() = 0; - virtual const rgw_zone_id& get_zone_id() = 0; - virtual const RGWRealm& get_realm() = 0; + virtual Zone* get_zone() = 0; virtual int cluster_stat(RGWClusterStat& stats) = 0; virtual std::unique_ptr get_lifecycle(void) = 0; virtual std::unique_ptr get_completions(void) = 0; @@ -886,6 +883,22 @@ protected: }; +class Zone { + public: + virtual ~Zone() = default; + + virtual const RGWZoneGroup& get_zonegroup() = 0; + virtual int get_zonegroup(const string& id, RGWZoneGroup& zonegroup) = 0; + virtual const RGWZoneParams& get_params() = 0; + virtual const rgw_zone_id& get_id() = 0; + virtual const RGWRealm& get_realm() = 0; + virtual const std::string& get_name() const = 0; + virtual bool is_writeable() = 0; + virtual bool get_redirect_endpoint(string *endpoint) = 0; + virtual bool has_zonegroup_api(const std::string& api) const = 0; + virtual const string& get_current_period_id() = 0; +}; + } } // namespace rgw::sal class RGWStoreManager { diff --git a/src/rgw/rgw_sal_rados.cc b/src/rgw/rgw_sal_rados.cc index bf33ba3a8d3..8fec427ca42 100644 --- a/src/rgw/rgw_sal_rados.cc +++ b/src/rgw/rgw_sal_rados.cc @@ -840,31 +840,6 @@ int RGWRadosStore::defer_gc(const DoutPrefixProvider *dpp, RGWObjectCtx *rctx, R return rados->defer_gc(dpp, rctx, bucket->get_info(), obj->get_obj(), y); } -const RGWZoneGroup& RGWRadosStore::get_zonegroup() -{ - return svc()->zone->get_zonegroup(); -} - -int RGWRadosStore::get_zonegroup(const string& id, RGWZoneGroup& zonegroup) -{ - return svc()->zone->get_zonegroup(id, zonegroup); -} - -const RGWZoneParams& RGWRadosStore::get_zone_params() -{ - return svc()->zone->get_zone_params(); -} - -const rgw_zone_id& RGWRadosStore::get_zone_id() -{ - return svc()->zone->zone_id(); -} - -const RGWRealm& RGWRadosStore::get_realm() -{ - return svc()->zone->get_realm(); -} - int RGWRadosStore::cluster_stat(RGWClusterStat& stats) { rados_cluster_stat_t rados_stats; @@ -1892,6 +1867,56 @@ RadosWriter::~RadosWriter() } } +const RGWZoneGroup& RadosZone::get_zonegroup() +{ + return store->svc()->zone->get_zonegroup(); +} + +int RadosZone::get_zonegroup(const string& id, RGWZoneGroup& zonegroup) +{ + return store->svc()->zone->get_zonegroup(id, zonegroup); +} + +const RGWZoneParams& RadosZone::get_params() +{ + return store->svc()->zone->get_zone_params(); +} + +const rgw_zone_id& RadosZone::get_id() +{ + return store->svc()->zone->zone_id(); +} + +const RGWRealm& RadosZone::get_realm() +{ + return store->svc()->zone->get_realm(); +} + +const std::string& RadosZone::get_name() const +{ + return store->svc()->zone->zone_name(); +} + +bool RadosZone::is_writeable() +{ + return store->svc()->zone->zone_is_writeable(); +} + +bool RadosZone::get_redirect_endpoint(std::string *endpoint) +{ + return store->svc()->zone->get_redirect_zone_endpoint(endpoint); +} + +bool RadosZone::has_zonegroup_api(const std::string& api) const +{ + return store->svc()->zone->has_zonegroup_api(api); +} + +const string& RadosZone::get_current_period_id() +{ + return store->svc()->zone->get_current_period_id(); +} + } // namespace rgw::sal extern "C" { diff --git a/src/rgw/rgw_sal_rados.h b/src/rgw/rgw_sal_rados.h index 01c012503b1..d5d5d574032 100644 --- a/src/rgw/rgw_sal_rados.h +++ b/src/rgw/rgw_sal_rados.h @@ -329,15 +329,35 @@ class RGWRadosBucket : public RGWBucket { friend class RGWRadosStore; }; +class RadosZone : public Zone { + protected: + RGWRadosStore* store; + public: + RadosZone(RGWRadosStore* _store) : store(_store) {} + ~RadosZone() = default; + + virtual const RGWZoneGroup& get_zonegroup() override; + virtual int get_zonegroup(const string& id, RGWZoneGroup& zonegroup) override; + virtual const RGWZoneParams& get_params() override; + virtual const rgw_zone_id& get_id() override; + virtual const RGWRealm& get_realm() override; + virtual const std::string& get_name() const override; + virtual bool is_writeable() override; + virtual bool get_redirect_endpoint(string *endpoint) override; + virtual bool has_zonegroup_api(const std::string& api) const override; + virtual const string& get_current_period_id() override; +}; + class RGWRadosStore : public RGWStore { private: RGWRados *rados; RGWUserCtl *user_ctl; std::string luarocks_path; + RadosZone zone; public: RGWRadosStore() - : rados(nullptr) { + : rados(nullptr), zone(this) { } ~RGWRadosStore() { delete rados; @@ -373,11 +393,7 @@ class RGWRadosStore : public RGWStore { optional_yield y) override; virtual int defer_gc(const DoutPrefixProvider *dpp, RGWObjectCtx *rctx, RGWBucket* bucket, RGWObject* obj, optional_yield y) override; - virtual const RGWZoneGroup& get_zonegroup() override; - virtual int get_zonegroup(const string& id, RGWZoneGroup& zonegroup) override; - virtual const RGWZoneParams& get_zone_params() override; - virtual const rgw_zone_id& get_zone_id() override; - virtual const RGWRealm& get_realm() override; + virtual Zone* get_zone() { return &zone; } virtual int cluster_stat(RGWClusterStat& stats) override; virtual std::unique_ptr get_lifecycle(void) override; virtual std::unique_ptr get_completions(void) override; diff --git a/src/rgw/rgw_sync_module_pubsub_rest.cc b/src/rgw/rgw_sync_module_pubsub_rest.cc index 440b9ae2ae9..6eaaab9ce4e 100644 --- a/src/rgw/rgw_sync_module_pubsub_rest.cc +++ b/src/rgw/rgw_sync_module_pubsub_rest.cc @@ -40,7 +40,7 @@ public: dest.arn_topic = topic_name; // the topic ARN will be sent in the reply const rgw::ARN arn(rgw::Partition::aws, rgw::Service::sns, - store->get_zonegroup().get_name(), + store->get_zone()->get_zonegroup().get_name(), s->user->get_tenant(), topic_name); topic_arn = arn.to_string(); return 0; diff --git a/src/rgw/rgw_tools.cc b/src/rgw/rgw_tools.cc index c8a1a8f298a..41d21c67525 100644 --- a/src/rgw/rgw_tools.cc +++ b/src/rgw/rgw_tools.cc @@ -497,7 +497,7 @@ int RGWDataAccess::Object::put(bufferlist& data, CompressorRef plugin; boost::optional compressor; - const auto& compression_type = store->get_zone_params().get_compression_type(bucket_info.placement_rule); + const auto& compression_type = store->get_zone()->get_params().get_compression_type(bucket_info.placement_rule); if (compression_type != "none") { plugin = Compressor::create(store->ctx(), compression_type); if (!plugin) { diff --git a/src/rgw/rgw_trim_bilog.cc b/src/rgw/rgw_trim_bilog.cc index eb3b381c15d..736c1ac10df 100644 --- a/src/rgw/rgw_trim_bilog.cc +++ b/src/rgw/rgw_trim_bilog.cc @@ -1081,7 +1081,7 @@ class BucketTrimManager::Impl : public TrimCounters::Server, Impl(rgw::sal::RGWRadosStore *store, const BucketTrimConfig& config) : store(store), config(config), - status_obj(store->get_zone_params().log_pool, BucketTrimStatus::oid), + status_obj(store->get_zone()->get_params().log_pool, BucketTrimStatus::oid), counter(config.counter_size), trimmed(config.recent_size, config.recent_duration), watcher(store, status_obj, this)