From 9c0ea720432c5bd0fe5d70b4608cb51282a53698 Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Tue, 12 Apr 2022 16:26:27 -0400 Subject: [PATCH] rgw: Clean up RGWBucketPipeSyncStatusManager construction The coupling between this class and RGWRemoteBucketManager makes no sense. Clean things up a bit. Signed-off-by: Adam C. Emerson --- src/rgw/rgw_data_sync.cc | 43 ++++++++++------------------------------ src/rgw/rgw_data_sync.h | 30 +++++++++++++++++----------- 2 files changed, 28 insertions(+), 45 deletions(-) diff --git a/src/rgw/rgw_data_sync.cc b/src/rgw/rgw_data_sync.cc index ec46ab55295c3..e45aab5b67b41 100644 --- a/src/rgw/rgw_data_sync.cc +++ b/src/rgw/rgw_data_sync.cc @@ -3405,26 +3405,6 @@ RGWCoroutine *RGWRemoteBucketManager::read_sync_status_cr(int num, rgw_bucket_sh return new RGWReadBucketPipeSyncStatusCoroutine(&sc, sync_pairs[num], sync_status, nullptr, full_status.incremental_gen); } -RGWBucketPipeSyncStatusManager::RGWBucketPipeSyncStatusManager(rgw::sal::RadosStore* _store, - std::optional _source_zone, - std::optional _source_bucket, - const rgw_bucket& _dest_bucket) : store(_store), - cr_mgr(_store->ctx(), _store->getRados()->get_cr_registry()), - http_manager(store->ctx(), cr_mgr.get_completion_mgr()), - source_zone(_source_zone), source_bucket(_source_bucket), - conn(NULL), error_logger(NULL), - dest_bucket(_dest_bucket) -{ -} - -RGWBucketPipeSyncStatusManager::~RGWBucketPipeSyncStatusManager() -{ - for (vector::iterator iter = source_mgrs.begin(); iter != source_mgrs.end(); ++iter) { - delete *iter; - } - delete error_logger; -} - CephContext *RGWBucketPipeSyncStatusManager::get_cct() const { return store->ctx(); @@ -5413,14 +5393,12 @@ int RGWBucketPipeSyncStatusManager::init(const DoutPrefixProvider *dpp) return ret; } - error_logger = new RGWSyncErrorLogger(store, RGW_SYNC_ERROR_LOG_SHARD_PREFIX, ERROR_LOGGER_SHARDS); - sync_module.reset(new RGWDefaultSyncModuleInstance()); auto async_rados = store->svc()->rados->get_async_processor(); sync_env.init(this, store->ctx(), store, store->svc(), async_rados, &http_manager, - error_logger, store->getRados()->get_sync_tracer(), + error_logger.get(), store->getRados()->get_sync_tracer(), sync_module, nullptr); rgw_sync_pipe_info_set pipes; @@ -5463,11 +5441,10 @@ int RGWBucketPipeSyncStatusManager::init(const DoutPrefixProvider *dpp) return r; } const int num_shards = remote_markers.get().size(); - source_mgrs.push_back(new RGWRemoteBucketManager(this, &sync_env, - szone, conn, - pipe.source.get_bucket_info(), - num_shards, - pipe.target.get_bucket())); + source_mgrs.emplace_back(this, &sync_env, szone, conn, + pipe.source.get_bucket_info(), + num_shards, + pipe.target.get_bucket()); } return 0; @@ -5484,7 +5461,7 @@ int RGWBucketPipeSyncStatusManager::init_sync_status(const DoutPrefixProvider *d RGWCoroutinesStack *stack = new RGWCoroutinesStack(store->ctx(), &cr_mgr); objvs.emplace_back(); infos.emplace_back(); - stack->call(mgr->init_sync_status_cr(objvs.back(), infos.back())); + stack->call(mgr.init_sync_status_cr(objvs.back(), infos.back())); stacks.push_back(stack); } @@ -5498,8 +5475,8 @@ int RGWBucketPipeSyncStatusManager::read_sync_status(const DoutPrefixProvider *d for (auto& mgr : source_mgrs) { RGWCoroutinesStack *stack = new RGWCoroutinesStack(store->ctx(), &cr_mgr); - for (int i = 0; i < mgr->num_pipes(); ++i) { - stack->call(mgr->read_sync_status_cr(i, &sync_status[i])); + for (int i = 0; i < mgr.num_pipes(); ++i) { + stack->call(mgr.read_sync_status_cr(i, &sync_status[i])); } stacks.push_back(stack); @@ -5521,8 +5498,8 @@ int RGWBucketPipeSyncStatusManager::run(const DoutPrefixProvider *dpp) for (auto& mgr : source_mgrs) { RGWCoroutinesStack *stack = new RGWCoroutinesStack(store->ctx(), &cr_mgr); - for (int i = 0; i < mgr->num_pipes(); ++i) { - stack->call(mgr->run_sync_cr(i)); + for (int i = 0; i < mgr.num_pipes(); ++i) { + stack->call(mgr.run_sync_cr(i)); } stacks.push_back(stack); diff --git a/src/rgw/rgw_data_sync.h b/src/rgw/rgw_data_sync.h index 259d048d3981d..8beb3fba772be 100644 --- a/src/rgw/rgw_data_sync.h +++ b/src/rgw/rgw_data_sync.h @@ -13,6 +13,7 @@ #include "rgw_sal_rados.h" #include "rgw_datalog.h" +#include "rgw_sync.h" #include "rgw_sync_module.h" #include "rgw_sync_trace.h" #include "rgw_sync_policy.h" @@ -711,29 +712,34 @@ class RGWBucketPipeSyncStatusManager : public DoutPrefixProvider { RGWDataSyncEnv sync_env; - RGWCoroutinesManager cr_mgr; + RGWCoroutinesManager cr_mgr{store->ctx(), + store->getRados()->get_cr_registry()}; - RGWHTTPManager http_manager; + RGWHTTPManager http_manager{store->ctx(), cr_mgr.get_completion_mgr()}; std::optional source_zone; std::optional source_bucket; - RGWRESTConn *conn; - RGWSyncErrorLogger *error_logger; + RGWRESTConn* conn = nullptr; + std::unique_ptr error_logger = + std::make_unique(store, RGW_SYNC_ERROR_LOG_SHARD_PREFIX, + ERROR_LOGGER_SHARDS); RGWSyncModuleInstanceRef sync_module; rgw_bucket dest_bucket; - std::vector source_mgrs; + std::vector source_mgrs; std::map sync_status; public: - RGWBucketPipeSyncStatusManager(rgw::sal::RadosStore* _store, - std::optional _source_zone, - std::optional _source_bucket, - const rgw_bucket& dest_bucket); - ~RGWBucketPipeSyncStatusManager(); + RGWBucketPipeSyncStatusManager(rgw::sal::RadosStore* store, + std::optional source_zone, + std::optional source_bucket, + const rgw_bucket& dest_bucket) + : store(store), source_zone(source_zone), source_bucket(source_bucket), + dest_bucket(dest_bucket) {} + ~RGWBucketPipeSyncStatusManager() = default; int init(const DoutPrefixProvider *dpp); @@ -748,8 +754,8 @@ public: uint64_t gen); // specific source obj sync status, can be used by sync modules static std::string obj_status_oid(const rgw_bucket_sync_pipe& sync_pipe, - const rgw_zone_id& source_zone, const rgw::sal::Object* obj); /* specific source obj sync status, - can be used by sync modules */ + const rgw_zone_id& source_zone, const rgw::sal::Object* obj); /* specific source obj sync status, + can be used by sync modules */ // implements DoutPrefixProvider CephContext *get_cct() const override; -- 2.39.5