Coverage Report

Created: 2026-05-08 23:56

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/service/http/action/compaction_action.h
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
#pragma once
19
20
#include <stdint.h>
21
22
#include <string>
23
24
#include "common/status.h"
25
#include "service/http/http_handler_with_auth.h"
26
#include "storage/tablet/tablet.h"
27
28
namespace doris {
29
class HttpRequest;
30
31
class ExecEnv;
32
33
enum class CompactionActionType {
34
    SHOW_INFO = 1,
35
    RUN_COMPACTION = 2,
36
    RUN_COMPACTION_STATUS = 3,
37
};
38
39
const std::string PARAM_COMPACTION_TYPE = "compact_type";
40
const std::string PARAM_COMPACTION_BASE = "base";
41
const std::string PARAM_COMPACTION_CUMULATIVE = "cumulative";
42
const std::string PARAM_COMPACTION_FULL = "full";
43
const std::string PARAM_COMPACTION_REMOTE = "remote";
44
const std::string PARAM_COMPACTION_FORCE = "force";
45
46
/// This action is used for viewing the compaction status.
47
/// See compaction-action.md for details.
48
class CompactionAction : public HttpHandlerWithAuth {
49
public:
50
    CompactionAction(CompactionActionType ctype, ExecEnv* exec_env, StorageEngine& engine,
51
                     TPrivilegeHier::type hier, TPrivilegeType::type ptype);
52
53
16
    ~CompactionAction() override = default;
54
55
    void handle(HttpRequest* req) override;
56
57
private:
58
    Status _handle_show_compaction(HttpRequest* req, std::string* json_result);
59
60
    /// execute compaction request to run compaction task
61
    /// param compact_type in req to distinguish the task type, base or cumulative
62
    Status _handle_run_compaction(HttpRequest* req, std::string* json_result);
63
64
    /// thread callback function for the tablet to do base/cumulative compaction
65
    Status _execute_compaction_callback(TabletSharedPtr tablet, const std::string& compaction_type,
66
                                        bool fetch_from_remote);
67
68
    /// fetch compaction running status
69
    Status _handle_run_status_compaction(HttpRequest* req, std::string* json_result);
70
71
private:
72
    StorageEngine& _engine;
73
    CompactionActionType _compaction_type;
74
};
75
76
} // end namespace doris