diff options
author | Matt Benjamin <mbenjamin@redhat.com> | 2021-11-20 19:45:51 +0100 |
---|---|---|
committer | Matt Benjamin <mbenjamin@redhat.com> | 2022-07-18 00:36:51 +0200 |
commit | 23a588da12aa498bb40e800ab1cb84656f2fc763 (patch) | |
tree | 05e3a67b10cafb059c19a9b25c3bee0effa311a5 /src/rgw/rgw_lc.h | |
parent | Merge pull request #47025 from adamemerson/wip-55765 (diff) | |
download | ceph-23a588da12aa498bb40e800ab1cb84656f2fc763.tar.xz ceph-23a588da12aa498bb40e800ab1cb84656f2fc763.zip |
rgwlc: introduce lifecycle config flags extension
rgwlc: add uint32_t flags bitmap to LCFilter
This is intended to support a concise set of extensions to S3
LifecycleConfiguration, initially, just a flag that indicates a
rule is intended for execution on RGW ArchiveZone.
rgwlc: add machinery to define and recognize LCFilter flags
Add a concept of filter flags to lifecycle filter rules, an RGW
extension. The initial purpose of flags is to permit marking
specific lifecycle rules as specific to an RGW archive zone, but
other flags could be added in future.
rgwlc: add new unittest_rgw_lc to run internal checks, add a few
valid and invalid lifecycle configuration xml parses for now.
Fixes: https://tracker.ceph.com/issues/53361
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
Diffstat (limited to 'src/rgw/rgw_lc.h')
-rw-r--r-- | src/rgw/rgw_lc.h | 55 |
1 files changed, 51 insertions, 4 deletions
diff --git a/src/rgw/rgw_lc.h b/src/rgw/rgw_lc.h index e62ab480f81..81294bc95f3 100644 --- a/src/rgw/rgw_lc.h +++ b/src/rgw/rgw_lc.h @@ -5,6 +5,7 @@ #define CEPH_RGW_LC_H #include <map> +#include <array> #include <string> #include <iostream> @@ -159,13 +160,51 @@ public: }; WRITE_CLASS_ENCODER(LCTransition) +enum class LCFlagType : uint16_t +{ + none = 0, + ArchiveZone, +}; + +class LCFlag { +public: + LCFlagType bit; + const char* name; + + constexpr LCFlag(LCFlagType ord, const char* name) : bit(ord), name(name) + {} +}; + class LCFilter { - protected: + public: + + static constexpr uint32_t make_flag(LCFlagType type) { + switch (type) { + case LCFlagType::none: + return 0; + break; + default: + return 1 << (uint32_t(type) - 1); + } + } + + static constexpr std::array<LCFlag, 2> filter_flags = + { + LCFlag(LCFlagType::none, "none"), + LCFlag(LCFlagType::ArchiveZone, "ArchiveZone"), + }; + +protected: std::string prefix; RGWObjTags obj_tags; + uint32_t flags; - public: +public: +static uint32_t recognize_flags(const std::string& flag_expr); + + LCFilter() : flags(make_flag(LCFlagType::none)) + {} const std::string& get_prefix() const { return prefix; @@ -175,6 +214,10 @@ class LCFilter return obj_tags; } + const uint32_t get_flags() { + return flags; + } + bool empty() const { return !(has_prefix() || has_tags()); } @@ -195,16 +238,20 @@ class LCFilter } void encode(bufferlist& bl) const { - ENCODE_START(2, 1, bl); + ENCODE_START(3, 1, bl); encode(prefix, bl); encode(obj_tags, bl); + encode(flags, bl); ENCODE_FINISH(bl); } void decode(bufferlist::const_iterator& bl) { - DECODE_START(2, bl); + DECODE_START(3, bl); decode(prefix, bl); if (struct_v >= 2) { decode(obj_tags, bl); + if (struct_v >= 3) { + decode(flags, bl); + } } DECODE_FINISH(bl); } |