Skip to content

Commit 96e3b35

Browse files
committed
[Feature] change env name
1 parent 3dc56c7 commit 96e3b35

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

mooncake-store/include/ha_helper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class MasterViewHelper {
2323
public:
2424
MasterViewHelper(const MasterViewHelper&) = delete;
2525
MasterViewHelper& operator=(const MasterViewHelper&) = delete;
26-
MasterViewHelper() = default;
26+
MasterViewHelper();
2727

2828
/*
2929
* @brief Connect to the etcd cluster. This function should be called at

mooncake-store/src/ha_helper.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,23 @@
44

55
namespace mooncake {
66

7-
ErrorCode MasterViewHelper::ConnectToEtcd(const std::string& etcd_endpoints) {
8-
std::string custom_key;
9-
const char* custom_prefix = std::getenv("MC_STORE_ETCD_KEY_PREFIX");
10-
if (custom_prefix != nullptr && strlen(custom_prefix) > 0) {
11-
custom_key = custom_prefix;
12-
// Ensure the custom key ends with '/'
13-
if (!custom_key.empty() && custom_key.back() != '/') {
14-
custom_key += '/';
15-
}
16-
LOG(INFO) << "Using custom store etcd key prefix: mooncake-store/"
17-
<< custom_key;
7+
MasterViewHelper::MasterViewHelper() {
8+
std::string cluster_id;
9+
const char* cluster_id_env = std::getenv("MC_STORE_CLUSTER_ID");
10+
if (cluster_id_env != nullptr && strlen(cluster_id_env) > 0) {
11+
cluster_id = cluster_id_env;
12+
} else {
13+
cluster_id = "mooncake";
1814
}
19-
master_view_key_ = "mooncake-store/" + custom_key + "master_view";
15+
// Ensure the cluster_id ends with '/' if not empty
16+
if (!cluster_id.empty() && cluster_id.back() != '/') {
17+
cluster_id += '/';
18+
}
19+
master_view_key_ = "mooncake-store/" + cluster_id + "master_view";
2020
LOG(INFO) << "Master view key: " << master_view_key_;
21+
}
2122

23+
ErrorCode MasterViewHelper::ConnectToEtcd(const std::string& etcd_endpoints) {
2224
return EtcdHelper::ConnectToEtcdStoreClient(etcd_endpoints);
2325
}
2426

mooncake-transfer-engine/src/transfer_metadata.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,14 @@ TransferMetadata::TransferMetadata(const std::string &conn_string) {
7878
std::string protocol = extractProtocolFromConnString(conn_string);
7979
std::string custom_key;
8080

81-
if (protocol == "etcd") {
82-
const char *custom_prefix = std::getenv("MC_METADATA_ETCD_KEY_PREFIX");
83-
if (custom_prefix != nullptr && strlen(custom_prefix) > 0) {
84-
custom_key = custom_prefix;
85-
// Ensure the custom key ends with '/'
86-
if (!custom_key.empty() && custom_key.back() != '/') {
87-
custom_key += '/';
88-
}
89-
LOG(INFO) << "Using custom metadata etcd key prefix: mooncake/"
90-
<< custom_key;
81+
const char *custom_prefix = std::getenv("MC_METADATA_CLUSTER_ID");
82+
if (custom_prefix != nullptr && strlen(custom_prefix) > 0) {
83+
custom_key = custom_prefix;
84+
// Ensure the custom key ends with '/'
85+
if (!custom_key.empty() && custom_key.back() != '/') {
86+
custom_key += '/';
9187
}
88+
LOG(INFO) << "Using metadata cluster ID: mooncake/" << custom_key;
9289
}
9390

9491
common_key_prefix_ = "mooncake/" + custom_key;

0 commit comments

Comments
 (0)