Class NodeInfo

java.lang.Object
com.loomcache.common.model.NodeInfo

public final class NodeInfo extends Object
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 Details

    • NodeInfo

      public NodeInfo(String nodeId, String host, int port, int instanceNumber)
      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 number
      instanceNumber - 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 number
      instanceNumber - instance number for logging
      attributes - immutable member attributes such as rack, zone, node, or region
      Throws:
      IllegalArgumentException - if nodeId, host, or attributes are invalid
  • Method Details

    • withAlive

      public NodeInfo withAlive(boolean alive)
      Return a copy of this node with the alive flag 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

      public NodeInfo withPort(int port)
    • withAttributes

      public NodeInfo withAttributes(Map<String,String> attributes)
    • address

      public String address()
      Get the full address of this node.
      Returns:
      "host:port" format address
    • logPrefix

      public String logPrefix()
      Get the log prefix for this node.
      Returns:
      formatted log prefix like "[Node-1/node-1]"