Record Class IdentityNodeIdMapping
java.lang.Object
java.lang.Record
io.kroxylicious.proxy.internal.routing.IdentityNodeIdMapping
- All Implemented Interfaces:
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
ConstructorsConstructorDescriptionIdentityNodeIdMapping(String routeName) Creates an instance of aIdentityNodeIdMappingrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates 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.intfromVirtual(String route, int virtualNodeId) Translates a virtual node ID back to its target-cluster node ID, given the route.final inthashCode()Returns a hash code value for this object.Returns the value of therouteNamerecord component.final StringtoString()Returns a string representation of this record class.intTranslates a target-cluster node ID to a virtual node ID.
-
Constructor Details
-
IdentityNodeIdMapping
Creates an instance of aIdentityNodeIdMappingrecord class.- Parameters:
routeName- the value for therouteNamerecord component
-
-
Method Details
-
toVirtual
Description copied from interface:NodeIdMappingTranslates 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:
toVirtualin interfaceNodeIdMapping- Parameters:
route- the route nametargetNodeId- the node ID on the target cluster- Returns:
- the virtual node ID, or
targetNodeIdunchanged if negative
-
fromVirtual
Description copied from interface:NodeIdMappingTranslates a virtual node ID back to its target-cluster node ID, given the route. The route is always supplied by the router viaRouterContext.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:
fromVirtualin interfaceNodeIdMapping- Parameters:
route- the route namevirtualNodeId- the virtual node ID- Returns:
- the target-cluster node ID, or
virtualNodeIdunchanged if negative
-
fromVirtual
Description copied from interface:NodeIdMappingTranslates 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:
fromVirtualin interfaceNodeIdMapping- Parameters:
virtualNodeId- the virtual node ID- Returns:
- the route name and target node ID
-
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. -
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. -
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). -
routeName
Returns the value of therouteNamerecord component.- Returns:
- the value of the
routeNamerecord component
-