diff --git a/src/replica/duplication/duplication_sync_timer.cpp b/src/replica/duplication/duplication_sync_timer.cpp index d04d014fe6..9e315c111a 100644 --- a/src/replica/duplication/duplication_sync_timer.cpp +++ b/src/replica/duplication/duplication_sync_timer.cpp @@ -35,12 +35,21 @@ #include "runtime/task/async_calls.h" #include "runtime/task/task_code.h" #include "utils/autoref_ptr.h" +#include "utils/chrono_literals.h" #include "utils/error_code.h" +#include "utils/flags.h" #include "utils/fmt_logging.h" #include "utils/threadpool_code.h" +DSN_DEFINE_uint64( + replication, + duplication_sync_period_second, + 10, + "The period seconds of duplication to sync data from local cluster to remote cluster"); + namespace dsn { namespace replication { +using namespace literals::chrono_literals; DEFINE_TASK_CODE(LPC_DUPLICATION_SYNC_TIMER, TASK_PRIORITY_COMMON, THREAD_POOL_DEFAULT) @@ -169,14 +178,14 @@ void duplication_sync_timer::close() void duplication_sync_timer::start() { - LOG_INFO("run duplication sync periodically in {}s", DUPLICATION_SYNC_PERIOD_SECOND); + LOG_INFO("run duplication sync periodically in {}s", FLAGS_duplication_sync_period_second); _timer_task = tasking::enqueue_timer(LPC_DUPLICATION_SYNC_TIMER, &_stub->_tracker, [this]() { run(); }, - DUPLICATION_SYNC_PERIOD_SECOND * 1_s, + FLAGS_duplication_sync_period_second * 1_s, 0, - DUPLICATION_SYNC_PERIOD_SECOND * 1_s); + FLAGS_duplication_sync_period_second * 1_s); } std::multimap diff --git a/src/replica/duplication/duplication_sync_timer.h b/src/replica/duplication/duplication_sync_timer.h index 4a112b1d58..ff1b6c0660 100644 --- a/src/replica/duplication/duplication_sync_timer.h +++ b/src/replica/duplication/duplication_sync_timer.h @@ -26,7 +26,6 @@ #include "duplication_types.h" #include "replica/replica.h" #include "runtime/task/task.h" -#include "utils/chrono_literals.h" #include "utils/zlocks.h" namespace dsn { @@ -35,10 +34,6 @@ class error_code; namespace replication { class replica_stub; -using namespace literals::chrono_literals; - -constexpr int DUPLICATION_SYNC_PERIOD_SECOND = 10; - // Per-server(replica_stub)-instance. class duplication_sync_timer {