Record Class TopologyConfig

java.lang.Object
java.lang.Record
com.loomcache.server.cluster.TopologyConfig
Record Components:
localNodeId - the local node identifier
localRack - rack identifier for the local node
localZone - zone identifier for the local node
localRegion - region identifier for the local node
preferLocalReads - whether to prefer local reads (default true)
maxTopologyDistance - maximum topology distance to consider for routing (default 4)

public record TopologyConfig(String localNodeId, String localRack, String localZone, String localRegion, boolean preferLocalReads, int maxTopologyDistance) extends Record
Configuration for topology-aware request routing.

Defines the local node's topology location and routing preferences.

Since:
1.0
  • Constructor Details

    • TopologyConfig

      public TopologyConfig(String localNodeId, String localRack, String localZone, String localRegion)
      Create a TopologyConfig with default values.
      Parameters:
      localNodeId - local node identifier
      localRack - local rack identifier
      localZone - local zone identifier
      localRegion - local region identifier
    • TopologyConfig

      public TopologyConfig(String localNodeId, String localRack, String localZone, String localRegion, boolean preferLocalReads, int maxTopologyDistance)
      Creates an instance of a TopologyConfig record class.
      Parameters:
      localNodeId - the value for the localNodeId record component
      localRack - the value for the localRack record component
      localZone - the value for the localZone record component
      localRegion - the value for the localRegion record component
      preferLocalReads - the value for the preferLocalReads record component
      maxTopologyDistance - the value for the maxTopologyDistance record component
  • Method Details

    • getLocalTopology

      public TopologyInfo getLocalTopology()
      Get the local topology info for this config.
      Returns:
      TopologyInfo for the local node
    • withPreferLocalReads

      public TopologyConfig withPreferLocalReads(boolean preferLocalReads)
      Create a new TopologyConfig with different routing preferences.
      Parameters:
      preferLocalReads - new preference for local reads
      Returns:
      new TopologyConfig with updated preference
    • withMaxTopologyDistance

      public TopologyConfig withMaxTopologyDistance(int maxTopologyDistance)
      Create a new TopologyConfig with different max topology distance.
      Parameters:
      maxTopologyDistance - new max distance
      Returns:
      new TopologyConfig with updated max distance
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • localNodeId

      public String localNodeId()
      Returns the value of the localNodeId record component.
      Returns:
      the value of the localNodeId record component
    • localRack

      public String localRack()
      Returns the value of the localRack record component.
      Returns:
      the value of the localRack record component
    • localZone

      public String localZone()
      Returns the value of the localZone record component.
      Returns:
      the value of the localZone record component
    • localRegion

      public String localRegion()
      Returns the value of the localRegion record component.
      Returns:
      the value of the localRegion record component
    • preferLocalReads

      public boolean preferLocalReads()
      Returns the value of the preferLocalReads record component.
      Returns:
      the value of the preferLocalReads record component
    • maxTopologyDistance

      public int maxTopologyDistance()
      Returns the value of the maxTopologyDistance record component.
      Returns:
      the value of the maxTopologyDistance record component