Interface ConnectionManager
-
- All Known Implementing Classes:
TransportConnectionManager
public interface ConnectionManagerThis is used for unified manage server and client connection.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcloseClient(ConnectionId connectionId)Close a client from theConnectionManagerTransportClientgetOrCreateClient(java.lang.String host, int port)Get aTransportClientinstance from the connection pool first.TransportClientgetOrCreateClient(ConnectionId connectionId)Get aTransportClientinstance from the connection pool first.TransportServergetServer()Return the only one listened server.voidinitClientManager(org.apache.hugegraph.computer.core.config.Config config, ClientHandler clientHandler)Initialize the client connection manager.voidshutdown()Shutdown the client connection manager and server.voidshutdownClients()Shutdown the client connection manager.voidshutdownServer()Shutdown the server.intstartServer(org.apache.hugegraph.computer.core.config.Config config, MessageHandler serverHandler)Start the server, return the port listened.
-
-
-
Method Detail
-
startServer
int startServer(org.apache.hugegraph.computer.core.config.Config config, MessageHandler serverHandler)Start the server, return the port listened. This method is called only once.
-
getServer
TransportServer getServer()
Return the only one listened server.
-
shutdownServer
void shutdownServer()
Shutdown the server.
-
initClientManager
void initClientManager(org.apache.hugegraph.computer.core.config.Config config, ClientHandler clientHandler)Initialize the client connection manager. This method is called only once.
-
getOrCreateClient
TransportClient getOrCreateClient(ConnectionId connectionId) throws TransportException
Get aTransportClientinstance from the connection pool first. If it is not found or not active, create a new one.- Parameters:
connectionId-ConnectionId- Throws:
TransportException
-
getOrCreateClient
TransportClient getOrCreateClient(java.lang.String host, int port) throws TransportException
Get aTransportClientinstance from the connection pool first. If {it is not found or not active, create a new one.- Parameters:
host- the hostName or Ipport- the port- Throws:
TransportException
-
closeClient
void closeClient(ConnectionId connectionId)
Close a client from theConnectionManager- Parameters:
connectionId-ConnectionId
-
shutdownClients
void shutdownClients()
Shutdown the client connection manager.
-
shutdown
void shutdown()
Shutdown the client connection manager and server.
-
-