const string& access, const string& secret,
bool force)
{
- const string& master_zone = period.get_master_zone();
+ auto& master_zone = period.get_master_zone();
if (master_zone.empty()) {
cerr << "cannot commit period: period does not have a master zone of a master zonegroup" << std::endl;
return -EINVAL;
}
// are we the period's master zone?
- if (store->svc()->zone->get_zone_params().get_id() == master_zone) {
+ if (store->svc()->zone->zone_id() == master_zone) {
// read the current period
RGWPeriod current_period;
int ret = current_period.init(g_ceph_context, store->svc()->sysobj, realm.get_id());
if (remote.empty() && url.empty()) {
// use the new master zone's connection
- remote = master_zone;
+ remote = master_zone.id;
cout << "Sending period to new master zone " << remote << std::endl;
}
boost::optional<RGWRESTConn> conn;
}
// push period to the master with an empty period id
- period.set_id("");
+ period.set_id(string());
RGWEnv env;
req_info info(g_ceph_context, &env);
flush_ss(ss, status);
}
-static void get_data_sync_status(const string& source_zone, list<string>& status, int tab)
+static void get_data_sync_status(const rgw_zone_id& source_zone, list<string>& status, int tab)
{
stringstream ss;
RGWZone *sz;
- if (!store->svc()->zone->find_zone_by_id(source_zone, &sz)) {
+ if (!store->svc()->zone->find_zone(source_zone, &sz)) {
push_ss(ss, status, tab) << string("zone not found");
flush_ss(ss, status);
return;
auto& zone_conn_map = store->svc()->zone->get_zone_conn_map();
for (auto iter : zone_conn_map) {
- const string& source_id = iter.first;
+ const rgw_zone_id& source_id = iter.first;
string source_str = "source: ";
- string s = source_str + source_id;
+ string s = source_str + source_id.id;
RGWZone *sz;
- if (store->svc()->zone->find_zone_by_id(source_id, &sz)) {
+ if (store->svc()->zone->find_zone(source_id, &sz)) {
s += string(" (") + sz->name + ")";
}
data_status.push_back(s);
return std::move(result);
}
-static void get_hint_entities(const std::set<string>& zone_names, const std::set<rgw_bucket>& buckets,
+static void get_hint_entities(const std::set<rgw_zone_id>& zones, const std::set<rgw_bucket>& buckets,
std::set<rgw_sync_bucket_entity> *hint_entities)
{
- for (auto& zone : zone_names) {
+ for (auto& zone_id : zones) {
for (auto& b : buckets) {
- string zid;
- if (!store->svc()->zone->find_zone_id_by_name(zone, &zid)) {
- cerr << "WARNING: cannot find zone id for zone=" << zone << ", skippping" << std::endl;
- continue;
- }
-
RGWBucketInfo hint_bucket_info;
rgw_bucket hint_bucket;
int ret = init_bucket(b, hint_bucket_info, hint_bucket);
continue;
}
- hint_entities->insert(rgw_sync_bucket_entity(zid, hint_bucket));
+ hint_entities->insert(rgw_sync_bucket_entity(zone_id, hint_bucket));
}
}
}
-static int sync_info(std::optional<string> opt_target_zone, std::optional<rgw_bucket> opt_bucket, Formatter *formatter)
+static rgw_zone_id resolve_zone_id(const string& s)
{
- string zone_name;
- std::optional<string> zone_id;
+ rgw_zone_id result;
- if (opt_target_zone) {
- string zid;
- if (!store->svc()->zone->find_zone_id_by_name(*opt_target_zone, &zid)) {
- cerr << "WARNING: cannot find zone id for zone=" << *opt_target_zone << std::endl;
- return -ENOENT;
- }
- zone_name = *opt_target_zone;
- zone_id = zid;
- } else {
- zone_name = store->svc ()->zone->zone_name();
+ RGWZone *zone;
+ if (store->svc()->zone->find_zone(s, &zone)) {
+ return rgw_zone_id(s);
+ }
+ if (store->svc()->zone->find_zone_id_by_name(s, &result)) {
+ return result;
}
+ return rgw_zone_id(s);
+}
+
+rgw_zone_id validate_zone_id(const rgw_zone_id& zone_id)
+{
+ return resolve_zone_id(zone_id.id);
+}
+
+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->svc()->zone->zone_id());
auto zone_policy_handler = store->svc()->zone->get_sync_policy_handler(zone_id);
std::set<rgw_sync_bucket_pipe> resolved_sources;
std::set<rgw_sync_bucket_pipe> resolved_dests;
- rgw_sync_bucket_entity self_entity(zone_name, opt_bucket);
+ rgw_sync_bucket_entity self_entity(zone_id, opt_bucket);
- set<string> source_zones;
- set<string> target_zones;
+ set<rgw_zone_id> source_zones;
+ set<rgw_zone_id> target_zones;
zone_policy_handler->reflect(nullptr, nullptr,
nullptr, nullptr,
continue; /* shouldn't really happen */
}
- auto& zid = *hint_entity.zone;
+ auto zid = validate_zone_id(*hint_entity.zone);
auto& hint_bucket = *hint_entity.bucket;
RGWBucketSyncPolicyHandlerRef hint_bucket_handler;
}
hint_bucket_handler->get_pipes(&resolved_dests,
- &resolved_sources,
- self_entity); /* flipping resolved dests and sources as these are
- relative to the remote entity */
+ &resolved_sources,
+ self_entity); /* flipping resolved dests and sources as these are
+ relative to the remote entity */
}
{
encode_json("dests", target_hints_vec, formatter);
}
{
- Formatter::ObjectSection resolved_hints_section(*formatter, "resolved-hints");
+ Formatter::ObjectSection resolved_hints_section(*formatter, "resolved-hints-1");
encode_json("sources", resolved_sources, formatter);
encode_json("dests", resolved_dests, formatter);
}
+ {
+ Formatter::ObjectSection resolved_hints_section(*formatter, "resolved-hints");
+ encode_json("sources", handler->get_resolved_source_hints(), formatter);
+ encode_json("dests", handler->get_resolved_dest_hints(), formatter);
+ }
}
formatter->flush(cout);
}
static int bucket_sync_status(rgw::sal::RGWRadosStore *store, const RGWBucketInfo& info,
- const std::string& source_zone_id,
+ const rgw_zone_id& source_zone_id,
std::ostream& out)
{
const RGWRealm& realm = store->svc()->zone->get_realm();
auto& sources = handler->get_sources();
auto& zone_conn_map = store->svc()->zone->get_zone_conn_map();
- set<string> zone_ids;
+ set<rgw_zone_id> zone_ids;
if (!source_zone_id.empty()) {
auto z = zonegroup.zones.find(source_zone_id);
}
for (auto& zone_id : zone_ids) {
- auto z = zonegroup.zones.find(zone_id);
+ auto z = zonegroup.zones.find(zone_id.id);
if (z == zonegroup.zones.end()) { /* should't happen */
continue;
}
for (auto& m : sources) {
for (auto& entry : m.second.pipe_map) {
auto& pipe = entry.second;
- if (pipe.source.zone.value_or("") == z->second.id) {
+ if (pipe.source.zone.value_or(rgw_zone_id()) == z->second.id) {
bucket_source_sync_status(store, zone, z->second,
c->second,
info, pipe,
};
+void resolve_zone_id_opt(std::optional<string>& zone_name, std::optional<rgw_zone_id>& zone_id)
+{
+ if (!zone_name || zone_id) {
+ return;
+ }
+ zone_id.emplace();
+ if (!store->svc()->zone->find_zone_id_by_name(*zone_name, &(*zone_id))) {
+ cerr << "WARNING: cannot find source zone id for name=" << *zone_name << std::endl;
+ zone_id = rgw_zone_id(*zone_name);
+ }
+}
+void resolve_zone_ids_opt(std::optional<vector<string> >& names, std::optional<vector<rgw_zone_id> >& ids)
+{
+ if (!names || ids) {
+ return;
+ }
+ ids.emplace();
+ for (auto& name : *names) {
+ rgw_zone_id zid;
+ if (!store->svc()->zone->find_zone_id_by_name(name, &zid)) {
+ cerr << "WARNING: cannot find source zone id for name=" << name << std::endl;
+ zid = rgw_zone_id(name);
+ }
+ ids->push_back(zid);
+ }
+}
+
+static vector<rgw_zone_id> zone_ids_from_str(const string& val)
+{
+ vector<rgw_zone_id> result;
+ vector<string> v;
+ get_str_vec(val, v);
+ for (auto& z : v) {
+ result.push_back(rgw_zone_id(z));
+ }
+ return result;
+}
int main(int argc, const char **argv)
{
string err;
string source_zone_name;
- string source_zone; /* zone id */
+ rgw_zone_id source_zone; /* zone id */
string tier_type;
bool tier_type_specified = false;
std::optional<string> opt_group_id;
std::optional<string> opt_status;
std::optional<string> opt_flow_type;
- std::optional<vector<string> > opt_zones;
+ std::optional<vector<string> > opt_zone_names;
+ std::optional<vector<rgw_zone_id> > opt_zone_ids;
std::optional<string> opt_flow_id;
std::optional<string> opt_source_zone;
std::optional<string> opt_dest_zone;
- std::optional<vector<string> > opt_source_zones;
- std::optional<vector<string> > opt_dest_zones;
+ std::optional<vector<string> > opt_source_zone_names;
+ std::optional<vector<rgw_zone_id> > opt_source_zone_ids;
+ std::optional<vector<string> > opt_dest_zone_names;
+ std::optional<vector<rgw_zone_id> > opt_dest_zone_ids;
std::optional<string> opt_pipe_id;
std::optional<rgw_bucket> opt_bucket;
std::optional<string> opt_tenant;
std::optional<string> opt_dest_tenant;
std::optional<string> opt_dest_bucket_name;
std::optional<string> opt_dest_bucket_id;
- std::optional<string> opt_effective_zone;
+ std::optional<string> opt_effective_zone_name;
+ std::optional<rgw_zone_id> opt_effective_zone_id;
std::optional<string> opt_prefix;
std::optional<string> opt_prefix_rm;
opt_status = val;
} else if (ceph_argparse_witharg(args, i, &val, "--flow-type", (char*)NULL)) {
opt_flow_type = val;
- } else if (ceph_argparse_witharg(args, i, &val, "--zones", (char*)NULL)) {
+ } else if (ceph_argparse_witharg(args, i, &val, "--zones", "--zone-names", (char*)NULL)) {
vector<string> v;
get_str_vec(val, v);
- opt_zones = std::move(v);
- } else if (ceph_argparse_witharg(args, i, &val, "--source-zones", (char*)NULL)) {
+ opt_zone_names = std::move(v);
+ } else if (ceph_argparse_witharg(args, i, &val, "--zone-ids", (char*)NULL)) {
+ opt_zone_ids = zone_ids_from_str(val);
+ } else if (ceph_argparse_witharg(args, i, &val, "--source-zones", "--source-zone-names", (char*)NULL)) {
vector<string> v;
get_str_vec(val, v);
- opt_source_zones = std::move(v);
- } else if (ceph_argparse_witharg(args, i, &val, "--dest-zones", (char*)NULL)) {
+ opt_source_zone_names = std::move(v);
+ } else if (ceph_argparse_witharg(args, i, &val, "--source-zone-ids", (char*)NULL)) {
+ opt_source_zone_ids = zone_ids_from_str(val);
+ } else if (ceph_argparse_witharg(args, i, &val, "--dest-zones", "--dest-zone-names", (char*)NULL)) {
vector<string> v;
get_str_vec(val, v);
- opt_dest_zones = std::move(v);
+ opt_dest_zone_names = std::move(v);
+ } else if (ceph_argparse_witharg(args, i, &val, "--dest-zone-ids", (char*)NULL)) {
+ opt_dest_zone_ids = zone_ids_from_str(val);
} else if (ceph_argparse_witharg(args, i, &val, "--flow-id", (char*)NULL)) {
opt_flow_id = val;
} else if (ceph_argparse_witharg(args, i, &val, "--pipe-id", (char*)NULL)) {
opt_dest_bucket_name = val;
} else if (ceph_argparse_witharg(args, i, &val, "--dest-bucket-id", (char*)NULL)) {
opt_dest_bucket_id = val;
- } else if (ceph_argparse_witharg(args, i, &val, "--effective-zone", (char*)NULL)) {
- opt_effective_zone = val;
+ } else if (ceph_argparse_witharg(args, i, &val, "--effective-zone-name", "--effective-zone", (char*)NULL)) {
+ opt_effective_zone_name = val;
+ } else if (ceph_argparse_witharg(args, i, &val, "--effective-zone-id", (char*)NULL)) {
+ opt_effective_zone_id = rgw_zone_id(val);
} else if (ceph_argparse_witharg(args, i, &val, "--prefix", (char*)NULL)) {
opt_prefix = val;
} else if (ceph_argparse_witharg(args, i, &val, "--prefix-rm", (char*)NULL)) {
}
if (remote.empty()) {
// use realm master zone as remote
- remote = current_period.get_master_zone();
+ remote = current_period.get_master_zone().id;
}
conn = get_remote_conn(store, current_period.get_map(), remote);
if (!conn) {
return 0;
}
+ resolve_zone_id_opt(opt_effective_zone_name, opt_effective_zone_id);
+ resolve_zone_ids_opt(opt_zone_names, opt_zone_ids);
+ resolve_zone_ids_opt(opt_source_zone_names, opt_source_zone_ids);
+ resolve_zone_ids_opt(opt_dest_zone_names, opt_dest_zone_ids);
+
bool non_master_cmd = (!store->svc()->zone->is_meta_master() && !yes_i_really_mean_it);
std::set<OPT> non_master_ops_list = {OPT::USER_CREATE, OPT::USER_RM,
OPT::USER_MODIFY, OPT::USER_ENABLE,
}
if (opt_cmd == OPT::SYNC_INFO) {
- sync_info(opt_effective_zone, opt_bucket, formatter);
+ sync_info(opt_effective_zone_id, opt_bucket, formatter);
}
if (opt_cmd == OPT::SYNC_STATUS) {
auto& group = iter->second;
if (symmetrical_flow_opt(*opt_flow_type)) {
- CHECK_TRUE(require_non_empty_opt(opt_zones), "ERROR: --zones not provided for symmetrical flow, or is empty", EINVAL);
+ CHECK_TRUE(require_non_empty_opt(opt_zone_ids), "ERROR: --zones not provided for symmetrical flow, or is empty", EINVAL);
rgw_sync_symmetric_group *flow_group;
group.data_flow.find_symmetrical(*opt_flow_id, true, &flow_group);
- for (auto& z : *opt_zones) {
+ for (auto& z : *opt_zone_ids) {
flow_group->zones.insert(z);
}
} else { /* directional */
auto& group = iter->second;
if (symmetrical_flow_opt(*opt_flow_type)) {
- group.data_flow.remove_symmetrical(*opt_flow_id, opt_zones);
+ group.data_flow.remove_symmetrical(*opt_flow_id, opt_zone_ids);
} else { /* directional */
CHECK_TRUE(require_non_empty_opt(opt_source_zone), "ERROR: --source-zone not provided for directional flow rule, or is empty", EINVAL);
CHECK_TRUE(require_non_empty_opt(opt_dest_zone), "ERROR: --dest-zone not provided for directional flow rule, or is empty", EINVAL);
CHECK_TRUE(require_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL);
CHECK_TRUE(require_opt(opt_pipe_id), "ERROR: --pipe-id not specified", EINVAL);
if (opt_cmd == OPT::SYNC_GROUP_PIPE_CREATE) {
- CHECK_TRUE(require_non_empty_opt(opt_source_zones), "ERROR: --source-zones not provided or is empty; should be list of zones or '*'", EINVAL);
- CHECK_TRUE(require_non_empty_opt(opt_dest_zones), "ERROR: --dest-zones not provided or is empty; should be list of zones or '*'", EINVAL);
+ CHECK_TRUE(require_non_empty_opt(opt_source_zone_ids), "ERROR: --source-zones not provided or is empty; should be list of zones or '*'", EINVAL);
+ CHECK_TRUE(require_non_empty_opt(opt_dest_zone_ids), "ERROR: --dest-zones not provided or is empty; should be list of zones or '*'", EINVAL);
}
SyncPolicyContext sync_policy_ctx(zonegroup_id, zonegroup_name, opt_bucket);
}
}
- pipe->source.add_zones(*opt_source_zones);
+ pipe->source.add_zones(*opt_source_zone_ids);
pipe->source.set_bucket(opt_source_tenant,
opt_source_bucket_name,
opt_source_bucket_id);
- pipe->dest.add_zones(*opt_dest_zones);
+ pipe->dest.add_zones(*opt_dest_zone_ids);
pipe->dest.set_bucket(opt_dest_tenant,
opt_dest_bucket_name,
opt_dest_bucket_id);
return ENOENT;
}
- if (opt_source_zones) {
- pipe->source.remove_zones(*opt_source_zones);
+ if (opt_source_zone_ids) {
+ pipe->source.remove_zones(*opt_source_zone_ids);
}
pipe->source.remove_bucket(opt_source_tenant,
opt_source_bucket_name,
opt_source_bucket_id);
- if (opt_dest_zones) {
- pipe->dest.remove_zones(*opt_dest_zones);
+ if (opt_dest_zone_ids) {
+ pipe->dest.remove_zones(*opt_dest_zone_ids);
}
pipe->dest.remove_bucket(opt_dest_tenant,
opt_dest_bucket_name,
opt_dest_bucket_id);
- if (!(opt_source_zones ||
+ if (!(opt_source_zone_ids ||
opt_source_tenant ||
opt_source_bucket ||
opt_source_bucket_id ||
- opt_dest_zones ||
+ opt_dest_zone_ids ||
opt_dest_tenant ||
opt_dest_bucket ||
opt_dest_bucket_id)) {
return ctl.user->flush_bucket_stats(user_id, *pent);
}
-int RGWBucketCtl::get_sync_policy_handler(std::optional<string> zone,
+int RGWBucketCtl::get_sync_policy_handler(std::optional<rgw_zone_id> zone,
std::optional<rgw_bucket> bucket,
RGWBucketSyncPolicyHandlerRef *phandler,
optional_yield y)
RGWBucketEnt* pent = nullptr);
/* bucket sync */
- int get_sync_policy_handler(std::optional<string> zone,
+ int get_sync_policy_handler(std::optional<rgw_zone_id> zone,
std::optional<rgw_bucket> bucket,
RGWBucketSyncPolicyHandlerRef *phandler,
optional_yield y);
ostream& operator<<(ostream& os, const rgw_sync_bucket_entity& e) {
- os << "{b=" << rgw_sync_bucket_entities::bucket_key(e.bucket) << ",z=" << e.zone.value_or("") << ",az=" << (int)e.all_zones << "}";
+ os << "{b=" << rgw_sync_bucket_entities::bucket_key(e.bucket) << ",z=" << e.zone.value_or(rgw_zone_id()) << ",az=" << (int)e.all_zones << "}";
return os;
}
}
ostream& operator<<(ostream& os, const rgw_sync_bucket_entities& e) {
- os << "{b=" << rgw_sync_bucket_entities::bucket_key(e.bucket) << ",z=" << e.zones.value_or(std::set<string>()) << "}";
+ os << "{b=" << rgw_sync_bucket_entities::bucket_key(e.bucket) << ",z=" << e.zones.value_or(std::set<rgw_zone_id>()) << "}";
return os;
}
}
static std::vector<rgw_sync_bucket_pipe> filter_relevant_pipes(const std::vector<rgw_sync_bucket_pipes>& pipes,
- const string& source_zone,
- const string& dest_zone)
+ const rgw_zone_id& source_zone,
+ const rgw_zone_id& dest_zone)
{
std::vector<rgw_sync_bucket_pipe> relevant_pipes;
for (auto& p : pipes) {
void rgw_sync_group_pipe_map::dump(ceph::Formatter *f) const
{
- encode_json("zone", zone, f);
+ encode_json("zone", zone.id, f);
encode_json("buckets", rgw_sync_bucket_entities::bucket_key(bucket), f);
encode_json("sources", sources, f);
encode_json("dests", dests, f);
template <typename CB1, typename CB2>
-void rgw_sync_group_pipe_map::try_add_to_pipe_map(const string& source_zone,
- const string& dest_zone,
+void rgw_sync_group_pipe_map::try_add_to_pipe_map(const rgw_zone_id& source_zone,
+ const rgw_zone_id& dest_zone,
const std::vector<rgw_sync_bucket_pipes>& pipes,
zb_pipe_map_t *pipe_map,
CB1 filter_cb,
}
template <typename CB>
-void rgw_sync_group_pipe_map::try_add_source(const string& source_zone,
- const string& dest_zone,
+void rgw_sync_group_pipe_map::try_add_source(const rgw_zone_id& source_zone,
+ const rgw_zone_id& dest_zone,
const std::vector<rgw_sync_bucket_pipes>& pipes,
CB filter_cb)
{
}
template <typename CB>
-void rgw_sync_group_pipe_map::try_add_dest(const string& source_zone,
- const string& dest_zone,
+void rgw_sync_group_pipe_map::try_add_dest(const rgw_zone_id& source_zone,
+ const rgw_zone_id& dest_zone,
const std::vector<rgw_sync_bucket_pipes>& pipes,
CB filter_cb)
{
using zb_pipe_map_t = rgw_sync_group_pipe_map::zb_pipe_map_t;
pair<zb_pipe_map_t::const_iterator, zb_pipe_map_t::const_iterator> rgw_sync_group_pipe_map::find_pipes(const zb_pipe_map_t& m,
- const string& zone,
+ const rgw_zone_id& zone,
std::optional<rgw_bucket> b) const
{
if (!b) {
template <typename CB>
-void rgw_sync_group_pipe_map::init(const string& _zone,
+void rgw_sync_group_pipe_map::init(const rgw_zone_id& _zone,
std::optional<rgw_bucket> _bucket,
const rgw_sync_policy_group& group,
rgw_sync_data_flow_group *_default_flow,
- std::set<std::string> *_pall_zones,
+ std::set<rgw_zone_id> *_pall_zones,
CB filter_cb) {
zone = _zone;
bucket = _bucket;
/*
* find all relevant pipes in our zone that match {dest_bucket} <- {source_zone, source_bucket}
*/
-vector<rgw_sync_bucket_pipe> rgw_sync_group_pipe_map::find_source_pipes(const string& source_zone,
+vector<rgw_sync_bucket_pipe> rgw_sync_group_pipe_map::find_source_pipes(const rgw_zone_id& source_zone,
std::optional<rgw_bucket> source_bucket,
std::optional<rgw_bucket> dest_bucket) const {
vector<rgw_sync_bucket_pipe> result;
* source bucket in out zone {source_bucket} -> {dest_zone, dest_bucket}
*/
vector<rgw_sync_bucket_pipe> rgw_sync_group_pipe_map::find_dest_pipes(std::optional<rgw_bucket> source_bucket,
- const string& dest_zone,
+ const rgw_zone_id& dest_zone,
std::optional<rgw_bucket> dest_bucket) const {
vector<rgw_sync_bucket_pipe> result;
/*
* find all relevant pipes from {source_zone, source_bucket} -> {dest_zone, dest_bucket}
*/
-vector<rgw_sync_bucket_pipe> rgw_sync_group_pipe_map::find_pipes(const string& source_zone,
+vector<rgw_sync_bucket_pipe> rgw_sync_group_pipe_map::find_pipes(const rgw_zone_id& source_zone,
std::optional<rgw_bucket> source_bucket,
- const string& dest_zone,
+ const rgw_zone_id& dest_zone,
std::optional<rgw_bucket> dest_bucket) const {
if (dest_zone == zone) {
return find_source_pipes(source_zone, source_bucket, dest_bucket);
encode_json("pipes", pipe_map, f);
}
-bool RGWBucketSyncFlowManager::allowed_data_flow(const string& source_zone,
+bool RGWBucketSyncFlowManager::allowed_data_flow(const rgw_zone_id& source_zone,
std::optional<rgw_bucket> source_bucket,
- const string& dest_zone,
+ const rgw_zone_id& dest_zone,
std::optional<rgw_bucket> dest_bucket,
bool check_activated) const
{
auto& group = item.second;
auto& flow_group_map = flow_groups[group.id];
- flow_group_map.init(zone_name, bucket, group,
+ flow_group_map.init(zone_id, bucket, group,
(default_flow ? &(*default_flow) : nullptr),
&all_zones,
- [&](const string& source_zone,
+ [&](const rgw_zone_id& source_zone,
std::optional<rgw_bucket> source_bucket,
- const string& dest_zone,
+ const rgw_zone_id& dest_zone,
std::optional<rgw_bucket> dest_bucket) {
if (!parent) {
return true;
{
rgw_sync_bucket_entity entity;
- entity.zone = zone_name;
+ entity.zone = zone_id;
entity.bucket = effective_bucket.value_or(rgw_bucket());
if (parent) {
}
-RGWBucketSyncFlowManager::RGWBucketSyncFlowManager(const string& _zone_name,
+RGWBucketSyncFlowManager::RGWBucketSyncFlowManager(const rgw_zone_id& _zone_id,
std::optional<rgw_bucket> _bucket,
- const RGWBucketSyncFlowManager *_parent) : zone_name(_zone_name),
+ const RGWBucketSyncFlowManager *_parent) : zone_id(_zone_id),
bucket(_bucket),
parent(_parent) {}
auto& zonegroup = zone_svc->get_zonegroup();
for (const auto& ziter1 : zonegroup.zones) {
- const string& id1 = ziter1.first;
+ auto& id1 = ziter1.first;
const RGWZone& z1 = ziter1.second;
for (const auto& ziter2 : zonegroup.zones) {
- const string& id2 = ziter2.first;
+ auto& id2 = ziter2.first;
const RGWZone& z2 = ziter2.second;
if (id1 == id2) {
if (z1.syncs_from(z2.name)) {
found = true;
rgw_sync_directional_rule *rule;
- group.data_flow.find_directional(z2.name, z1.name, true, &rule);
+ group.data_flow.find_directional(id2,
+ id1,
+ true,
+ &rule);
}
}
}
RGWBucketSyncPolicyHandler::RGWBucketSyncPolicyHandler(RGWSI_Zone *_zone_svc,
RGWSI_SyncModules *sync_modules_svc,
RGWSI_Bucket_Sync *_bucket_sync_svc,
- std::optional<string> effective_zone) : zone_svc(_zone_svc) ,
- bucket_sync_svc(_bucket_sync_svc) {
- zone_name = effective_zone.value_or(zone_svc->zone_name());
- flow_mgr.reset(new RGWBucketSyncFlowManager(zone_name,
+ std::optional<rgw_zone_id> effective_zone) : zone_svc(_zone_svc) ,
+ bucket_sync_svc(_bucket_sync_svc) {
+ zone_id = effective_zone.value_or(zone_svc->zone_id());
+ flow_mgr.reset(new RGWBucketSyncFlowManager(zone_id,
nullopt,
nullptr));
sync_policy = zone_svc->get_zonegroup().sync_policy;
bucket = _bucket_info.bucket;
zone_svc = parent->zone_svc;
bucket_sync_svc = parent->bucket_sync_svc;
- flow_mgr.reset(new RGWBucketSyncFlowManager(parent->zone_name,
+ flow_mgr.reset(new RGWBucketSyncFlowManager(parent->zone_id,
_bucket_info.bucket,
parent->flow_mgr.get()));
}
bucket = _bucket;
zone_svc = parent->zone_svc;
bucket_sync_svc = parent->bucket_sync_svc;
- flow_mgr.reset(new RGWBucketSyncFlowManager(parent->zone_name,
+ flow_mgr.reset(new RGWBucketSyncFlowManager(parent->zone_id,
_bucket,
parent->flow_mgr.get()));
}
flow_mgr->init(sync_policy);
- reflect(&sources_by_name,
- &targets_by_name,
+ reflect(&source_pipes,
+ &target_pipes,
&sources,
&targets,
&source_zones,
return 0;
}
-void RGWBucketSyncPolicyHandler::reflect(RGWBucketSyncFlowManager::pipe_set *psources_by_name,
- RGWBucketSyncFlowManager::pipe_set *ptargets_by_name,
- map<string, RGWBucketSyncFlowManager::pipe_set> *psources,
- map<string, RGWBucketSyncFlowManager::pipe_set> *ptargets,
- std::set<string> *psource_zones,
- std::set<string> *ptarget_zones,
+void RGWBucketSyncPolicyHandler::reflect(RGWBucketSyncFlowManager::pipe_set *psource_pipes,
+ RGWBucketSyncFlowManager::pipe_set *ptarget_pipes,
+ map<rgw_zone_id, RGWBucketSyncFlowManager::pipe_set> *psources,
+ map<rgw_zone_id, RGWBucketSyncFlowManager::pipe_set> *ptargets,
+ std::set<rgw_zone_id> *psource_zones,
+ std::set<rgw_zone_id> *ptarget_zones,
bool only_enabled) const
{
- RGWBucketSyncFlowManager::pipe_set _sources_by_name;
- RGWBucketSyncFlowManager::pipe_set _targets_by_name;
- map<string, RGWBucketSyncFlowManager::pipe_set> _sources;
- map<string, RGWBucketSyncFlowManager::pipe_set> _targets;
- std::set<string> _source_zones;
- std::set<string> _target_zones;
+ RGWBucketSyncFlowManager::pipe_set _source_pipes;
+ RGWBucketSyncFlowManager::pipe_set _target_pipes;
+ map<rgw_zone_id, RGWBucketSyncFlowManager::pipe_set> _sources;
+ map<rgw_zone_id, RGWBucketSyncFlowManager::pipe_set> _targets;
+ std::set<rgw_zone_id> _source_zones;
+ std::set<rgw_zone_id> _target_zones;
- flow_mgr->reflect(bucket, &_sources_by_name, &_targets_by_name, only_enabled);
+ flow_mgr->reflect(bucket, &_source_pipes, &_target_pipes, only_enabled);
- for (auto& entry : _sources_by_name.pipe_map) {
+ for (auto& entry : _source_pipes.pipe_map) {
auto& pipe = entry.second;
if (!pipe.source.zone) {
continue;
}
_source_zones.insert(*pipe.source.zone);
- rgw_sync_bucket_pipe new_pipe = pipe;
- string zone_id;
-
- if (zone_svc->find_zone_id_by_name(*pipe.source.zone, &zone_id)) {
- new_pipe.source.zone = zone_id;
- }
- _sources[*new_pipe.source.zone].insert(new_pipe);
+ _sources[*pipe.source.zone].insert(pipe);
}
- for (auto& entry : _targets_by_name.pipe_map) {
+ for (auto& entry : _target_pipes.pipe_map) {
auto& pipe = entry.second;
if (!pipe.dest.zone) {
continue;
}
_target_zones.insert(*pipe.dest.zone);
- rgw_sync_bucket_pipe new_pipe = pipe;
- string zone_id;
- if (zone_svc->find_zone_id_by_name(*pipe.dest.zone, &zone_id)) {
- new_pipe.dest.zone = zone_id;
- }
- _targets[*new_pipe.dest.zone].insert(new_pipe);
+ _targets[*pipe.dest.zone].insert(pipe);
}
- if (psources_by_name) {
- *psources_by_name = std::move(_sources_by_name);
+ if (psource_pipes) {
+ *psource_pipes = std::move(_source_pipes);
}
- if (ptargets_by_name) {
- *ptargets_by_name = std::move(_targets_by_name);
+ if (ptarget_pipes) {
+ *ptarget_pipes = std::move(_target_pipes);
}
if (psources) {
*psources = std::move(_sources);
}
}
-void RGWBucketSyncPolicyHandler::get_pipes(std::set<rgw_sync_bucket_pipe> *sources, std::set<rgw_sync_bucket_pipe> *targets,
- std::optional<rgw_sync_bucket_entity> filter_peer) { /* return raw pipes (with zone name) */
- for (auto& entry : sources_by_name.pipe_map) {
+void RGWBucketSyncPolicyHandler::get_pipes(std::set<rgw_sync_bucket_pipe> *_sources, std::set<rgw_sync_bucket_pipe> *_targets,
+ std::optional<rgw_sync_bucket_entity> filter_peer) { /* return raw pipes */
+ for (auto& entry : source_pipes.pipe_map) {
auto& source_pipe = entry.second;
if (!filter_peer ||
source_pipe.source.match(*filter_peer)) {
- sources->insert(source_pipe);
+ _sources->insert(source_pipe);
}
}
- for (auto& entry : targets_by_name.pipe_map) {
+ for (auto& entry : target_pipes.pipe_map) {
auto& target_pipe = entry.second;
if (!filter_peer ||
target_pipe.dest.match(*filter_peer)) {
- targets->insert(target_pipe);
+ _targets->insert(target_pipe);
}
}
}
struct rgw_sync_policy_info;
struct rgw_sync_group_pipe_map {
- string zone;
+ rgw_zone_id zone;
std::optional<rgw_bucket> bucket;
rgw_sync_policy_group::Status status{rgw_sync_policy_group::Status::FORBIDDEN};
zb_pipe_map_t sources; /* all the pipes where zone is pulling from */
zb_pipe_map_t dests; /* all the pipes that pull from zone */
- std::set<string> *pall_zones{nullptr};
+ std::set<rgw_zone_id> *pall_zones{nullptr};
rgw_sync_data_flow_group *default_flow{nullptr}; /* flow to use if policy doesn't define it,
used in the case of bucket sync policy, not at the
zonegroup level */
void dump(ceph::Formatter *f) const;
template <typename CB1, typename CB2>
- void try_add_to_pipe_map(const string& source_zone,
- const string& dest_zone,
+ void try_add_to_pipe_map(const rgw_zone_id& source_zone,
+ const rgw_zone_id& dest_zone,
const std::vector<rgw_sync_bucket_pipes>& pipes,
zb_pipe_map_t *pipe_map,
CB1 filter_cb,
CB2 call_filter_cb);
template <typename CB>
- void try_add_source(const string& source_zone,
- const string& dest_zone,
+ void try_add_source(const rgw_zone_id& source_zone,
+ const rgw_zone_id& dest_zone,
const std::vector<rgw_sync_bucket_pipes>& pipes,
CB filter_cb);
template <typename CB>
- void try_add_dest(const string& source_zone,
- const string& dest_zone,
+ void try_add_dest(const rgw_zone_id& source_zone,
+ const rgw_zone_id& dest_zone,
const std::vector<rgw_sync_bucket_pipes>& pipes,
CB filter_cb);
pair<zb_pipe_map_t::const_iterator, zb_pipe_map_t::const_iterator> find_pipes(const zb_pipe_map_t& m,
- const string& zone,
+ const rgw_zone_id& zone,
std::optional<rgw_bucket> b) const;
template <typename CB>
- void init(const string& _zone,
+ void init(const rgw_zone_id& _zone,
std::optional<rgw_bucket> _bucket,
const rgw_sync_policy_group& group,
rgw_sync_data_flow_group *_default_flow,
- std::set<std::string> *_pall_zones,
+ std::set<rgw_zone_id> *_pall_zones,
CB filter_cb);
/*
* find all relevant pipes in our zone that match {dest_bucket} <- {source_zone, source_bucket}
*/
- vector<rgw_sync_bucket_pipe> find_source_pipes(const string& source_zone,
+ vector<rgw_sync_bucket_pipe> find_source_pipes(const rgw_zone_id& source_zone,
std::optional<rgw_bucket> source_bucket,
std::optional<rgw_bucket> dest_bucket) const;
* source bucket in out zone {source_bucket} -> {dest_zone, dest_bucket}
*/
vector<rgw_sync_bucket_pipe> find_dest_pipes(std::optional<rgw_bucket> source_bucket,
- const string& dest_zone,
+ const rgw_zone_id& dest_zone,
std::optional<rgw_bucket> dest_bucket) const;
/*
* find all relevant pipes from {source_zone, source_bucket} -> {dest_zone, dest_bucket}
*/
- vector<rgw_sync_bucket_pipe> find_pipes(const string& source_zone,
+ vector<rgw_sync_bucket_pipe> find_pipes(const rgw_zone_id& source_zone,
std::optional<rgw_bucket> source_bucket,
- const string& dest_zone,
+ const rgw_zone_id& dest_zone,
std::optional<rgw_bucket> dest_bucket) const;
};
private:
- string zone_name;
+ rgw_zone_id zone_id;
std::optional<rgw_bucket> bucket;
const RGWBucketSyncFlowManager *parent{nullptr};
map<string, rgw_sync_group_pipe_map> flow_groups;
- std::set<std::string> all_zones;
+ std::set<rgw_zone_id> all_zones;
- bool allowed_data_flow(const string& source_zone,
+ bool allowed_data_flow(const rgw_zone_id& source_zone,
std::optional<rgw_bucket> source_bucket,
- const string& dest_zone,
+ const rgw_zone_id& dest_zone,
std::optional<rgw_bucket> dest_bucket,
bool check_activated) const;
public:
- RGWBucketSyncFlowManager(const string& _zone_name,
+ RGWBucketSyncFlowManager(const rgw_zone_id& _zone_id,
std::optional<rgw_bucket> _bucket,
const RGWBucketSyncFlowManager *_parent);
const RGWBucketSyncPolicyHandler *parent{nullptr};
RGWSI_Zone *zone_svc;
RGWSI_Bucket_Sync *bucket_sync_svc;
- string zone_name;
+ rgw_zone_id zone_id;
std::optional<RGWBucketInfo> bucket_info;
std::optional<rgw_bucket> bucket;
std::unique_ptr<RGWBucketSyncFlowManager> flow_mgr;
rgw_sync_policy_info sync_policy;
- RGWBucketSyncFlowManager::pipe_set sources_by_name;
- RGWBucketSyncFlowManager::pipe_set targets_by_name;
+ RGWBucketSyncFlowManager::pipe_set source_pipes;
+ RGWBucketSyncFlowManager::pipe_set target_pipes;
- map<string, RGWBucketSyncFlowManager::pipe_set> sources; /* source pipes by source zone id */
- map<string, RGWBucketSyncFlowManager::pipe_set> targets; /* target pipes by target zone id */
+ map<rgw_zone_id, RGWBucketSyncFlowManager::pipe_set> sources; /* source pipes by source zone id */
+ map<rgw_zone_id, RGWBucketSyncFlowManager::pipe_set> targets; /* target pipes by target zone id */
- std::set<string> source_zones; /* source zones by name */
- std::set<string> target_zones; /* target zones by name */
+ std::set<rgw_zone_id> source_zones;
+ std::set<rgw_zone_id> target_zones;
std::set<rgw_bucket> source_hints;
std::set<rgw_bucket> target_hints;
RGWBucketSyncPolicyHandler(RGWSI_Zone *_zone_svc,
RGWSI_SyncModules *sync_modules_svc,
RGWSI_Bucket_Sync *bucket_sync_svc,
- std::optional<string> effective_zone = std::nullopt);
+ std::optional<rgw_zone_id> effective_zone = std::nullopt);
RGWBucketSyncPolicyHandler *alloc_child(const RGWBucketInfo& bucket_info) const;
RGWBucketSyncPolicyHandler *alloc_child(const rgw_bucket& bucket,
int init(optional_yield y);
- void reflect(RGWBucketSyncFlowManager::pipe_set *psources_by_name,
- RGWBucketSyncFlowManager::pipe_set *ptargets_by_name,
- map<string, RGWBucketSyncFlowManager::pipe_set> *psources,
- map<string, RGWBucketSyncFlowManager::pipe_set> *ptargets,
- std::set<string> *psource_zones,
- std::set<string> *ptarget_zones,
+ void reflect(RGWBucketSyncFlowManager::pipe_set *psource_pipes,
+ RGWBucketSyncFlowManager::pipe_set *ptarget_pipes,
+ map<rgw_zone_id, RGWBucketSyncFlowManager::pipe_set> *psources,
+ map<rgw_zone_id, RGWBucketSyncFlowManager::pipe_set> *ptargets,
+ std::set<rgw_zone_id> *psource_zones,
+ std::set<rgw_zone_id> *ptarget_zones,
bool only_enabled) const;
void set_resolved_hints(std::set<rgw_sync_bucket_pipe>&& _resolved_sources,
return resolved_dests;
}
- const std::set<string>& get_source_zones() const {
+ const std::set<rgw_zone_id>& get_source_zones() const {
return source_zones;
}
- const std::set<string>& get_target_zones() const {
+ const std::set<rgw_zone_id>& get_target_zones() const {
return target_zones;
}
- const map<string, RGWBucketSyncFlowManager::pipe_set>& get_sources() {
+ const map<rgw_zone_id, RGWBucketSyncFlowManager::pipe_set>& get_sources() {
return sources;
}
- const map<string, RGWBucketSyncFlowManager::pipe_set>& get_targets() {
+ const map<rgw_zone_id, RGWBucketSyncFlowManager::pipe_set>& get_targets() {
return targets;
}
return bucket_info;
}
- void get_pipes(RGWBucketSyncFlowManager::pipe_set **sources, RGWBucketSyncFlowManager::pipe_set **targets) { /* return raw pipes (with zone name) */
- *sources = &sources_by_name;
- *targets = &targets_by_name;
+ void get_pipes(RGWBucketSyncFlowManager::pipe_set **_sources, RGWBucketSyncFlowManager::pipe_set **_targets) { /* return raw pipes (with zone name) */
+ *_sources = &source_pipes;
+ *_targets = &target_pipes;
}
void get_pipes(std::set<rgw_sync_bucket_pipe> *sources, std::set<rgw_sync_bucket_pipe> *targets,
std::optional<rgw_sync_bucket_entity> filter_peer);
return sync_policy->empty();
}
+void encode_json(const char *name, const rgw_zone_id& zid, Formatter *f)
+{
+ encode_json(name, zid.id, f);
+}
+
+void decode_json_obj(rgw_zone_id& zid, JSONObj *obj)
+{
+ decode_json_obj(zid.id, obj);
+}
+
return 0;
}
+/*
+ * should avoid encoding rgw_opt_zone_nid, and rgw_zone_nid,
+ * these should be used for run time representation of zone,
+ * but internally we should keep zone ids
+ */
+struct rgw_opt_zone_nid {
+ std::optional<string> id;
+ std::optional<string> name;
+};
+
+struct rgw_zone_nid {
+ string id;
+ string name;
+};
+
+struct rgw_zone_id {
+ string id;
+
+ rgw_zone_id() {}
+ rgw_zone_id(const string& _id) : id(_id) {}
+ rgw_zone_id(string&& _id) : id(std::move(_id)) {}
+
+ void encode(bufferlist& bl) const {
+ /* backward compatiblity, not using ENCODE_{START,END} macros */
+ ceph::encode(id, bl);
+ }
+
+ void decode(bufferlist::const_iterator& bl) {
+ /* backward compatiblity, not using DECODE_{START,END} macros */
+ ceph::decode(id, bl);
+ }
+
+ void clear() {
+ id.clear();
+ }
+
+ bool operator==(const string& _id) const {
+ return (id == _id);
+ }
+ bool operator==(const rgw_zone_id& zid) const {
+ return (id == zid.id);
+ }
+ bool operator!=(const rgw_zone_id& zid) const {
+ return (id != zid.id);
+ }
+ bool operator<(const rgw_zone_id& zid) const {
+ return (id < zid.id);
+ }
+ bool operator>(const rgw_zone_id& zid) const {
+ return (id > zid.id);
+ }
+
+ bool empty() const {
+ return id.empty();
+ }
+};
+WRITE_CLASS_ENCODER(rgw_zone_id)
+
+static inline ostream& operator<<(ostream& os, const rgw_zone_id& zid) {
+ os << zid.id;
+ return os;
+}
+
+void encode_json(const char *name, const rgw_zone_id& zid, Formatter *f);
+void decode_json_obj(rgw_zone_id& zid, JSONObj *obj);
+
#endif
class RGWAsyncFetchRemoteObj : public RGWAsyncRadosRequest {
rgw::sal::RGWRadosStore *store;
- string source_zone;
+ rgw_zone_id source_zone;
rgw_bucket src_bucket;
std::optional<rgw_placement_rule> dest_placement_rule;
int _send_request() override;
public:
RGWAsyncFetchRemoteObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, rgw::sal::RGWRadosStore *_store,
- const string& _source_zone,
+ const rgw_zone_id& _source_zone,
const rgw_bucket& _src_bucket,
std::optional<rgw_placement_rule> _dest_placement_rule,
const RGWBucketInfo& _dest_bucket_info,
CephContext *cct;
RGWAsyncRadosProcessor *async_rados;
rgw::sal::RGWRadosStore *store;
- string source_zone;
+ rgw_zone_id source_zone;
rgw_bucket src_bucket;
std::optional<rgw_placement_rule> dest_placement_rule;
public:
RGWFetchRemoteObjCR(RGWAsyncRadosProcessor *_async_rados, rgw::sal::RGWRadosStore *_store,
- const string& _source_zone,
+ const rgw_zone_id& _source_zone,
const rgw_bucket& _src_bucket,
std::optional<rgw_placement_rule> _dest_placement_rule,
const RGWBucketInfo& _dest_bucket_info,
class RGWAsyncStatRemoteObj : public RGWAsyncRadosRequest {
rgw::sal::RGWRadosStore *store;
- string source_zone;
+ rgw_zone_id source_zone;
rgw_bucket src_bucket;
rgw_obj_key key;
int _send_request() override;
public:
RGWAsyncStatRemoteObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, rgw::sal::RGWRadosStore *_store,
- const string& _source_zone,
+ const rgw_zone_id& _source_zone,
rgw_bucket& _src_bucket,
const rgw_obj_key& _key,
ceph::real_time *_pmtime,
CephContext *cct;
RGWAsyncRadosProcessor *async_rados;
rgw::sal::RGWRadosStore *store;
- string source_zone;
+ rgw_zone_id source_zone;
rgw_bucket src_bucket;
rgw_obj_key key;
public:
RGWStatRemoteObjCR(RGWAsyncRadosProcessor *_async_rados, rgw::sal::RGWRadosStore *_store,
- const string& _source_zone,
+ const rgw_zone_id& _source_zone,
rgw_bucket& _src_bucket,
const rgw_obj_key& _key,
ceph::real_time *_pmtime,
class RGWAsyncRemoveObj : public RGWAsyncRadosRequest {
rgw::sal::RGWRadosStore *store;
- string source_zone;
+ rgw_zone_id source_zone;
RGWBucketInfo bucket_info;
int _send_request() override;
public:
RGWAsyncRemoveObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, rgw::sal::RGWRadosStore *_store,
- const string& _source_zone,
+ const rgw_zone_id& _source_zone,
RGWBucketInfo& _bucket_info,
const rgw_obj_key& _key,
const string& _owner,
CephContext *cct;
RGWAsyncRadosProcessor *async_rados;
rgw::sal::RGWRadosStore *store;
- string source_zone;
+ rgw_zone_id source_zone;
RGWBucketInfo bucket_info;
public:
RGWRemoveObjCR(RGWAsyncRadosProcessor *_async_rados, rgw::sal::RGWRadosStore *_store,
- const string& _source_zone,
+ const rgw_zone_id& _source_zone,
RGWBucketInfo& _bucket_info,
const rgw_obj_key& _key,
bool _versioned,
using RGWBucketLifecycleConfigCR = RGWSimpleWriteOnlyAsyncCR<rgw_bucket_lifecycle_config_params>;
struct rgw_bucket_get_sync_policy_params {
- std::optional<string> zone;
+ std::optional<rgw_zone_id> zone;
std::optional<rgw_bucket> bucket;
};
/* fetch current position in logs */
yield {
- RGWRESTConn *conn = sync_env->svc->zone->get_zone_conn_by_id(sc->source_zone);
+ RGWRESTConn *conn = sync_env->svc->zone->get_zone_conn(sc->source_zone);
if (!conn) {
tn->log(0, SSTR("ERROR: connection to zone " << sc->source_zone << " does not exist!"));
return set_cr_error(-EIO);
return run(new RGWListRemoteDataLogCR(&sc, shard_markers, 1, result));
}
-int RGWRemoteDataLog::init(const string& _source_zone, RGWRESTConn *_conn, RGWSyncErrorLogger *_error_logger,
+int RGWRemoteDataLog::init(const rgw_zone_id& _source_zone, RGWRESTConn *_conn, RGWSyncErrorLogger *_error_logger,
RGWSyncTraceManager *_sync_tracer, RGWSyncModuleInstanceRef& _sync_module,
PerfCounters* counters)
{
return ret;
}
-static string full_data_sync_index_shard_oid(const string& source_zone, int shard_id)
+static string full_data_sync_index_shard_oid(const rgw_zone_id& source_zone, int shard_id)
{
- char buf[datalog_sync_full_sync_index_prefix.size() + 1 + source_zone.size() + 1 + 16];
- snprintf(buf, sizeof(buf), "%s.%s.%d", datalog_sync_full_sync_index_prefix.c_str(), source_zone.c_str(), shard_id);
+ char buf[datalog_sync_full_sync_index_prefix.size() + 1 + source_zone.id.size() + 1 + 16];
+ snprintf(buf, sizeof(buf), "%s.%s.%d", datalog_sync_full_sync_index_prefix.c_str(), source_zone.id.c_str(), shard_id);
return string(buf);
}
rgw_data_sync_status *_sync_status) : RGWCoroutine(_sc->cct), sc(_sc), sync_env(_sc->env),
store(sync_env->store), sync_status(_sync_status),
req_ret(0), ret(0), entries_index(NULL), i(0), failed(false), truncated(false) {
- oid_prefix = datalog_sync_full_sync_index_prefix + "." + sc->source_zone;
+ oid_prefix = datalog_sync_full_sync_index_prefix + "." + sc->source_zone.id;
path = "/admin/metadata/bucket.instance";
num_shards = sync_status->sync_info.num_shards;
}
bool _has_bucket_info{false};
public:
- string zone;
+ rgw_zone_id zone;
rgw_sync_pipe_info_entity() {}
rgw_sync_pipe_info_entity(const rgw_sync_bucket_entity& e,
RGWDataSyncCtx *cur_sc{nullptr};
RGWRESTConn *conn{nullptr};
- string last_zone;
+ rgw_zone_id last_zone;
int ret{0};
{
RGWZone *zone_def;
- if (!store->svc()->zone->find_zone_by_id(source_zone, &zone_def)) {
+ if (!store->svc()->zone->find_zone(source_zone, &zone_def)) {
ldpp_dout(this, 0) << "ERROR: failed to find zone config info for zone=" << source_zone << dendl;
return -EIO;
}
sync_module = store->getRados()->get_sync_module();
}
- conn = store->svc()->zone->get_zone_conn_by_id(source_zone);
+ conn = store->svc()->zone->get_zone_conn(source_zone);
if (!conn) {
ldpp_dout(this, 0) << "connection object to zone " << source_zone << " does not exist" << dendl;
return -EINVAL;
std::ostream& RGWDataSyncStatusManager::gen_prefix(std::ostream& out) const
{
- auto zone = std::string_view{source_zone};
+ auto zone = std::string_view{source_zone.id};
return out << "data sync zone:" << zone.substr(0, 8) << ' ';
}
-string RGWDataSyncStatusManager::sync_status_oid(const string& source_zone)
+string RGWDataSyncStatusManager::sync_status_oid(const rgw_zone_id& source_zone)
{
- char buf[datalog_sync_status_oid_prefix.size() + source_zone.size() + 16];
- snprintf(buf, sizeof(buf), "%s.%s", datalog_sync_status_oid_prefix.c_str(), source_zone.c_str());
+ char buf[datalog_sync_status_oid_prefix.size() + source_zone.id.size() + 16];
+ snprintf(buf, sizeof(buf), "%s.%s", datalog_sync_status_oid_prefix.c_str(), source_zone.id.c_str());
return string(buf);
}
-string RGWDataSyncStatusManager::shard_obj_name(const string& source_zone, int shard_id)
+string RGWDataSyncStatusManager::shard_obj_name(const rgw_zone_id& source_zone, int shard_id)
{
- char buf[datalog_sync_status_shard_prefix.size() + source_zone.size() + 16];
- snprintf(buf, sizeof(buf), "%s.%s.%d", datalog_sync_status_shard_prefix.c_str(), source_zone.c_str(), shard_id);
+ char buf[datalog_sync_status_shard_prefix.size() + source_zone.id.size() + 16];
+ snprintf(buf, sizeof(buf), "%s.%s.%d", datalog_sync_status_shard_prefix.c_str(), source_zone.id.c_str(), shard_id);
return string(buf);
}
RGWRemoteBucketManager::RGWRemoteBucketManager(const DoutPrefixProvider *_dpp,
RGWDataSyncEnv *_sync_env,
- const string& _source_zone,
+ const rgw_zone_id& _source_zone,
RGWRESTConn *_conn,
const RGWBucketInfo& source_bucket_info,
const rgw_bucket& dest_bucket) : dpp(_dpp), sync_env(_sync_env)
}
RGWBucketPipeSyncStatusManager::RGWBucketPipeSyncStatusManager(rgw::sal::RGWRadosStore *_store,
- std::optional<string> _source_zone,
+ std::optional<rgw_zone_id> _source_zone,
std::optional<rgw_bucket> _source_bucket,
const rgw_bucket& _dest_bucket) : store(_store),
cr_mgr(_store->ctx(), _store->getRados()->get_cr_registry()),
status_oid(status_oid),
tn(sync_env->sync_tracer->add_node(tn_parent, "full_sync",
SSTR(bucket_shard_str{bs}))) {
- zones_trace.insert(sc->source_zone, sync_pipe.info.dest_bs.bucket.get_key());
+ zones_trace.insert(sc->source_zone.id, sync_pipe.info.dest_bs.bucket.get_key());
marker_tracker.set_tn(tn);
prefix_handler.set_rules(sync_pipe.get_rules());
}
RGWBucketIncSyncShardMarkerTrack marker_tracker;
bool updated_status{false};
const string& status_oid;
- const string& zone_id;
+ rgw_zone_id zone_id;
string target_location_key;
string cur_id;
if (e.state != CLS_RGW_STATE_COMPLETE) {
continue;
}
- if (e.zones_trace.exists(zone_id, target_location_key)) {
+ if (e.zones_trace.exists(zone_id.id, target_location_key)) {
continue;
}
auto& squash_entry = squash_map[make_pair(e.object, e.instance)];
marker_tracker.try_update_high_marker(cur_id, 0, entry->timestamp);
continue;
}
- if (entry->zones_trace.exists(zone_id, target_location_key)) {
+ if (entry->zones_trace.exists(zone_id.id, target_location_key)) {
set_status() << "redundant operation, skipping";
tn->log(20, SSTR("skipping object: "
<<bucket_shard_str{bs} <<"/"<<key<<": redundant operation"));
return 0;
}
-struct rgw_bucket_sync_source_local_info {
- string id;
- string type;
- string zone;
- rgw_bucket bucket;
- /* FIXME: config */
-
- void encode(bufferlist& bl) const {
- ENCODE_START(1, 1, bl);
- encode(id, bl);
- encode(type, bl);
- encode(zone, bl);
- encode(bucket, bl);
- ENCODE_FINISH(bl);
- }
-
- void decode(bufferlist::const_iterator& bl) {
- DECODE_START(1, bl);
- decode(id, bl);
- decode(type, bl);
- decode(zone, bl);
- decode(bucket, bl);
- DECODE_FINISH(bl);
- }
- void dump(ceph::Formatter *f) const {
- encode_json("id", id, f);
- encode_json("type", type, f);
- encode_json("zone", zone, f);
- encode_json("bucket", bucket, f);
- }
-};
-WRITE_CLASS_ENCODER(rgw_bucket_sync_source_local_info)
-
-struct rgw_bucket_sync_sources_local_info {
- map<string, rgw_bucket_sync_source_local_info> sources; /* id -> source */
-
- void encode(bufferlist& bl) const {
- ENCODE_START(1, 1, bl);
- encode(sources, bl);
- ENCODE_FINISH(bl);
- }
-
- void decode(bufferlist::const_iterator& bl) {
- DECODE_START(1, bl);
- decode(sources, bl);
- DECODE_FINISH(bl);
- }
-
- void dump(ceph::Formatter *f) const {
- encode_json("sources", sources, f);
- }
-};
-WRITE_CLASS_ENCODER(rgw_bucket_sync_sources_local_info)
-
-
class RGWGetBucketPeersCR : public RGWCoroutine {
RGWDataSyncEnv *sync_env;
std::optional<rgw_bucket> target_bucket;
- std::optional<string> source_zone;
+ std::optional<rgw_zone_id> source_zone;
std::optional<rgw_bucket> source_bucket;
rgw_sync_pipe_info_set *pipes;
RGWSyncTraceNodeRef tn;
- using pipe_const_iter = map<string, RGWBucketSyncFlowManager::pipe_set>::const_iterator;
+ using pipe_const_iter = map<rgw_zone_id, RGWBucketSyncFlowManager::pipe_set>::const_iterator;
- static pair<pipe_const_iter, pipe_const_iter> get_pipe_iters(const map<string, RGWBucketSyncFlowManager::pipe_set>& m, std::optional<string> zone) {
+ static pair<pipe_const_iter, pipe_const_iter> get_pipe_iters(const map<rgw_zone_id, RGWBucketSyncFlowManager::pipe_set>& m, std::optional<rgw_zone_id> zone) {
if (!zone) {
return { m.begin(), m.end() };
}
return { b, std::next(b) };
}
- void filter_sources(std::optional<string> source_zone,
+ void filter_sources(std::optional<rgw_zone_id> source_zone,
std::optional<rgw_bucket> source_bucket,
- const map<string, RGWBucketSyncFlowManager::pipe_set>& all_sources,
+ const map<rgw_zone_id, RGWBucketSyncFlowManager::pipe_set>& all_sources,
rgw_sync_pipe_info_set *result) {
- ldpp_dout(sync_env->dpp, 20) << __func__ << ": source_zone=" << source_zone.value_or("*")
+ ldpp_dout(sync_env->dpp, 20) << __func__ << ": source_zone=" << source_zone.value_or(rgw_zone_id("*")).id
<< " source_bucket=" << source_bucket.value_or(rgw_bucket())
<< " all_sources.size()=" << all_sources.size() << dendl;
auto iters = get_pipe_iters(all_sources, source_zone);
}
}
- void filter_targets(std::optional<string> target_zone,
+ void filter_targets(std::optional<rgw_zone_id> target_zone,
std::optional<rgw_bucket> target_bucket,
- const map<string, RGWBucketSyncFlowManager::pipe_set>& all_targets,
+ const map<rgw_zone_id, RGWBucketSyncFlowManager::pipe_set>& all_targets,
rgw_sync_pipe_info_set *result) {
- ldpp_dout(sync_env->dpp, 20) << __func__ << ": target_zone=" << source_zone.value_or("*")
+ ldpp_dout(sync_env->dpp, 20) << __func__ << ": target_zone=" << source_zone.value_or(rgw_zone_id("*")).id
<< " target_bucket=" << source_bucket.value_or(rgw_bucket())
<< " all_targets.size()=" << all_targets.size() << dendl;
auto iters = get_pipe_iters(all_targets, target_zone);
public:
RGWGetBucketPeersCR(RGWDataSyncEnv *_sync_env,
std::optional<rgw_bucket> _target_bucket,
- std::optional<string> _source_zone,
+ std::optional<rgw_zone_id> _source_zone,
std::optional<rgw_bucket> _source_bucket,
rgw_sync_pipe_info_set *_pipes,
const RGWSyncTraceNodeRef& _tn_parent)
tn(sync_env->sync_tracer->add_node(_tn_parent, "get_bucket_peers",
SSTR( "target=" << target_bucket.value_or(rgw_bucket())
<< ":source=" << target_bucket.value_or(rgw_bucket())
- << ":source_zone=" << source_zone.value_or("*")))) {
+ << ":source_zone=" << source_zone.value_or(rgw_zone_id("*")).id))) {
}
int operate() override;
return ret;
}
- string last_zone;
+ rgw_zone_id last_zone;
for (auto& pipe : pipes) {
auto& szone = pipe.source.zone;
if (last_zone != szone) {
- conn = store->svc()->zone->get_zone_conn_by_id(szone);
+ conn = store->svc()->zone->get_zone_conn(szone);
if (!conn) {
ldpp_dout(this, 0) << "connection object to zone " << szone << " does not exist" << dendl;
return -EINVAL;
std::ostream& RGWBucketPipeSyncStatusManager::gen_prefix(std::ostream& out) const
{
- auto zone = std::string_view{source_zone.value_or("*")};
+ auto zone = std::string_view{source_zone.value_or(rgw_zone_id("*")).id};
return out << "bucket sync zone:" << zone.substr(0, 8)
<< " bucket:" << dest_bucket << ' ';
}
-string RGWBucketPipeSyncStatusManager::status_oid(const string& source_zone,
+string RGWBucketPipeSyncStatusManager::status_oid(const rgw_zone_id& source_zone,
const rgw_bucket_sync_pair_info& sync_pair)
{
if (sync_pair.source_bs == sync_pair.dest_bs) {
- return bucket_status_oid_prefix + "." + source_zone + ":" + sync_pair.dest_bs.get_key();
+ return bucket_status_oid_prefix + "." + source_zone.id + ":" + sync_pair.dest_bs.get_key();
} else {
- return bucket_status_oid_prefix + "." + source_zone + ":" + sync_pair.dest_bs.get_key() + ":" + sync_pair.source_bs.get_key();
+ return bucket_status_oid_prefix + "." + source_zone.id + ":" + sync_pair.dest_bs.get_key() + ":" + sync_pair.source_bs.get_key();
}
}
-string RGWBucketPipeSyncStatusManager::obj_status_oid(const string& source_zone,
+string RGWBucketPipeSyncStatusManager::obj_status_oid(const rgw_zone_id& source_zone,
const rgw_obj& obj)
{
#warning FIXME
- return object_status_oid_prefix + "." + source_zone + ":" + obj.bucket.get_key() + ":" +
+ return object_status_oid_prefix + "." + source_zone.id + ":" + obj.bucket.get_key() + ":" +
obj.key.name + ":" + obj.key.instance;
}
RGWDataSyncEnv *env{nullptr};
RGWRESTConn *conn{nullptr};
- string source_zone;
+ rgw_zone_id source_zone;
void init(RGWDataSyncEnv *_env,
RGWRESTConn *_conn,
- const string& _source_zone) {
+ const rgw_zone_id& _source_zone) {
cct = _env->cct;
env = _env;
conn = _conn;
RGWRemoteDataLog(const DoutPrefixProvider *dpp,
rgw::sal::RGWRadosStore *_store,
RGWAsyncRadosProcessor *async_rados);
- int init(const string& _source_zone, RGWRESTConn *_conn, RGWSyncErrorLogger *_error_logger,
+ int init(const rgw_zone_id& _source_zone, RGWRESTConn *_conn, RGWSyncErrorLogger *_error_logger,
RGWSyncTraceManager *_sync_tracer, RGWSyncModuleInstanceRef& module,
PerfCounters* _counters);
void finish();
class RGWDataSyncStatusManager : public DoutPrefixProvider {
rgw::sal::RGWRadosStore *store;
- string source_zone;
+ rgw_zone_id source_zone;
RGWRESTConn *conn;
RGWSyncErrorLogger *error_logger;
RGWSyncModuleInstanceRef sync_module;
public:
RGWDataSyncStatusManager(rgw::sal::RGWRadosStore *_store, RGWAsyncRadosProcessor *async_rados,
- const string& _source_zone, PerfCounters* counters)
+ const rgw_zone_id& _source_zone, PerfCounters* counters)
: store(_store), source_zone(_source_zone), conn(NULL), error_logger(NULL),
sync_module(nullptr), counters(counters),
source_log(this, store, async_rados), num_shards(0) {}
RGWDataSyncStatusManager(rgw::sal::RGWRadosStore *_store, RGWAsyncRadosProcessor *async_rados,
- const string& _source_zone, PerfCounters* counters,
+ const rgw_zone_id& _source_zone, PerfCounters* counters,
const RGWSyncModuleInstanceRef& _sync_module)
: store(_store), source_zone(_source_zone), conn(NULL), error_logger(NULL),
sync_module(_sync_module), counters(counters),
int init();
void finalize();
- static string shard_obj_name(const string& source_zone, int shard_id);
- static string sync_status_oid(const string& source_zone);
+ static string shard_obj_name(const rgw_zone_id& source_zone, int shard_id);
+ static string sync_status_oid(const rgw_zone_id& source_zone);
int read_sync_status(rgw_data_sync_status *sync_status) {
return source_log.read_sync_status(sync_status);
RGWDataSyncEnv *sync_env;
RGWRESTConn *conn{nullptr};
- string source_zone;
+ rgw_zone_id source_zone;
vector<rgw_bucket_sync_pair_info> sync_pairs;
public:
RGWRemoteBucketManager(const DoutPrefixProvider *_dpp,
RGWDataSyncEnv *_sync_env,
- const string& _source_zone, RGWRESTConn *_conn,
+ const rgw_zone_id& _source_zone, RGWRESTConn *_conn,
const RGWBucketInfo& source_bucket_info,
const rgw_bucket& dest_bucket);
- void init(const string& _source_zone, RGWRESTConn *_conn,
+ void init(const rgw_zone_id& _source_zone, RGWRESTConn *_conn,
const rgw_bucket& source_bucket, int shard_id,
const rgw_bucket& dest_bucket);
RGWHTTPManager http_manager;
- std::optional<string> source_zone;
+ std::optional<rgw_zone_id> source_zone;
std::optional<rgw_bucket> source_bucket;
RGWRESTConn *conn;
public:
RGWBucketPipeSyncStatusManager(rgw::sal::RGWRadosStore *_store,
- std::optional<string> _source_zone,
+ std::optional<rgw_zone_id> _source_zone,
std::optional<rgw_bucket> _source_bucket,
const rgw_bucket& dest_bucket);
~RGWBucketPipeSyncStatusManager();
map<int, rgw_bucket_shard_sync_info>& get_sync_status() { return sync_status; }
int init_sync_status();
- static string status_oid(const string& source_zone, const rgw_bucket_sync_pair_info& bs);
- static string obj_status_oid(const string& source_zone, const rgw_obj& obj); /* specific source obj sync status,
- can be used by sync modules */
+ static string status_oid(const rgw_zone_id& source_zone, const rgw_bucket_sync_pair_info& bs);
+ static string obj_status_oid(const rgw_zone_id& source_zone, const rgw_obj& obj); /* specific source obj sync status,
+ can be used by sync modules */
// implements DoutPrefixProvider
CephContext *get_cct() const override;
encode_json("sync_policy", sync_policy, f);
}
-static void decode_zones(map<string, RGWZone>& zones, JSONObj *o)
+static void decode_zones(map<rgw_zone_id, RGWZone>& zones, JSONObj *o)
{
RGWZone z;
z.decode_json(o);
{
::encode_json("user", *this, f);
}
+
http_manager.start();
}
- int notify_all(map<string, RGWRESTConn *>& conn_map, set<int>& shards) {
+ int notify_all(map<rgw_zone_id, RGWRESTConn *>& conn_map, set<int>& shards) {
rgw_http_param_pair pairs[] = { { "type", "metadata" },
{ "notify", NULL },
{ NULL, NULL } };
list<RGWCoroutinesStack *> stacks;
- for (map<string, RGWRESTConn *>::iterator iter = conn_map.begin(); iter != conn_map.end(); ++iter) {
+ for (auto iter = conn_map.begin(); iter != conn_map.end(); ++iter) {
RGWRESTConn *conn = iter->second;
RGWCoroutinesStack *stack = new RGWCoroutinesStack(store->ctx(), this);
stack->call(new RGWPostRESTResourceCR<set<int>, int>(store->ctx(), conn, &http_manager, "/admin/log", pairs, shards, NULL));
http_manager.start();
}
- int notify_all(map<string, RGWRESTConn *>& conn_map, map<int, set<string> >& shards) {
+ int notify_all(map<rgw_zone_id, RGWRESTConn *>& conn_map, map<int, set<string> >& shards) {
rgw_http_param_pair pairs[] = { { "type", "data" },
{ "notify", NULL },
{ "source-zone", store->svc.zone->get_zone_params().get_id().c_str() },
{ NULL, NULL } };
list<RGWCoroutinesStack *> stacks;
- for (map<string, RGWRESTConn *>::iterator iter = conn_map.begin(); iter != conn_map.end(); ++iter) {
+ for (auto iter = conn_map.begin(); iter != conn_map.end(); ++iter) {
RGWRESTConn *conn = iter->second;
RGWCoroutinesStack *stack = new RGWCoroutinesStack(store->ctx(), this);
stack->call(new RGWPostRESTResourceCR<map<int, set<string> >, int>(store->ctx(), conn, &http_manager, "/admin/log", pairs, shards, NULL));
}
}
-void RGWRados::wakeup_data_sync_shards(const string& source_zone, map<int, set<string> >& shard_ids)
+void RGWRados::wakeup_data_sync_shards(const rgw_zone_id& source_zone, map<int, set<string> >& shard_ids)
{
ldout(ctx(), 20) << __func__ << ": source_zone=" << source_zone << ", shard_ids=" << shard_ids << dendl;
std::lock_guard l{data_sync_thread_lock};
- map<string, RGWDataSyncProcessorThread *>::iterator iter = data_sync_processor_threads.find(source_zone);
+ auto iter = data_sync_processor_threads.find(source_zone);
if (iter == data_sync_processor_threads.end()) {
ldout(ctx(), 10) << __func__ << ": couldn't find sync thread for zone " << source_zone << ", skipping async data sync processing" << dendl;
return;
return nullptr;
}
-RGWDataSyncStatusManager* RGWRados::get_data_sync_manager(const std::string& source_zone)
+RGWDataSyncStatusManager* RGWRados::get_data_sync_manager(const rgw_zone_id& source_zone)
{
std::lock_guard l{data_sync_thread_lock};
auto thread = data_sync_processor_threads.find(source_zone);
metadata["zonegroup_id"] = svc.zone->get_zonegroup().get_id();
metadata["zonegroup_name"] = svc.zone->get_zonegroup().get_name();
metadata["zone_name"] = svc.zone->zone_name();
- metadata["zone_id"] = svc.zone->zone_id();
+ metadata["zone_id"] = svc.zone->zone_id().id;
string name = cct->_conf->name.get_id();
if (name.compare(0, 4, "rgw.") == 0) {
name = name.substr(4);
return ret;
}
thread->start();
- data_sync_processor_threads[source_zone->id] = thread;
+ data_sync_processor_threads[rgw_zone_id(source_zone->id)] = thread;
}
auto interval = cct->_conf->rgw_sync_log_trim_interval;
if (interval > 0) {
obj_ctx.set_atomic(dest_obj);
- string no_zone;
+ rgw_zone_id no_zone;
r = copy_obj(obj_ctx,
user,
/* This code will be executed on latest version of the object. */
const auto handler = [&](const rgw_bucket_dir_entry& entry) -> int {
- std::string no_zone;
+ rgw_zone_id no_zone;
/* We don't support object versioning of Swift API on those buckets that
* are already versioned using the S3 mechanism. This affects also bucket
int RGWRados::stat_remote_obj(RGWObjectCtx& obj_ctx,
const rgw_user& user_id,
req_info *info,
- const string& source_zone,
+ const rgw_zone_id& source_zone,
rgw_obj& src_obj,
const RGWBucketInfo *src_bucket_info,
real_time *src_mtime,
}
} else {
auto& zone_conn_map = svc.zone->get_zone_conn_map();
- map<string, RGWRESTConn *>::iterator iter = zone_conn_map.find(source_zone);
+ auto iter = zone_conn_map.find(source_zone);
if (iter == zone_conn_map.end()) {
ldout(cct, 0) << "could not find zone connection to zone: " << source_zone << dendl;
return -ENOENT;
int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx,
const rgw_user& user_id,
req_info *info,
- const string& source_zone,
+ const rgw_zone_id& source_zone,
const rgw_obj& dest_obj,
const rgw_obj& src_obj,
const RGWBucketInfo& dest_bucket_info,
conn = iter->second;
}
} else {
- map<string, RGWRESTConn *>::iterator iter = zone_conn_map.find(source_zone);
+ auto iter = zone_conn_map.find(source_zone);
if (iter == zone_conn_map.end()) {
ldout(cct, 0) << "could not find zone connection to zone: " << source_zone << dendl;
return -ENOENT;
int RGWRados::copy_obj(RGWObjectCtx& obj_ctx,
const rgw_user& user_id,
req_info *info,
- const string& source_zone,
+ const rgw_zone_id& source_zone,
rgw_obj& dest_obj,
rgw_obj& src_obj,
RGWBucketInfo& dest_bucket_info,
RGWDataNotifier *data_notifier;
RGWMetaSyncProcessorThread *meta_sync_processor_thread;
RGWSyncTraceManager *sync_tracer = nullptr;
- map<string, RGWDataSyncProcessorThread *> data_sync_processor_threads;
+ map<rgw_zone_id, RGWDataSyncProcessorThread *> data_sync_processor_threads;
boost::optional<rgw::BucketTrimManager> bucket_trim;
RGWSyncLogTrimThread *sync_log_trimmer{nullptr};
int stat_remote_obj(RGWObjectCtx& obj_ctx,
const rgw_user& user_id,
req_info *info,
- const string& source_zone,
+ const rgw_zone_id& source_zone,
rgw_obj& src_obj,
const RGWBucketInfo *src_bucket_info,
real_time *src_mtime,
int fetch_remote_obj(RGWObjectCtx& obj_ctx,
const rgw_user& user_id,
req_info *info,
- const string& source_zone,
+ const rgw_zone_id& source_zone,
const rgw_obj& dest_obj,
const rgw_obj& src_obj,
const RGWBucketInfo& dest_bucket_info,
int copy_obj(RGWObjectCtx& obj_ctx,
const rgw_user& user_id,
req_info *info,
- const string& source_zone,
+ const rgw_zone_id& source_zone,
rgw_obj& dest_obj,
rgw_obj& src_obj,
RGWBucketInfo& dest_bucket_info,
int delete_bucket(RGWBucketInfo& bucket_info, RGWObjVersionTracker& objv_tracker, optional_yield y, bool check_empty = true);
void wakeup_meta_sync_shards(set<int>& shard_ids);
- void wakeup_data_sync_shards(const string& source_zone, map<int, set<string> >& shard_ids);
+ void wakeup_data_sync_shards(const rgw_zone_id& source_zone, map<int, set<string> >& shard_ids);
RGWMetaSyncStatusManager* get_meta_sync_manager();
- RGWDataSyncStatusManager* get_data_sync_manager(const std::string& source_zone);
+ RGWDataSyncStatusManager* get_data_sync_manager(const rgw_zone_id& source_zone);
int set_bucket_owner(rgw_bucket& bucket, ACLOwner& owner);
int set_buckets_enabled(std::vector<rgw_bucket>& buckets, bool enabled);
int get_target_shard_id(const RGWBucketInfo& bucket_info, const string& obj_key, int *shard_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);
+ int lock_exclusive(const rgw_pool& pool, const string& oid, ceph::timespan& duration, rgw_zone_id& zone_id, string& owner_id);
+ int unlock(const rgw_pool& pool, const string& oid, rgw_zone_id& 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);
<< " zone_short_id=" << src_zone_short_id << " pg_ver=" << src_pg_ver
<< dendl;
- source_conn = sync_env->svc->zone->get_zone_conn_by_id(sc->source_zone);
+ source_conn = sync_env->svc->zone->get_zone_conn(sc->source_zone);
if (!source_conn) {
ldout(sc->cct, 0) << "ERROR: cannot find http connection to zone " << sc->source_zone << dendl;
return set_cr_error(-EINVAL);
}
}
-void rgw_sync_bucket_entities::add_zones(const std::vector<string>& new_zones) {
+void rgw_sync_bucket_entities::add_zones(const std::vector<rgw_zone_id>& new_zones) {
for (auto& z : new_zones) {
if (z == "*") {
all_zones = true;
return result;
}
-void rgw_sync_bucket_entities::remove_zones(const std::vector<string>& rm_zones) {
+void rgw_sync_bucket_entities::remove_zones(const std::vector<rgw_zone_id>& rm_zones) {
all_zones = false;
if (!zones) {
return true;
}
-void rgw_sync_data_flow_group::remove_symmetrical(const string& flow_id, std::optional<std::vector<string> > zones)
+void rgw_sync_data_flow_group::remove_symmetrical(const string& flow_id, std::optional<std::vector<rgw_zone_id> > zones)
{
if (!symmetrical) {
return;
}
}
-bool rgw_sync_data_flow_group::find_directional(const string& source_zone, const string& dest_zone, bool create, rgw_sync_directional_rule **flow_group)
+bool rgw_sync_data_flow_group::find_directional(const rgw_zone_id& source_zone, const rgw_zone_id& dest_zone, bool create, rgw_sync_directional_rule **flow_group)
{
if (!directional) {
if (!create) {
return true;
}
-void rgw_sync_data_flow_group::remove_directional(const string& source_zone, const string& dest_zone)
+void rgw_sync_data_flow_group::remove_directional(const rgw_zone_id& source_zone, const rgw_zone_id& dest_zone)
{
if (!directional) {
return;
}
}
-void rgw_sync_data_flow_group::init_default(const std::set<string>& zones)
+void rgw_sync_data_flow_group::init_default(const std::set<rgw_zone_id>& zones)
{
symmetrical.emplace();
symmetrical->push_back(rgw_sync_symmetric_group("default", zones));
struct rgw_sync_symmetric_group {
string id;
- std::set<string> zones;
+ std::set<rgw_zone_id> zones;
rgw_sync_symmetric_group() {}
rgw_sync_symmetric_group(const string& _id,
- const std::set<string> _zones) : id(_id), zones(_zones) {}
+ const std::set<rgw_zone_id> _zones) : id(_id), zones(_zones) {}
void encode(bufferlist& bl) const {
WRITE_CLASS_ENCODER(rgw_sync_symmetric_group)
struct rgw_sync_directional_rule {
- string source_zone;
- string dest_zone;
+ rgw_zone_id source_zone;
+ rgw_zone_id dest_zone;
void encode(bufferlist& bl) const {
ENCODE_START(1, 1, bl);
WRITE_CLASS_ENCODER(rgw_sync_directional_rule)
struct rgw_sync_bucket_entity {
- std::optional<string> zone; /* define specific zones */
+ std::optional<rgw_zone_id> zone; /* define specific zones */
std::optional<rgw_bucket> bucket; /* define specific bucket */
static bool match_str(const string& s1, const string& s2) { /* empty string is wildcard */
bool all_zones{false};
rgw_sync_bucket_entity() {}
- rgw_sync_bucket_entity(const string& _zone,
+ rgw_sync_bucket_entity(const rgw_zone_id& _zone,
std::optional<rgw_bucket> _bucket) : zone(_zone),
bucket(_bucket.value_or(rgw_bucket())) {}
string bucket_key() const;
- bool match_zone(const string& z) const {
+ bool match_zone(const rgw_zone_id& z) const {
if (all_zones) {
return true;
}
return (*zone == z);
}
- void apply_zone(const string& z) {
+ void apply_zone(const rgw_zone_id& z) {
all_zones = false;
zone = z;
}
if (zone < e.zone) {
return true;
}
- if (zone > e.zone) {
+ if (e.zone < zone) {
return false;
}
return (bucket < e.bucket);
struct rgw_sync_bucket_entities {
std::optional<rgw_bucket> bucket; /* define specific bucket */
- std::optional<std::set<string> > zones; /* define specific zones, if not set then all zones */
+ std::optional<std::set<rgw_zone_id> > zones; /* define specific zones, if not set then all zones */
bool all_zones{false};
rgw_sync_bucket_entity::match_str(bucket->bucket_id, b->bucket_id));
}
- void add_zones(const std::vector<string>& new_zones);
- void remove_zones(const std::vector<string>& rm_zones);
+ void add_zones(const std::vector<rgw_zone_id>& new_zones);
+ void remove_zones(const std::vector<rgw_zone_id>& rm_zones);
void set_bucket(std::optional<string> tenant,
std::optional<string> bucket_name,
std::optional<string> bucket_id);
std::optional<string> bucket_name,
std::optional<string> bucket_id);
- bool match_zone(const string& zone) const {
+ bool match_zone(const rgw_zone_id& zone) const {
if (all_zones) {
return true;
} else if (!zones) {
DECODE_FINISH(bl);
}
- bool match_source(const string& zone, std::optional<rgw_bucket> b) const {
+ bool match_source(const rgw_zone_id& zone, std::optional<rgw_bucket> b) const {
return (source.match_zone(zone) && source.match_bucket(b));
}
- bool match_dest(const string& zone, std::optional<rgw_bucket> b) const {
+ bool match_dest(const rgw_zone_id& zone, std::optional<rgw_bucket> b) const {
return (dest.match_zone(zone) && dest.match_bucket(b));
}
- bool contains_zone_bucket(const string& zone, std::optional<rgw_bucket> b) const {
+ bool contains_zone_bucket(const rgw_zone_id& zone, std::optional<rgw_bucket> b) const {
return (match_source(zone, b) || match_dest(zone, b));
}
}
bool find_symmetrical(const string& flow_id, bool create, rgw_sync_symmetric_group **flow_group);
- void remove_symmetrical(const string& flow_id, std::optional<std::vector<string> > zones);
- bool find_directional(const string& source_zone, const string& dest_zone, bool create, rgw_sync_directional_rule **flow_group);
- void remove_directional(const string& source_zone, const string& dest_zone);
+ void remove_symmetrical(const string& flow_id, std::optional<std::vector<rgw_zone_id> > zones);
+ bool find_directional(const rgw_zone_id& source_zone, const rgw_zone_id& dest_zone, bool create, rgw_sync_directional_rule **flow_group);
+ void remove_directional(const rgw_zone_id& source_zone, const rgw_zone_id& dest_zone);
- void init_default(const std::set<string>& zones);
+ void init_default(const std::set<rgw_zone_id>& zones);
};
WRITE_CLASS_ENCODER(rgw_sync_data_flow_group)
for (auto& g : zonegroups) {
for (auto& z : g.second.zones) {
std::unique_ptr<RGWRESTConn> conn{
- new RGWRESTConn(store->ctx(), store->svc()->zone, z.first, z.second.endpoints)};
- connections.emplace(z.first, std::move(conn));
+ new RGWRESTConn(store->ctx(), store->svc()->zone, z.first.id, z.second.endpoints)};
+ connections.emplace(z.first.id, std::move(conn));
}
}
return connections;
rgw::sal::RGWRadosStore *const store;
RGWHTTPManager *const http;
int num_shards;
- const std::string& zone;
+ const rgw_zone_id& zone;
Cursor current; //< cursor to current period
epoch_t last_trim_epoch{0}; //< epoch of last mdlog that was purged
TrimEnv(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore *store, RGWHTTPManager *http, int num_shards)
: dpp(dpp), store(store), http(http), num_shards(num_shards),
- zone(store->svc()->zone->get_zone_params().get_id()),
+ zone(store->svc()->zone->zone_id()),
current(store->svc()->mdlog->get_period_history()->get_current())
{}
};
{
auto& period = current.get_period();
connections = make_peer_connections(store, period.get_map().zonegroups);
- connections.erase(zone);
+ connections.erase(zone.id);
peer_status.resize(connections.size());
}
};
bool log_data = zones.size() > 1;
if (master_zone.empty()) {
- map<string, RGWZone>::iterator iter = zones.begin();
+ auto iter = zones.begin();
if (iter != zones.end()) {
master_zone = iter->first;
}
}
- for (map<string, RGWZone>::iterator iter = zones.begin(); iter != zones.end(); ++iter) {
- RGWZone& zone = iter->second;
+ for (auto& item : zones) {
+ RGWZone& zone = item.second;
zone.log_data = log_data;
RGWZoneParams zone_params(zone.id, zone.name);
continue;
}
- for (map<string, RGWZonePlacementInfo>::iterator iter = zone_params.placement_pools.begin();
- iter != zone_params.placement_pools.end(); ++iter) {
- const string& placement_name = iter->first;
+ for (auto& pitem : zone_params.placement_pools) {
+ const string& placement_name = pitem.first;
if (placement_targets.find(placement_name) == placement_targets.end()) {
RGWZoneGroupPlacementTarget placement_target;
placement_target.name = placement_name;
int RGWZoneGroup::remove_zone(const std::string& zone_id)
{
- map<string, RGWZone>::iterator iter = zones.find(zone_id);
+ auto iter = zones.find(zone_id);
if (iter == zones.end()) {
ldout(cct, 0) << "zone id " << zone_id << " is not a part of zonegroup "
<< name << dendl;
class JSONObj;
class RGWSyncModulesManager;
+
struct RGWNameToId {
std::string obj_id;
RGWZoneParams() : RGWSystemMetaObj() {}
explicit RGWZoneParams(const std::string& name) : RGWSystemMetaObj(name){}
- RGWZoneParams(const std::string& id, const std::string& name) : RGWSystemMetaObj(id, name) {}
- RGWZoneParams(const std::string& id, const std::string& name, const std::string& _realm_id)
- : RGWSystemMetaObj(id, name), realm_id(_realm_id) {}
+ RGWZoneParams(const rgw_zone_id& id, const std::string& name) : RGWSystemMetaObj(id.id, name) {}
+ RGWZoneParams(const rgw_zone_id& id, const std::string& name, const std::string& _realm_id)
+ : RGWSystemMetaObj(id.id, name), realm_id(_realm_id) {}
rgw_pool get_pool(CephContext *cct) const override;
const std::string get_default_oid(bool old_format = false) const override;
list<std::string> endpoints;
bool is_master = false;
- std::string master_zone;
- map<std::string, RGWZone> zones;
+ rgw_zone_id master_zone;
+ map<rgw_zone_id, RGWZone> zones;
map<std::string, RGWZoneGroupPlacementTarget> placement_targets;
rgw_placement_rule default_placement;
RGWPeriodMap period_map;
RGWPeriodConfig period_config;
std::string master_zonegroup;
- std::string master_zone;
+ rgw_zone_id master_zone;
std::string realm_id;
std::string realm_name;
epoch_t get_epoch() const { return epoch; }
epoch_t get_realm_epoch() const { return realm_epoch; }
const std::string& get_predecessor() const { return predecessor_uuid; }
- const std::string& get_master_zone() const { return master_zone; }
+ const rgw_zone_id& get_master_zone() const { return master_zone; }
const std::string& get_master_zonegroup() const { return master_zonegroup; }
const std::string& get_realm() const { return realm_id; }
const RGWPeriodMap& get_map() const { return period_map; }
period_config.bucket_quota = bucket_quota;
}
- void set_id(const std::string& id) {
- this->id = id;
- period_map.id = id;
+ void set_id(const string& _id) {
+ this->id = _id;
+ period_map.id = _id;
}
void set_epoch(epoch_t epoch) { this->epoch = epoch; }
void set_realm_epoch(epoch_t epoch) { realm_epoch = epoch; }
RGWSI_Bucket_Sync(CephContext *cct) : RGWServiceInstance(cct) {}
virtual int get_policy_handler(RGWSI_Bucket_X_Ctx& ctx,
- std::optional<string> zone,
+ std::optional<rgw_zone_id> zone,
std::optional<rgw_bucket> bucket,
RGWBucketSyncPolicyHandlerRef *handler,
optional_yield y) = 0;
}
void RGWSI_Bucket_Sync_SObj::get_hint_entities(RGWSI_Bucket_X_Ctx& ctx,
- const std::set<string>& zone_names,
+ const std::set<rgw_zone_id>& zones,
const std::set<rgw_bucket>& buckets,
std::set<rgw_sync_bucket_entity> *hint_entities,
optional_yield y)
{
- for (auto& zone : zone_names) {
+ for (auto& zone : zones) {
for (auto& b : buckets) {
- string zid;
- if (!svc.zone->find_zone_id_by_name(zone, &zid)) {
- cerr << "WARNING: cannot find zone id for zone=" << zone << ", skippping" << std::endl;
- continue;
- }
-
RGWBucketInfo hint_bucket_info;
int ret = svc.bucket_sobj->read_bucket_info(ctx, b, &hint_bucket_info,
nullptr, nullptr, boost::none,
continue;
}
- hint_entities->insert(rgw_sync_bucket_entity(zid, hint_bucket_info.bucket));
+ hint_entities->insert(rgw_sync_bucket_entity(zone, hint_bucket_info.bucket));
}
}
}
std::map<optional_zone_bucket, RGWBucketSyncPolicyHandlerRef>& temp_map,
optional_yield y)
{
- set<string> source_zones;
- set<string> target_zones;
+ set<rgw_zone_id> source_zones;
+ set<rgw_zone_id> target_zones;
zone_policy_handler->reflect(nullptr, nullptr,
nullptr, nullptr,
}
int RGWSI_Bucket_Sync_SObj::do_get_policy_handler(RGWSI_Bucket_X_Ctx& ctx,
- std::optional<string> zone,
+ std::optional<rgw_zone_id> zone,
std::optional<rgw_bucket> _bucket,
std::map<optional_zone_bucket, RGWBucketSyncPolicyHandlerRef>& temp_map,
RGWBucketSyncPolicyHandlerRef *handler,
string bucket_key;
if (zone && *zone != svc.zone->zone_id()) {
- zone_key = *zone;
+ zone_key = zone->id;
}
bucket_key = RGWSI_Bucket::get_bi_meta_key(bucket);
}
auto zone_policy_handler = svc.zone->get_sync_policy_handler(zone);
+ if (!zone_policy_handler) {
+ ldout(cct, 20) << "ERROR: could not find policy handler for zone=" << zone << dendl;
+ return -ENOENT;
+ }
e.handler.reset(zone_policy_handler->alloc_child(bucket_info));
}
int RGWSI_Bucket_Sync_SObj::get_policy_handler(RGWSI_Bucket_X_Ctx& ctx,
- std::optional<string> zone,
+ std::optional<rgw_zone_id> zone,
std::optional<rgw_bucket> _bucket,
RGWBucketSyncPolicyHandlerRef *handler,
optional_yield y)
int do_start() override;
struct optional_zone_bucket {
- optional<string> zone;
+ optional<rgw_zone_id> zone;
optional<rgw_bucket> bucket;
- optional_zone_bucket(const optional<string>& _zone,
+ optional_zone_bucket(const optional<rgw_zone_id>& _zone,
const optional<rgw_bucket>& _bucket) : zone(_zone), bucket(_bucket) {}
bool operator<(const optional_zone_bucket& ozb) const {
};
void get_hint_entities(RGWSI_Bucket_X_Ctx& ctx,
- const std::set<string>& zone_names,
+ const std::set<rgw_zone_id>& zone_names,
const std::set<rgw_bucket>& buckets,
std::set<rgw_sync_bucket_entity> *hint_entities,
optional_yield y);
std::map<optional_zone_bucket, RGWBucketSyncPolicyHandlerRef>& temp_map,
optional_yield y);
int do_get_policy_handler(RGWSI_Bucket_X_Ctx& ctx,
- std::optional<string> zone,
+ std::optional<rgw_zone_id> zone,
std::optional<rgw_bucket> _bucket,
std::map<optional_zone_bucket, RGWBucketSyncPolicyHandlerRef>& temp_map,
RGWBucketSyncPolicyHandlerRef *handler,
int get_policy_handler(RGWSI_Bucket_X_Ctx& ctx,
- std::optional<string> zone,
+ std::optional<rgw_zone_id> zone,
std::optional<rgw_bucket> bucket,
RGWBucketSyncPolicyHandlerRef *handler,
optional_yield y);
delete current_period;
}
-std::shared_ptr<RGWBucketSyncPolicyHandler> RGWSI_Zone::get_sync_policy_handler(std::optional<string> zone) const {
+std::shared_ptr<RGWBucketSyncPolicyHandler> RGWSI_Zone::get_sync_policy_handler(std::optional<rgw_zone_id> zone) const {
if (!zone || *zone == zone_id()) {
return sync_policy_handler;
}
lderr(cct) << "failed reading zone info: ret "<< ret << " " << cpp_strerror(-ret) << dendl;
return ret;
}
+
+ cur_zone_id = rgw_zone_id(zone_params->get_id());
+
auto zone_iter = zonegroup->zones.find(zone_params->get_id());
if (zone_iter == zonegroup->zones.end()) {
if (using_local) {
zone_short_id = current_period->get_map().get_zone_short_id(zone_params->get_id());
for (auto ziter : zonegroup->zones) {
- auto zone_handler = new RGWBucketSyncPolicyHandler(this, sync_modules_svc, bucket_sync_svc, ziter.second.name);
+ auto zone_handler = new RGWBucketSyncPolicyHandler(this, sync_modules_svc, bucket_sync_svc, ziter.second.id);
ret = zone_handler->init(null_yield);
if (ret < 0) {
lderr(cct) << "ERROR: could not initialize zone policy handler for zone=" << ziter.second.name << dendl;
sync_policy_handler = sync_policy_handlers[zone_id()]; /* we made sure earlier that zonegroup->zones has our zone */
- set<string> source_zones_by_name;
- set<string> target_zones_by_name;
+ set<rgw_zone_id> source_zones;
+ set<rgw_zone_id> target_zones;
sync_policy_handler->reflect(nullptr, nullptr,
nullptr, nullptr,
- &source_zones_by_name,
- &target_zones_by_name,
+ &source_zones,
+ &target_zones,
false); /* relaxed: also get all zones that we allow to sync to/from */
ret = sync_modules_svc->start();
/* first build all zones index */
for (auto ziter : zonegroup->zones) {
- const string& id = ziter.first;
+ const rgw_zone_id& id = ziter.first;
RGWZone& z = ziter.second;
zone_id_by_name[z.name] = id;
zone_by_id[id] = z;
}
for (const auto& ziter : zonegroup->zones) {
- const string& id = ziter.first;
+ const rgw_zone_id& id = ziter.first;
const RGWZone& z = ziter.second;
if (id == zone_id()) {
continue;
RGWRESTConn *conn = new RGWRESTConn(cct, this, z.id, z.endpoints);
zone_conn_map[id] = conn;
- bool zone_is_source = source_zones_by_name.find(z.name) != source_zones_by_name.end();
- bool zone_is_target = target_zones_by_name.find(z.name) != target_zones_by_name.end();
+ bool zone_is_source = source_zones.find(z.id) != source_zones.end();
+ bool zone_is_target = target_zones.find(z.id) != target_zones.end();
if (zone_is_source || zone_is_target) {
if (zone_is_source) {
{
delete rest_master_conn;
- map<string, RGWRESTConn *>::iterator iter;
- for (iter = zone_conn_map.begin(); iter != zone_conn_map.end(); ++iter) {
- RGWRESTConn *conn = iter->second;
+ for (auto& item : zone_conn_map) {
+ auto conn = item.second;
delete conn;
}
- for (iter = zonegroup_conn_map.begin(); iter != zonegroup_conn_map.end(); ++iter) {
- RGWRESTConn *conn = iter->second;
+ for (auto& item : zonegroup_conn_map) {
+ auto conn = item.second;
delete conn;
}
}
return 0;
}
- string master_region, master_zone;
+ string master_region;
+ rgw_zone_id master_zone;
for (list<string>::iterator iter = regions.begin(); iter != regions.end(); ++iter) {
if (*iter != default_zonegroup_name){
RGWZoneGroup region(*iter);
The realm name will be the region and zone concatenated
realm id will be mds of its name */
if (realm->get_id().empty() && !master_region.empty() && !master_zone.empty()) {
- string new_realm_name = master_region + "." + master_zone;
+ string new_realm_name = master_region + "." + master_zone.id;
unsigned char md5[CEPH_CRYPTO_MD5_DIGESTSIZE];
char md5_str[CEPH_CRYPTO_MD5_DIGESTSIZE * 2 + 1];
MD5 hash;
return ret;
}
}
- for (map<string, RGWZone>::const_iterator iter = zonegroup.zones.begin(); iter != zonegroup.zones.end();
+ for (auto iter = zonegroup.zones.begin(); iter != zonegroup.zones.end();
++iter) {
ldout(cct, 0) << __func__ << " Converting zone" << iter->first << dendl;
- RGWZoneParams zoneparams(iter->first, iter->first);
- zoneparams.set_id(iter->first);
+ RGWZoneParams zoneparams(iter->first, iter->second.name);
+ zoneparams.set_id(iter->first.id);
zoneparams.realm_id = realm->get_id();
ret = zoneparams.init(cct, sysobj_svc);
if (ret < 0 && ret != -ENOENT) {
{
return get_zone_params().get_name();
}
-const string& RGWSI_Zone::zone_id() const
-{
- return get_zone_params().get_id();
-}
-bool RGWSI_Zone::find_zone_by_id(const string& id, RGWZone **zone)
+bool RGWSI_Zone::find_zone(const rgw_zone_id& id, RGWZone **zone)
{
auto iter = zone_by_id.find(id);
if (iter == zone_by_id.end()) {
return true;
}
-RGWRESTConn *RGWSI_Zone::get_zone_conn_by_id(const string& id) {
- auto citer = zone_conn_map.find(id);
+RGWRESTConn *RGWSI_Zone::get_zone_conn(const rgw_zone_id& zone_id) {
+ auto citer = zone_conn_map.find(zone_id.id);
if (citer == zone_conn_map.end()) {
return NULL;
}
return NULL;
}
- return get_zone_conn_by_id(i->second);
+ return get_zone_conn(i->second);
}
-bool RGWSI_Zone::find_zone_id_by_name(const string& name, string *id) {
+bool RGWSI_Zone::find_zone_id_by_name(const string& name, rgw_zone_id *id) {
auto i = zone_id_by_name.find(name);
if (i == zone_id_by_name.end()) {
return false;
}
/* zone is not master */
- if (zonegroup->master_zone.compare(zone_public_config->id) != 0) {
+ if (zonegroup->master_zone != zone_public_config->id) {
return false;
}
RGWZone *zone_public_config{nullptr}; /* external zone params, e.g., entrypoints, log flags, etc. */
RGWZoneParams *zone_params{nullptr}; /* internal zone params, e.g., rados pools */
RGWPeriod *current_period{nullptr};
+ rgw_zone_id cur_zone_id;
uint32_t zone_short_id{0};
bool writeable_zone{false};
std::shared_ptr<RGWBucketSyncPolicyHandler> sync_policy_handler;
- std::map<string, std::shared_ptr<RGWBucketSyncPolicyHandler> > sync_policy_handlers;
+ std::map<rgw_zone_id, std::shared_ptr<RGWBucketSyncPolicyHandler> > sync_policy_handlers;
RGWRESTConn *rest_master_conn{nullptr};
- map<string, RGWRESTConn *> zone_conn_map;
+ map<rgw_zone_id, RGWRESTConn *> zone_conn_map;
std::vector<const RGWZone*> data_sync_source_zones;
- map<string, RGWRESTConn *> zone_data_notify_to_map;
+ map<rgw_zone_id, RGWRESTConn *> zone_data_notify_to_map;
map<string, RGWRESTConn *> zonegroup_conn_map;
- map<string, string> zone_id_by_name;
- map<string, RGWZone> zone_by_id;
+ map<string, rgw_zone_id> zone_id_by_name;
+ map<rgw_zone_id, RGWZone> zone_by_id;
std::unique_ptr<rgw_sync_policy_info> sync_policy;
int get_zonegroup(const string& id, RGWZoneGroup& zonegroup) const;
const RGWZone& get_zone() const;
- std::shared_ptr<RGWBucketSyncPolicyHandler> get_sync_policy_handler(std::optional<string> zone = nullopt) const;
+ std::shared_ptr<RGWBucketSyncPolicyHandler> get_sync_policy_handler(std::optional<rgw_zone_id> zone = nullopt) const;
const string& zone_name() const;
- const string& zone_id() const;
+ const rgw_zone_id& zone_id() const {
+ return cur_zone_id;
+ }
uint32_t get_zone_short_id() const;
const string& get_current_period_id() const;
return zonegroup_conn_map;
}
- map<string, RGWRESTConn *>& get_zone_conn_map() {
+ map<rgw_zone_id, RGWRESTConn *>& get_zone_conn_map() {
return zone_conn_map;
}
return data_sync_source_zones;
}
- map<string, RGWRESTConn *>& get_zone_data_notify_to_map() {
+ map<rgw_zone_id, RGWRESTConn *>& get_zone_data_notify_to_map() {
return zone_data_notify_to_map;
}
- bool find_zone_by_id(const string& id, RGWZone **zone);
+ bool find_zone(const rgw_zone_id& id, RGWZone **zone);
- RGWRESTConn *get_zone_conn_by_id(const string& id);
+ RGWRESTConn *get_zone_conn(const rgw_zone_id& zone_id);
RGWRESTConn *get_zone_conn_by_name(const string& name);
- bool find_zone_id_by_name(const string& name, string *id);
+ bool find_zone_id_by_name(const string& name, rgw_zone_id *id);
int select_bucket_placement(const RGWUserInfo& user_info, const string& zonegroup_id,
const rgw_placement_rule& rule,