REQ
- the type of request the server expects to receive.RESP
- the type of response the server will send.@Internal @ChannelHandler.Sharable public abstract class AbstractServerHandler<REQ extends MessageBody,RESP extends MessageBody> extends org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandlerAdapter
AbstractServerBase
.Modifier and Type | Field and Description |
---|---|
protected ExecutorService |
queryExecutor
Thread pool for query execution.
|
Constructor and Description |
---|
AbstractServerHandler(AbstractServerBase<REQ,RESP> server,
MessageSerializer<REQ,RESP> serializer,
KvStateRequestStats stats)
Create the handler.
|
Modifier and Type | Method and Description |
---|---|
void |
channelActive(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx) |
void |
channelInactive(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx) |
void |
channelRead(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx,
Object msg) |
void |
exceptionCaught(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx,
Throwable cause) |
protected String |
getServerName() |
abstract CompletableFuture<RESP> |
handleRequest(long requestId,
REQ request)
Handles an incoming request and returns a
CompletableFuture containing the
corresponding response. |
abstract CompletableFuture<Void> |
shutdown()
Shuts down any handler-specific resources, e.g. thread pools etc and returns a
CompletableFuture . |
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
protected final ExecutorService queryExecutor
public AbstractServerHandler(AbstractServerBase<REQ,RESP> server, MessageSerializer<REQ,RESP> serializer, KvStateRequestStats stats)
serializer
- the serializer used to (de-)serialize messagesstats
- statistics collectorprotected String getServerName()
public void channelActive(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx) throws Exception
channelActive
in interface org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandler
channelActive
in class org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandlerAdapter
Exception
public void channelInactive(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx) throws Exception
channelInactive
in interface org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandler
channelInactive
in class org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandlerAdapter
Exception
public void channelRead(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx, Object msg) throws Exception
channelRead
in interface org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandler
channelRead
in class org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandlerAdapter
Exception
public void exceptionCaught(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception
exceptionCaught
in interface org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler
exceptionCaught
in interface org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandler
exceptionCaught
in class org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandlerAdapter
Exception
public abstract CompletableFuture<RESP> handleRequest(long requestId, REQ request)
CompletableFuture
containing the
corresponding response.
NOTE: This method is called by multiple threads.
requestId
- the id of the received request to be handled.request
- the request to be handled.public abstract CompletableFuture<Void> shutdown()
CompletableFuture
.
If an exception is thrown during the shutdown process, then that exception will be included in the returned future.
CompletableFuture
that will be completed when the shutdown process actually
finishes.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.