Coverage Report

Created: 2025-07-23 20:08

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