Skip to content

Commit 38d2c11

Browse files
committed
rgw/cloud-tier: Redefining cloud tier types
Signed-off-by: Soumya Koduri <[email protected]>
1 parent b1ddd68 commit 38d2c11

File tree

5 files changed

+32
-18
lines changed

5 files changed

+32
-18
lines changed

src/rgw/driver/rados/rgw_obj_manifest.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ void RGWObjManifest::dump(Formatter *f) const
347347
::encode_json("tail_placement", tail_placement, f);
348348
::encode_json("tier_type", tier_type, f);
349349

350-
if (tier_type == "cloud-s3" || tier_type == "cloud-s3-glacier") {
350+
if (RGWTierType::is_tier_type_supported(tier_type)) {
351351
::encode_json("tier_config", tier_config, f);
352352
}
353353

src/rgw/driver/rados/rgw_obj_manifest.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,22 +472,25 @@ class RGWObjManifest {
472472
}
473473

474474
bool is_tier_type_s3() {
475-
return (tier_type == "cloud-s3" || tier_type == "cloud-s3-glacier");
475+
return (tier_type == RGWTierType::CLOUD_S3 ||
476+
tier_type == RGWTierType::CLOUD_S3_GLACIER);
476477
}
477478

478479
bool is_tier_type_s3_glacier() {
479-
return (tier_type == "cloud-s3-glacier");
480+
return (tier_type == RGWTierType::CLOUD_S3_GLACIER);
480481
}
481482

482483
inline void set_tier_type(std::string value) {
483-
/* Only "cloud-s3" & "cloud-s3-glacier" tier-type is supported for now */
484-
if (value == "cloud-s3" || value == "cloud-s3-glacier") {
484+
/* Only RGWTierType::CLOUD_S3 & RGWTierType::CLOUD_S3_GLACIER
485+
* tier-type are supported for now */
486+
if (RGWTierType::is_tier_type_supported(value)) {
485487
tier_type = value;
486488
}
487489
}
488490

489491
inline void set_tier_config(RGWObjTier t) {
490-
/* Set only if tier_type set to "cloud-s3" or "cloud-s3-glacier" */
492+
/* Set only if tier_type set to RGWTierType::CLOUD_S3 or
493+
* RGWTierType::CLOUD_S3_GLACIER */
491494
if (!is_tier_type_s3())
492495
return;
493496

src/rgw/driver/rados/rgw_putobj_processor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ int read_cloudtier_info_from_attrs(rgw::sal::Attrs& attrs, RGWObjCategory& categ
4545
auto i = attr_iter->second;
4646
string m = i.to_str();
4747

48-
if (m == "cloud-s3" || m == "cloud-s3-glacier") {
48+
if (RGWTierType::is_tier_type_supported(m)) {
4949
category = RGWObjCategory::CloudTiered;
5050
manifest.set_tier_type(m);
5151

src/rgw/radosgw-admin/radosgw-admin.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5937,7 +5937,7 @@ int main(int argc, const char **argv)
59375937
pt = &ptiter->second;
59385938
tier_class = true;
59395939
} else if (tier_type_specified) {
5940-
if (tier_type == "cloud-s3" || tier_type == "cloud-s3-glacier") {
5940+
if (RGWTierType::is_tier_type_supported(tier_type)) {
59415941
/* we support only cloud-s3 & cloud-s3-glacier tier-type for now.
59425942
* Once set cant be reset. */
59435943
tier_class = true;

src/rgw/rgw_zone_types.h

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,16 @@ struct RGWZoneGroupTierS3Glacier {
578578
};
579579
WRITE_CLASS_ENCODER(RGWZoneGroupTierS3Glacier)
580580

581+
582+
struct RGWTierType {
583+
static constexpr const char* CLOUD_S3 = "cloud-s3";
584+
static constexpr const char* CLOUD_S3_GLACIER = "cloud-s3-glacier";
585+
586+
static bool is_tier_type_supported(const std::string& t) {
587+
return ((t == CLOUD_S3) || (t == CLOUD_S3_GLACIER));
588+
}
589+
};
590+
581591
struct RGWZoneGroupPlacementTier {
582592
#define DEFAULT_READ_THROUGH_RESTORE_DAYS 1
583593

@@ -621,13 +631,13 @@ struct RGWZoneGroupPlacementTier {
621631
decode(storage_class, bl);
622632
decode(retain_head_object, bl);
623633
if (struct_v == 1) {
624-
if (tier_type == "cloud-s3") {
634+
if (tier_type == RGWTierType::CLOUD_S3) {
625635
decode(t.s3, bl);
626636
}
627637
} else if (struct_v == 2) {
628638
decode(allow_read_through, bl);
629639
decode(read_through_restore_days, bl);
630-
if (tier_type == "cloud-s3") {
640+
if (tier_type == RGWTierType::CLOUD_S3) {
631641
decode(t.s3, bl);
632642
}
633643
} else if (struct_v >= 3) {
@@ -647,22 +657,23 @@ struct RGWZoneGroupPlacementTier {
647657
}
648658

649659
bool is_tier_type_s3() const {
650-
return (tier_type == "cloud-s3" || tier_type == "cloud-s3-glacier");
660+
return (tier_type == RGWTierType::CLOUD_S3 ||
661+
tier_type == RGWTierType::CLOUD_S3_GLACIER);
651662
}
652663

653664
bool is_tier_type_s3_glacier() const {
654-
return (tier_type == "cloud-s3-glacier");
665+
return (tier_type == RGWTierType::CLOUD_S3_GLACIER);
655666
}
656667

657668
void dump(Formatter *f) const;
658669
void decode_json(JSONObj *obj);
659670
static void generate_test_instances(std::list<RGWZoneGroupPlacementTier*>& o) {
660671
o.push_back(new RGWZoneGroupPlacementTier);
661672
o.push_back(new RGWZoneGroupPlacementTier);
662-
o.back()->tier_type = "cloud-s3";
663-
o.back()->storage_class = "STANDARD";
673+
o.back()->tier_type = RGWTierType::CLOUD_S3;
674+
o.back()->storage_class = RGW_STORAGE_CLASS_STANDARD;
664675
o.back()->allow_read_through = false;
665-
o.back()->restore_storage_class = "STANDARD";
676+
o.back()->restore_storage_class = RGW_STORAGE_CLASS_STANDARD;
666677
o.back()->s3_glacier.glacier_restore_days = 2;
667678
o.back()->s3_glacier.glacier_restore_tier_type = GlacierRestoreTierType::Expedited;
668679
}
@@ -715,14 +726,14 @@ struct RGWZoneGroupPlacementTarget {
715726
void decode_json(JSONObj *obj);
716727
static void generate_test_instances(std::list<RGWZoneGroupPlacementTarget*>& o) {
717728
o.push_back(new RGWZoneGroupPlacementTarget);
718-
o.back()->storage_classes.insert("STANDARD");
729+
o.back()->storage_classes.insert(RGW_STORAGE_CLASS_STANDARD);
719730
o.push_back(new RGWZoneGroupPlacementTarget);
720731
o.back()->name = "target";
721732
o.back()->tags.insert("tag1");
722733
o.back()->tags.insert("tag2");
723734
o.back()->storage_classes.insert("STANDARD_IA");
724-
o.back()->tier_targets["cloud-s3"].tier_type = "cloud-s3";
725-
o.back()->tier_targets["cloud-s3"].storage_class = "STANDARD";
735+
o.back()->tier_targets[RGWTierType::CLOUD_S3].tier_type = RGWTierType::CLOUD_S3;
736+
o.back()->tier_targets[RGWTierType::CLOUD_S3].storage_class = RGW_STORAGE_CLASS_STANDARD;
726737
}
727738
};
728739
WRITE_CLASS_ENCODER(RGWZoneGroupPlacementTarget)

0 commit comments

Comments
 (0)