Class AbstractServerHandler<REQ extends MessageBody,​RESP extends MessageBody>

  • 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
    Direct Known Subclasses:
    KvStateClientProxyHandler, KvStateServerHandler

    @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.
    • Field Detail

      • queryExecutor

        protected final ExecutorService queryExecutor
        Thread pool for query execution.
    • Method Detail

      • getServerName

        protected String getServerName()
      • channelActive

        public void channelActive​(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx)
                           throws Exception
        Specified by:
        channelActive in interface org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandler
        Overrides:
        channelActive in class org.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:
        channelInactive in interface org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandler
        Overrides:
        channelInactive in class org.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:
        channelRead in interface org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandler
        Overrides:
        channelRead in class org.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:
        exceptionCaught in interface org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler
        Specified by:
        exceptionCaught in interface org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandler
        Overrides:
        exceptionCaught in class org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        Exception
      • handleRequest

        public abstract CompletableFuture<RESP> handleRequest​(long requestId,
                                                              REQ request)
        Handles an incoming request and returns a CompletableFuture containing 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

        public abstract CompletableFuture<Void> shutdown()
        Shuts down any handler-specific resources, e.g. thread pools etc and returns a CompletableFuture.

        If an exception is thrown during the shutdown process, then that exception will be included in the returned future.

        Returns:
        A CompletableFuture that will be completed when the shutdown process actually finishes.