virtual ~DaosPlacementTier() = default;
virtual const std::string& get_tier_type() { return tier.tier_type; }
+ virtual bool is_tier_type_s3() { return (tier.is_tier_type_s3()); }
virtual const std::string& get_storage_class() { return tier.storage_class; }
virtual bool retain_head_object() { return tier.retain_head_object; }
+ virtual bool allow_read_through() { return tier.allow_read_through; }
+ virtual uint64_t get_read_through_restore_days() { return tier.read_through_restore_days; }
RGWZoneGroupPlacementTier& get_rt() { return tier; }
};
virtual ~MotrPlacementTier() = default;
virtual const std::string& get_tier_type() { return tier.tier_type; }
+ virtual bool is_tier_type_s3() { return (tier.is_tier_type_s3()); }
virtual const std::string& get_storage_class() { return tier.storage_class; }
virtual bool retain_head_object() { return tier.retain_head_object; }
+ virtual bool allow_read_through() { return tier.allow_read_through; }
+ virtual uint64_t get_read_through_restore_days() { return tier.read_through_restore_days; }
RGWZoneGroupPlacementTier& get_rt() { return tier; }
};
rgw::sal::Driver *driver;
RGWBucketInfo& bucket_info;
std::string storage_class;
+ std::string restore_storage_class;
+ std::string tier_type;
rgw::sal::Object *obj;
::encode_json("tail_placement", tail_placement, f);
::encode_json("tier_type", tier_type, f);
- if (tier_type == "cloud-s3") {
+ if (tier_type == "cloud-s3" || tier_type == "cloud-s3-glacier") {
::encode_json("tier_config", tier_config, f);
}
return tier_type;
}
+ bool is_tier_type_s3() {
+ return (tier_type == "cloud-s3" || tier_type == "cloud-s3-glacier");
+ }
+
+ bool is_tier_type_s3_glacier() {
+ return (tier_type == "cloud-s3-glacier");
+ }
+
inline void set_tier_type(std::string value) {
- /* Only "cloud-s3" tier-type is supported for now */
- if (value == "cloud-s3") {
+ /* Only "cloud-s3" & "cloud-s3-glacier" tier-type is supported for now */
+ if (value == "cloud-s3" || value == "cloud-s3-glacier") {
tier_type = value;
}
}
inline void set_tier_config(RGWObjTier t) {
- /* Set only if tier_type set to "cloud-s3" */
- if (tier_type != "cloud-s3")
+ /* Set only if tier_type set to "cloud-s3" or "cloud-s3-glacier" */
+ if (!is_tier_type_s3())
return;
tier_config.name = t.name;
}
inline const void get_tier_config(RGWObjTier* t) {
- if (tier_type != "cloud-s3")
+ if (!is_tier_type_s3())
return;
t->name = tier_config.name;
auto i = attr_iter->second;
string m = i.to_str();
- if (m == "cloud-s3") {
+ if (m == "cloud-s3" || m == "cloud-s3-glacier") {
category = RGWObjCategory::CloudTiered;
- manifest.set_tier_type("cloud-s3");
+ manifest.set_tier_type(m);
auto config_iter = attrs.find(RGW_ATTR_CLOUD_TIER_CONFIG);
if (config_iter != attrs.end()) {
}
boost::optional<RGWPutObj_Compress> compressor;
CompressorRef plugin;
+ dest_placement.storage_class = tier_ctx.restore_storage_class;
RGWRadosPutObj cb(dpp, cct, plugin, compressor, &processor, progress_cb, progress_data,
[&](map<string, bufferlist> obj_attrs) {
- // XXX: do we need filter() like in fetch_remote_obj() cb
+ // XXX: do we need filter() lke in fetch_remote_obj() cb
dest_placement.inherit_from(dest_bucket_info.placement_rule);
/* For now we always restore to STANDARD storage-class.
* Later we will add support to take restore-target-storage-class
* for permanent restore
*/
- dest_placement.storage_class = RGW_STORAGE_CLASS_STANDARD;
+ // dest_placement.storage_class = RGW_STORAGE_CLASS_STANDARD;
processor.set_tail_placement(dest_placement);
// set tier-config only for temp restored objects, as
// permanent copies will be treated as regular objects
{
- t.append("cloud-s3");
+ t.append(tier_ctx.tier_type);
encode(tier_config, t_tier);
attrs[RGW_ATTR_CLOUD_TIER_TYPE] = t;
attrs[RGW_ATTR_CLOUD_TIER_CONFIG] = t_tier;
const rgw::sal::ZoneGroup& zonegroup = store->get_zone()->get_zonegroup();
int ret = 0;
string src_storage_class = o.meta.storage_class; // or take src_placement also as input
+ // update tier_config in case tier params are updated
+ tier_config.tier_placement = rtier->get_rt();
if (bucket_name.empty()) {
bucket_name = "rgwx-" + zonegroup.get_name() + "-" + tier->get_storage_class() +
tier_ctx.multipart_min_part_size = rtier->get_rt().t.s3.multipart_min_part_size;
tier_ctx.multipart_sync_threshold = rtier->get_rt().t.s3.multipart_sync_threshold;
tier_ctx.storage_class = tier->get_storage_class();
+ tier_ctx.restore_storage_class = rtier->get_rt().restore_storage_class;
+ tier_ctx.tier_type = rtier->get_rt().tier_type;
ldpp_dout(dpp, 20) << "Restoring object(" << o.key << ") from the cloud endpoint(" << endpoint << ")" << dendl;
tier_config.tier_placement = rtier->get_rt();
tier_config.is_multipart_upload = is_multipart_upload;
- pmanifest->set_tier_type("cloud-s3");
+ pmanifest->set_tier_type(rtier->get_rt().tier_type);
pmanifest->set_tier_config(tier_config);
/* check if its necessary */
virtual ~RadosPlacementTier() = default;
virtual const std::string& get_tier_type() { return tier.tier_type; }
+ virtual bool is_tier_type_s3() { return (tier.is_tier_type_s3()); }
virtual const std::string& get_storage_class() { return tier.storage_class; }
virtual bool retain_head_object() { return tier.retain_head_object; }
+ virtual bool allow_read_through() { return tier.allow_read_through; }
+ virtual uint64_t get_read_through_restore_days() { return tier.read_through_restore_days; }
RGWZoneGroupPlacementTier& get_rt() { return tier; }
};
}
}
- if (tier_type == "cloud-s3") {
+ if (is_tier_type_s3()) {
r = t.s3.update_params(config);
}
+ if (config.exists("restore_storage_class")) {
+ restore_storage_class = config["restore_storage_class"];
+ }
+
+ if (is_tier_type_s3_glacier()) {
+ r = s3_glacier.update_params(config);
+ }
return r;
}
read_through_restore_days = DEFAULT_READ_THROUGH_RESTORE_DAYS;
}
- if (tier_type == "cloud-s3") {
+ if (is_tier_type_s3()) {
t.s3.clear_params(config);
}
+ if (config.exists("restore_storage_class")) {
+ restore_storage_class = RGW_STORAGE_CLASS_STANDARD;
+ }
+
+ if (is_tier_type_s3_glacier()) {
+ s3_glacier.clear_params(config);
+ }
+
return 0;
}
return 0;
}
+int RGWZoneGroupTierS3Glacier::update_params(const JSONFormattable& config)
+{
+ int r = -1;
+
+ if (config.exists("glacier_restore_days")) {
+ r = conf_to_uint64(config, "glacier_restore_days", &glacier_restore_days);
+ if (r < 0) {
+ glacier_restore_days = DEFAULT_GLACIER_RESTORE_DAYS;
+ }
+ }
+ if (config.exists("glacier_restore_tier_type")) {
+ string s;
+ s = config["glacier_restore_tier_type"];
+ if (s != "Expedited") {
+ glacier_restore_tier_type = Standard;
+ } else {
+ glacier_restore_tier_type = Expedited;
+ }
+ }
+ return 0;
+}
+
+int RGWZoneGroupTierS3Glacier::clear_params(const JSONFormattable& config)
+{
+ if (config.exists("glacier_restore_days")) {
+ glacier_restore_days = DEFAULT_GLACIER_RESTORE_DAYS;
+ }
+ if (config.exists("glacier_restore_tier_type")) {
+ /* default */
+ glacier_restore_tier_type = Standard;
+ }
+ return 0;
+}
+
void rgw_meta_sync_info::generate_test_instances(list<rgw_meta_sync_info*>& o)
{
auto info = new rgw_meta_sync_info;
/* Tier options */
bool tier_class = false;
std::string storage_class = rule.get_storage_class();
- RGWZoneGroupPlacementTier t{storage_class};
+ RGWZoneGroupPlacementTier t;
RGWZoneGroupPlacementTier *pt = &t;
auto ptiter = target.tier_targets.find(storage_class);
pt = &ptiter->second;
tier_class = true;
} else if (tier_type_specified) {
- if (tier_type == "cloud-s3") {
- /* we support only cloud-s3 tier-type for now.
+ if (tier_type == "cloud-s3" || tier_type == "cloud-s3-glacier") {
+ /* we support only cloud-s3 & cloud-s3-glacier tier-type for now.
* Once set cant be reset. */
tier_class = true;
pt->tier_type = tier_type;
r = zonegroup.get_placement_tier(target_placement, &oc.tier);
- if (!r && oc.tier->get_tier_type() == "cloud-s3") {
+ if (!r && oc.tier->is_tier_type_s3()) {
ldpp_dout(oc.dpp, 30) << "Found cloud s3 tier: " << target_placement.storage_class << dendl;
if (!oc.o.is_current() &&
!pass_object_lock_check(oc.driver, oc.obj.get(), oc.dpp)) {
RGWObjManifest m;
try {
decode(m, attr_iter->second);
- if (m.get_tier_type() != "cloud-s3") {
+ if (!m.is_tier_type_s3()) {
ldpp_dout(dpp, 20) << "not a cloud tier object " << s->object->get_key().name << dendl;
if (restore_op) {
op_ret = -ERR_INVALID_OBJECT_STATE;
m.get_tier_config(&tier_config);
if (sync_cloudtiered) {
bufferlist t, t_tier;
- t.append("cloud-s3");
+ t.append(m.get_tier_type());
attrs[RGW_ATTR_CLOUD_TIER_TYPE] = t;
encode(tier_config, t_tier);
attrs[RGW_ATTR_CLOUD_TIER_CONFIG] = t_tier;
s->err.message = "failed to restore object";
return op_ret;
}
- rgw::sal::RadosPlacementTier* rtier = static_cast<rgw::sal::RadosPlacementTier*>(tier.get());
- tier_config.tier_placement = rtier->get_rt();
if (!restore_op) {
- if (tier_config.tier_placement.allow_read_through) {
- days = tier_config.tier_placement.read_through_restore_days;
+ if (tier->allow_read_through()) {
+ days = tier->get_read_through_restore_days();
} else { //read-through is not enabled
op_ret = -ERR_INVALID_OBJECT_STATE;
s->err.message = "Read through is not enabled for this config";
RGWObjManifest m;
try{
decode(m, bl);
- if (m.get_tier_type() == "cloud-s3") {
+ if (m.is_tier_type_s3()) {
op_ret = -ERR_INVALID_OBJECT_STATE;
s->err.message = "This object was transitioned to cloud-s3";
ldpp_dout(this, 4) << "Cannot copy cloud tiered object. Failing with "
RGWObjManifest m;
try{
decode(m, bl);
- if (m.get_tier_type() == "cloud-s3") {
+ if (m.is_tier_type_s3()) {
op_ret = -ERR_INVALID_OBJECT_STATE;
s->err.message = "This object was transitioned to cloud-s3";
ldpp_dout(this, 4) << "Cannot copy cloud tiered object. Failing with "
/** Get the type of this tier */
virtual const std::string& get_tier_type() = 0;
+ /** Is the type of this tier cloud-s3/clous-s3-glacier */
+ virtual bool is_tier_type_s3() = 0;
/** Get the storage class of this tier */
virtual const std::string& get_storage_class() = 0;
/** Should we retain the head object when transitioning */
virtual bool retain_head_object() = 0;
+ /** Is read_through allowed */
+ virtual bool allow_read_through() = 0;
+ /** Get read_through restore_days */
+ virtual uint64_t get_read_through_restore_days() = 0;
/** Get the placement rule associated with this tier */
};
virtual ~DBPlacementTier() = default;
virtual const std::string& get_tier_type() { return tier.tier_type; }
+ virtual bool is_tier_type_s3() { return (tier.is_tier_type_s3()); }
virtual const std::string& get_storage_class() { return tier.storage_class; }
+ virtual bool allow_read_through() { return tier.allow_read_through; }
+ virtual uint64_t get_read_through_restore_days() { return tier.read_through_restore_days; }
virtual bool retain_head_object() { return tier.retain_head_object; }
RGWZoneGroupPlacementTier& get_rt() { return tier; }
};
virtual ~FilterPlacementTier() = default;
virtual const std::string& get_tier_type() override { return next->get_tier_type(); }
+ virtual bool is_tier_type_s3() { return next->is_tier_type_s3(); }
virtual const std::string& get_storage_class() override { return next->get_storage_class(); }
virtual bool retain_head_object() override { return next->retain_head_object(); }
+ virtual bool allow_read_through() { return next->allow_read_through(); }
+ virtual uint64_t get_read_through_restore_days() { return next->get_read_through_restore_days(); }
/* Internal to Filters */
PlacementTier* get_next() { return next.get(); }
JSONDecoder::decode_json("tier_type", tier_type, obj);
JSONDecoder::decode_json("storage_class", storage_class, obj);
JSONDecoder::decode_json("retain_head_object", retain_head_object, obj);
+ if (is_tier_type_s3()) {
+ JSONDecoder::decode_json("s3", t.s3, obj);
+ }
JSONDecoder::decode_json("allow_read_through", allow_read_through, obj);
JSONDecoder::decode_json("read_through_restore_days", read_through_restore_days, obj);
-
- if (tier_type == "cloud-s3") {
- JSONDecoder::decode_json("s3", t.s3, obj);
+ JSONDecoder::decode_json("restore_storage_class", restore_storage_class, obj);
+ if (is_tier_type_s3_glacier()) {
+ JSONDecoder::decode_json("s3-glacier", s3_glacier, obj);
}
}
standard_class = &m[RGW_STORAGE_CLASS_STANDARD];
}
+void RGWZoneGroupTierS3Glacier::dump(Formatter *f) const
+{
+ encode_json("glacier_restore_days", glacier_restore_days, f);
+ string s = (glacier_restore_tier_type == Standard ? "Standard" : "Expedited");
+ encode_json("glacier_restore_tier_type", s, f);
+}
+
+void RGWZoneGroupTierS3Glacier::decode_json(JSONObj *obj)
+{
+ JSONDecoder::decode_json("glacier_restore_days", glacier_restore_days, obj);
+ string s;
+ JSONDecoder::decode_json("glacier_restore_tier_type", s, obj);
+ if (s != "Expedited") {
+ glacier_restore_tier_type = Standard;
+ } else {
+ glacier_restore_tier_type = Expedited;
+ }
+}
+
void RGWZoneGroupPlacementTier::dump(Formatter *f) const
{
encode_json("tier_type", tier_type, f);
encode_json("storage_class", storage_class, f);
encode_json("retain_head_object", retain_head_object, f);
+ if (is_tier_type_s3()) {
+ encode_json("s3", t.s3, f);
+ }
encode_json("allow_read_through", allow_read_through, f);
encode_json("read_through_restore_days", read_through_restore_days, f);
+ encode_json("restore_storage_class", restore_storage_class, f);
- if (tier_type == "cloud-s3") {
- encode_json("s3", t.s3, f);
+ if (is_tier_type_s3_glacier()) {
+ encode_json("s3-glacier", s3_glacier, f);
}
}
};
WRITE_CLASS_ENCODER(RGWZoneGroupPlacementTierS3)
+enum GlacierRestoreTierType : uint8_t {
+ Standard = 0,
+ Expedited = 1,
+};
+
+struct RGWZoneGroupTierS3Glacier {
+#define DEFAULT_GLACIER_RESTORE_DAYS 1
+ uint64_t glacier_restore_days = DEFAULT_GLACIER_RESTORE_DAYS;
+ GlacierRestoreTierType glacier_restore_tier_type{Standard};
+
+ int update_params(const JSONFormattable& config);
+ int clear_params(const JSONFormattable& config);
+
+ void encode(bufferlist& bl) const {
+ ENCODE_START(1, 1, bl);
+ encode(glacier_restore_days, bl);
+ encode(glacier_restore_tier_type, bl);
+ ENCODE_FINISH(bl);
+ }
+
+ void decode(bufferlist::const_iterator& bl) {
+ DECODE_START(1, bl);
+ decode(glacier_restore_days, bl);
+ decode(glacier_restore_tier_type, bl);
+ DECODE_FINISH(bl);
+ }
+ void dump(Formatter *f) const;
+ void decode_json(JSONObj *obj);
+ static void generate_test_instances(std::list<RGWZoneGroupTierS3Glacier*>& o) {
+ o.push_back(new RGWZoneGroupTierS3Glacier);
+ o.back()->glacier_restore_days = 2;
+ o.back()->glacier_restore_tier_type = GlacierRestoreTierType::Expedited;
+ }
+};
+WRITE_CLASS_ENCODER(RGWZoneGroupTierS3Glacier)
+
struct RGWZoneGroupPlacementTier {
#define DEFAULT_READ_THROUGH_RESTORE_DAYS 1
bool allow_read_through = false;
uint64_t read_through_restore_days = 1;
+ std::string restore_storage_class = RGW_STORAGE_CLASS_STANDARD;
+
+ RGWZoneGroupTierS3Glacier s3_glacier;
int update_params(const JSONFormattable& config);
int clear_params(const JSONFormattable& config);
void encode(bufferlist& bl) const {
- ENCODE_START(3, 1, bl);
+ ENCODE_START(4, 1, bl);
encode(tier_type, bl);
encode(storage_class, bl);
encode(retain_head_object, bl);
- if (tier_type == "cloud-s3") {
+ if (is_tier_type_s3()) {
encode(t.s3, bl);
}
encode(allow_read_through, bl);
encode(read_through_restore_days, bl);
+ encode(restore_storage_class, bl);
+ if (is_tier_type_s3_glacier()) {
+ encode(s3_glacier, bl);
+ }
ENCODE_FINISH(bl);
}
decode(t.s3, bl);
}
} else if (struct_v >= 3) {
- if (tier_type == "cloud-s3") {
+ if (is_tier_type_s3()) {
decode(t.s3, bl);
}
decode(allow_read_through, bl);
decode(read_through_restore_days, bl);
}
+ if (struct_v >= 4) {
+ decode(restore_storage_class, bl);
+ if (is_tier_type_s3_glacier()) {
+ decode(s3_glacier, bl);
+ }
+ }
DECODE_FINISH(bl);
}
+ bool is_tier_type_s3() const {
+ return (tier_type == "cloud-s3" || tier_type == "cloud-s3-glacier");
+ }
+
+ bool is_tier_type_s3_glacier() const {
+ return (tier_type == "cloud-s3-glacier");
+ }
+
void dump(Formatter *f) const;
void decode_json(JSONObj *obj);
static void generate_test_instances(std::list<RGWZoneGroupPlacementTier*>& o) {
o.push_back(new RGWZoneGroupPlacementTier);
o.back()->tier_type = "cloud-s3";
o.back()->storage_class = "STANDARD";
+ o.back()->allow_read_through = false;
+ o.back()->restore_storage_class = "STANDARD";
+ o.back()->s3_glacier.glacier_restore_days = 2;
+ o.back()->s3_glacier.glacier_restore_tier_type = GlacierRestoreTierType::Expedited;
}
};
WRITE_CLASS_ENCODER(RGWZoneGroupPlacementTier)