Coverage Report

Created: 2026-06-02 21:33

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_BINLOG = "binlog";
44
const std::string PARAM_COMPACTION_REMOTE = "remote";
45
const std::string PARAM_COMPACTION_FORCE = "force";
46
47
/// This action is used for viewing the compaction status.
48
/// See compaction-action.md for details.
49
class CompactionAction : public HttpHandlerWithAuth {
50
public:
51
    CompactionAction(CompactionActionType ctype, ExecEnv* exec_env, StorageEngine& engine,
52
                     TPrivilegeHier::type hier, TPrivilegeType::type ptype);
53
54
16
    ~CompactionAction() override = default;
55
56
    void handle(HttpRequest* req) override;
57
58
private:
59
    Status _handle_show_compaction(HttpRequest* req, std::string* json_result);
60
61
    /// execute compaction request to run compaction task
62
    /// param compact_type in req to distinguish the task type, base/cumulative/full/binlog
63
    Status _handle_run_compaction(HttpRequest* req, std::string* json_result);
64
65
    /// thread callback function for the tablet to do base/cumulative/binlog compaction
66
    Status _execute_compaction_callback(TabletSharedPtr tablet, const std::string& compaction_type,
67
                                        bool fetch_from_remote,
68
                                        int8_t prefer_compaction_level = -1);
69
70
    /// fetch compaction running status
71
    Status _handle_run_status_compaction(HttpRequest* req, std::string* json_result);
72
73
private:
74
    StorageEngine& _engine;
75
    CompactionActionType _compaction_type;
76
};
77
78
} // end namespace doris