File tree Expand file tree Collapse file tree 3 files changed +22
-23
lines changed
mooncake-transfer-engine/src Expand file tree Collapse file tree 3 files changed +22
-23
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 44
55namespace 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
Original file line number Diff line number Diff 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;
You can’t perform that action at this time.
0 commit comments