Class AbstractServerBase<REQ extends MessageBody,RESP extends MessageBody>
- java.lang.Object
-
- org.apache.flink.queryablestate.network.AbstractServerBase<REQ,RESP>
-
- Type Parameters:
REQ
- the type of request the server expects to receive.RESP
- the type of response the server will send.
- Direct Known Subclasses:
KvStateClientProxyImpl
,KvStateServerImpl
@Internal public abstract class AbstractServerBase<REQ extends MessageBody,RESP extends MessageBody> extends Object
The base class for every server in the queryable state module. It is using pure netty to send and receive messages of typeMessageBody
.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Logger
log
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractServerBase(String serverName, String bindAddress, Iterator<Integer> bindPortIterator, Integer numEventLoopThreads, Integer numQueryThreads)
Creates theAbstractServerBase
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected ExecutorService
getQueryExecutor()
Returns the thread-pool responsible for processing incoming requests.InetSocketAddress
getServerAddress()
Returns the address of this server.String
getServerName()
Gets the name of the server.abstract AbstractServerHandler<REQ,RESP>
initializeHandler()
Returns thehandler
to be used for serving the incoming requests.boolean
isEventGroupShutdown()
CompletableFuture<Void>
shutdownServer()
Shuts down the server and all related thread pools.void
start()
Starts the server by binding to the configured bind address (blocking).
-
-
-
Constructor Detail
-
AbstractServerBase
protected AbstractServerBase(String serverName, String bindAddress, Iterator<Integer> bindPortIterator, Integer numEventLoopThreads, Integer numQueryThreads)
Creates theAbstractServerBase
.The server needs to be started via
start()
.- Parameters:
serverName
- the name of the serverbindAddress
- address to bind tobindPortIterator
- port to bind tonumEventLoopThreads
- number of event loop threads
-
-
Method Detail
-
getQueryExecutor
protected ExecutorService getQueryExecutor()
Returns the thread-pool responsible for processing incoming requests.
-
getServerName
public String getServerName()
Gets the name of the server. This is useful for debugging.- Returns:
- The name of the server.
-
initializeHandler
public abstract AbstractServerHandler<REQ,RESP> initializeHandler()
Returns thehandler
to be used for serving the incoming requests.
-
getServerAddress
public InetSocketAddress getServerAddress()
Returns the address of this server.- Returns:
- AbstractServerBase address
- Throws:
IllegalStateException
- If server has not been started yet
-
start
public void start() throws Throwable
Starts the server by binding to the configured bind address (blocking).
-
shutdownServer
public CompletableFuture<Void> shutdownServer()
Shuts down the server and all related thread pools.- Returns:
- A
CompletableFuture
that will be completed upon termination of the shutdown process.
-
isEventGroupShutdown
@VisibleForTesting public boolean isEventGroupShutdown()
-
-