/root/doris/be/src/service/backend_options.h
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #pragma once |
19 | | |
20 | | #include <butil/macros.h> |
21 | | |
22 | | #include <string> |
23 | | #include <vector> |
24 | | |
25 | | #include "gen_cpp/Types_types.h" |
26 | | #include "util/network_util.h" |
27 | | |
28 | | namespace doris { |
29 | | |
30 | | class CIDR; |
31 | | |
32 | | class BackendOptions { |
33 | | public: |
34 | | BackendOptions() = delete; |
35 | | static bool init(); |
36 | | static const std::string& get_localhost(); |
37 | | static std::string get_be_endpoint(); |
38 | | static TBackend get_local_backend(); |
39 | | static void set_backend_id(int64_t backend_id); |
40 | 39 | static int64_t get_backend_id() { return _s_backend_id; } |
41 | | static void set_localhost(const std::string& host); |
42 | | static bool is_bind_ipv6(); |
43 | | static const char* get_service_bind_address(); |
44 | | static const char* get_service_bind_address_without_bracket(); |
45 | | static bool analyze_priority_cidrs(const std::string& priority_networks, |
46 | | std::vector<CIDR>* cidrs); |
47 | | static bool analyze_localhost(std::string& localhost, bool& bind_ipv6, std::vector<CIDR>* cidrs, |
48 | | std::vector<InetAddress>* hosts); |
49 | | |
50 | | private: |
51 | | static bool is_in_prior_network(const std::string& ip); |
52 | | |
53 | | static std::string _s_localhost; |
54 | | static int64_t _s_backend_id; |
55 | | static std::vector<CIDR> _s_priority_cidrs; |
56 | | static bool _bind_ipv6; |
57 | | }; |
58 | | |
59 | | } // namespace doris |