ServerConfig.h 3.2 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
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_CLUSTER_MODE = "mode";
static const char* CONFIG_GPU_INDEX = "gpu_index";
G
groot 已提交
22

J
jinhai 已提交
23 24 25 26 27 28 29 30
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_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 已提交
31

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

J
jinhai 已提交
34 35 36
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";
37
static const char* CACHE_FREE_PERCENT = "cpu_cache_free_percent";
J
jinhai 已提交
38
static const char* CONFIG_INSERT_CACHE_IMMEDIATELY = "insert_cache_immediately";
Y
Yu Kun 已提交
39 40
static const char* CONFIG_GPU_IDS = "gpu_ids";
static const char *GPU_CACHE_FREE_PERCENT = "gpu_cache_free_percent";
G
groot 已提交
41

J
jinhai 已提交
42 43 44 45 46
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 已提交
47

Y
Yu Kun 已提交
48 49 50
static const char* CONFIG_ENGINE = "engine_config";
static const char* CONFIG_DCBT = "use_blas_threshold";
static const char* CONFIG_OMP_THREAD_NUM = "omp_thread_num";
Y
yu yunfeng 已提交
51

W
wxyu 已提交
52 53 54 55 56 57 58
static const char* CONFIG_RESOURCE = "resource_config";
static const char* CONFIG_RESOURCES = "resources";
static const char* CONFIG_RESOURCE_TYPE = "type";
static const char* CONFIG_RESOURCE_MEMORY = "memory";
static const char* CONFIG_RESOURCE_DEVICE_ID = "device_id";
static const char* CONFIG_RESOURCE_ENABLE_LOADER = "enable_loader";
static const char* CONFIG_RESOURCE_ENABLE_EXECUTOR = "enable_executor";
X
xj.lin 已提交
59 60 61
static const char* CONFIG_RESOURCE_NUM = "gpu_resource_num";
static const char* CONFIG_RESOURCE_PIN_MEMORY = "pinned_memory";
static const char* CONFIG_RESOURCE_TEMP_MEMORY = "temp_memory";
W
wxyu 已提交
62
static const char* CONFIG_RESOURCE_CONNECTIONS = "connections";
63
static const char* CONFIG_SPEED_CONNECTIONS = "speed";
Y
Yu Kun 已提交
64
static const char* CONFIG_ENDPOINT_CONNECTIONS = "endpoint";
W
wxyu 已提交
65 66


G
groot 已提交
67 68
class ServerConfig {
 public:
G
groot 已提交
69
    static ServerConfig &GetInstance();
G
groot 已提交
70

G
groot 已提交
71 72
    ErrorCode LoadConfigFile(const std::string& config_filename);
    ErrorCode ValidateConfig() const;
G
groot 已提交
73 74
    void PrintAll() const;

G
groot 已提交
75 76
    ConfigNode GetConfig(const std::string& name) const;
    ConfigNode& GetConfig(const std::string& name);
G
groot 已提交
77 78 79 80 81 82
};

}
}
}