1/**
2 * Copyright 2021 Alibaba, Inc. and its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15
16 * \author Hongqing.hu
17 * \date Nov 2020
18 * \brief Interface of Bilin Config
19 */
20
21#pragma once
22
23#include <ailego/pattern/singleton.h>
24#include "proto/config.pb.h"
25#include "macro_define.h"
26
27namespace proxima {
28namespace be {
29
30/*! Config
31 */
32class Config : public ailego::Singleton<Config> {
33 public:
34 //! Load config from file
35 int load_config(const std::string &file_name);
36
37 //! Cleanup config options
38 int cleanup();
39
40 //! Validate config
41 bool validate_config() const;
42
43 /** ============Common Config for ProximaSE============= **/
44 //! Get rpc protocol
45 std::string get_protocol() const;
46
47 //! Get grpc listen port
48 uint32_t get_grpc_listen_port() const;
49
50 //! Get http listen port
51 uint32_t get_http_listen_port() const;
52
53 //! Get log directory
54 std::string get_log_dir() const;
55
56 //! Get log file name
57 std::string get_log_file() const;
58
59 //! Get log print level [0~5]
60 uint32_t get_log_level() const;
61
62 //! Get logger type
63 std::string get_logger_type() const;
64
65 /** ============Index Config============= **/
66 //! Get index build thread count
67 uint32_t get_index_build_thread_count(void) const;
68
69 //! Get index dump thread count
70 uint32_t get_index_dump_thread_count(void) const;
71
72 //! Get index agent max build qps
73 uint32_t get_index_max_build_qps(void) const;
74
75 //! Get directory of index data
76 std::string get_index_directory(void) const;
77
78 //! Get flush internal seconds
79 uint32_t get_index_flush_internal(void) const;
80
81 //! Get optimize internal seconds
82 uint32_t get_index_optimize_internal(void) const;
83
84 /** ============Meta Config============= **/
85 std::string get_meta_uri(void) const;
86
87 /** ============Query Config============= **/
88 //! Get query thread count
89 uint32_t get_query_thread_count(void) const;
90
91 //! Get metrics config
92 const proto::MetricsConfig &metrics_config() const {
93 return config_.common_config().metrics_config();
94 }
95
96 private:
97 //! Members
98 std::string config_file_{};
99 proto::ProximaSEConfig config_{};
100};
101
102
103} // namespace be
104} // end namespace proxima
105