Record Class IdentityNodeIdMapping

java.lang.Object
java.lang.Record
io.kroxylicious.proxy.internal.routing.IdentityNodeIdMapping
All Implemented Interfaces:
NodeIdMapping

public record IdentityNodeIdMapping(String routeName) extends Record implements NodeIdMapping
Identity node ID mapping for single-route configurations. Virtual IDs equal target IDs. Negative node IDs (Kafka protocol sentinels) are returned unchanged by all methods, satisfying the NodeIdMapping contract.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.kroxylicious.proxy.internal.routing.NodeIdMapping

    NodeIdMapping.RouteAndNode
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an instance of a IdentityNodeIdMapping record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    fromVirtual(int virtualNodeId)
    Translates a virtual node ID back to its route and target-cluster node ID.
    int
    fromVirtual(String route, int virtualNodeId)
    Translates a virtual node ID back to its target-cluster node ID, given the route.
    final int
    Returns a hash code value for this object.
    Returns the value of the routeName record component.
    final String
    Returns a string representation of this record class.
    int
    toVirtual(String route, int targetNodeId)
    Translates a target-cluster node ID to a virtual node ID.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • IdentityNodeIdMapping

      public IdentityNodeIdMapping(String routeName)
      Creates an instance of a IdentityNodeIdMapping record class.
      Parameters:
      routeName - the value for the routeName record component
  • Method Details

    • toVirtual

      public int toVirtual(String route, int targetNodeId)
      Description copied from interface: NodeIdMapping
      Translates a target-cluster node ID to a virtual node ID.

      Negative values (Kafka protocol sentinels such as -1 "no leader") are returned unchanged and must not be fed into the translation formula.

      Specified by:
      toVirtual in interface NodeIdMapping
      Parameters:
      route - the route name
      targetNodeId - the node ID on the target cluster
      Returns:
      the virtual node ID, or targetNodeId unchanged if negative
    • fromVirtual

      public int fromVirtual(String route, int virtualNodeId)
      Description copied from interface: NodeIdMapping
      Translates a virtual node ID back to its target-cluster node ID, given the route. The route is always supplied by the router via RouterContext.sendRequest(io.kroxylicious.proxy.topology.VirtualNode, org.apache.kafka.common.message.RequestHeaderData, org.apache.kafka.common.protocol.ApiMessage).

      As with NodeIdMapping.toVirtual(java.lang.String, int), negative values are returned unchanged.

      Specified by:
      fromVirtual in interface NodeIdMapping
      Parameters:
      route - the route name
      virtualNodeId - the virtual node ID
      Returns:
      the target-cluster node ID, or virtualNodeId unchanged if negative
    • fromVirtual

      public NodeIdMapping.RouteAndNode fromVirtual(int virtualNodeId)
      Description copied from interface: NodeIdMapping
      Translates a virtual node ID back to its route and target-cluster node ID. Only works for dedicated (one-to-one) mappings where the route can be recovered from the virtual node ID alone.

      Behaviour is undefined for negative inputs; proxy port node IDs are always non-negative and this method is never called with a sentinel value.

      Specified by:
      fromVirtual in interface NodeIdMapping
      Parameters:
      virtualNodeId - the virtual node ID
      Returns:
      the route name and target node ID
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • routeName

      public String routeName()
      Returns the value of the routeName record component.
      Returns:
      the value of the routeName record component