From 416cdfc76b72115a316ed4803ac2ce37830b6295 Mon Sep 17 00:00:00 2001 From: lvshanchun Date: Tue, 19 Dec 2017 10:53:06 +0800 Subject: [PATCH] rgw: create sync-module instance when execute radosgw-admin data sync run Signed-off-by: lvshanchun --- src/rgw/rgw_admin.cc | 13 +++++++++++-- src/rgw/rgw_data_sync.cc | 4 +++- src/rgw/rgw_data_sync.h | 6 ++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index c6d06067f4625..183a37eeec8af 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -6469,9 +6469,18 @@ next: cerr << "ERROR: source zone not specified" << std::endl; return EINVAL; } - RGWDataSyncStatusManager sync(store, store->get_async_rados(), source_zone); - int ret = sync.init(); + RGWSyncModuleInstanceRef sync_module; + int ret = store->get_sync_modules_manager()->create_instance(g_ceph_context, store->get_zone().tier_type, + store->get_zone_params().tier_config, &sync_module); + if (ret < 0) { + lderr(cct) << "ERROR: failed to init sync module instance, ret=" << ret << dendl; + return ret; + } + + RGWDataSyncStatusManager sync(store, store->get_async_rados(), source_zone, sync_module); + + ret = sync.init(); if (ret < 0) { cerr << "ERROR: sync.init() returned ret=" << ret << std::endl; return -ret; diff --git a/src/rgw/rgw_data_sync.cc b/src/rgw/rgw_data_sync.cc index 6d3f01d40ebe8..e4be405498676 100644 --- a/src/rgw/rgw_data_sync.cc +++ b/src/rgw/rgw_data_sync.cc @@ -1775,7 +1775,9 @@ int RGWDataSyncStatusManager::init() RGWZoneParams& zone_params = store->get_zone_params(); - sync_module = store->get_sync_module(); + if (sync_module == nullptr) { + sync_module = store->get_sync_module(); + } conn = store->get_zone_conn_by_id(source_zone); if (!conn) { diff --git a/src/rgw/rgw_data_sync.h b/src/rgw/rgw_data_sync.h index 6e45b932c3e0b..4623836bb8722 100644 --- a/src/rgw/rgw_data_sync.h +++ b/src/rgw/rgw_data_sync.h @@ -311,6 +311,12 @@ public: : store(_store), source_zone(_source_zone), conn(NULL), error_logger(NULL), sync_module(nullptr), source_log(store, async_rados, observer), num_shards(0) {} + RGWDataSyncStatusManager(RGWRados *_store, RGWAsyncRadosProcessor *async_rados, + const string& _source_zone, const RGWSyncModuleInstanceRef& _sync_module, + rgw::BucketChangeObserver *observer = nullptr) + : store(_store), source_zone(_source_zone), conn(NULL), error_logger(NULL), + sync_module(_sync_module), + source_log(store, async_rados, observer), num_shards(0) {} ~RGWDataSyncStatusManager() { finalize(); } -- 2.39.5