Class NodeInfo
java.lang.Object
com.loomcache.common.model.NodeInfo
Identity of a cache cluster node.
Shared between server and client for partition table lookups.
Thread safety: effectively immutable after construction. The alive flag
is changed via withAlive(boolean), which returns a new instance (copy-on-write).
This allows atomic replacement inside ConcurrentHashMap
without external synchronization.
A no-arg constructor is retained for Kryo deserialization (which sets fields via reflection).
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
NodeInfo
Create a new NodeInfo with the given parameters.- Parameters:
nodeId- unique node identifier (must not be null or blank)host- IP address or hostname (must not be null or blank)port- TCP port numberinstanceNumber- instance number for logging- Throws:
IllegalArgumentException- if nodeId or host are null or blank
-
NodeInfo
public NodeInfo(String nodeId, String host, int port, int instanceNumber, Map<String, String> attributes) Create a new NodeInfo with member attributes.- Parameters:
nodeId- unique node identifier (must not be null or blank)host- IP address or hostname (must not be null or blank)port- TCP port numberinstanceNumber- instance number for loggingattributes- immutable member attributes such as rack, zone, node, or region- Throws:
IllegalArgumentException- if nodeId, host, or attributes are invalid
-
-
Method Details
-
withAlive
Return a copy of this node with thealiveflag set to the given value. All other fields are copied as-is. This is the only supported way to change liveness after construction (copy-on-write for thread safety).- Parameters:
alive- the new alive status- Returns:
- a new NodeInfo instance with the updated alive flag
-
withPort
-
withAttributes
-
address
-
logPrefix
Get the log prefix for this node.- Returns:
- formatted log prefix like "[Node-1/node-1]"
-