Coverage Report

Created: 2025-04-30 19:30

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