Coverage Report

Created: 2026-06-23 16:30

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