add configuration cluster.node_id (#4419)

* add configuration cluster.node_id

Signed-off-by: Xiangyu Wang <xiangyu.wang@zilliz.com>

* add valid function for cluster.node_id

Signed-off-by: Xiangyu Wang <xiangyu.wang@zilliz.com>
pull/4424/head
Wang Xiangyu 2020-12-09 15:40:39 +08:00 committed by GitHub
parent 1b14664fa4
commit cb4d94c72b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 0 deletions

View File

@ -18,9 +18,12 @@ version: 0.6
#----------------------+------------------------------------------------------------+------------+-----------------+
# role | Milvus deployment role: rw / ro | Role | rw |
#----------------------+------------------------------------------------------------+------------+-----------------+
# node_id | Node ID, used in log message only. | String | master |
#----------------------+------------------------------------------------------------+------------+-----------------+
cluster:
enable: false
role: rw
node_id: master
#----------------------+------------------------------------------------------------+------------+-----------------+
# General Config | Description | Type | Default |

View File

@ -18,9 +18,12 @@ version: 0.6
#----------------------+------------------------------------------------------------+------------+-----------------+
# role | Milvus deployment role: rw / ro | Role | rw |
#----------------------+------------------------------------------------------------+------------+-----------------+
# node_id | Node ID, used in log message only. | String | master |
#----------------------+------------------------------------------------------------+------------+-----------------+
cluster:
enable: false
role: rw
node_id: master
#----------------------+------------------------------------------------------------+------------+-----------------+
# General Config | Description | Type | Default |

View File

@ -22,6 +22,25 @@ const int64_t GB = (1024ll * 1024 * 1024);
namespace milvus {
bool
is_nodeid_valid(const std::string& val, std::string& err) {
// lambda, check if it's [0-9a-zA-Z_-]
auto is_valid = [](char ch) {
if (isalnum(ch) || ch == '_' || ch == '-') {
return true;
}
return false;
};
for (auto& ch : val) {
if (not is_valid(ch)) {
err = "Invalid nodeid: " + val + ", supported char: [0-9a-zA-Z_-]";
return false;
}
}
return true;
}
bool
is_timezone_valid(const std::string& val, std::string& err) {
auto plus_count = std::count(val.begin(), val.end(), '+');
@ -101,6 +120,7 @@ InitConfig() {
/* cluster */
Bool(cluster.enable, false),
Enum(cluster.role, &ClusterRoleMap, ClusterRole::RW),
String_(cluster.node_id, _MODIFIABLE, "master", is_nodeid_valid),
/* general */
String_(general.timezone, _MODIFIABLE, "UTC+8", is_timezone_valid),
@ -194,9 +214,12 @@ version: @version@
#----------------------+------------------------------------------------------------+------------+-----------------+
# role | Milvus deployment role: rw / ro | Role | rw |
#----------------------+------------------------------------------------------------+------------+-----------------+
# node_id | Node ID, used in log message only. | String | master |
#----------------------+------------------------------------------------------------+------------+-----------------+
cluster:
enable: @cluster.enable@
role: @cluster.role@
node_id: @cluster.node_id@
#----------------------+------------------------------------------------------------+------------+-----------------+
# General Config | Description | Type | Default |

View File

@ -66,6 +66,7 @@ struct ServerConfig {
struct Cluster {
Bool enable;
Integer role;
String node_id;
} cluster;
struct General {