Coverage Report

Created: 2026-06-03 19:59

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