encode_json("sync_from_all", sync_from_all, f);
encode_json("sync_from", sync_from, f);
encode_json("redirect_zone", redirect_zone, f);
+ encode_json("supported_features", supported_features, f);
}
void RGWZone::decode_json(JSONObj *obj)
JSONDecoder::decode_json("sync_from_all", sync_from_all, true, obj);
JSONDecoder::decode_json("sync_from", sync_from, obj);
JSONDecoder::decode_json("redirect_zone", redirect_zone, obj);
+ JSONDecoder::decode_json("supported_features", supported_features, obj);
}
void RGWZoneGroupPlacementTarget::dump(Formatter *f) const
encode_json("default_placement", default_placement, f);
encode_json("realm_id", realm_id, f);
encode_json("sync_policy", sync_policy, f);
+ encode_json("enabled_features", enabled_features, f);
}
static void decode_zones(map<rgw_zone_id, RGWZone>& zones, JSONObj *o)
JSONDecoder::decode_json("default_storage_class", default_placement.storage_class, obj);
JSONDecoder::decode_json("realm_id", realm_id, obj);
JSONDecoder::decode_json("sync_policy", sync_policy, obj);
+ JSONDecoder::decode_json("enabled_features", enabled_features, obj);
}
#include "rgw_common.h"
#include "rgw_sync_policy.h"
+#include "rgw_zone_features.h"
namespace rgw_zone_defaults {
bool sync_from_all;
std::set<std::string> sync_from; /* list of zones to sync from */
+ rgw::zone_features::set supported_features;
+
RGWZone()
: log_meta(false), log_data(false), read_only(false),
bucket_index_max_shards(default_bucket_index_max_shards),
sync_from_all(true) {}
void encode(bufferlist& bl) const {
- ENCODE_START(7, 1, bl);
+ ENCODE_START(8, 1, bl);
encode(name, bl);
encode(endpoints, bl);
encode(log_meta, bl);
encode(sync_from_all, bl);
encode(sync_from, bl);
encode(redirect_zone, bl);
+ encode(supported_features, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::const_iterator& bl) {
- DECODE_START(7, bl);
+ DECODE_START(8, bl);
decode(name, bl);
if (struct_v < 4) {
id = name;
if (struct_v >= 7) {
decode(redirect_zone, bl);
}
+ if (struct_v >= 8) {
+ decode(supported_features, bl);
+ }
DECODE_FINISH(bl);
}
void dump(Formatter *f) const;
bool syncs_from(const std::string& zone_name) const {
return (sync_from_all || sync_from.find(zone_name) != sync_from.end());
}
+
+ bool supports(std::string_view feature) const {
+ return supported_features.contains(feature);
+ }
};
WRITE_CLASS_ENCODER(RGWZone)
std::string realm_id;
rgw_sync_policy_info sync_policy;
+ rgw::zone_features::set enabled_features;
RGWZoneGroup(): is_master(false){}
RGWZoneGroup(const std::string &id, const std::string &name):RGWSystemMetaObj(id, name) {}
void post_process_params(const DoutPrefixProvider *dpp, optional_yield y);
void encode(bufferlist& bl) const override {
- ENCODE_START(5, 1, bl);
+ ENCODE_START(6, 1, bl);
encode(name, bl);
encode(api_name, bl);
encode(is_master, bl);
RGWSystemMetaObj::encode(bl);
encode(realm_id, bl);
encode(sync_policy, bl);
+ encode(enabled_features, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::const_iterator& bl) override {
- DECODE_START(5, bl);
+ DECODE_START(6, bl);
decode(name, bl);
decode(api_name, bl);
decode(is_master, bl);
if (struct_v >= 5) {
decode(sync_policy, bl);
}
+ if (struct_v >= 6) {
+ decode(enabled_features, bl);
+ }
DECODE_FINISH(bl);
}
void dump(Formatter *f) const;
void decode_json(JSONObj *obj);
static void generate_test_instances(std::list<RGWZoneGroup*>& o);
+
+ bool supports(std::string_view feature) const {
+ return enabled_features.contains(feature);
+ }
};
WRITE_CLASS_ENCODER(RGWZoneGroup)
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab ft=cpp
+
+#pragma once
+
+#include <string>
+#include <boost/container/flat_set.hpp>
+
+namespace rgw::zone_features {
+
+// zone feature names
+inline constexpr std::string_view resharding = "resharding";
+
+// static list of features supported by this release
+inline constexpr std::initializer_list<std::string_view> supported = {
+ resharding,
+};
+
+inline constexpr bool supports(std::string_view feature) {
+ for (auto i : supported) {
+ if (feature.compare(i) == 0) {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+// enable string_view overloads for find() contains() etc
+struct feature_less : std::less<std::string_view> {
+ using is_transparent = std::true_type;
+};
+
+using set = boost::container::flat_set<std::string, feature_less>;
+
+} // namespace rgw::zone_features