]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Clean up RGWBucketPipeSyncStatusManager construction
authorAdam C. Emerson <aemerson@redhat.com>
Tue, 12 Apr 2022 20:26:27 +0000 (16:26 -0400)
committerCasey Bodley <cbodley@redhat.com>
Fri, 27 May 2022 19:47:34 +0000 (15:47 -0400)
The coupling between this class and RGWRemoteBucketManager makes no
sense. Clean things up a bit.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/rgw/rgw_data_sync.cc
src/rgw/rgw_data_sync.h

index ec46ab55295c3f93407271a84d64fbc3e90d60cc..e45aab5b67b4170cbc50a24f42f67ec5ead632e1 100644 (file)
@@ -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<rgw_zone_id> _source_zone,
-                                                               std::optional<rgw_bucket> _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<RGWRemoteBucketManager *>::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);
index 259d048d3981dd941b4d1439f1dc69639a059914..8beb3fba772bec9d799776581865477e5682ddb4 100644 (file)
@@ -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<rgw_zone_id> source_zone;
   std::optional<rgw_bucket> source_bucket;
 
-  RGWRESTConn *conn;
-  RGWSyncErrorLogger *error_logger;
+  RGWRESTConn* conn = nullptr;
+  std::unique_ptr<RGWSyncErrorLogger> error_logger =
+    std::make_unique<RGWSyncErrorLogger>(store, RGW_SYNC_ERROR_LOG_SHARD_PREFIX,
+                                        ERROR_LOGGER_SHARDS);
   RGWSyncModuleInstanceRef sync_module;
 
   rgw_bucket dest_bucket;
 
-  std::vector<RGWRemoteBucketManager *> source_mgrs;
+  std::vector<RGWRemoteBucketManager> source_mgrs;
 
   std::map<int, rgw_bucket_shard_sync_info> sync_status;
 
 public:
-  RGWBucketPipeSyncStatusManager(rgw::sal::RadosStore* _store,
-                             std::optional<rgw_zone_id> _source_zone,
-                             std::optional<rgw_bucket> _source_bucket,
-                             const rgw_bucket& dest_bucket);
-  ~RGWBucketPipeSyncStatusManager();
+  RGWBucketPipeSyncStatusManager(rgw::sal::RadosStore* store,
+                                std::optional<rgw_zone_id> source_zone,
+                                std::optional<rgw_bucket> 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;