Class AbstractServerHandler<REQ extends MessageBody,RESP extends MessageBody>
java.lang.Object
org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerAdapter
org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandlerAdapter
org.apache.flink.queryablestate.network.AbstractServerHandler<REQ,RESP>
- Type Parameters:
REQ- the type of request the server expects to receive.RESP- the type of response the server will send.
- All Implemented Interfaces:
org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler,org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandler
@Internal
@Sharable
public abstract class AbstractServerHandler<REQ extends MessageBody,RESP extends MessageBody>
extends org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandlerAdapter
The base class of every handler used by an
AbstractServerBase.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler
org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ExecutorServiceThread pool for query execution. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractServerHandler(AbstractServerBase<REQ, RESP> server, MessageSerializer<REQ, RESP> serializer, KvStateRequestStats stats) Create the handler. -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelActive(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx) voidchannelInactive(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx) voidchannelRead(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx, Object msg) voidexceptionCaught(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx, Throwable cause) protected Stringabstract CompletableFuture<RESP>handleRequest(long requestId, REQ request) Handles an incoming request and returns aCompletableFuturecontaining the corresponding response.abstract CompletableFuture<Void>shutdown()Shuts down any handler-specific resources, e.g. thread pools etc and returns aCompletableFuture.Methods inherited from class org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandlerAdapter
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredMethods inherited from class org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Field Details
-
queryExecutor
Thread pool for query execution.
-
-
Constructor Details
-
AbstractServerHandler
public AbstractServerHandler(AbstractServerBase<REQ, RESP> server, MessageSerializer<REQ, RESP> serializer, KvStateRequestStats stats) Create the handler.- Parameters:
serializer- the serializer used to (de-)serialize messagesstats- statistics collector
-
-
Method Details
-
getServerName
-
channelActive
public void channelActive(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx) throws Exception - Specified by:
channelActivein interfaceorg.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classorg.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelInactive
public void channelInactive(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx) throws Exception - Specified by:
channelInactivein interfaceorg.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classorg.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelRead
public void channelRead(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx, Object msg) throws Exception - Specified by:
channelReadin interfaceorg.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandler- Overrides:
channelReadin classorg.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
exceptionCaught
public void exceptionCaught(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception - Specified by:
exceptionCaughtin interfaceorg.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceorg.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classorg.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
handleRequest
Handles an incoming request and returns aCompletableFuturecontaining the corresponding response.NOTE: This method is called by multiple threads.
- Parameters:
requestId- the id of the received request to be handled.request- the request to be handled.- Returns:
- A future with the response to be forwarded to the client.
-
shutdown
Shuts down any handler-specific resources, e.g. thread pools etc and returns aCompletableFuture.If an exception is thrown during the shutdown process, then that exception will be included in the returned future.
- Returns:
- A
CompletableFuturethat will be completed when the shutdown process actually finishes.
-