REQ
- the type of request the server expects to receive.RESP
- the type of response the server will send.@ChannelHandler.Sharable
public abstract class AbstractServerHandler<REQ extends MessageBody,RESP extends MessageBody>
extends org.apache.paimon.shade.netty4.io.netty.channel.ChannelInboundHandlerAdapter
NetworkServer
.Modifier and Type | Field and Description |
---|---|
protected ExecutorService |
queryExecutor
Thread pool for query execution.
|
Constructor and Description |
---|
AbstractServerHandler(NetworkServer<REQ,RESP> server,
MessageSerializer<REQ,RESP> serializer,
ServiceRequestStats stats)
Create the handler.
|
Modifier and Type | Method and Description |
---|---|
void |
channelActive(org.apache.paimon.shade.netty4.io.netty.channel.ChannelHandlerContext ctx) |
void |
channelInactive(org.apache.paimon.shade.netty4.io.netty.channel.ChannelHandlerContext ctx) |
void |
channelRead(org.apache.paimon.shade.netty4.io.netty.channel.ChannelHandlerContext ctx,
Object msg) |
void |
exceptionCaught(org.apache.paimon.shade.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.
|
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
protected final ExecutorService queryExecutor
public AbstractServerHandler(NetworkServer<REQ,RESP> server, MessageSerializer<REQ,RESP> serializer, ServiceRequestStats stats)
serializer
- the serializer used to (de-)serialize messagesstats
- statistics collectorprotected String getServerName()
public void channelActive(org.apache.paimon.shade.netty4.io.netty.channel.ChannelHandlerContext ctx)
channelActive
in interface org.apache.paimon.shade.netty4.io.netty.channel.ChannelInboundHandler
channelActive
in class org.apache.paimon.shade.netty4.io.netty.channel.ChannelInboundHandlerAdapter
public void channelInactive(org.apache.paimon.shade.netty4.io.netty.channel.ChannelHandlerContext ctx)
channelInactive
in interface org.apache.paimon.shade.netty4.io.netty.channel.ChannelInboundHandler
channelInactive
in class org.apache.paimon.shade.netty4.io.netty.channel.ChannelInboundHandlerAdapter
public void channelRead(org.apache.paimon.shade.netty4.io.netty.channel.ChannelHandlerContext ctx, Object msg) throws Exception
channelRead
in interface org.apache.paimon.shade.netty4.io.netty.channel.ChannelInboundHandler
channelRead
in class org.apache.paimon.shade.netty4.io.netty.channel.ChannelInboundHandlerAdapter
Exception
public void exceptionCaught(org.apache.paimon.shade.netty4.io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception
exceptionCaught
in interface org.apache.paimon.shade.netty4.io.netty.channel.ChannelHandler
exceptionCaught
in interface org.apache.paimon.shade.netty4.io.netty.channel.ChannelInboundHandler
exceptionCaught
in class org.apache.paimon.shade.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 © 2023–2024 The Apache Software Foundation. All rights reserved.