From c8ccf1d69a7f5ef85bfd3a0781c3d5b3cd1b7f89 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 21 Oct 2019 11:27:31 -0700 Subject: [PATCH] rgw: rename some datastructures to signify plurality pipe -> pipes, entity -> entities Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_admin.cc | 6 ++-- src/rgw/rgw_bucket_sync.cc | 64 +++++++++++++++++++------------------- src/rgw/rgw_bucket_sync.h | 20 ++++++------ src/rgw/rgw_json_enc.cc | 10 +++--- src/rgw/rgw_sync_policy.h | 16 +++++----- 5 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 2739b0c87f2..e83ca9221d9 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -2330,7 +2330,7 @@ void encode_json(const char *name, const RGWBucketSyncFlowManager::flow_map_t& m auto& bucket = entry.first; auto& pflow = entry.second; - encode_json("bucket", rgw_sync_bucket_entity::bucket_key(bucket), f); + encode_json("buckets", rgw_sync_bucket_entities::bucket_key(bucket), f); #if 0 { Formatter::ArraySection fg(*f, "flow_groups"); @@ -8052,7 +8052,7 @@ next: auto& group = iter->second; - rgw_sync_bucket_pipe *pipe; + rgw_sync_bucket_pipes *pipe; group.find_pipe(*opt_pipe_id, true, &pipe); @@ -8092,7 +8092,7 @@ next: auto& group = iter->second; - rgw_sync_bucket_pipe *pipe; + rgw_sync_bucket_pipes *pipe; if (!group.find_pipe(*opt_pipe_id, false, &pipe)) { cerr << "ERROR: could not find pipe '" << *opt_pipe_id << "'" << std::endl; diff --git a/src/rgw/rgw_bucket_sync.cc b/src/rgw/rgw_bucket_sync.cc index 7cd007cf98b..dce8839c13d 100644 --- a/src/rgw/rgw_bucket_sync.cc +++ b/src/rgw/rgw_bucket_sync.cc @@ -10,7 +10,7 @@ #define dout_subsys ceph_subsys_rgw -void rgw_sync_bucket_entity::add_zones(const std::vector& new_zones) { +void rgw_sync_bucket_entities::add_zones(const std::vector& new_zones) { for (auto& z : new_zones) { if (z == "*") { all_zones = true; @@ -26,7 +26,7 @@ void rgw_sync_bucket_entity::add_zones(const std::vector& new_zones) { } } -void rgw_sync_bucket_entity::remove_zones(const std::vector& rm_zones) { +void rgw_sync_bucket_entities::remove_zones(const std::vector& rm_zones) { all_zones = false; if (!zones) { @@ -49,7 +49,7 @@ static void set_bucket_field(std::optional source, string *field) { *field = *source; } -void rgw_sync_bucket_entity::set_bucket(std::optional tenant, +void rgw_sync_bucket_entities::set_bucket(std::optional tenant, std::optional bucket_name, std::optional bucket_id) { @@ -68,7 +68,7 @@ void rgw_sync_bucket_entity::set_bucket(std::optional tenant, } } -void rgw_sync_bucket_entity::remove_bucket(std::optional tenant, +void rgw_sync_bucket_entities::remove_bucket(std::optional tenant, std::optional bucket_name, std::optional bucket_id) { @@ -94,7 +94,7 @@ void rgw_sync_bucket_entity::remove_bucket(std::optional tenant, } -string rgw_sync_bucket_entity::bucket_key(std::optional b) +string rgw_sync_bucket_entities::bucket_key(std::optional b) { if (!b) { return string("*"); @@ -217,7 +217,7 @@ void rgw_sync_data_flow_group::remove_directional(const string& source_zone, con } } -bool rgw_sync_policy_group::find_pipe(const string& pipe_id, bool create, rgw_sync_bucket_pipe **pipe) +bool rgw_sync_policy_group::find_pipe(const string& pipe_id, bool create, rgw_sync_bucket_pipes **pipe) { for (auto& p : pipes) { if (pipe_id == p.id) { @@ -247,11 +247,11 @@ void rgw_sync_policy_group::remove_pipe(const string& pipe_id) } } -static std::vector filter_relevant_pipes(const std::vector& pipes, +static std::vector filter_relevant_pipes(const std::vector& pipes, const string& source_zone, const string& dest_zone) { - std::vector relevant_pipes; + std::vector relevant_pipes; for (auto& pipe : pipes) { if (pipe.source.match_zone(source_zone) && pipe.dest.match_zone(dest_zone)) { @@ -270,23 +270,23 @@ static bool is_wildcard_bucket(const rgw_bucket& bucket) void rgw_sync_group_pipe_map::zone_bucket::dump(ceph::Formatter *f) const { encode_json("zone", zone, f); - encode_json("bucket", rgw_sync_bucket_entity::bucket_key(bucket), f); + encode_json("buckets", rgw_sync_bucket_entities::bucket_key(bucket), f); } void rgw_sync_group_pipe_map::dump(ceph::Formatter *f) const { encode_json("zone", zone, f); - encode_json("bucket", rgw_sync_bucket_entity::bucket_key(bucket), f); + encode_json("buckets", rgw_sync_bucket_entities::bucket_key(bucket), f); encode_json("sources", sources, f); encode_json("dests", dests, f); } -ostream& operator<<(ostream& os, const rgw_sync_bucket_entity& e) { - os << "{b=" << rgw_sync_bucket_entity::bucket_key(e.bucket) << ",z=" << e.zones.value_or(std::set()) << "}"; +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()) << "}"; return os; } -ostream& operator<<(ostream& os, const rgw_sync_bucket_pipe& pipe) { +ostream& operator<<(ostream& os, const rgw_sync_bucket_pipes& pipe) { os << "{id=" << pipe.id << ",s=" << pipe.source << ",d=" << pipe.dest << "}"; return os; } @@ -295,7 +295,7 @@ ostream& operator<<(ostream& os, const rgw_sync_bucket_pipe& pipe) { template void rgw_sync_group_pipe_map::try_add_to_pipe_map(const string& source_zone, const string& dest_zone, - const std::vector& pipes, + const std::vector& pipes, zb_pipe_map_t *pipe_map, CB1 filter_cb, CB2 call_filter_cb) @@ -317,13 +317,13 @@ void rgw_sync_group_pipe_map::try_add_to_pipe_map(const string& source_zone, template void rgw_sync_group_pipe_map::try_add_source(const string& source_zone, const string& dest_zone, - const std::vector& pipes, + const std::vector& pipes, CB filter_cb) { return try_add_to_pipe_map(source_zone, dest_zone, pipes, &sources, filter_cb, - [&](const rgw_sync_bucket_pipe& pipe, zone_bucket *zb) { + [&](const rgw_sync_bucket_pipes& pipe, zone_bucket *zb) { *zb = zone_bucket{source_zone, pipe.source.get_bucket()}; return filter_cb(source_zone, zb->bucket, dest_zone, pipe.dest.get_bucket()); }); @@ -332,13 +332,13 @@ void rgw_sync_group_pipe_map::try_add_source(const string& source_zone, template void rgw_sync_group_pipe_map::try_add_dest(const string& source_zone, const string& dest_zone, - const std::vector& pipes, + const std::vector& pipes, CB filter_cb) { return try_add_to_pipe_map(source_zone, dest_zone, pipes, &dests, filter_cb, - [&](const rgw_sync_bucket_pipe& pipe, zone_bucket *zb) { + [&](const rgw_sync_bucket_pipes& pipe, zone_bucket *zb) { *zb = zone_bucket{dest_zone, pipe.dest.get_bucket()}; return filter_cb(source_zone, pipe.source.get_bucket(), dest_zone, zb->bucket); }); @@ -380,7 +380,7 @@ void rgw_sync_group_pipe_map::init(const string& _zone, status = group.status; - std::vector zone_pipes; + std::vector zone_pipes; /* only look at pipes that touch the specific zone and bucket */ for (auto& pipe : group.pipes) { @@ -424,10 +424,10 @@ void rgw_sync_group_pipe_map::init(const string& _zone, /* * find all relevant pipes in our zone that match {dest_bucket} <- {source_zone, source_bucket} */ -vector rgw_sync_group_pipe_map::find_source_pipes(const string& source_zone, +vector rgw_sync_group_pipe_map::find_source_pipes(const string& source_zone, std::optional source_bucket, std::optional dest_bucket) { - vector result; + vector result; auto range = find_pipes(sources, source_zone, source_bucket); @@ -444,10 +444,10 @@ vector rgw_sync_group_pipe_map::find_source_pipes(const st * find all relevant pipes in other zones that pull from a specific * source bucket in out zone {source_bucket} -> {dest_zone, dest_bucket} */ -vector rgw_sync_group_pipe_map::find_dest_pipes(std::optional source_bucket, +vector rgw_sync_group_pipe_map::find_dest_pipes(std::optional source_bucket, const string& dest_zone, std::optional dest_bucket) { - vector result; + vector result; auto range = find_pipes(dests, dest_zone, dest_bucket); @@ -464,7 +464,7 @@ vector rgw_sync_group_pipe_map::find_dest_pipes(std::optio /* * find all relevant pipes from {source_zone, source_bucket} -> {dest_zone, dest_bucket} */ -vector rgw_sync_group_pipe_map::find_pipes(const string& source_zone, +vector rgw_sync_group_pipe_map::find_pipes(const string& source_zone, std::optional source_bucket, const string& dest_zone, std::optional dest_bucket) { @@ -476,7 +476,7 @@ vector rgw_sync_group_pipe_map::find_pipes(const string& s return find_dest_pipes(source_bucket, dest_zone, dest_bucket); } - return vector(); + return vector(); } void RGWBucketSyncFlowManager::pipe_flow::dump(ceph::Formatter *f) const @@ -549,7 +549,7 @@ RGWBucketSyncFlowManager::flow_map_t::iterator RGWBucketSyncFlowManager::find_bu } -void RGWBucketSyncFlowManager::update_flow_maps(const rgw_sync_bucket_pipe& pipe) { +void RGWBucketSyncFlowManager::update_flow_maps(const rgw_sync_bucket_pipes& pipe) { auto source_bucket = pipe.source.get_bucket(); auto dest_bucket = pipe.dest.get_bucket(); @@ -581,7 +581,7 @@ void RGWBucketSyncFlowManager::update_flow_maps(const rgw_sync_bucket_pipe& pipe } void RGWBucketSyncFlowManager::init(const rgw_sync_policy_info& sync_policy) { - rgw_sync_bucket_entity entity; + rgw_sync_bucket_entities entity; entity.zones = std::set( { zone_name } ); entity.bucket = bucket; @@ -605,8 +605,8 @@ void RGWBucketSyncFlowManager::init(const rgw_sync_policy_info& sync_policy) { }); for (auto& entry : flow_group_map.sources) { - rgw_sync_bucket_pipe pipe; - rgw_sync_bucket_entity source; + rgw_sync_bucket_pipes pipe; + rgw_sync_bucket_entities source; pipe.source.zones = std::set( { entry.first.zone } ); pipe.source.bucket = entry.first.bucket; pipe.dest = entity; @@ -616,8 +616,8 @@ void RGWBucketSyncFlowManager::init(const rgw_sync_policy_info& sync_policy) { } for (auto& entry : flow_group_map.dests) { - rgw_sync_bucket_pipe pipe; - rgw_sync_bucket_entity dest; + rgw_sync_bucket_pipes pipe; + rgw_sync_bucket_entities dest; pipe.dest.zones = std::set( { entry.first.zone } ); pipe.dest.bucket = entry.first.bucket; pipe.source = entity; @@ -637,7 +637,7 @@ void RGWBucketSyncFlowManager::init(const rgw_sync_policy_info& sync_policy) { update_flow_maps(pipe, flow_group_map); } } else { - update_flow_maps(rgw_sync_bucket_pipe(), flow_group_map); + update_flow_maps(rgw_sync_bucket_pipes(), flow_group_map); } } #endif diff --git a/src/rgw/rgw_bucket_sync.h b/src/rgw/rgw_bucket_sync.h index b6d3f4400f2..e8b1af9d194 100644 --- a/src/rgw/rgw_bucket_sync.h +++ b/src/rgw/rgw_bucket_sync.h @@ -21,7 +21,7 @@ class RGWSI_Zone; struct rgw_sync_group_pipe_map; -struct rgw_sync_bucket_pipe; +struct rgw_sync_bucket_pipes; struct rgw_sync_policy_info; struct rgw_sync_group_pipe_map { @@ -52,7 +52,7 @@ struct rgw_sync_group_pipe_map { void dump(ceph::Formatter *f) const; }; - using zb_pipe_map_t = std::multimap; + using zb_pipe_map_t = std::multimap; 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 */ @@ -62,7 +62,7 @@ struct rgw_sync_group_pipe_map { template void try_add_to_pipe_map(const string& source_zone, const string& dest_zone, - const std::vector& pipes, + const std::vector& pipes, zb_pipe_map_t *pipe_map, CB1 filter_cb, CB2 call_filter_cb); @@ -70,13 +70,13 @@ struct rgw_sync_group_pipe_map { template void try_add_source(const string& source_zone, const string& dest_zone, - const std::vector& pipes, + const std::vector& pipes, CB filter_cb); template void try_add_dest(const string& source_zone, const string& dest_zone, - const std::vector& pipes, + const std::vector& pipes, CB filter_cb); pair find_pipes(const zb_pipe_map_t& m, @@ -92,7 +92,7 @@ struct rgw_sync_group_pipe_map { /* * find all relevant pipes in our zone that match {dest_bucket} <- {source_zone, source_bucket} */ - vector find_source_pipes(const string& source_zone, + vector find_source_pipes(const string& source_zone, std::optional source_bucket, std::optional dest_bucket); @@ -100,14 +100,14 @@ struct rgw_sync_group_pipe_map { * find all relevant pipes in other zones that pull from a specific * source bucket in out zone {source_bucket} -> {dest_zone, dest_bucket} */ - vector find_dest_pipes(std::optional source_bucket, + vector find_dest_pipes(std::optional source_bucket, const string& dest_zone, std::optional dest_bucket); /* * find all relevant pipes from {source_zone, source_bucket} -> {dest_zone, dest_bucket} */ - vector find_pipes(const string& source_zone, + vector find_pipes(const string& source_zone, std::optional source_bucket, const string& dest_zone, std::optional dest_bucket); @@ -116,7 +116,7 @@ struct rgw_sync_group_pipe_map { class RGWBucketSyncFlowManager { public: struct pipe_flow { - std::vector pipe; + std::vector pipe; void dump(ceph::Formatter *f) const; }; @@ -146,7 +146,7 @@ private: */ flow_map_t::iterator find_bucket_flow(flow_map_t& m, std::optional bucket); - void update_flow_maps(const rgw_sync_bucket_pipe& pipe); + void update_flow_maps(const rgw_sync_bucket_pipes& pipe); public: diff --git a/src/rgw/rgw_json_enc.cc b/src/rgw/rgw_json_enc.cc index fa7c00e12ae..ba3d574d4a4 100644 --- a/src/rgw/rgw_json_enc.cc +++ b/src/rgw/rgw_json_enc.cc @@ -865,9 +865,9 @@ void rgw_sync_symmetric_group::decode_json(JSONObj *obj) JSONDecoder::decode_json("zones", zones, obj); } -void rgw_sync_bucket_entity::dump(Formatter *f) const +void rgw_sync_bucket_entities::dump(Formatter *f) const { - encode_json("bucket", rgw_sync_bucket_entity::bucket_key(bucket), f); + encode_json("bucket", rgw_sync_bucket_entities::bucket_key(bucket), f); if (zones) { encode_json("zones", zones, f); } else if (all_zones) { @@ -876,7 +876,7 @@ void rgw_sync_bucket_entity::dump(Formatter *f) const } } -void rgw_sync_bucket_entity::decode_json(JSONObj *obj) +void rgw_sync_bucket_entities::decode_json(JSONObj *obj) { string s; JSONDecoder::decode_json("bucket", s, obj); @@ -903,14 +903,14 @@ void rgw_sync_bucket_entity::decode_json(JSONObj *obj) JSONDecoder::decode_json("zones", zones, obj); } -void rgw_sync_bucket_pipe::dump(Formatter *f) const +void rgw_sync_bucket_pipes::dump(Formatter *f) const { encode_json("id", id, f); encode_json("source", source, f); encode_json("dest", dest, f); } -void rgw_sync_bucket_pipe::decode_json(JSONObj *obj) +void rgw_sync_bucket_pipes::decode_json(JSONObj *obj) { JSONDecoder::decode_json("id", id, obj); JSONDecoder::decode_json("source", source, obj); diff --git a/src/rgw/rgw_sync_policy.h b/src/rgw/rgw_sync_policy.h index fdb803fd75c..30513895a73 100644 --- a/src/rgw/rgw_sync_policy.h +++ b/src/rgw/rgw_sync_policy.h @@ -219,7 +219,7 @@ struct rgw_sync_directional_rule { }; WRITE_CLASS_ENCODER(rgw_sync_directional_rule) -struct rgw_sync_bucket_entity { +struct rgw_sync_bucket_entities { private: bool match_str(const string& s1, const string& s2) const { /* empty string is wildcard */ return (s1.empty() || @@ -291,9 +291,9 @@ public: static string bucket_key(std::optional b); }; -WRITE_CLASS_ENCODER(rgw_sync_bucket_entity) +WRITE_CLASS_ENCODER(rgw_sync_bucket_entities) -struct rgw_sync_bucket_pipe { +struct rgw_sync_bucket_pipes { private: void symmetrical_copy_if_empty(string& s1, string& s2) const { if (s1.empty()) { @@ -305,8 +305,8 @@ private: public: string id; - rgw_sync_bucket_entity source; - rgw_sync_bucket_entity dest; + rgw_sync_bucket_entities source; + rgw_sync_bucket_entities dest; void encode(bufferlist& bl) const { ENCODE_START(1, 1, bl); @@ -358,7 +358,7 @@ public: } } }; -WRITE_CLASS_ENCODER(rgw_sync_bucket_pipe) +WRITE_CLASS_ENCODER(rgw_sync_bucket_pipes) /* * define data flow between zones. Symmetrical: zones sync from each other. @@ -403,7 +403,7 @@ struct rgw_sync_policy_group { rgw_sync_data_flow_group data_flow; /* override data flow, howver, will not be able to add new flows that don't exist at higher level */ - std::vector pipes; /* if not defined then applies to all + std::vector pipes; /* if not defined then applies to all buckets (DR sync) */ enum Status { @@ -451,7 +451,7 @@ struct rgw_sync_policy_group { return true; } - bool find_pipe(const string& pipe_id, bool create, rgw_sync_bucket_pipe **pipe); + bool find_pipe(const string& pipe_id, bool create, rgw_sync_bucket_pipes **pipe); void remove_pipe(const string& pipe_id); }; WRITE_CLASS_ENCODER(rgw_sync_policy_group) -- 2.39.5