/root/doris/be/src/agent/utils.h
Line | Count | Source (jump to first uncovered line) |
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 <map> |
23 | | #include <string> |
24 | | |
25 | | #include "common/status.h" |
26 | | |
27 | | namespace doris { |
28 | | class TConfirmUnusedRemoteFilesRequest; |
29 | | class TConfirmUnusedRemoteFilesResult; |
30 | | class TFinishTaskRequest; |
31 | | class TMasterResult; |
32 | | class TReportRequest; |
33 | | class ClusterInfo; |
34 | | |
35 | | class MasterServerClient { |
36 | | public: |
37 | | static MasterServerClient* create(const ClusterInfo* cluster_info); |
38 | | static MasterServerClient* instance(); |
39 | | |
40 | | ~MasterServerClient() = default; |
41 | | |
42 | | // Report finished task to the master server |
43 | | // |
44 | | // Input parameters: |
45 | | // * request: The information of finished task |
46 | | // |
47 | | // Output parameters: |
48 | | // * result: The result of report task |
49 | | Status finish_task(const TFinishTaskRequest& request, TMasterResult* result); |
50 | | |
51 | | // Report tasks/olap tablet/disk state to the master server |
52 | | // |
53 | | // Input parameters: |
54 | | // * request: The information to report |
55 | | // |
56 | | // Output parameters: |
57 | | // * result: The result of report task |
58 | | Status report(const TReportRequest& request, TMasterResult* result); |
59 | | |
60 | | Status confirm_unused_remote_files(const TConfirmUnusedRemoteFilesRequest& request, |
61 | | TConfirmUnusedRemoteFilesResult* result); |
62 | | |
63 | | private: |
64 | | MasterServerClient(const ClusterInfo* cluster_info); |
65 | | |
66 | | DISALLOW_COPY_AND_ASSIGN(MasterServerClient); |
67 | | |
68 | | // Not owner. Reference to the ExecEnv::_cluster_info |
69 | | const ClusterInfo* _cluster_info; |
70 | | }; |
71 | | |
72 | | class AgentUtils { |
73 | | public: |
74 | 0 | AgentUtils() = default; |
75 | 0 | virtual ~AgentUtils() = default; |
76 | | |
77 | | // Execute shell cmd |
78 | | virtual bool exec_cmd(const std::string& command, std::string* errmsg, |
79 | | bool redirect_stderr = true); |
80 | | |
81 | | // Write a map to file by json format |
82 | | virtual bool write_json_to_file(const std::map<std::string, std::string>& info, |
83 | | const std::string& path); |
84 | | |
85 | | private: |
86 | | DISALLOW_COPY_AND_ASSIGN(AgentUtils); |
87 | | }; // class AgentUtils |
88 | | |
89 | | } // namespace doris |