From b83266ec24524e0337c942256d4fe0e5bb839f12 Mon Sep 17 00:00:00 2001 From: yujingwei Date: Wed, 29 Nov 2023 20:45:26 +0800 Subject: [PATCH] feat(replica): parameterize-fileddatatype --- src/replica/replica.cpp | 2 +- src/replica/replication_app_base.cpp | 14 +++++++------- src/replica/replication_app_base.h | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/replica/replica.cpp b/src/replica/replica.cpp index 5d1b6c8437..78510f7f61 100644 --- a/src/replica/replica.cpp +++ b/src/replica/replica.cpp @@ -592,7 +592,7 @@ error_code replica::store_app_info(app_info &info, const std::string &path) { replica_app_info new_info((app_info *)&info); const auto &info_path = path.empty() ? utils::filesystem::path_combine(_dir, kAppInfo) : path; - auto err = new_info.store(info_path, utils::FileDataType::kSensitive); + auto err = new_info.store(info_path, dsn::utils::FileDataType::kSensitive); if (dsn_unlikely(err != ERR_OK)) { LOG_ERROR_PREFIX("failed to save app_info to {}, error = {}", info_path, err); } diff --git a/src/replica/replication_app_base.cpp b/src/replica/replication_app_base.cpp index b08779dfae..231450d7c5 100644 --- a/src/replica/replication_app_base.cpp +++ b/src/replica/replication_app_base.cpp @@ -66,7 +66,7 @@ namespace replication { const std::string replica_init_info::kInitInfo = ".init-info"; namespace { -error_code write_blob_to_file(const std::string &fname, const blob &data, const utils::FileDataType &fileDataType) +error_code write_blob_to_file(const std::string &fname, const blob &data, const dsn::utils::FileDataType &fileDataType) { // TODO(yingchun): consider not encrypt the meta files. std::string tmp_fname = fname + ".tmp"; @@ -88,7 +88,7 @@ error_code write_blob_to_file(const std::string &fname, const blob &data, const } } // namespace -error_code replica_init_info::load(const std::string &dir, const utils::FileDataType &fileDataType) +error_code replica_init_info::load(const std::string &dir, const dsn::utils::FileDataType &fileDataType) { std::string info_path = utils::filesystem::path_combine(dir, kInitInfo); LOG_AND_RETURN_NOT_TRUE(ERROR, @@ -102,7 +102,7 @@ error_code replica_init_info::load(const std::string &dir, const utils::FileData return ERR_OK; } -error_code replica_init_info::store(const std::string &dir, const utils::FileDataType &fileDataType) +error_code replica_init_info::store(const std::string &dir, const dsn::utils::FileDataType &fileDataType) { uint64_t start = dsn_now_ns(); std::string info_path = utils::filesystem::path_combine(dir, kInitInfo); @@ -118,7 +118,7 @@ error_code replica_init_info::store(const std::string &dir, const utils::FileDat return ERR_OK; } -error_code replica_init_info::load_json(const std::string &fname, const utils::FileDataType &fileDataType) +error_code replica_init_info::load_json(const std::string &fname, const dsn::utils::FileDataType &fileDataType) { std::string data; auto s = rocksdb::ReadFileToString( @@ -133,7 +133,7 @@ error_code replica_init_info::load_json(const std::string &fname, const utils::F return ERR_OK; } -error_code replica_init_info::store_json(const std::string &fname, const utils::FileDataType &fileDataType) +error_code replica_init_info::store_json(const std::string &fname, const dsn::utils::FileDataType &fileDataType) { return write_blob_to_file(fname, json::json_forwarder::encode(*this), fileDataType); } @@ -148,7 +148,7 @@ std::string replica_init_info::to_string() return oss.str(); } -error_code replica_app_info::load(const std::string &fname, const utils::FileDataType &fileDataType) +error_code replica_app_info::load(const std::string &fname, const dsn::utils::FileDataType &fileDataType) { std::string data; auto s = rocksdb::ReadFileToString( @@ -163,7 +163,7 @@ error_code replica_app_info::load(const std::string &fname, const utils::FileDat return ERR_OK; } -error_code replica_app_info::store(const std::string &fname, const utils::FileDataType &fileDataType) +error_code replica_app_info::store(const std::string &fname, const dsn::utils::FileDataType &fileDataType) { binary_writer writer; int magic = 0xdeadbeef; diff --git a/src/replica/replication_app_base.h b/src/replica/replication_app_base.h index af48044835..7a30c08840 100644 --- a/src/replica/replication_app_base.h +++ b/src/replica/replication_app_base.h @@ -72,13 +72,13 @@ class replica_init_info public: replica_init_info() { memset((void *)this, 0, sizeof(*this)); } - error_code load(const std::string &dir, const utils::FileDataType &fileDataType) WARN_UNUSED_RESULT; - error_code store(const std::string &dir, const utils::FileDataType &fileDataType); + error_code load(const std::string &dir, const dsn::utils::FileDataType &fileDataType) WARN_UNUSED_RESULT; + error_code store(const std::string &dir, const dsn::utils::FileDataType &fileDataType); std::string to_string(); private: - error_code load_json(const std::string &fname, const utils::FileDataType &fileDataType); - error_code store_json(const std::string &fname, const utils::FileDataType &fileDataType); + error_code load_json(const std::string &fname, const dsn::utils::FileDataType &fileDataType); + error_code store_json(const std::string &fname, const dsn::utils::FileDataType &fileDataType); }; class replica_app_info @@ -88,8 +88,8 @@ class replica_app_info public: replica_app_info(app_info *app) { _app = app; } - error_code load(const std::string &fname, const utils::FileDataType &fileDataType); - error_code store(const std::string &fname, const utils::FileDataType &fileDataType); + error_code load(const std::string &fname, const dsn::utils::FileDataType &fileDataType); + error_code store(const std::string &fname, const dsn::utils::FileDataType &fileDataType); }; /// The store engine interface of Pegasus.