ServerConfig.h 3.8 KB
Newer Older
J
jinhai 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

G
groot 已提交
18 19
#pragma once

S
starlord 已提交
20
#include "utils/Status.h"
G
groot 已提交
21 22
#include "config/ConfigNode.h"

Z
zhiru 已提交
23
#include "yaml-cpp/yaml.h"
G
groot 已提交
24 25

namespace zilliz {
J
jinhai 已提交
26
namespace milvus {
G
groot 已提交
27 28
namespace server {

J
jinhai 已提交
29 30 31 32
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";
33
static const char* CONFIG_TIME_ZONE = "time_zone";
G
groot 已提交
34

J
jinhai 已提交
35 36 37 38 39 40 41 42
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";
S
starlord 已提交
43
static const char* CONFIG_DB_BUILD_INDEX_GPU = "build_index_gpu";
G
groot 已提交
44

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

J
jinhai 已提交
47 48 49
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";
50
static const char* CACHE_FREE_PERCENT = "cpu_cache_free_percent";
J
jinhai 已提交
51
static const char* CONFIG_INSERT_CACHE_IMMEDIATELY = "insert_cache_immediately";
Y
Yu Kun 已提交
52
static const char *GPU_CACHE_FREE_PERCENT = "gpu_cache_free_percent";
G
groot 已提交
53

J
jinhai 已提交
54 55 56 57 58
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 已提交
59

Y
Yu Kun 已提交
60 61 62
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 已提交
63

W
wxyu 已提交
64 65 66 67 68
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_DEVICE_ID = "device_id";
static const char* CONFIG_RESOURCE_ENABLE_EXECUTOR = "enable_executor";
X
xj.lin 已提交
69 70 71
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 已提交
72
static const char* CONFIG_RESOURCE_CONNECTIONS = "connections";
73
static const char* CONFIG_SPEED_CONNECTIONS = "speed";
Y
Yu Kun 已提交
74
static const char* CONFIG_ENDPOINT_CONNECTIONS = "endpoint";
W
wxyu 已提交
75 76


G
groot 已提交
77 78
class ServerConfig {
 public:
G
groot 已提交
79
    static ServerConfig &GetInstance();
G
groot 已提交
80

S
starlord 已提交
81 82
    Status LoadConfigFile(const std::string& config_filename);
    Status ValidateConfig();
G
groot 已提交
83 84
    void PrintAll() const;

G
groot 已提交
85 86
    ConfigNode GetConfig(const std::string& name) const;
    ConfigNode& GetConfig(const std::string& name);
Z
zhiru 已提交
87 88

 private:
S
starlord 已提交
89 90 91 92 93 94
    Status CheckServerConfig();
    Status CheckDBConfig();
    Status CheckMetricConfig();
    Status CheckCacheConfig();
    Status CheckEngineConfig();
    Status CheckResourceConfig();
G
groot 已提交
95 96 97 98 99 100
};

}
}
}