Record Class HashNode<T>
java.lang.Object
java.lang.Record
cloud.opencode.base.hash.consistent.HashNode<T>
- Type Parameters:
T- data type | 数据类型Security | 安全性:
- Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
- Null-safe: Yes (validates inputs) - 空值安全: 是(验证输入)
- Record Components:
id- unique node identifier | 唯一节点标识符data- node data | 节点数据weight- node weight (affects virtual node count) | 节点权重(影响虚拟节点数量)
Hash ring node representation
哈希环节点表示
Represents a physical node in a consistent hash ring with an identifier, associated data, and weight for load balancing.
表示一致性哈希环中的物理节点,包含标识符、关联数据和用于负载均衡的权重。
Features | 主要功能:
- Unique identifier - 唯一标识符
- Associated data - 关联数据
- Weight for load balancing - 用于负载均衡的权重
Usage Examples | 使用示例:
// Create a node with default weight
HashNode<String> node = HashNode.of("server1", "192.168.1.1");
// Create a weighted node
HashNode<String> weighted = HashNode.of("server2", "192.168.1.2", 2);
- Since:
- JDK 25, opencode-base-hash V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondata()Returns the value of thedatarecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.static <T> HashNode<T> Creates a node with default weight (1) 使用默认权重(1)创建节点static <T> HashNode<T> Creates a weighted node 创建带权重的节点toString()Returns a string representation of this record class.intweight()Returns the value of theweightrecord component.
-
Constructor Details
-
HashNode
-
-
Method Details
-
of
-
of
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
id
-
data
-
weight
-