Line data Source code
1 : use utils::id::NodeId;
2 :
3 : use crate::hadron_dns::NodeType;
4 :
5 : /// Internal representation of how a compute node should connect to a PS or SK node. HCC uses this struct to
6 : /// construct connection strings that are passed to the compute node via the compute spec. This struct is never
7 : /// serialized or sent over the wire.
8 : #[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
9 : pub(crate) struct NodeConnectionInfo {
10 : // Type of the node.
11 : node_type: NodeType,
12 : // Node ID. Unique for each node type.
13 : pub(crate) node_id: NodeId,
14 : // The hostname reported by the node when it registers. This is the hostname we store in the meta PG, and is
15 : // typically the k8s cluster DNS name of the node. Note that this may not be resolvable from compute nodes running
16 : // on dblet. For this reason, this hostname is usually not communicated to the compute node. Instead, HCC computes
17 : // a DNS name of the node in the Cloud DNS hosted zone based on `node_type` and `node_id` and advertise the DNS name
18 : // to compute nodes. This hostname here is used as a fallback in tests or other scenarios where we do not have the
19 : // Cloud DNS hosted zone available.
20 : registration_hostname: String,
21 : // The PG wire protocol port on the PS or SK node.
22 : port: u16,
23 : }
24 :
25 : impl NodeConnectionInfo {
26 0 : pub(crate) fn new(node_type: NodeType, node_id: NodeId, hostname: String, port: u16) -> Self {
27 0 : NodeConnectionInfo {
28 0 : node_type,
29 0 : node_id,
30 0 : registration_hostname: hostname,
31 0 : port,
32 0 : }
33 0 : }
34 : }
|