From: Adam C. Emerson Date: Mon, 4 May 2020 19:23:21 +0000 (-0400) Subject: rgw: Get rid of BucketFilter class, use a std::function X-Git-Tag: v16.1.0~1154^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=186b22175ccc6bef52aaec5072b1db56ef54cdad;p=ceph.git rgw: Get rid of BucketFilter class, use a std::function Signed-off-by: Adam C. Emerson --- diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index aac26a0db037..0e6765b48c2b 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -2155,7 +2155,7 @@ bool RGWDataChangesLog::filter_bucket(const rgw_bucket& bucket, optional_yield y return true; } - return bucket_filter->filter(bucket, y); + return bucket_filter(bucket, y); } int RGWDataChangesLog::add_entry(const RGWBucketInfo& bucket_info, int shard_id) { @@ -3046,16 +3046,10 @@ public: } }; -bool RGWBucketCtl::DataLogFilter::filter(const rgw_bucket& bucket, optional_yield y) const -{ - return bucket_ctl->bucket_exports_data(bucket, null_yield); -} - RGWBucketCtl::RGWBucketCtl(RGWSI_Zone *zone_svc, RGWSI_Bucket *bucket_svc, RGWSI_Bucket_Sync *bucket_sync_svc, - RGWSI_BucketIndex *bi_svc) : cct(zone_svc->ctx()), - datalog_filter(this) + RGWSI_BucketIndex *bi_svc) : cct(zone_svc->ctx()) { svc.zone = zone_svc; svc.bucket = bucket_svc; @@ -3076,7 +3070,10 @@ void RGWBucketCtl::init(RGWUserCtl *user_ctl, bucket_be_handler = bm_handler->get_be_handler(); bi_be_handler = bmi_handler->get_be_handler(); - datalog->set_bucket_filter(&datalog_filter); + datalog->set_bucket_filter( + [this](const rgw_bucket& bucket, optional_yield y) { + return bucket_exports_data(bucket, y); + }); } int RGWBucketCtl::call(std::function f) { diff --git a/src/rgw/rgw_bucket.h b/src/rgw/rgw_bucket.h index 76e4369fd5ed..cd0ed2641a29 100644 --- a/src/rgw/rgw_bucket.h +++ b/src/rgw/rgw_bucket.h @@ -417,12 +417,12 @@ enum DataLogEntityType { struct rgw_data_change { DataLogEntityType entity_type; - string key; - real_time timestamp; + std::string key; + ceph::real_time timestamp; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); - uint8_t t = (uint8_t)entity_type; + auto t = std::uint8_t(entity_type); encode(t, bl); encode(key, bl); encode(timestamp, bl); @@ -431,25 +431,25 @@ struct rgw_data_change { void decode(bufferlist::const_iterator& bl) { DECODE_START(1, bl); - uint8_t t; + std::uint8_t t; decode(t, bl); - entity_type = (DataLogEntityType)t; + entity_type = DataLogEntityType(t); decode(key, bl); decode(timestamp, bl); DECODE_FINISH(bl); } - void dump(Formatter *f) const; - void decode_json(JSONObj *obj); + void dump(ceph::Formatter* f) const; + void decode_json(JSONObj* obj); }; WRITE_CLASS_ENCODER(rgw_data_change) struct rgw_data_change_log_entry { - string log_id; - real_time log_timestamp; + std::string log_id; + ceph::real_time log_timestamp; rgw_data_change entry; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { ENCODE_START(1, 1, bl); encode(log_id, bl); encode(log_timestamp, bl); @@ -457,7 +457,7 @@ struct rgw_data_change_log_entry { ENCODE_FINISH(bl); } - void decode(bufferlist::const_iterator& bl) { + void decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(1, bl); decode(log_id, bl); decode(log_timestamp, bl); @@ -465,17 +465,17 @@ struct rgw_data_change_log_entry { DECODE_FINISH(bl); } - void dump(Formatter *f) const; - void decode_json(JSONObj *obj); + void dump(ceph::Formatter* f) const; + void decode_json(JSONObj* obj); }; WRITE_CLASS_ENCODER(rgw_data_change_log_entry) struct RGWDataChangesLogInfo { - string marker; - real_time last_update; + std::string marker; + ceph::real_time last_update; - void dump(Formatter *f) const; - void decode_json(JSONObj *obj); + void dump(ceph::Formatter* f) const; + void decode_json(JSONObj* obj); }; namespace rgw { @@ -483,22 +483,13 @@ struct BucketChangeObserver; } struct RGWDataChangesLogMarker { - int shard; - string marker; + int shard = 0; + std::string marker; - RGWDataChangesLogMarker() : shard(0) {} + RGWDataChangesLogMarker() = default; }; class RGWDataChangesLog { -public: - class BucketFilter { - public: - virtual ~BucketFilter() {} - - virtual bool filter(const rgw_bucket& bucket, optional_yield y) const = 0; - }; -private: - CephContext *cct; rgw::BucketChangeObserver *observer = nullptr; @@ -508,34 +499,34 @@ private: } svc; int num_shards; - string *oids; + std::string* oids; ceph::mutex lock = ceph::make_mutex("RGWDataChangesLog::lock"); ceph::shared_mutex modified_lock = ceph::make_shared_mutex("RGWDataChangesLog::modified_lock"); - map > modified_shards; + std::map > modified_shards; std::atomic down_flag = { false }; struct ChangeStatus { std::shared_ptr sync_policy; - real_time cur_expiration; - real_time cur_sent; + ceph::real_time cur_expiration; + ceph::real_time cur_sent; bool pending = false; RefCountedCond *cond = nullptr; ceph::mutex lock = ceph::make_mutex("RGWDataChangesLog::ChangeStatus"); }; - typedef std::shared_ptr ChangeStatusPtr; + using ChangeStatusPtr = std::shared_ptr; lru_map changes; - map cur_cycle; + std::map cur_cycle; void _get_change(const rgw_bucket_shard& bs, ChangeStatusPtr& status); void register_renew(rgw_bucket_shard& bs); - void update_renewed(rgw_bucket_shard& bs, real_time& expiration); + void update_renewed(rgw_bucket_shard& bs, ceph::real_time& expiration); class ChangesRenewThread : public Thread { CephContext *cct; @@ -549,9 +540,9 @@ private: void stop(); }; - ChangesRenewThread *renew_thread; + ChangesRenewThread* renew_thread; - BucketFilter *bucket_filter{nullptr}; + std::function bucket_filter; public: @@ -586,8 +577,8 @@ public: bool going_down(); - void set_bucket_filter(BucketFilter *f) { - bucket_filter = f; + void set_bucket_filter(decltype(bucket_filter)&& f) { + bucket_filter = std::move(f); } bool filter_bucket(const rgw_bucket& bucket, optional_yield y) const; @@ -624,14 +615,6 @@ class RGWBucketCtl int call(std::function f); - class DataLogFilter : public RGWDataChangesLog::BucketFilter { - RGWBucketCtl *bucket_ctl; - public: - DataLogFilter(RGWBucketCtl *_bucket_ctl) : bucket_ctl(_bucket_ctl) {} - - bool filter(const rgw_bucket& bucket, optional_yield y) const override; - } datalog_filter; - public: RGWBucketCtl(RGWSI_Zone *zone_svc, RGWSI_Bucket *bucket_svc,