Coverage Report

Created: 2026-07-08 03:15

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