/root/doris/be/src/service/backend_service.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 <gen_cpp/BackendService.h> |
21 | | |
22 | | #include <memory> |
23 | | #include <string> |
24 | | #include <vector> |
25 | | |
26 | | #include "agent/agent_server.h" |
27 | | #include "agent/topic_subscriber.h" |
28 | | #include "common/status.h" |
29 | | #include "runtime/stream_load/stream_load_recorder.h" |
30 | | |
31 | | namespace doris { |
32 | | |
33 | | class StorageEngine; |
34 | | class ExecEnv; |
35 | | class ThriftServer; |
36 | | class TAgentResult; |
37 | | class TAgentTaskRequest; |
38 | | class TAgentPublishRequest; |
39 | | class TStreamLoadRecordResult; |
40 | | class TDiskTrashInfo; |
41 | | class TCheckStorageFormatResult; |
42 | | class TRoutineLoadTask; |
43 | | class TScanBatchResult; |
44 | | class TScanCloseParams; |
45 | | class TScanCloseResult; |
46 | | class TScanNextBatchParams; |
47 | | class TScanOpenParams; |
48 | | class TScanOpenResult; |
49 | | class TSnapshotRequest; |
50 | | class TStatus; |
51 | | class TTabletStatResult; |
52 | | class TUniqueId; |
53 | | class TIngestBinlogRequest; |
54 | | class TIngestBinlogResult; |
55 | | class ThreadPool; |
56 | | |
57 | | // This class just forward rpc for actual handler |
58 | | // make this class because we can bind multiple service on single point |
59 | | class BaseBackendService : public BackendServiceIf { |
60 | | public: |
61 | | BaseBackendService(ExecEnv* exec_env); |
62 | | |
63 | | ~BaseBackendService() override; |
64 | | |
65 | | // Agent service |
66 | | void submit_tasks(TAgentResult& return_value, |
67 | 0 | const std::vector<TAgentTaskRequest>& tasks) override { |
68 | 0 | _agent_server->submit_tasks(return_value, tasks); |
69 | 0 | } |
70 | | |
71 | 0 | void publish_cluster_state(TAgentResult& result, const TAgentPublishRequest& request) override { |
72 | 0 | _agent_server->publish_cluster_state(result, request); |
73 | 0 | } |
74 | | |
75 | | void publish_topic_info(TPublishTopicResult& result, |
76 | 0 | const TPublishTopicRequest& topic_request) override { |
77 | 0 | _agent_server->get_topic_subscriber()->handle_topic_info(topic_request); |
78 | 0 | } |
79 | | |
80 | | void submit_routine_load_task(TStatus& t_status, |
81 | | const std::vector<TRoutineLoadTask>& tasks) override; |
82 | | |
83 | | // used for external service, open means start the scan procedure |
84 | | void open_scanner(TScanOpenResult& result_, const TScanOpenParams& params) override; |
85 | | |
86 | | // used for external service, external use getNext to fetch data batch after batch until eos = true |
87 | | void get_next(TScanBatchResult& result_, const TScanNextBatchParams& params) override; |
88 | | |
89 | | // used for external service, close some context and release resource related with this context |
90 | | void close_scanner(TScanCloseResult& result_, const TScanCloseParams& params) override; |
91 | | |
92 | | //////////////////////////////////////////////////////////////////////////// |
93 | | // begin local backend functions |
94 | | //////////////////////////////////////////////////////////////////////////// |
95 | | void get_tablet_stat(TTabletStatResult& result) override; |
96 | | |
97 | | int64_t get_trash_used_capacity() override; |
98 | | |
99 | | void get_stream_load_record(TStreamLoadRecordResult& result, |
100 | | int64_t last_stream_record_time) override; |
101 | | |
102 | | void get_disk_trash_used_capacity(std::vector<TDiskTrashInfo>& diskTrashInfos) override; |
103 | | |
104 | | void make_snapshot(TAgentResult& return_value, |
105 | | const TSnapshotRequest& snapshot_request) override; |
106 | | |
107 | | void release_snapshot(TAgentResult& return_value, const std::string& snapshot_path) override; |
108 | | |
109 | | void check_storage_format(TCheckStorageFormatResult& result) override; |
110 | | |
111 | | void ingest_binlog(TIngestBinlogResult& result, const TIngestBinlogRequest& request) override; |
112 | | |
113 | | void query_ingest_binlog(TQueryIngestBinlogResult& result, |
114 | | const TQueryIngestBinlogRequest& request) override; |
115 | | |
116 | | void get_realtime_exec_status(TGetRealtimeExecStatusResponse& response, |
117 | | const TGetRealtimeExecStatusRequest& request) override; |
118 | | |
119 | | void get_dictionary_status(TDictionaryStatusList& result, |
120 | | const std::vector<int64_t>& dictionary_id) override; |
121 | | |
122 | | //////////////////////////////////////////////////////////////////////////// |
123 | | // begin cloud backend functions |
124 | | //////////////////////////////////////////////////////////////////////////// |
125 | | void warm_up_cache_async(TWarmUpCacheAsyncResponse& response, |
126 | | const TWarmUpCacheAsyncRequest& request) override; |
127 | | |
128 | | void check_warm_up_cache_async(TCheckWarmUpCacheAsyncResponse& response, |
129 | | const TCheckWarmUpCacheAsyncRequest& request) override; |
130 | | |
131 | | // If another cluster load, FE need to notify the cluster to sync the load data |
132 | | void sync_load_for_tablets(TSyncLoadForTabletsResponse& response, |
133 | | const TSyncLoadForTabletsRequest& request) override; |
134 | | |
135 | | void get_top_n_hot_partitions(TGetTopNHotPartitionsResponse& response, |
136 | | const TGetTopNHotPartitionsRequest& request) override; |
137 | | |
138 | | void warm_up_tablets(TWarmUpTabletsResponse& response, |
139 | | const TWarmUpTabletsRequest& request) override; |
140 | | |
141 | 0 | void stop_works() { _agent_server->stop_report_workers(); } |
142 | | |
143 | | protected: |
144 | | void get_stream_load_record(TStreamLoadRecordResult& result, int64_t last_stream_record_time, |
145 | | std::shared_ptr<StreamLoadRecorder> stream_load_recorder); |
146 | | |
147 | | ExecEnv* _exec_env = nullptr; |
148 | | std::unique_ptr<AgentServer> _agent_server; |
149 | | std::unique_ptr<ThreadPool> _ingest_binlog_workers; |
150 | | }; |
151 | | |
152 | | // `StorageEngine` mixin for `BaseBackendService` |
153 | | class BackendService final : public BaseBackendService { |
154 | | public: |
155 | | // NOTE: now we do not support multiple backend in one process |
156 | | static Status create_service(StorageEngine& engine, ExecEnv* exec_env, int port, |
157 | | std::unique_ptr<ThriftServer>* server, |
158 | | std::shared_ptr<doris::BackendService> service); |
159 | | |
160 | | BackendService(StorageEngine& engine, ExecEnv* exec_env); |
161 | | |
162 | | ~BackendService() override; |
163 | | |
164 | | void get_tablet_stat(TTabletStatResult& result) override; |
165 | | |
166 | | int64_t get_trash_used_capacity() override; |
167 | | |
168 | | void get_stream_load_record(TStreamLoadRecordResult& result, |
169 | | int64_t last_stream_record_time) override; |
170 | | |
171 | | void get_disk_trash_used_capacity(std::vector<TDiskTrashInfo>& diskTrashInfos) override; |
172 | | |
173 | | void make_snapshot(TAgentResult& return_value, |
174 | | const TSnapshotRequest& snapshot_request) override; |
175 | | |
176 | | void release_snapshot(TAgentResult& return_value, const std::string& snapshot_path) override; |
177 | | |
178 | | void check_storage_format(TCheckStorageFormatResult& result) override; |
179 | | |
180 | | void ingest_binlog(TIngestBinlogResult& result, const TIngestBinlogRequest& request) override; |
181 | | |
182 | | void query_ingest_binlog(TQueryIngestBinlogResult& result, |
183 | | const TQueryIngestBinlogRequest& request) override; |
184 | | |
185 | | private: |
186 | | StorageEngine& _engine; |
187 | | }; |
188 | | |
189 | | } // namespace doris |