const string& access, const string& secret,
bool force)
{
- auto& master_zone = period.get_master_zone();
+ auto& master_zone = period.get_master_zone().id;
if (master_zone.empty()) {
cerr << "cannot commit period: period does not have a master zone of a master zonegroup" << std::endl;
return -EINVAL;
if (remote.empty() && url.empty()) {
// use the new master zone's connection
- remote = master_zone.id;
+ remote = master_zone;
cerr << "Sending period to new master zone " << remote << std::endl;
}
boost::optional<RGWRESTConn> conn;
meta_map["zonegroup"] = zone_svc->get_zonegroup().get_name();
meta_map["zonegroup_id"] = zone_svc->get_zonegroup().get_id();
meta_map["zone"] = zone_svc->get_name();
- meta_map["zone_id"] = zone_svc->get_id().id;
+ meta_map["zone_id"] = zone_svc->get_id();
}
string process_str(const string& in);
// update other zone endpoints
for (auto& z : my_zonegroup.zones) {
auto& zone = z.second;
- if (zone.id == store->get_zone()->get_id().id)
+ if (zone.id == store->get_zone()->get_id())
continue;
if (zone.endpoints.empty())
continue;
set<rgw_zone_id> ids;
for (auto& name : zone_names) {
- rgw_zone_id id;
- if (static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->find_zone_id_by_name(name, &id)) {
+ std::unique_ptr<rgw::sal::Zone> zone;
+ int ret = store->get_zone()->get_zonegroup().get_zone_by_name(name, &zone);
+ if (ret >= 0) {
+ rgw_zone_id id = zone->get_id();
ids.insert(std::move(id));
}
}
vector<string> names;
for (auto& id : zone_ids) {
- RGWZone *zone;
- if ((zone = static_cast<rgw::sal::RadosStore*>(store)->svc()->zone->find_zone(id))) {
- names.emplace_back(zone->name);
+ std::unique_ptr<rgw::sal::Zone> zone;
+ int ret = store->get_zone()->get_zonegroup().get_zone_by_id(id.id, &zone);
+ if (ret >= 0) {
+ names.emplace_back(zone->get_name());
}
}
virtual int get_zone_count() const = 0;
/** Get the placement tier associated with the rule */
virtual int get_placement_tier(const rgw_placement_rule& rule, std::unique_ptr<PlacementTier>* tier) = 0;
+ /** Get a zone by ID */
+ virtual int get_zone_by_id(const std::string& id, std::unique_ptr<Zone>* zone) = 0;
+ /** Get a zone by Name */
+ virtual int get_zone_by_name(const std::string& name, std::unique_ptr<Zone>* zone) = 0;
/** Clone a copy of this zonegroup. */
virtual std::unique_ptr<ZoneGroup> clone() = 0;
};
/** Get info about the zonegroup containing this zone */
virtual ZoneGroup& get_zonegroup() = 0;
/** Get the ID of this zone */
- virtual const rgw_zone_id& get_id() = 0;
+ virtual const std::string& get_id() = 0;
/** Get the name of this zone */
virtual const std::string& get_name() const = 0;
/** True if this zone is writable */
return *zone_params;
}
- const rgw_zone_id& DBZone::get_id()
+ const std::string& DBZone::get_id()
{
- return cur_zone_id;
+ return zone_params->get_id();
}
std::unique_ptr<PlacementTier>* tier) {
return -1;
}
+ virtual int get_zone_by_id(const std::string& id, std::unique_ptr<Zone>* zone) override {
+ return -1;
+ }
+ virtual int get_zone_by_name(const std::string& name, std::unique_ptr<Zone>* zone) override {
+ return -1;
+ }
virtual std::unique_ptr<ZoneGroup> clone() override {
std::unique_ptr<RGWZoneGroup>zg = std::make_unique<RGWZoneGroup>(*group.get());
return std::make_unique<DBZoneGroup>(store, std::move(zg));
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;
public:
DBZone(DBStore* _store) : store(_store) {
zone_public_config = new RGWZone();
zone_params = new RGWZoneParams();
current_period = new RGWPeriod();
- cur_zone_id = rgw_zone_id(zone_params->get_id());
// XXX: only default and STANDARD supported for now
RGWZonePlacementInfo info;
}
virtual ZoneGroup& get_zonegroup() override;
const RGWZoneParams& get_rgw_params();
- virtual const rgw_zone_id& get_id() override;
+ virtual const std::string& get_id() override;
virtual const std::string& get_name() const override;
virtual bool is_writeable() override;
virtual bool get_redirect_endpoint(std::string* endpoint) override;
return 0;
}
+int FilterZoneGroup::get_zone_by_id(const std::string& id, std::unique_ptr<Zone>* zone)
+{
+ std::unique_ptr<Zone> nz;
+ int ret = next->get_zone_by_id(id, &nz);
+ if (ret < 0)
+ return ret;
+ Zone *z = new FilterZone(std::move(nz));
+
+ zone->reset(z);
+ return 0;
+}
+
+int FilterZoneGroup::get_zone_by_name(const std::string& name, std::unique_ptr<Zone>* zone)
+{
+ std::unique_ptr<Zone> nz;
+ int ret = next->get_zone_by_name(name, &nz);
+ if (ret < 0)
+ return ret;
+ Zone *z = new FilterZone(std::move(nz));
+
+ zone->reset(z);
+ return 0;
+}
+
int FilterStore::initialize(CephContext *cct, const DoutPrefixProvider *dpp)
{
zone = std::make_unique<FilterZone>(next->get_zone()->clone());
virtual int get_zone_count() const override
{ return next->get_zone_count(); }
virtual int get_placement_tier(const rgw_placement_rule& rule, std::unique_ptr<PlacementTier>* tier) override;
+ virtual int get_zone_by_id(const std::string& id, std::unique_ptr<Zone>* zone) override;
+ virtual int get_zone_by_name(const std::string& name, std::unique_ptr<Zone>* zone) override;
virtual std::unique_ptr<ZoneGroup> clone() override {
std::unique_ptr<ZoneGroup> nzg = next->clone();
return std::make_unique<FilterZoneGroup>(std::move(nzg));
virtual ZoneGroup& get_zonegroup() override {
return *group.get();
}
- virtual const rgw_zone_id& get_id() override {
+ virtual const std::string& get_id() override {
return next->get_id();
}
virtual const std::string& get_name() const override {
return zonegroup;
}
-const rgw_zone_id& MotrZone::get_id()
+const std::string& MotrZone::get_id()
{
- return cur_zone_id;
+ return zone_params->get_id();
}
const std::string& MotrZone::get_name() const
return group.zones.size();
}
virtual int get_placement_tier(const rgw_placement_rule& rule, std::unique_ptr<PlacementTier>* tier);
+ virtual int get_zone_by_id(const std::string& id, std::unique_ptr<Zone>* zone) override {
+ return -1;
+ }
+ virtual int get_zone_by_name(const std::string& name, std::unique_ptr<Zone>* zone) override {
+ return -1;
+ }
const RGWZoneGroup& get_group() { return group; }
virtual std::unique_ptr<ZoneGroup> clone() override {
return std::make_unique<MotrZoneGroup>(store, group);
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;
public:
MotrZone(MotrStore* _store) : store(_store), zonegroup(_store) {
zone_public_config = new RGWZone();
zone_params = new RGWZoneParams();
current_period = new RGWPeriod();
- cur_zone_id = rgw_zone_id(zone_params->get_id());
// XXX: only default and STANDARD supported for now
RGWZonePlacementInfo info;
zone_public_config = new RGWZone();
zone_params = new RGWZoneParams();
current_period = new RGWPeriod();
- cur_zone_id = rgw_zone_id(zone_params->get_id());
// XXX: only default and STANDARD supported for now
RGWZonePlacementInfo info;
return std::make_unique<MotrZone>(store);
}
virtual ZoneGroup& get_zonegroup() override;
- virtual const rgw_zone_id& get_id() override;
+ virtual const std::string& get_id() override;
virtual const std::string& get_name() const override;
virtual bool is_writeable() override;
virtual bool get_redirect_endpoint(std::string* endpoint) override;
return 0;
}
-const rgw_zone_id& RadosZone::get_id()
+int RadosZoneGroup::get_zone_by_id(const std::string& id, std::unique_ptr<Zone>* zone)
{
- return store->svc()->zone->zone_id();
+ RGWZone* rz = store->svc()->zone->find_zone(id);
+ if (!rz)
+ return -ENOENT;
+
+ Zone* z = new RadosZone(store, clone(), *rz);
+ zone->reset(z);
+ return 0;
+}
+
+int RadosZoneGroup::get_zone_by_name(const std::string& name, std::unique_ptr<Zone>* zone)
+{
+ rgw_zone_id id;
+ int ret = store->svc()->zone->find_zone_id_by_name(name, &id);
+ if (ret < 0)
+ return ret;
+
+ RGWZone* rz = store->svc()->zone->find_zone(id.id);
+ if (!rz)
+ return -ENOENT;
+
+ Zone* z = new RadosZone(store, clone(), *rz);
+ zone->reset(z);
+ return 0;
+}
+
+std::unique_ptr<Zone> RadosZone::clone()
+{
+ if (local_zone)
+ return std::make_unique<RadosZone>(store, group->clone());
+
+ return std::make_unique<RadosZone>(store, group->clone(), rgw_zone);
+}
+
+const std::string& RadosZone::get_id()
+{
+ if (local_zone)
+ return store->svc()->zone->zone_id().id;
+
+ return rgw_zone.id;
}
const std::string& RadosZone::get_name() const
{
- return store->svc()->zone->zone_name();
+ if (local_zone)
+ return store->svc()->zone->zone_name();
+
+ return rgw_zone.name;
}
bool RadosZone::is_writeable()
{
- return store->svc()->zone->zone_is_writeable();
+ if (local_zone)
+ return store->svc()->zone->zone_is_writeable();
+
+ return !rgw_zone.read_only;
}
bool RadosZone::get_redirect_endpoint(std::string* endpoint)
{
- return store->svc()->zone->get_redirect_zone_endpoint(endpoint);
+ if (local_zone)
+ return store->svc()->zone->get_redirect_zone_endpoint(endpoint);
+
+ endpoint = &rgw_zone.redirect_zone;
+ return true;
}
bool RadosZone::has_zonegroup_api(const std::string& api) const
const std::string_view RadosZone::get_tier_type()
{
- return store->svc()->zone->get_zone().tier_type;
+ if (local_zone)
+ return store->svc()->zone->get_zone().tier_type;
+
+ return rgw_zone.id;
}
RadosLuaManager::RadosLuaManager(RadosStore* _s) :
return group.zones.size();
}
virtual int get_placement_tier(const rgw_placement_rule& rule, std::unique_ptr<PlacementTier>* tier);
- const RGWZoneGroup& get_group() const { return group; }
+ virtual int get_zone_by_id(const std::string& id, std::unique_ptr<Zone>* zone) override;
+ virtual int get_zone_by_name(const std::string& name, std::unique_ptr<Zone>* zone) override;
virtual std::unique_ptr<ZoneGroup> clone() override {
return std::make_unique<RadosZoneGroup>(store, group);
}
+ const RGWZoneGroup& get_group() const { return group; }
};
class RadosZone : public StoreZone {
protected:
RadosStore* store;
std::unique_ptr<ZoneGroup> group;
+ RGWZone rgw_zone;
+ bool local_zone{false};
public:
- RadosZone(RadosStore* _store, std::unique_ptr<ZoneGroup> _zg) : store(_store), group(std::move(_zg)) {}
+ RadosZone(RadosStore* _store, std::unique_ptr<ZoneGroup> _zg) : store(_store), group(std::move(_zg)), local_zone(true) {}
+ RadosZone(RadosStore* _store, std::unique_ptr<ZoneGroup> _zg, RGWZone& z) : store(_store), group(std::move(_zg)), rgw_zone(z) {}
~RadosZone() = default;
- virtual std::unique_ptr<Zone> clone() override {
- return std::make_unique<RadosZone>(store, group->clone());
- }
+ virtual std::unique_ptr<Zone> clone() override;
virtual ZoneGroup& get_zonegroup() override { return *(group.get()); }
- virtual const rgw_zone_id& get_id() override;
+ virtual const std::string& get_id() override;
virtual const std::string& get_name() const override;
virtual bool is_writeable() override;
virtual bool get_redirect_endpoint(std::string* endpoint) override;