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();
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,
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<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_zone();
int width = 15;
static int sync_info(std::optional<rgw_zone_id> opt_target_zone, std::optional<rgw_bucket> 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<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_sync_policy_handler(zone_id);
static int bucket_sync_info(rgw::sal::RGWRadosStore *store, const RGWBucketInfo& info,
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 = store->svc()->zone->get_zone();
constexpr int width = 15;
std::optional<rgw_bucket>& 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<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_zone();
constexpr int width = 15;
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;
}
RGWSyncModuleInstanceRef sync_module;
int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->sync_modules->get_manager()->create_instance(g_ceph_context, static_cast<rgw::sal::RGWRadosStore*>(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;
map<string, string> 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);
key_is_cert = true;
}
- ExpandMetaVar emv(static_cast<rgw::sal::RGWRadosStore*>(env.store)->svc()->zone);
+ ExpandMetaVar emv(env.store->get_zone());
cert = emv.process_str(*cert);
key = emv.process_str(*key);
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 */
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
{
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;
{
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);
{
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,
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();
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;
auto reloader = std::make_unique<RGWRealmReloader>(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);
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<uint64_t, RGWObjManifestRule>::iterator& miter,
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);
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;
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;
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;
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) {}
public:
explicit RGWObjectExpirer(rgw::sal::RGWStore *_store)
: store(_store),
- exp_store(_store->ctx(), static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->rados, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone),
+ exp_store(_store->ctx(), static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->rados, store->get_zone()),
worker(NULL) {
}
~RGWObjectExpirer() {
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);
}
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 << ": "
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);
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;
const string& tenant,
vector<RGWOIDCProvider>& 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
&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);
}
}
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();
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 */
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;
}
ret = -EACCES;
}
- bool success = static_cast<rgw::sal::RGWRadosStore*>(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;
}
return -EPERM;
}
- if (!s->system_request && (required_mask & RGW_OP_TYPE_MODIFY) && !static_cast<rgw::sal::RGWRadosStore*>(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;
/* 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());
}
/* 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());
}
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)
if (!relaxed_region_enforcement &&
!location_constraint.empty() &&
- !static_cast<rgw::sal::RGWRadosStore*>(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;
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;
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;
}
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
// 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<RGWPutObj_Compress> compressor;
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);
op_ret = -ERR_INVALID_PART;
return;
} else {
- manifest.append(obj_part.manifest, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone);
+ manifest.append(obj_part.manifest, store->get_zone());
}
bool part_compressed = (obj_part.cs_info.compression_type != "none");
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
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,
/* 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<RGWPutObj_Compress> compressor;
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<rgw::sal::RGWRadosStore*>(store)->getRados()->get_rados_handle(), log_pool, ioctx);
if (r < 0) {
cerr << "ERROR: failed to open log pool (" << log_pool << " ret=" << r << std::endl;
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;
// 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;
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
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;
// 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;
//For Append obj, disable versioning
obj_op->params.versioning_disabled = true;
if (cur_manifest) {
- cur_manifest->append(manifest, static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone);
+ cur_manifest->append(manifest, store->get_zone());
obj_op->params.manifest = cur_manifest;
} else {
obj_op->params.manifest = &manifest;
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);
}
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);
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();
}
}
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();
}
}
if (period.empty()) {
ldout(s->cct, 5) << "Missing period id trying to use current" << dendl;
- period = static_cast<rgw::sal::RGWRadosStore*>(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;
if (period.empty()) {
ldout(s->cct, 5) << "Missing period id trying to use current" << dendl;
- period = static_cast<rgw::sal::RGWRadosStore*>(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;
if (period.empty()) {
ldout(s->cct, 5) << "Missing period id trying to use current" << dendl;
- period = static_cast<rgw::sal::RGWRadosStore*>(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;
if (period.empty()) {
ldout(s->cct, 5) << "Missing period id trying to use current" << dendl;
- period = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_current_period_id();
+ period = store->get_zone()->get_current_period_id();
}
if (period.empty() ||
if (period.empty()) {
ldout(s->cct, 5) << "Missing period id trying to use current" << dendl;
- period = static_cast<rgw::sal::RGWRadosStore*>(store)->svc()->zone->get_current_period_id();
+ period = store->get_zone()->get_current_period_id();
}
if (period.empty() ||
}
}
- 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;
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;
}
// 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;
}
}
// 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
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 {
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;
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);
}
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");
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;
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;
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);
}
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);
}
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);
}
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 << ": "
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) {
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) {
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;
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;
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;
vector<RGWRole>& 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
class Notification;
class GCChain;
class Writer;
+class Zone;
enum AttrsMod {
ATTRSMOD_NONE = 0,
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<Lifecycle> get_lifecycle(void) = 0;
virtual std::unique_ptr<Completions> get_completions(void) = 0;
};
+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 {
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;
}
}
+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" {
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;
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<Lifecycle> get_lifecycle(void) override;
virtual std::unique_ptr<Completions> get_completions(void) override;
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;
CompressorRef plugin;
boost::optional<RGWPutObj_Compress> 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) {
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)