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;
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";
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),
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();
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;
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);
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;
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);
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);
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);
#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
}
}
-int RGWRealmWatcher::watch_start(RGWRealm& realm)
+int RGWRealmWatcher::watch_start(const RGWRealm& realm)
{
// initialize a Rados client
int r = rados.init_with_context(cct);
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
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();
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;
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);
}
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");
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);
}
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()) {
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)
}
}
-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);
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()) {
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;
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;
}
}
-const string& RGWRealm::get_predefined_name(CephContext *cct) {
+const string& RGWRealm::get_predefined_name(CephContext *cct) const {
return cct->_conf->rgw_realm;
}
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);
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;
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;
}
return 0;
}
-string RGWRealm::get_control_oid()
+string RGWRealm::get_control_oid() const
{
return get_info_oid_prefix() + id + ".control";
}
}
-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);
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;
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();
.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);
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);
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;
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;
}
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);
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);
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());
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);
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
}
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
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,
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;
int reflect();
int get_zonegroup(RGWZoneGroup& zonegroup,
- const std::string& zonegroup_id);
+ const std::string& zonegroup_id) const;
bool is_single_zonegroup() const
{
/*
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) {
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);
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;
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 {
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()) {
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;
}
* 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;
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);
}
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);
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();
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() {