REQ
- the type of request the server expects to receive.RESP
- the type of response the server will send.public abstract class NetworkServer<REQ extends MessageBody,RESP extends MessageBody> extends Object
MessageBody
.Modifier | Constructor and Description |
---|---|
protected |
NetworkServer(String serverName,
String bindAddress,
Iterator<Integer> bindPortIterator,
Integer numEventLoopThreads,
Integer numQueryThreads)
Creates the
NetworkServer . |
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 NetworkServer(String serverName, String bindAddress, Iterator<Integer> bindPortIterator, Integer numEventLoopThreads, Integer numQueryThreads)
NetworkServer
.
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.public boolean isEventGroupShutdown()
Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.