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/load_channel_action.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/action/load_channel_action.h"
19
20
#include <algorithm>
21
#include <cstdint>
22
#include <cstdlib>
23
#include <limits>
24
#include <string>
25
#include <vector>
26
27
#include "cloud/config.h"
28
#include "load/channel/load_channel_mgr.h"
29
#include "runtime/exec_env.h"
30
#include "service/backend_options.h"
31
#include "service/http/http_channel.h"
32
#include "service/http/http_headers.h"
33
#include "service/http/http_request.h"
34
#include "service/http/http_status.h"
35
#include "storage/olap_common.h"
36
#include "storage/storage_engine.h"
37
#include "storage/tablet/tablet_manager.h"
38
39
namespace doris {
40
41
const static std::string HEADER_JSON = "application/json";
42
43
0
void LoadChannelAction::handle(HttpRequest* req) {
44
0
    req->add_output_header(HttpHeaders::CONTENT_TYPE, HEADER_JSON.c_str());
45
0
    HttpChannel::send_reply(req, HttpStatus::OK, _get_load_channels().ToString());
46
0
}
47
48
0
EasyJson LoadChannelAction::_get_load_channels() {
49
0
    EasyJson response;
50
51
0
    auto load_channels = ExecEnv::GetInstance()->load_channel_mgr()->get_all_load_channel_ids();
52
53
0
    response["msg"] = "OK";
54
0
    response["code"] = 0;
55
0
    EasyJson data = response.Set("data", EasyJson::kObject);
56
0
    data["host"] = BackendOptions::get_localhost();
57
0
    EasyJson tablets = data.Set("load_channels", EasyJson::kArray);
58
0
    for (auto& load_id : load_channels) {
59
0
        EasyJson tablet = tablets.PushBack(EasyJson::kObject);
60
0
        tablet["load_id"] = load_id;
61
0
    }
62
0
    response["count"] = load_channels.size();
63
0
    return response;
64
0
}
65
66
} // namespace doris