be/src/service/http_service.cpp
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 | | #include "service/http_service.h" |
19 | | |
20 | | #include <event2/bufferevent.h> |
21 | | #include <event2/http.h> |
22 | | #include <gen_cpp/FrontendService_types.h> |
23 | | |
24 | | #include <string> |
25 | | #include <vector> |
26 | | |
27 | | #include "cloud/cloud_compaction_action.h" |
28 | | #include "cloud/config.h" |
29 | | #include "cloud/injection_point_action.h" |
30 | | #include "common/config.h" |
31 | | #include "common/metrics/doris_metrics.h" |
32 | | #include "common/status.h" |
33 | | #include "load/load_path_mgr.h" |
34 | | #include "runtime/exec_env.h" |
35 | | #include "service/http/action/adjust_log_level.h" |
36 | | #include "service/http/action/adjust_tracing_dump.h" |
37 | | #include "service/http/action/batch_download_action.h" |
38 | | #include "service/http/action/be_proc_thread_action.h" |
39 | | #include "service/http/action/calc_file_crc_action.h" |
40 | | #include "service/http/action/check_encryption_action.h" |
41 | | #include "service/http/action/check_rpc_channel_action.h" |
42 | | #include "service/http/action/check_tablet_segment_action.h" |
43 | | #include "service/http/action/checksum_action.h" |
44 | | #include "service/http/action/clear_cache_action.h" |
45 | | #include "service/http/action/compaction_action.h" |
46 | | #include "service/http/action/compaction_profile_action.h" |
47 | | #include "service/http/action/compaction_score_action.h" |
48 | | #include "service/http/action/config_action.h" |
49 | | #include "service/http/action/debug_point_action.h" |
50 | | #include "service/http/action/delete_bitmap_action.h" |
51 | | #include "service/http/action/dictionary_status_action.h" |
52 | | #include "service/http/action/download_action.h" |
53 | | #include "service/http/action/download_binlog_action.h" |
54 | | #include "service/http/action/file_cache_action.h" |
55 | | #include "service/http/action/health_action.h" |
56 | | #include "service/http/action/http_stream.h" |
57 | | #include "service/http/action/jeprofile_actions.h" |
58 | | #include "service/http/action/load_channel_action.h" |
59 | | #include "service/http/action/load_stream_action.h" |
60 | | #include "service/http/action/meta_action.h" |
61 | | #include "service/http/action/metrics_action.h" |
62 | | #include "service/http/action/pad_rowset_action.h" |
63 | | #include "service/http/action/pipeline_task_action.h" |
64 | | #include "service/http/action/pprof_actions.h" |
65 | | #include "service/http/action/reload_tablet_action.h" |
66 | | #include "service/http/action/report_action.h" |
67 | | #include "service/http/action/reset_rpc_channel_action.h" |
68 | | #include "service/http/action/restore_tablet_action.h" |
69 | | #include "service/http/action/show_hotspot_action.h" |
70 | | #include "service/http/action/show_nested_index_file_action.h" |
71 | | #include "service/http/action/shrink_mem_action.h" |
72 | | #include "service/http/action/snapshot_action.h" |
73 | | #include "service/http/action/stream_load.h" |
74 | | #include "service/http/action/stream_load_2pc.h" |
75 | | #include "service/http/action/stream_load_forward_handler.h" |
76 | | #include "service/http/action/tablet_migration_action.h" |
77 | | #include "service/http/action/tablets_distribution_action.h" |
78 | | #include "service/http/action/tablets_info_action.h" |
79 | | #include "service/http/action/version_action.h" |
80 | | #include "service/http/default_path_handlers.h" |
81 | | #include "service/http/ev_http_server.h" |
82 | | #include "service/http/http_method.h" |
83 | | #include "service/http/web_page_handler.h" |
84 | | #include "storage/options.h" |
85 | | #include "storage/storage_engine.h" |
86 | | |
87 | | namespace doris { |
88 | | #include "common/compile_check_begin.h" |
89 | | namespace { |
90 | 8 | std::shared_ptr<bufferevent_rate_limit_group> get_rate_limit_group(event_base* event_base) { |
91 | 8 | auto rate_limit = config::download_binlog_rate_limit_kbs; |
92 | 8 | if (rate_limit <= 0) { |
93 | 8 | return nullptr; |
94 | 8 | } |
95 | | |
96 | 0 | auto max_value = std::numeric_limits<int32_t>::max() / 1024 * 10; |
97 | 0 | if (rate_limit > max_value) { |
98 | 0 | LOG(WARNING) << "rate limit is too large, set to max value."; |
99 | 0 | rate_limit = max_value; |
100 | 0 | } |
101 | 0 | struct timeval cfg_tick = {0, 100 * 1000}; // 100ms |
102 | 0 | rate_limit = rate_limit / 10 * 1024; // convert to KB/S |
103 | |
|
104 | 0 | auto token_bucket = std::unique_ptr<ev_token_bucket_cfg, decltype(&ev_token_bucket_cfg_free)>( |
105 | 0 | ev_token_bucket_cfg_new(rate_limit, rate_limit * 2, rate_limit, rate_limit * 2, |
106 | 0 | &cfg_tick), |
107 | 0 | ev_token_bucket_cfg_free); |
108 | 0 | return {bufferevent_rate_limit_group_new(event_base, token_bucket.get()), |
109 | 0 | bufferevent_rate_limit_group_free}; |
110 | 8 | } |
111 | | } // namespace |
112 | | |
113 | | HttpService::HttpService(ExecEnv* env, int port, int num_threads) |
114 | 8 | : _env(env), |
115 | 8 | _ev_http_server(new EvHttpServer(port, num_threads)), |
116 | 8 | _web_page_handler(new WebPageHandler(_ev_http_server.get(), env)) {} |
117 | | |
118 | 4 | HttpService::~HttpService() { |
119 | 4 | stop(); |
120 | 4 | } |
121 | | |
122 | | // NOLINTBEGIN(readability-function-size) |
123 | 7 | Status HttpService::start() { |
124 | 7 | add_default_path_handlers(_web_page_handler.get()); |
125 | | |
126 | 7 | auto event_base = _ev_http_server->get_event_bases()[0]; |
127 | 7 | _rate_limit_group = get_rate_limit_group(event_base.get()); |
128 | | |
129 | | // register load |
130 | 7 | StreamLoadAction* streamload_action = _pool.add(new StreamLoadAction(_env)); |
131 | 7 | _ev_http_server->register_handler(HttpMethod::PUT, "/api/{db}/{table}/_load", |
132 | 7 | streamload_action); |
133 | 7 | _ev_http_server->register_handler(HttpMethod::PUT, "/api/{db}/{table}/_stream_load", |
134 | 7 | streamload_action); |
135 | 7 | StreamLoad2PCAction* streamload_2pc_action = _pool.add(new StreamLoad2PCAction(_env)); |
136 | 7 | _ev_http_server->register_handler(HttpMethod::PUT, "/api/{db}/_stream_load_2pc", |
137 | 7 | streamload_2pc_action); |
138 | 7 | _ev_http_server->register_handler(HttpMethod::PUT, "/api/{db}/{table}/_stream_load_2pc", |
139 | 7 | streamload_2pc_action); |
140 | | |
141 | | // register stream load forward handler |
142 | 7 | auto* forward_handler = _pool.add(new StreamLoadForwardHandler()); |
143 | 7 | _ev_http_server->register_handler(HttpMethod::PUT, "/api/{db}/{table}/_stream_load_forward", |
144 | 7 | forward_handler); |
145 | | |
146 | | // register http_stream |
147 | 7 | HttpStreamAction* http_stream_action = _pool.add(new HttpStreamAction(_env)); |
148 | 7 | _ev_http_server->register_handler(HttpMethod::PUT, "/api/_http_stream", http_stream_action); |
149 | | |
150 | 7 | DownloadAction* error_log_download_action = |
151 | 7 | _pool.add(new DownloadAction(_env, _env->load_path_mgr()->get_load_error_file_dir())); |
152 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/api/_load_error_log", |
153 | 7 | error_log_download_action); |
154 | 7 | _ev_http_server->register_handler(HttpMethod::HEAD, "/api/_load_error_log", |
155 | 7 | error_log_download_action); |
156 | | |
157 | 7 | AdjustLogLevelAction* adjust_log_level_action = _pool.add(new AdjustLogLevelAction(_env)); |
158 | 7 | _ev_http_server->register_handler(HttpMethod::POST, "api/glog/adjust", adjust_log_level_action); |
159 | | |
160 | | //TODO: add query GET interface |
161 | 7 | auto* adjust_tracing_dump = _pool.add(new AdjustTracingDump(_env)); |
162 | 7 | _ev_http_server->register_handler(HttpMethod::POST, "api/pipeline/tracing", |
163 | 7 | adjust_tracing_dump); |
164 | | |
165 | | // Register BE version action |
166 | 7 | VersionAction* version_action = |
167 | 7 | _pool.add(new VersionAction(_env, TPrivilegeHier::GLOBAL, TPrivilegeType::NONE)); |
168 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/api/be_version_info", version_action); |
169 | | |
170 | | // Register BE health action |
171 | 7 | HealthAction* health_action = _pool.add(new HealthAction(_env)); |
172 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/api/health", health_action); |
173 | | |
174 | | // Clear cache action |
175 | 7 | ClearCacheAction* clear_cache_action = _pool.add(new ClearCacheAction(_env)); |
176 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/api/clear_cache/{type}", |
177 | 7 | clear_cache_action); |
178 | | |
179 | | // Dump all running pipeline tasks |
180 | 7 | PipelineTaskAction* pipeline_task_action = _pool.add(new PipelineTaskAction(_env)); |
181 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/api/running_pipeline_tasks", |
182 | 7 | pipeline_task_action); |
183 | | |
184 | | // Dump all running pipeline tasks which has been running for more than {duration} seconds |
185 | 7 | LongPipelineTaskAction* long_pipeline_task_action = _pool.add(new LongPipelineTaskAction(_env)); |
186 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/api/running_pipeline_tasks/{duration}", |
187 | 7 | long_pipeline_task_action); |
188 | | |
189 | | // Dump all running pipeline tasks which has been running for more than {duration} seconds |
190 | 7 | QueryPipelineTaskAction* query_pipeline_task_action = |
191 | 7 | _pool.add(new QueryPipelineTaskAction(_env)); |
192 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/api/query_pipeline_tasks/{query_id}", |
193 | 7 | query_pipeline_task_action); |
194 | | |
195 | | // Dump all be process thread num |
196 | 7 | BeProcThreadAction* be_proc_thread_action = _pool.add(new BeProcThreadAction(_env)); |
197 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/api/be_process_thread_num", |
198 | 7 | be_proc_thread_action); |
199 | | |
200 | | // Register BE LoadStream action |
201 | 7 | LoadStreamAction* load_stream_action = _pool.add(new LoadStreamAction(_env)); |
202 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/api/load_streams", load_stream_action); |
203 | | |
204 | | // Register BE LoadChannel action |
205 | 7 | LoadChannelAction* load_channel_action = _pool.add(new LoadChannelAction(_env)); |
206 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/api/load_channels", load_channel_action); |
207 | | |
208 | | // Register Tablets Info action |
209 | 7 | TabletsInfoAction* tablets_info_action = |
210 | 7 | _pool.add(new TabletsInfoAction(_env, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
211 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/tablets_json", tablets_info_action); |
212 | | |
213 | | // register pprof actions |
214 | 7 | static_cast<void>(PprofActions::setup(_env, _ev_http_server.get(), _pool)); |
215 | | |
216 | | // register jeprof actions |
217 | 7 | SetJeHeapProfileActiveActions* set_jeheap_profile_active_action = |
218 | 7 | _pool.add(new SetJeHeapProfileActiveActions(_env)); |
219 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/jeheap/active/{prof_value}", |
220 | 7 | set_jeheap_profile_active_action); |
221 | | |
222 | 7 | SetJeHeapProfileResetActions* set_jeheap_profile_reset_action = |
223 | 7 | _pool.add(new SetJeHeapProfileResetActions(_env)); |
224 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/jeheap/reset/{reset_value}", |
225 | 7 | set_jeheap_profile_reset_action); |
226 | | |
227 | 7 | DumpJeHeapProfileToDotActions* dump_jeheap_profile_to_dot_action = |
228 | 7 | _pool.add(new DumpJeHeapProfileToDotActions(_env)); |
229 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/jeheap/dump", |
230 | 7 | dump_jeheap_profile_to_dot_action); |
231 | | |
232 | 7 | DumpJeHeapProfileActions* dump_jeheap_profile_action = |
233 | 7 | _pool.add(new DumpJeHeapProfileActions(_env)); |
234 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/jeheap/dump_only", |
235 | 7 | dump_jeheap_profile_action); |
236 | | |
237 | | // register dictionary status action |
238 | 7 | DictionaryStatusAction* dict_status_action = _pool.add(new DictionaryStatusAction(_env)); |
239 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/api/dictionary_status", |
240 | 7 | dict_status_action); |
241 | | |
242 | | // register metrics |
243 | 7 | { |
244 | 7 | auto* action = |
245 | 7 | _pool.add(new MetricsAction(DorisMetrics::instance()->metric_registry(), _env, |
246 | 7 | TPrivilegeHier::GLOBAL, TPrivilegeType::NONE)); |
247 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/metrics", action); |
248 | 7 | } |
249 | | |
250 | 7 | MetaAction* meta_action = |
251 | 7 | _pool.add(new MetaAction(_env, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
252 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/api/meta/{op}/{tablet_id}", meta_action); |
253 | | |
254 | 7 | ConfigAction* update_config_action = |
255 | 7 | _pool.add(new ConfigAction(ConfigActionType::UPDATE_CONFIG, _env)); |
256 | 7 | _ev_http_server->register_handler(HttpMethod::POST, "/api/update_config", update_config_action); |
257 | | |
258 | 7 | ConfigAction* show_config_action = |
259 | 7 | _pool.add(new ConfigAction(ConfigActionType::SHOW_CONFIG, _env)); |
260 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/api/show_config", show_config_action); |
261 | | |
262 | | // 3 check action |
263 | 7 | CheckRPCChannelAction* check_rpc_channel_action = _pool.add( |
264 | 7 | new CheckRPCChannelAction(_env, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
265 | 7 | _ev_http_server->register_handler(HttpMethod::GET, |
266 | 7 | "/api/check_rpc_channel/{ip}/{port}/{payload_size}", |
267 | 7 | check_rpc_channel_action); |
268 | | |
269 | 7 | ResetRPCChannelAction* reset_rpc_channel_action = _pool.add( |
270 | 7 | new ResetRPCChannelAction(_env, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
271 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/api/reset_rpc_channel/{endpoints}", |
272 | 7 | reset_rpc_channel_action); |
273 | | |
274 | 7 | register_debug_point_handler(); |
275 | | |
276 | 7 | ReportAction* report_task_action = _pool.add( |
277 | 7 | new ReportAction(_env, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN, "REPORT_TASK")); |
278 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/api/report/task", report_task_action); |
279 | | |
280 | | // shrink memory for starting co-exist process during upgrade |
281 | 7 | ShrinkMemAction* shrink_mem_action = _pool.add(new ShrinkMemAction(_env)); |
282 | 7 | _ev_http_server->register_handler(HttpMethod::GET, "/api/shrink_mem", shrink_mem_action); |
283 | | |
284 | 7 | #ifndef BE_TEST |
285 | 7 | auto& engine = _env->storage_engine(); |
286 | 7 | if (config::is_cloud_mode()) { |
287 | 1 | register_cloud_handler(engine.to_cloud()); |
288 | 6 | } else { |
289 | 6 | register_local_handler(engine.to_local()); |
290 | 6 | } |
291 | 7 | #endif |
292 | 7 | _ev_http_server->start(); |
293 | 7 | return Status::OK(); |
294 | 7 | } |
295 | | // NOLINTEND(readability-function-size) |
296 | | |
297 | 8 | void HttpService::register_debug_point_handler() { |
298 | | // debug point |
299 | 8 | AddDebugPointAction* add_debug_point_action = |
300 | 8 | _pool.add(new AddDebugPointAction(_env, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
301 | 8 | _ev_http_server->register_handler(HttpMethod::POST, "/api/debug_point/add/{debug_point}", |
302 | 8 | add_debug_point_action); |
303 | | |
304 | 8 | RemoveDebugPointAction* remove_debug_point_action = _pool.add( |
305 | 8 | new RemoveDebugPointAction(_env, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
306 | 8 | _ev_http_server->register_handler(HttpMethod::POST, "/api/debug_point/remove/{debug_point}", |
307 | 8 | remove_debug_point_action); |
308 | | |
309 | 8 | ClearDebugPointsAction* clear_debug_points_action = _pool.add( |
310 | 8 | new ClearDebugPointsAction(_env, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
311 | 8 | _ev_http_server->register_handler(HttpMethod::POST, "/api/debug_point/clear", |
312 | 8 | clear_debug_points_action); |
313 | 8 | } |
314 | | |
315 | | // NOLINTBEGIN(readability-function-size) |
316 | 6 | void HttpService::register_local_handler(StorageEngine& engine) { |
317 | | // register download action |
318 | 6 | std::vector<std::string> allow_paths; |
319 | 10 | for (const auto& path : _env->store_paths()) { |
320 | 10 | allow_paths.emplace_back(path.path); |
321 | 10 | } |
322 | 6 | DownloadAction* download_action = _pool.add(new DownloadAction(_env, nullptr, allow_paths)); |
323 | 6 | _ev_http_server->register_handler(HttpMethod::HEAD, "/api/_download_load", download_action); |
324 | 6 | _ev_http_server->register_handler(HttpMethod::GET, "/api/_download_load", download_action); |
325 | | |
326 | 6 | DownloadAction* tablet_download_action = |
327 | 6 | _pool.add(new DownloadAction(_env, _rate_limit_group, allow_paths)); |
328 | 6 | _ev_http_server->register_handler(HttpMethod::HEAD, "/api/_tablet/_download", |
329 | 6 | tablet_download_action); |
330 | 6 | _ev_http_server->register_handler(HttpMethod::GET, "/api/_tablet/_download", |
331 | 6 | tablet_download_action); |
332 | | |
333 | 6 | BatchDownloadAction* batch_download_action = |
334 | 6 | _pool.add(new BatchDownloadAction(_env, _rate_limit_group, allow_paths)); |
335 | 6 | _ev_http_server->register_handler(HttpMethod::HEAD, "/api/_tablet/_batch_download", |
336 | 6 | batch_download_action); |
337 | 6 | _ev_http_server->register_handler(HttpMethod::GET, "/api/_tablet/_batch_download", |
338 | 6 | batch_download_action); |
339 | 6 | _ev_http_server->register_handler(HttpMethod::POST, "/api/_tablet/_batch_download", |
340 | 6 | batch_download_action); |
341 | | |
342 | 6 | if (config::enable_single_replica_load) { |
343 | 6 | DownloadAction* single_replica_download_action = _pool.add(new DownloadAction( |
344 | 6 | _env, nullptr, allow_paths, config::single_replica_load_download_num_workers)); |
345 | 6 | _ev_http_server->register_handler(HttpMethod::HEAD, "/api/_single_replica/_download", |
346 | 6 | single_replica_download_action); |
347 | 6 | _ev_http_server->register_handler(HttpMethod::GET, "/api/_single_replica/_download", |
348 | 6 | single_replica_download_action); |
349 | 6 | } |
350 | | |
351 | 6 | DownloadBinlogAction* download_binlog_action = |
352 | 6 | _pool.add(new DownloadBinlogAction(_env, engine, _rate_limit_group)); |
353 | 6 | _ev_http_server->register_handler(HttpMethod::GET, "/api/_binlog/_download", |
354 | 6 | download_binlog_action); |
355 | 6 | _ev_http_server->register_handler(HttpMethod::HEAD, "/api/_binlog/_download", |
356 | 6 | download_binlog_action); |
357 | | |
358 | 6 | FileCacheAction* file_cache_action = _pool.add(new FileCacheAction(_env)); |
359 | 6 | _ev_http_server->register_handler(HttpMethod::POST, "/api/file_cache", file_cache_action); |
360 | | |
361 | 6 | TabletsDistributionAction* tablets_distribution_action = |
362 | 6 | _pool.add(new TabletsDistributionAction(_env, engine, TPrivilegeHier::GLOBAL, |
363 | 6 | TPrivilegeType::ADMIN)); |
364 | 6 | _ev_http_server->register_handler(HttpMethod::GET, "/api/tablets_distribution", |
365 | 6 | tablets_distribution_action); |
366 | | |
367 | | // Register tablet migration action |
368 | 6 | TabletMigrationAction* tablet_migration_action = _pool.add( |
369 | 6 | new TabletMigrationAction(_env, engine, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
370 | 6 | _ev_http_server->register_handler(HttpMethod::GET, "/api/tablet_migration", |
371 | 6 | tablet_migration_action); |
372 | | |
373 | 6 | #ifndef BE_TEST |
374 | | // Register BE checksum action |
375 | 6 | ChecksumAction* checksum_action = _pool.add( |
376 | 6 | new ChecksumAction(_env, engine, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
377 | 6 | _ev_http_server->register_handler(HttpMethod::GET, "/api/checksum", checksum_action); |
378 | | |
379 | | // Register BE reload tablet action |
380 | 6 | ReloadTabletAction* reload_tablet_action = _pool.add( |
381 | 6 | new ReloadTabletAction(_env, engine, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
382 | 6 | _ev_http_server->register_handler(HttpMethod::GET, "/api/reload_tablet", reload_tablet_action); |
383 | | |
384 | 6 | RestoreTabletAction* restore_tablet_action = _pool.add( |
385 | 6 | new RestoreTabletAction(_env, engine, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
386 | 6 | _ev_http_server->register_handler(HttpMethod::POST, "/api/restore_tablet", |
387 | 6 | restore_tablet_action); |
388 | | |
389 | | // Register BE snapshot action |
390 | 6 | SnapshotAction* snapshot_action = _pool.add( |
391 | 6 | new SnapshotAction(_env, engine, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
392 | 6 | _ev_http_server->register_handler(HttpMethod::GET, "/api/snapshot", snapshot_action); |
393 | 6 | #endif |
394 | | // 2 compaction actions |
395 | 6 | CompactionAction* show_compaction_action = |
396 | 6 | _pool.add(new CompactionAction(CompactionActionType::SHOW_INFO, _env, engine, |
397 | 6 | TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
398 | 6 | _ev_http_server->register_handler(HttpMethod::GET, "/api/compaction/show", |
399 | 6 | show_compaction_action); |
400 | 6 | CompactionAction* run_compaction_action = |
401 | 6 | _pool.add(new CompactionAction(CompactionActionType::RUN_COMPACTION, _env, engine, |
402 | 6 | TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
403 | 6 | _ev_http_server->register_handler(HttpMethod::POST, "/api/compaction/run", |
404 | 6 | run_compaction_action); |
405 | 6 | CompactionAction* run_status_compaction_action = |
406 | 6 | _pool.add(new CompactionAction(CompactionActionType::RUN_COMPACTION_STATUS, _env, |
407 | 6 | engine, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
408 | | |
409 | 6 | _ev_http_server->register_handler(HttpMethod::GET, "/api/compaction/run_status", |
410 | 6 | run_status_compaction_action); |
411 | | |
412 | 6 | CompactionProfileAction* compaction_profile_action = _pool.add( |
413 | 6 | new CompactionProfileAction(_env, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
414 | 6 | _ev_http_server->register_handler(HttpMethod::GET, "/api/compaction/profile", |
415 | 6 | compaction_profile_action); |
416 | | |
417 | 6 | DeleteBitmapAction* count_delete_bitmap_action = |
418 | 6 | _pool.add(new DeleteBitmapAction(DeleteBitmapActionType::COUNT_LOCAL, _env, engine, |
419 | 6 | TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
420 | 6 | _ev_http_server->register_handler(HttpMethod::GET, "/api/delete_bitmap/count_local", |
421 | 6 | count_delete_bitmap_action); |
422 | 6 | DeleteBitmapAction* count_agg_cache_delete_bitmap_action = |
423 | 6 | _pool.add(new DeleteBitmapAction(DeleteBitmapActionType::COUNT_AGG_CACHE, _env, engine, |
424 | 6 | TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
425 | 6 | _ev_http_server->register_handler(HttpMethod::GET, "/api/delete_bitmap/count_agg_cache", |
426 | 6 | count_agg_cache_delete_bitmap_action); |
427 | | |
428 | 6 | CheckTabletSegmentAction* check_tablet_segment_action = _pool.add(new CheckTabletSegmentAction( |
429 | 6 | _env, engine, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
430 | 6 | _ev_http_server->register_handler(HttpMethod::POST, "/api/check_tablet_segment_lost", |
431 | 6 | check_tablet_segment_action); |
432 | | |
433 | 6 | PadRowsetAction* pad_rowset_action = _pool.add( |
434 | 6 | new PadRowsetAction(_env, engine, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
435 | 6 | _ev_http_server->register_handler(HttpMethod::POST, "/api/pad_rowset", pad_rowset_action); |
436 | | |
437 | 6 | ReportAction* report_tablet_action = _pool.add(new ReportAction( |
438 | 6 | _env, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN, "REPORT_OLAP_TABLET")); |
439 | 6 | _ev_http_server->register_handler(HttpMethod::GET, "/api/report/tablet", report_tablet_action); |
440 | | |
441 | 6 | ReportAction* report_disk_action = _pool.add(new ReportAction( |
442 | 6 | _env, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN, "REPORT_DISK_STATE")); |
443 | 6 | _ev_http_server->register_handler(HttpMethod::GET, "/api/report/disk", report_disk_action); |
444 | | |
445 | 6 | CalcFileCrcAction* calc_crc_action = _pool.add( |
446 | 6 | new CalcFileCrcAction(_env, engine, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
447 | 6 | _ev_http_server->register_handler(HttpMethod::GET, "/api/calc_crc", calc_crc_action); |
448 | | |
449 | 6 | ShowNestedIndexFileAction* show_nested_index_file_action = _pool.add( |
450 | 6 | new ShowNestedIndexFileAction(_env, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
451 | 6 | _ev_http_server->register_handler(HttpMethod::GET, "/api/show_nested_index_file", |
452 | 6 | show_nested_index_file_action); |
453 | | |
454 | 6 | CompactionScoreAction* compaction_score_action = _pool.add(new CompactionScoreAction( |
455 | 6 | _env, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN, engine.tablet_manager())); |
456 | 6 | _ev_http_server->register_handler(HttpMethod::GET, "/api/compaction_score", |
457 | 6 | compaction_score_action); |
458 | 6 | CheckEncryptionAction* check_encryption_action = |
459 | 6 | _pool.add(new CheckEncryptionAction(_env, TPrivilegeHier::GLOBAL, TPrivilegeType::ALL)); |
460 | 6 | _ev_http_server->register_handler(HttpMethod::GET, "/api/check_tablet_encryption", |
461 | 6 | check_encryption_action); |
462 | 6 | } |
463 | | |
464 | 1 | void HttpService::register_cloud_handler(CloudStorageEngine& engine) { |
465 | 1 | CloudCompactionAction* show_compaction_action = |
466 | 1 | _pool.add(new CloudCompactionAction(CompactionActionType::SHOW_INFO, _env, engine, |
467 | 1 | TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
468 | 1 | _ev_http_server->register_handler(HttpMethod::GET, "/api/compaction/show", |
469 | 1 | show_compaction_action); |
470 | 1 | CloudCompactionAction* run_compaction_action = |
471 | 1 | _pool.add(new CloudCompactionAction(CompactionActionType::RUN_COMPACTION, _env, engine, |
472 | 1 | TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
473 | 1 | _ev_http_server->register_handler(HttpMethod::POST, "/api/compaction/run", |
474 | 1 | run_compaction_action); |
475 | 1 | CloudCompactionAction* run_status_compaction_action = _pool.add( |
476 | 1 | new CloudCompactionAction(CompactionActionType::RUN_COMPACTION_STATUS, _env, engine, |
477 | 1 | TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
478 | 1 | _ev_http_server->register_handler(HttpMethod::GET, "/api/compaction/run_status", |
479 | 1 | run_status_compaction_action); |
480 | | |
481 | 1 | CompactionProfileAction* compaction_profile_action = _pool.add( |
482 | 1 | new CompactionProfileAction(_env, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
483 | 1 | _ev_http_server->register_handler(HttpMethod::GET, "/api/compaction/profile", |
484 | 1 | compaction_profile_action); |
485 | | |
486 | 1 | DeleteBitmapAction* count_local_delete_bitmap_action = |
487 | 1 | _pool.add(new DeleteBitmapAction(DeleteBitmapActionType::COUNT_LOCAL, _env, engine, |
488 | 1 | TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
489 | 1 | _ev_http_server->register_handler(HttpMethod::GET, "/api/delete_bitmap/count_local", |
490 | 1 | count_local_delete_bitmap_action); |
491 | 1 | DeleteBitmapAction* count_ms_delete_bitmap_action = |
492 | 1 | _pool.add(new DeleteBitmapAction(DeleteBitmapActionType::COUNT_MS, _env, engine, |
493 | 1 | TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
494 | 1 | _ev_http_server->register_handler(HttpMethod::GET, "/api/delete_bitmap/count_ms", |
495 | 1 | count_ms_delete_bitmap_action); |
496 | 1 | DeleteBitmapAction* count_agg_cache_delete_bitmap_action = |
497 | 1 | _pool.add(new DeleteBitmapAction(DeleteBitmapActionType::COUNT_AGG_CACHE, _env, engine, |
498 | 1 | TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
499 | 1 | _ev_http_server->register_handler(HttpMethod::GET, "/api/delete_bitmap/count_agg_cache", |
500 | 1 | count_agg_cache_delete_bitmap_action); |
501 | | #ifdef ENABLE_INJECTION_POINT |
502 | | |
503 | | InjectionPointAction* injection_point_action = _pool.add(new InjectionPointAction); |
504 | | _ev_http_server->register_handler(HttpMethod::GET, "/api/injection_point/{op}", |
505 | | injection_point_action); |
506 | | #endif |
507 | 1 | FileCacheAction* file_cache_action = _pool.add(new FileCacheAction(_env)); |
508 | 1 | _ev_http_server->register_handler(HttpMethod::GET, "/api/file_cache", file_cache_action); |
509 | 1 | auto* show_hotspot_action = _pool.add(new ShowHotspotAction(engine, _env)); |
510 | 1 | _ev_http_server->register_handler(HttpMethod::GET, "/api/hotspot/tablet", show_hotspot_action); |
511 | | |
512 | 1 | CalcFileCrcAction* calc_crc_action = _pool.add( |
513 | 1 | new CalcFileCrcAction(_env, engine, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
514 | 1 | _ev_http_server->register_handler(HttpMethod::GET, "/api/calc_crc", calc_crc_action); |
515 | | |
516 | 1 | ShowNestedIndexFileAction* show_nested_index_file_action = _pool.add( |
517 | 1 | new ShowNestedIndexFileAction(_env, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN)); |
518 | 1 | _ev_http_server->register_handler(HttpMethod::GET, "/api/show_nested_index_file", |
519 | 1 | show_nested_index_file_action); |
520 | 1 | CompactionScoreAction* compaction_score_action = _pool.add(new CompactionScoreAction( |
521 | 1 | _env, TPrivilegeHier::GLOBAL, TPrivilegeType::ADMIN, engine.tablet_mgr())); |
522 | 1 | _ev_http_server->register_handler(HttpMethod::GET, "/api/compaction_score", |
523 | 1 | compaction_score_action); |
524 | 1 | CheckEncryptionAction* check_encryption_action = |
525 | 1 | _pool.add(new CheckEncryptionAction(_env, TPrivilegeHier::GLOBAL, TPrivilegeType::ALL)); |
526 | 1 | _ev_http_server->register_handler(HttpMethod::GET, "/api/check_tablet_encryption", |
527 | 1 | check_encryption_action); |
528 | 1 | } |
529 | | // NOLINTEND(readability-function-size) |
530 | | |
531 | 7 | void HttpService::stop() { |
532 | 7 | if (stopped) { |
533 | 3 | return; |
534 | 3 | } |
535 | 4 | _ev_http_server->stop(); |
536 | 4 | _pool.clear(); |
537 | 4 | stopped = true; |
538 | 4 | } |
539 | | |
540 | 1 | int HttpService::get_real_port() const { |
541 | 1 | return _ev_http_server->get_real_port(); |
542 | 1 | } |
543 | | |
544 | | #include "common/compile_check_end.h" |
545 | | } // namespace doris |