Skip to content

Commit

Permalink
feat(replica): parameterize-fileddatatype
Browse files Browse the repository at this point in the history
  • Loading branch information
yujingwei committed Nov 29, 2023
1 parent 4416667 commit b83266e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/replica/replica.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
14 changes: 7 additions & 7 deletions src/replica/replication_app_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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,
Expand All @@ -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);
Expand All @@ -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(
Expand All @@ -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<replica_init_info>::encode(*this), fileDataType);
}
Expand All @@ -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(
Expand All @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/replica/replication_app_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down

0 comments on commit b83266e

Please sign in to comment.