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
MessageBody
.Modifier and Type | Field and Description |
---|---|
protected org.slf4j.Logger |
log |
Modifier | Constructor and Description |
---|---|
protected |
AbstractServerBase(String serverName,
String bindAddress,
Iterator<Integer> bindPortIterator,
Integer numEventLoopThreads,
Integer numQueryThreads)
Creates the
AbstractServerBase . |
Modifier and Type | Method and 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 the
handler 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).
|
protected AbstractServerBase(String serverName, String bindAddress, Iterator<Integer> bindPortIterator, Integer numEventLoopThreads, Integer numQueryThreads)
AbstractServerBase
.
The server needs to be started via start()
.
serverName
- the name of the serverbindAddress
- address to bind tobindPortIterator
- port to bind tonumEventLoopThreads
- number of event loop threadsprotected ExecutorService getQueryExecutor()
public String getServerName()
public abstract AbstractServerHandler<REQ,RESP> initializeHandler()
handler
to be used for serving the incoming
requests.public InetSocketAddress getServerAddress()
IllegalStateException
- If server has not been started yetpublic void start() throws Throwable
public CompletableFuture<Void> shutdownServer()
CompletableFuture
that will be completed upon termination of the shutdown
process.@VisibleForTesting public boolean isEventGroupShutdown()
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.