Record Class TopologyInfo
java.lang.Object
java.lang.Record
com.loomcache.server.cluster.TopologyInfo
- Record Components:
nodeId- unique node identifier (e.g., "node-1")rack- rack identifier (e.g., "rack-a")zone- zone identifier (e.g., "zone-1")region- region identifier (e.g., "us-west-2")
Represents the physical topology location of a node in a distributed cluster.
Topology hierarchy (from most specific to most general):
- Node ID: unique identifier for this node
- Rack: physical or logical grouping (e.g., same power supply, network switch)
- Zone: availability zone or data center section
- Region: geographic region or data center
Distance calculation:
- 0: same node
- 1: different node, same rack
- 2: different rack, same zone
- 3: different zone, same region
- 4: different region
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionTopologyInfo(String nodeId, String rack, String zone, String region) Creates an instance of aTopologyInforecord class. -
Method Summary
Modifier and TypeMethodDescriptionintdistance(TopologyInfo other) Calculate the distance to another topology location.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.nodeId()Returns the value of thenodeIdrecord component.rack()Returns the value of therackrecord component.region()Returns the value of theregionrecord component.booleansameRack(TopologyInfo other) Check if this topology is in the same rack as another.booleansameRegion(TopologyInfo other) Check if this topology is in the same region as another.booleansameZone(TopologyInfo other) Check if this topology is in the same zone as another.final StringtoString()Returns a string representation of this record class.zone()Returns the value of thezonerecord component.
-
Constructor Details
-
Method Details
-
distance
Calculate the distance to another topology location.Distance represents network proximity and failure correlation:
- 0: same node
- 1: same rack (different node)
- 2: same zone, different rack
- 3: same region, different zone
- 4: different region
- Parameters:
other- the other topology location- Returns:
- distance (0-4)
- Throws:
IllegalArgumentException- if other is null
-
sameRack
Check if this topology is in the same rack as another.- Parameters:
other- the other topology location- Returns:
- true if both are in the same rack
-
sameZone
Check if this topology is in the same zone as another.- Parameters:
other- the other topology location- Returns:
- true if both are in the same zone
-
sameRegion
Check if this topology is in the same region as another.- Parameters:
other- the other topology location- Returns:
- true if both are in the same region
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
nodeId
-
rack
-
zone
-
region
-