public interface ConnectionManager extends Scannable
| 限定符和类型 | 方法和说明 |
|---|---|
void |
add(Connection connection)
Add a connection to
ConnectionPool. |
void |
add(Connection connection,
String poolKey)
Add a connection to
ConnectionPool with the specified poolKey. |
void |
check(Connection connection)
check a connection whether available, if not, throw RemotingException
|
int |
count(String poolKey)
Get the number of
Connection in ConnectionPool with the specified pool key |
Connection |
create(String address,
int connectTimeout)
Create a connection using specified
String address. |
Connection |
create(String ip,
int port,
int connectTimeout)
Create a connection using specified ip and port.
|
Connection |
create(Url url)
Create a connection using specified
Url. |
void |
createConnectionAndHealIfNeed(Url url)
This method can create connection pool with connections initialized and check the number of connections.
|
Connection |
get(String poolKey)
Get a connection from
ConnectionPool with the specified poolKey. |
Map<String,List<Connection>> |
getAll()
Get all connections of all poolKey.
|
List<Connection> |
getAll(String poolKey)
Get all connections from
ConnectionPool with the specified poolKey. |
Connection |
getAndCreateIfAbsent(Url url)
|
void |
init()
init
|
void |
remove(Connection connection)
|
void |
remove(Connection connection,
String poolKey)
Remove and close a
Connection from ConnectionPool with the specified poolKey. |
void |
remove(String poolKey)
Remove and close all connections from
ConnectionPool with the specified poolKey. |
void |
removeAll()
Remove and close all connections from all
ConnectionPool. |
void init()
void add(Connection connection)
ConnectionPool.
If it contains multiple pool keys, this connection will be added to multiple ConnectionPool too.connection - an available connection, you should check(Connection) this connection before addvoid add(Connection connection, String poolKey)
ConnectionPool with the specified poolKey.connection - an available connection, you should check(Connection) this connection before addpoolKey - unique key of a ConnectionPoolConnection get(String poolKey)
ConnectionPool with the specified poolKey.poolKey - unique key of a ConnectionPoolConnection selected by ConnectionSelectStrategynull if there is no ConnectionPool mapping with poolKeynull if there is no Connection in ConnectionPool.List<Connection> getAll(String poolKey)
ConnectionPool with the specified poolKey.poolKey - unique key of a ConnectionPoolConnectionConnectionPool mapping with poolKey.Map<String,List<Connection>> getAll()
void remove(Connection connection)
void remove(Connection connection, String poolKey)
Connection from ConnectionPool with the specified poolKey.connection - target connectionpoolKey - unique key of a ConnectionPoolvoid remove(String poolKey)
ConnectionPool with the specified poolKey.poolKey - unique key of a ConnectionPoolvoid removeAll()
ConnectionPool.void check(Connection connection) throws RemotingException
connection - target connectionRemotingExceptionint count(String poolKey)
Connection in ConnectionPool with the specified pool keypoolKey - unique key of a ConnectionPoolConnection getAndCreateIfAbsent(Url url) throws InterruptedException, RemotingException
Url, if null then create and add into ConnectionPool.
The connection number of ConnectionPool is decided by Url.getConnNum()url - Url contains connect infos.Connection.InterruptedException - if interruptedRemotingException - if create failed.void createConnectionAndHealIfNeed(Url url) throws InterruptedException, RemotingException
ConnectionPool is decided by Url.getConnNum().
Each time call this method, will check the number of connection, if not enough, this will do the healing logic additionally.Connection create(Url url) throws RemotingException
Url.url - Url contains connect infos.RemotingExceptionConnection create(String address, int connectTimeout) throws RemotingException
String address.address - a String address, e.g. 127.0.0.1:1111connectTimeout - an int connect timeout valueConnectionRemotingException - if create failedConnection create(String ip, int port, int connectTimeout) throws RemotingException
ip - connect ip, e.g. 127.0.0.1port - connect port, e.g. 1111connectTimeout - an int connect timeout valueConnectionRemotingExceptionCopyright © 2021. All rights reserved.