Skip to content

Commit

Permalink
Merge pull request #53584 from cbodley/wip-62924-reef
Browse files Browse the repository at this point in the history
reef: rgw/sal: get_placement_target_names() returns void

Reviewed-by: Daniel Gryniewicz <dang@redhat.com>
  • Loading branch information
yuriw committed Oct 3, 2023
2 parents a2c3305 + 0b02adf commit 27be5a7
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 31 deletions.
4 changes: 1 addition & 3 deletions src/rgw/driver/rados/rgw_sal_rados.cc
Expand Up @@ -3191,13 +3191,11 @@ bool RadosZoneGroup::placement_target_exists(std::string& target) const
return !!group.placement_targets.count(target);
}

int RadosZoneGroup::get_placement_target_names(std::set<std::string>& names) const
void RadosZoneGroup::get_placement_target_names(std::set<std::string>& names) const
{
for (const auto& target : group.placement_targets) {
names.emplace(target.second.name);
}

return 0;
}

int RadosZoneGroup::get_placement_tier(const rgw_placement_rule& rule,
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/driver/rados/rgw_sal_rados.h
Expand Up @@ -70,7 +70,7 @@ class RadosZoneGroup : public StoreZoneGroup {
return group.is_master_zonegroup();
};
virtual const std::string& get_api_name() const override { return group.api_name; };
virtual int get_placement_target_names(std::set<std::string>& names) const override;
virtual void get_placement_target_names(std::set<std::string>& names) const override;
virtual const std::string& get_default_placement_name() const override {
return group.default_placement.name; };
virtual int get_hostnames(std::list<std::string>& names) const override {
Expand Down
7 changes: 3 additions & 4 deletions src/rgw/rgw_op.cc
Expand Up @@ -2529,10 +2529,9 @@ void RGWListBuckets::execute(optional_yield y)
* isn't actually used in a given account. In such situation its usage
* stats would be simply full of zeros. */
std::set<std::string> targets;
if (driver->get_zone()->get_zonegroup().get_placement_target_names(targets)) {
for (const auto& policy : targets) {
policies_stats.emplace(policy, decltype(policies_stats)::mapped_type());
}
driver->get_zone()->get_zonegroup().get_placement_target_names(targets);
for (const auto& policy : targets) {
policies_stats.emplace(policy, decltype(policies_stats)::mapped_type());
}

std::map<std::string, std::unique_ptr<rgw::sal::Bucket>>& m = buckets.get_buckets();
Expand Down
15 changes: 7 additions & 8 deletions src/rgw/rgw_rest_swift.cc
Expand Up @@ -1898,14 +1898,13 @@ void RGWInfo_ObjStore_SWIFT::list_swift_data(Formatter& formatter,
const rgw::sal::ZoneGroup& zonegroup = driver->get_zone()->get_zonegroup();

std::set<std::string> targets;
if (zonegroup.get_placement_target_names(targets)) {
for (const auto& placement_targets : targets) {
formatter.open_object_section("policy");
if (placement_targets.compare(zonegroup.get_default_placement_name()) == 0)
formatter.dump_bool("default", true);
formatter.dump_string("name", placement_targets.c_str());
formatter.close_section();
}
zonegroup.get_placement_target_names(targets);
for (const auto& placement_targets : targets) {
formatter.open_object_section("policy");
if (placement_targets.compare(zonegroup.get_default_placement_name()) == 0)
formatter.dump_bool("default", true);
formatter.dump_string("name", placement_targets.c_str());
formatter.close_section();
}
formatter.close_section();

Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_sal.h
Expand Up @@ -1483,7 +1483,7 @@ class ZoneGroup {
/** Get the API name of this zonegroup */
virtual const std::string& get_api_name() const = 0;
/** Get the list of placement target names for this zone */
virtual int get_placement_target_names(std::set<std::string>& names) const = 0;
virtual void get_placement_target_names(std::set<std::string>& names) const = 0;
/** Get the name of the default placement target for this zone */
virtual const std::string& get_default_placement_name() const = 0;
/** Get the list of hostnames from this zone */
Expand Down
4 changes: 1 addition & 3 deletions src/rgw/rgw_sal_daos.cc
Expand Up @@ -826,13 +826,11 @@ bool DaosZoneGroup::placement_target_exists(std::string& target) const {
return !!group.placement_targets.count(target);
}

int DaosZoneGroup::get_placement_target_names(
void DaosZoneGroup::get_placement_target_names(
std::set<std::string>& names) const {
for (const auto& target : group.placement_targets) {
names.emplace(target.second.name);
}

return 0;
}

int DaosZoneGroup::get_placement_tier(const rgw_placement_rule& rule,
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_sal_daos.h
Expand Up @@ -414,7 +414,7 @@ class DaosZoneGroup : public StoreZoneGroup {
virtual const std::string& get_api_name() const override {
return group.api_name;
};
virtual int get_placement_target_names(
virtual void get_placement_target_names(
std::set<std::string>& names) const override;
virtual const std::string& get_default_placement_name() const override {
return group.default_placement.name;
Expand Down
4 changes: 1 addition & 3 deletions src/rgw/rgw_sal_dbstore.cc
Expand Up @@ -531,12 +531,10 @@ namespace rgw::sal {
return !!group->placement_targets.count(target);
}

int DBZoneGroup::get_placement_target_names(std::set<std::string>& names) const {
void DBZoneGroup::get_placement_target_names(std::set<std::string>& names) const {
for (const auto& target : group->placement_targets) {
names.emplace(target.second.name);
}

return 0;
}

ZoneGroup& DBZone::get_zonegroup()
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_sal_dbstore.h
Expand Up @@ -271,7 +271,7 @@ class DBNotification : public StoreNotification {
return group->is_master_zonegroup();
};
virtual const std::string& get_api_name() const override { return group->api_name; };
virtual int get_placement_target_names(std::set<std::string>& names) const override;
virtual void get_placement_target_names(std::set<std::string>& names) const override;
virtual const std::string& get_default_placement_name() const override {
return group->default_placement.name; };
virtual int get_hostnames(std::list<std::string>& names) const override {
Expand Down
4 changes: 2 additions & 2 deletions src/rgw/rgw_sal_filter.h
Expand Up @@ -68,8 +68,8 @@ class FilterZoneGroup : public ZoneGroup {
{ return next->is_master_zonegroup(); }
virtual const std::string& get_api_name() const override
{ return next->get_api_name(); }
virtual int get_placement_target_names(std::set<std::string>& names) const override
{ return next->get_placement_target_names(names); }
virtual void get_placement_target_names(std::set<std::string>& names) const override
{ next->get_placement_target_names(names); }
virtual const std::string& get_default_placement_name() const override
{ return next->get_default_placement_name(); }
virtual int get_hostnames(std::list<std::string>& names) const override
Expand Down
4 changes: 1 addition & 3 deletions src/rgw/rgw_sal_motr.cc
Expand Up @@ -1081,13 +1081,11 @@ bool MotrZoneGroup::placement_target_exists(std::string& target) const
return !!group.placement_targets.count(target);
}

int MotrZoneGroup::get_placement_target_names(std::set<std::string>& names) const
void MotrZoneGroup::get_placement_target_names(std::set<std::string>& names) const
{
for (const auto& target : group.placement_targets) {
names.emplace(target.second.name);
}

return 0;
}

int MotrZoneGroup::get_placement_tier(const rgw_placement_rule& rule,
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_sal_motr.h
Expand Up @@ -445,7 +445,7 @@ class MotrZoneGroup : public StoreZoneGroup {
return group.is_master_zonegroup();
};
virtual const std::string& get_api_name() const override { return group.api_name; };
virtual int get_placement_target_names(std::set<std::string>& names) const override;
virtual void get_placement_target_names(std::set<std::string>& names) const override;
virtual const std::string& get_default_placement_name() const override {
return group.default_placement.name; };
virtual int get_hostnames(std::list<std::string>& names) const override {
Expand Down

0 comments on commit 27be5a7

Please sign in to comment.