diff options
author | Yehuda Sadeh <yehuda@redhat.com> | 2019-11-19 19:56:33 +0100 |
---|---|---|
committer | Yehuda Sadeh <yehuda@redhat.com> | 2020-01-28 19:20:39 +0100 |
commit | 2d7a94900e518cf1517a07d4e1ec011160099560 (patch) | |
tree | a35da0202087b09a7e82ded38190ce8592632499 /src | |
parent | rgw: sync: add mode (system, user) as a pipe param (diff) | |
download | ceph-2d7a94900e518cf1517a07d4e1ec011160099560.tar.xz ceph-2d7a94900e518cf1517a07d4e1ec011160099560.zip |
rgw: find pipe rules param for specific obj changes
- reuse RGWObjTags::tag_map_t instead of vector of strings
- fix the prefix search
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/rgw/rgw_bucket_sync.cc | 21 | ||||
-rw-r--r-- | src/rgw/rgw_bucket_sync.h | 4 |
2 files changed, 17 insertions, 8 deletions
diff --git a/src/rgw/rgw_bucket_sync.cc b/src/rgw/rgw_bucket_sync.cc index ba3fbc3518b..ec76ef67c94 100644 --- a/src/rgw/rgw_bucket_sync.cc +++ b/src/rgw/rgw_bucket_sync.cc @@ -290,22 +290,31 @@ void RGWBucketSyncFlowManager::pipe_rules::insert(const rgw_sync_bucket_pipe& pi #warning add support for tags bool RGWBucketSyncFlowManager::pipe_rules::find_obj_params(const rgw_obj_key& key, - const vector<string>& tags, + const RGWObjTags::tag_map_t& tags, rgw_sync_pipe_params *params) const { - auto iter = prefix_refs.lower_bound(key.name); + if (prefix_refs.empty()) { + return false; + } + + auto iter = prefix_refs.upper_bound(key.name); + if (iter != prefix_refs.begin()) { + --iter; + } if (iter == prefix_refs.end()) { return false; } - auto max = prefix_refs.end(); + auto end = prefix_refs.upper_bound(key.name); + auto max = end; std::optional<int> priority; - for (; iter != prefix_refs.end(); ++iter) { + for (; iter != end; ++iter) { +#warning this is not the most efficient way to do it, need trie maybe auto& prefix = iter->first; if (!boost::starts_with(key.name, prefix)) { - break; + continue; } auto& rule_params = iter->second->params; @@ -321,7 +330,7 @@ bool RGWBucketSyncFlowManager::pipe_rules::find_obj_params(const rgw_obj_key& ke } } - if (max == prefix_refs.end()) { + if (max == end) { return false; } diff --git a/src/rgw/rgw_bucket_sync.h b/src/rgw/rgw_bucket_sync.h index ceb1c14b909..63da7836a87 100644 --- a/src/rgw/rgw_bucket_sync.h +++ b/src/rgw/rgw_bucket_sync.h @@ -147,7 +147,7 @@ public: void insert(const rgw_sync_bucket_pipe& pipe); bool find_obj_params(const rgw_obj_key& key, - const vector<string>& tags, + const RGWObjTags::tag_map_t& tags, rgw_sync_pipe_params *params) const; void scan_prefixes(std::vector<string> *prefixes) const; @@ -178,7 +178,7 @@ public: } bool find_obj_params(const rgw_obj_key& key, - const std::vector<string>& tags, + const RGWObjTags::tag_map_t& tags, rgw_sync_pipe_params *params) const { if (!rules) { return false; |