Class RouterDispatchHandler
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
io.kroxylicious.proxy.internal.routing.RouterDispatchHandler
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler,io.netty.channel.ChannelOutboundHandler
public class RouterDispatchHandler
extends io.netty.channel.ChannelDuplexHandler
Sits at the end of the VC-level filter chain (instead of
FilterChainCompletionHandler) when a
virtual cluster uses a router.
Statically-routed requests are forwarded directly to the
ClientConnectionStateMachine. Dynamically-routed requests are
deserialised and dispatched to Router.onRequest(org.apache.kafka.common.protocol.ApiKeys, short, org.apache.kafka.common.message.RequestHeaderData, org.apache.kafka.common.protocol.ApiMessage, io.kroxylicious.proxy.router.RouterContext).
The write(io.netty.channel.ChannelHandlerContext, java.lang.Object, io.netty.channel.ChannelPromise) override applies node ID translation for statically-routed
API keys whose responses carry broker node IDs.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Set<org.apache.kafka.common.protocol.ApiKeys> API keys whose responses carry node IDs that must be translated to virtual node IDs. -
Constructor Summary
ConstructorsConstructorDescriptionRouterDispatchHandler(io.kroxylicious.proxy.router.Router router, Map<String, RouteDescriptor> routes, Map<org.apache.kafka.common.protocol.ApiKeys, String> staticRoutes, ClientConnectionStateMachine ccsm, String virtualClusterName, NodeIdMapping nodeIdMapping, Integer nodeId) -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg) voidhandlerAdded(io.netty.channel.ChannelHandlerContext ctx) voidhandlerRemoved(io.netty.channel.ChannelHandlerContext ctx) resolveRouterNodeAddress(int virtualNodeId) Returns the upstream address for the given virtual node ID, as learned from the most recent internal METADATA response.voidwrite(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) Methods inherited from class io.netty.channel.ChannelDuplexHandler
bind, close, connect, deregister, disconnect, flush, readMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharable
-
Field Details
-
NODE_ID_TRANSLATION_APIS
API keys whose responses carry node IDs that must be translated to virtual node IDs. These keys are always decoded (even when statically routed) so the response bodies are accessible for translation.
-
-
Constructor Details
-
RouterDispatchHandler
public RouterDispatchHandler(io.kroxylicious.proxy.router.Router router, Map<String, RouteDescriptor> routes, Map<org.apache.kafka.common.protocol.ApiKeys, String> staticRoutes, ClientConnectionStateMachine ccsm, String virtualClusterName, NodeIdMapping nodeIdMapping, @Nullable Integer nodeId)
-
-
Method Details
-
handlerAdded
public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
handlerAddedin interfaceio.netty.channel.ChannelHandler- Overrides:
handlerAddedin classio.netty.channel.ChannelHandlerAdapter
-
handlerRemoved
public void handlerRemoved(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
handlerRemovedin interfaceio.netty.channel.ChannelHandler- Overrides:
handlerRemovedin classio.netty.channel.ChannelHandlerAdapter
-
resolveRouterNodeAddress
Returns the upstream address for the given virtual node ID, as learned from the most recent internal METADATA response. Returns empty if the address has not been cached yet. -
channelRead
- Specified by:
channelReadin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelReadin classio.netty.channel.ChannelInboundHandlerAdapter
-
write
public void write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) throws Exception - Specified by:
writein interfaceio.netty.channel.ChannelOutboundHandler- Overrides:
writein classio.netty.channel.ChannelDuplexHandler- Throws:
Exception
-