Commit 2aad94b6 authored by 蔡宇东's avatar 蔡宇东
Browse files

#560 add version in server config file

parent 7e394a26
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
- \#488 - Add log in scheduler/optimizer
- \#502 - C++ SDK support IVFPQ and SPTAG
- \#560 - Add version in server config file

## Improvement
- \#255 - Add ivfsq8 test report detailed version
+2 −0
Original line number Diff line number Diff line
# Default values are used when you make no changes to the following parameters.

version: 0.1                        # config version

server_config:
  address: 0.0.0.0                  # milvus server ip address (IPv4)
  port: 19530                       # milvus server port, must in range [1025, 65534]
+2 −0
Original line number Diff line number Diff line
# Default values are used when you make no changes to the following parameters.

version: 0.1                        # config version

server_config:
  address: 0.0.0.0                  # milvus server ip address (IPv4)
  port: 19530                       # milvus server port, must in range [1025, 65534]
+32 −3
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <iostream>
#include <regex>
#include <string>
#include <unordered_map>
#include <vector>

#include "config/YamlConfigMgr.h"
@@ -33,6 +34,8 @@ namespace server {

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::GetInstance() {
    static Config config_inst;
@@ -69,6 +72,12 @@ Status
Config::ValidateConfig() {
    Status s;

    std::string config_version;
    s = GetConfigVersion(config_version);
    if (!s.ok()) {
        return s;
    }

    /* server config */
    std::string 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
Config::CheckServerConfigAddress(const std::string& value) {
    if (!ValidationUtil::ValidateIpAddress(value).ok()) {
@@ -766,10 +785,14 @@ Config::CheckGpuResourceConfigBuildIndexResources(const std::vector<std::string>

////////////////////////////////////////////////////////////////////////////////
ConfigNode&
Config::GetConfigNode(const std::string& name) {
Config::GetConfigRoot() {
    ConfigMgr* mgr = YamlConfigMgr::GetInstance();
    ConfigNode& root_node = mgr->GetRootNode();
    return root_node.GetChild(name);
    return mgr->GetRootNode();
}

ConfigNode&
Config::GetConfigNode(const std::string& name) {
    return GetConfigRoot().GetChild(name);
}

Status
@@ -816,6 +839,12 @@ Config::GetConfigSequenceStr(const std::string& parent_key, const std::string& c
    return value;
}

Status
Config::GetConfigVersion(std::string& value) {
    value = GetConfigRoot().GetValue(CONFIG_VERSION);
    return CheckConfigVersion(value);
}

Status
Config::GetServerConfigAddress(std::string& value) {
    value = GetConfigStr(CONFIG_SERVER, CONFIG_SERVER_ADDRESS, CONFIG_SERVER_ADDRESS_DEFAULT);
+9 −0
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@
namespace milvus {
namespace server {

static const char* CONFIG_VERSION = "version";

/* server config */
static const char* CONFIG_SERVER = "server_config";
static const char* CONFIG_SERVER_ADDRESS = "address";
@@ -115,6 +117,8 @@ class Config {
    PrintAll();

 private:
    ConfigNode&
    GetConfigRoot();
    ConfigNode&
    GetConfigNode(const std::string& name);
    Status
@@ -125,6 +129,9 @@ class Config {
    PrintConfigSection(const std::string& config_node_name);

    ///////////////////////////////////////////////////////////////////////////
    Status
    CheckConfigVersion(const std::string& value);

    /* server config */
    Status
    CheckServerConfigAddress(const std::string& value);
@@ -193,6 +200,8 @@ class Config {
    std::string
    GetConfigSequenceStr(const std::string& parent_key, const std::string& child_key, const std::string& delim = ",",
                         const std::string& default_value = "");
    Status
    GetConfigVersion(std::string& value);

 public:
    /* server config */
Loading