ServerConfig.h 3.0 KB
Newer Older
G
groot 已提交
1 2 3 4 5 6 7 8 9 10
/*******************************************************************************
 * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
 * Unauthorized copying of this file, via any medium is strictly prohibited.
 * Proprietary and confidential.
 ******************************************************************************/
#pragma once

#include "utils/Error.h"
#include "config/ConfigNode.h"

Z
zhiru 已提交
11
#include "yaml-cpp/yaml.h"
G
groot 已提交
12 13

namespace zilliz {
J
jinhai 已提交
14
namespace milvus {
G
groot 已提交
15 16
namespace server {

J
jinhai 已提交
17 18 19 20 21 22
static const char* CONFIG_SERVER = "server_config";
static const char* CONFIG_SERVER_ADDRESS = "address";
static const char* CONFIG_SERVER_PORT = "port";
static const char* CONFIG_SERVER_PROTOCOL = "transfer_protocol";
static const char* CONFIG_CLUSTER_MODE = "mode";
static const char* CONFIG_GPU_INDEX = "gpu_index";
G
groot 已提交
23

J
jinhai 已提交
24 25 26 27 28 29 30 31 32
static const char* CONFIG_DB = "db_config";
static const char* CONFIG_DB_URL = "db_backend_url";
static const char* CONFIG_DB_PATH = "db_path";
static const char* CONFIG_DB_SLAVE_PATH = "db_slave_path";
static const char* CONFIG_DB_INDEX_TRIGGER_SIZE = "index_building_threshold";
static const char* CONFIG_DB_ARCHIVE_DISK = "archive_disk_threshold";
static const char* CONFIG_DB_ARCHIVE_DAYS = "archive_days_threshold";
static const char* CONFIG_DB_INSERT_BUFFER_SIZE = "insert_buffer_size";
static const char* CONFIG_DB_PARALLEL_REDUCE = "parallel_reduce";
G
groot 已提交
33

J
jinhai 已提交
34
static const char* CONFIG_LOG = "log_config";
G
groot 已提交
35

J
jinhai 已提交
36 37 38 39 40
static const char* CONFIG_CACHE = "cache_config";
static const char* CONFIG_CPU_CACHE_CAPACITY = "cpu_cache_capacity";
static const char* CONFIG_GPU_CACHE_CAPACITY = "gpu_cache_capacity";
static const char* CACHE_FREE_PERCENT = "cache_free_percent";
static const char* CONFIG_INSERT_CACHE_IMMEDIATELY = "insert_cache_immediately";
Y
Yu Kun 已提交
41 42
static const char* CONFIG_GPU_IDS = "gpu_ids";
static const char *GPU_CACHE_FREE_PERCENT = "gpu_cache_free_percent";
G
groot 已提交
43

J
jinhai 已提交
44 45
static const char* CONFIG_LICENSE = "license_config";
static const char* CONFIG_LICENSE_PATH = "license_path";
Y
yangwei.yao 已提交
46

J
jinhai 已提交
47 48 49 50 51
static const char* CONFIG_METRIC = "metric_config";
static const char* CONFIG_METRIC_IS_STARTUP = "is_startup";
static const char* CONFIG_METRIC_COLLECTOR = "collector";
static const char* CONFIG_PROMETHEUS = "prometheus_config";
static const char* CONFIG_METRIC_PROMETHEUS_PORT = "port";
Y
yu yunfeng 已提交
52

G
groot 已提交
53 54 55 56 57 58 59 60
static const std::string CONFIG_ENGINE = "engine_config";
static const std::string CONFIG_NPROBE = "nprobe";
static const std::string CONFIG_NLIST = "nlist";
static const std::string CONFIG_DCBT = "use_blas_threshold";
static const std::string CONFIG_METRICTYPE = "metric_type";
static const std::string CONFIG_OMP_THREAD_NUM = "omp_thread_num";
static const std::string CONFIG_USE_HYBRID_INDEX = "use_hybrid_index";
static const std::string CONFIG_HYBRID_INDEX_GPU = "hybrid_index_gpu";
Y
yu yunfeng 已提交
61

G
groot 已提交
62 63
class ServerConfig {
 public:
G
groot 已提交
64
    static ServerConfig &GetInstance();
G
groot 已提交
65 66

    ServerError LoadConfigFile(const std::string& config_filename);
G
groot 已提交
67
    ServerError ValidateConfig() const;
G
groot 已提交
68 69
    void PrintAll() const;

G
groot 已提交
70 71
    ConfigNode GetConfig(const std::string& name) const;
    ConfigNode& GetConfig(const std::string& name);
G
groot 已提交
72 73 74 75 76 77
};

}
}
}