Coverage Report

Created: 2026-09-14 20:34

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/runtime/cluster_info.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 <gen_cpp/Types_types.h>
21
22
#include <atomic>
23
#include <string>
24
25
namespace doris {
26
27
// This class is used to save the cluster info
28
// like cluster id, epoch, cloud_unique_id, etc.
29
// These info are usually in heartbeat from Master FE.
30
class ClusterInfo {
31
public:
32
2.19M
    int64_t row_binlog_ttl_reference_tso() const {
33
2.19M
        return _row_binlog_ttl_reference_tso.load(std::memory_order_acquire);
34
2.19M
    }
35
36
    // Heartbeat identity validation must precede this call. Never persist this value:
37
    // after a restart cleanup waits for a fresh, authenticated master heartbeat.
38
26.0k
    void advance_row_binlog_ttl_reference_tso(int64_t tso) {
39
26.0k
        auto previous = _row_binlog_ttl_reference_tso.load(std::memory_order_acquire);
40
26.0k
        while (tso > previous && !_row_binlog_ttl_reference_tso.compare_exchange_weak(
41
552
                                         previous, tso, std::memory_order_acq_rel)) {
42
5
        }
43
26.0k
    }
44
45
    // Unique cluster id
46
    int32_t cluster_id = 0;
47
    // Master FE addr: ip:rpc_port
48
    TNetworkAddress master_fe_addr;
49
    // Master FE http_port
50
    int32_t master_fe_http_port = 0;
51
    // Unique cluster token
52
    std::string token = "";
53
    // Backend ID
54
    int64_t backend_id = 0;
55
56
    // Auth token for internal authentication
57
    // Save the last 2 tokens to avoid token invalid during token update
58
    std::string curr_auth_token = "";
59
    std::string last_auth_token = "";
60
61
private:
62
    std::atomic<int64_t> _row_binlog_ttl_reference_tso {0};
63
};
64
65
} // namespace doris