Coverage Report

Created: 2026-06-05 20:48

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/agent/heartbeat_server.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 <butil/macros.h>
21
#include <gen_cpp/HeartbeatService.h>
22
#include <stdint.h>
23
24
#include <mutex>
25
26
#include "common/status.h"
27
28
namespace doris {
29
class ClusterInfo;
30
class THeartbeatResult;
31
class TMasterInfo;
32
33
const uint32_t HEARTBEAT_INTERVAL = 10;
34
class BaseStorageEngine;
35
36
class HeartbeatServer : public HeartbeatServiceIf {
37
public:
38
    explicit HeartbeatServer(ClusterInfo* cluster_info);
39
0
    ~HeartbeatServer() override = default;
40
41
    void init_cluster_id();
42
43
    // Master send heartbeat to this server
44
    //
45
    // Input parameters:
46
    // * master_info: The struct of master info, contains cluster info from Master FE
47
    //
48
    // Output parameters:
49
    // * heartbeat_result: The result of heartbeat set
50
    void heartbeat(THeartbeatResult& heartbeat_result, const TMasterInfo& master_info) override;
51
52
private:
53
    Status _heartbeat(const TMasterInfo& master_info);
54
55
    BaseStorageEngine& _engine;
56
    int64_t _be_epoch;
57
58
    // mutex to protect cluster_info and _epoch
59
    std::mutex _hb_mtx;
60
    // Not owned. Point to the ExecEnv::_cluster_info
61
    ClusterInfo* _cluster_info = nullptr;
62
    int64_t _fe_epoch;
63
64
    DISALLOW_COPY_AND_ASSIGN(HeartbeatServer);
65
}; // class HeartBeatServer
66
67
} // namespace doris