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.
@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.Loggerlog
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractServerBase(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 ExecutorServicegetQueryExecutor()Returns the thread-pool responsible for processing incoming requests.InetSocketAddressgetServerAddress()Returns the address of this server.StringgetServerName()Gets the name of the server.abstract AbstractServerHandler<REQ,RESP>initializeHandler()Returns thehandlerto be used for serving the incoming requests.booleanisEventGroupShutdown()CompletableFuture<Void>shutdownServer()Shuts down the server and all related thread pools.voidstart()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 thehandlerto 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 ThrowableStarts 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
CompletableFuturethat will be completed upon termination of the shutdown process.
-
isEventGroupShutdown
@VisibleForTesting public boolean isEventGroupShutdown()
-
-