add version in server config file

pull/595/head
yudong.cai 2019-11-28 16:12:39 +08:00
parent 7e394a26a2
commit 2aad94b678
6 changed files with 48 additions and 3 deletions

View File

@ -44,6 +44,7 @@ Please mark all change in change log and use the ticket from JIRA.
- \#420 - Update shards merge part to match v0.5.3 - \#420 - Update shards merge part to match v0.5.3
- \#488 - Add log in scheduler/optimizer - \#488 - Add log in scheduler/optimizer
- \#502 - C++ SDK support IVFPQ and SPTAG - \#502 - C++ SDK support IVFPQ and SPTAG
- \#560 - Add version in server config file
## Improvement ## Improvement
- \#255 - Add ivfsq8 test report detailed version - \#255 - Add ivfsq8 test report detailed version

View File

@ -1,5 +1,7 @@
# Default values are used when you make no changes to the following parameters. # Default values are used when you make no changes to the following parameters.
version: 0.1 # config version
server_config: server_config:
address: 0.0.0.0 # milvus server ip address (IPv4) address: 0.0.0.0 # milvus server ip address (IPv4)
port: 19530 # milvus server port, must in range [1025, 65534] port: 19530 # milvus server port, must in range [1025, 65534]

View File

@ -1,5 +1,7 @@
# Default values are used when you make no changes to the following parameters. # Default values are used when you make no changes to the following parameters.
version: 0.1 # config version
server_config: server_config:
address: 0.0.0.0 # milvus server ip address (IPv4) address: 0.0.0.0 # milvus server ip address (IPv4)
port: 19530 # milvus server port, must in range [1025, 65534] port: 19530 # milvus server port, must in range [1025, 65534]

View File

@ -20,6 +20,7 @@
#include <iostream> #include <iostream>
#include <regex> #include <regex>
#include <string> #include <string>
#include <unordered_map>
#include <vector> #include <vector>
#include "config/YamlConfigMgr.h" #include "config/YamlConfigMgr.h"
@ -33,6 +34,8 @@ namespace server {
constexpr uint64_t GB = 1UL << 30; constexpr uint64_t GB = 1UL << 30;
static const std::unordered_map<std::string, std::string> milvus_config_version_map({{"0.6.0", "0.1"}});
Config& Config&
Config::GetInstance() { Config::GetInstance() {
static Config config_inst; static Config config_inst;
@ -69,6 +72,12 @@ Status
Config::ValidateConfig() { Config::ValidateConfig() {
Status s; Status s;
std::string config_version;
s = GetConfigVersion(config_version);
if (!s.ok()) {
return s;
}
/* server config */ /* server config */
std::string server_addr; std::string server_addr;
s = GetServerConfigAddress(server_addr); s = GetServerConfigAddress(server_addr);
@ -383,6 +392,16 @@ Config::PrintAll() {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Status
Config::CheckConfigVersion(const std::string& value) {
if (milvus_config_version_map.at(MILVUS_VERSION) != value) {
std::string msg = "Invalid config version: " + value +
". Expected config version: " + milvus_config_version_map.at(MILVUS_VERSION);
return Status(SERVER_INVALID_ARGUMENT, msg);
}
return Status::OK();
}
Status Status
Config::CheckServerConfigAddress(const std::string& value) { Config::CheckServerConfigAddress(const std::string& value) {
if (!ValidationUtil::ValidateIpAddress(value).ok()) { if (!ValidationUtil::ValidateIpAddress(value).ok()) {
@ -766,10 +785,14 @@ Config::CheckGpuResourceConfigBuildIndexResources(const std::vector<std::string>
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ConfigNode& ConfigNode&
Config::GetConfigNode(const std::string& name) { Config::GetConfigRoot() {
ConfigMgr* mgr = YamlConfigMgr::GetInstance(); ConfigMgr* mgr = YamlConfigMgr::GetInstance();
ConfigNode& root_node = mgr->GetRootNode(); return mgr->GetRootNode();
return root_node.GetChild(name); }
ConfigNode&
Config::GetConfigNode(const std::string& name) {
return GetConfigRoot().GetChild(name);
} }
Status Status
@ -816,6 +839,12 @@ Config::GetConfigSequenceStr(const std::string& parent_key, const std::string& c
return value; return value;
} }
Status
Config::GetConfigVersion(std::string& value) {
value = GetConfigRoot().GetValue(CONFIG_VERSION);
return CheckConfigVersion(value);
}
Status Status
Config::GetServerConfigAddress(std::string& value) { Config::GetServerConfigAddress(std::string& value) {
value = GetConfigStr(CONFIG_SERVER, CONFIG_SERVER_ADDRESS, CONFIG_SERVER_ADDRESS_DEFAULT); value = GetConfigStr(CONFIG_SERVER, CONFIG_SERVER_ADDRESS, CONFIG_SERVER_ADDRESS_DEFAULT);

View File

@ -28,6 +28,8 @@
namespace milvus { namespace milvus {
namespace server { namespace server {
static const char* CONFIG_VERSION = "version";
/* server config */ /* server config */
static const char* CONFIG_SERVER = "server_config"; static const char* CONFIG_SERVER = "server_config";
static const char* CONFIG_SERVER_ADDRESS = "address"; static const char* CONFIG_SERVER_ADDRESS = "address";
@ -115,6 +117,8 @@ class Config {
PrintAll(); PrintAll();
private: private:
ConfigNode&
GetConfigRoot();
ConfigNode& ConfigNode&
GetConfigNode(const std::string& name); GetConfigNode(const std::string& name);
Status Status
@ -125,6 +129,9 @@ class Config {
PrintConfigSection(const std::string& config_node_name); PrintConfigSection(const std::string& config_node_name);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
Status
CheckConfigVersion(const std::string& value);
/* server config */ /* server config */
Status Status
CheckServerConfigAddress(const std::string& value); CheckServerConfigAddress(const std::string& value);
@ -193,6 +200,8 @@ class Config {
std::string std::string
GetConfigSequenceStr(const std::string& parent_key, const std::string& child_key, const std::string& delim = ",", GetConfigSequenceStr(const std::string& parent_key, const std::string& child_key, const std::string& delim = ",",
const std::string& default_value = ""); const std::string& default_value = "");
Status
GetConfigVersion(std::string& value);
public: public:
/* server config */ /* server config */

View File

@ -28,6 +28,8 @@ namespace {
static const char* VALID_CONFIG_STR = static const char* VALID_CONFIG_STR =
"# Default values are used when you make no changes to the following parameters.\n" "# Default values are used when you make no changes to the following parameters.\n"
"\n" "\n"
"version: 0.1"
"\n"
"server_config:\n" "server_config:\n"
" address: 0.0.0.0 # milvus server ip address (IPv4)\n" " address: 0.0.0.0 # milvus server ip address (IPv4)\n"
" port: 19530 # port range: 1025 ~ 65534\n" " port: 19530 # port range: 1025 ~ 65534\n"