Coverage Report

Created: 2026-03-14 20:54

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