public class DefaultConnectionManager extends Object implements ConnectionManager, ConnectionHeartbeatManager, Scannable
| 限定符和类型 | 字段和说明 |
|---|---|
protected RemotingAddressParser |
addressParser
address parser
|
protected ConnectionEventHandler |
connectionEventHandler
connection event handler
|
protected ConnectionEventListener |
connectionEventListener
connection event listener
|
protected ConnectionFactory |
connectionFactory
connection factory
|
protected ConnectionSelectStrategy |
connectionSelectStrategy
connection pool select strategy
|
protected ConcurrentHashMap<String,RunStateRecordedFutureTask<ConnectionPool>> |
connTasks
connection pool initialize tasks
|
protected ConcurrentHashMap<String,FutureTask<Integer>> |
healTasks
heal connection tasks
|
| 构造器和说明 |
|---|
DefaultConnectionManager()
Default constructor
|
DefaultConnectionManager(ConnectionFactory connectionFactory,
RemotingAddressParser addressParser,
ConnectionEventHandler connectionEventHandler) |
DefaultConnectionManager(ConnectionSelectStrategy connectionSelectStrategy) |
DefaultConnectionManager(ConnectionSelectStrategy connectionSelectStrategy,
ConnectionFactory connectionFactory) |
DefaultConnectionManager(ConnectionSelectStrategy connectionSelectStrategy,
ConnectionFactory connectionFactory,
ConnectionEventHandler connectionEventHandler,
ConnectionEventListener connectionEventListener) |
DefaultConnectionManager(ConnectionSelectStrategy connectionSelectStrategy,
ConnectionFactory connctionFactory,
ConnectionEventHandler connectionEventHandler,
ConnectionEventListener connectionEventListener,
GlobalSwitch globalSwitch) |
| 限定符和类型 | 方法和说明 |
|---|---|
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)
If no task cached, create one and initialize the connections.
|
void |
disableHeartbeat(Connection connection)
disable heart beat for a certain connection
|
void |
enableHeartbeat(Connection connection)
enable heart beat for a certain connection
|
Connection |
get(String poolKey)
Get a connection from
ConnectionPool with the specified poolKey. |
RemotingAddressParser |
getAddressParser()
Getter method for property addressParser.
|
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)
If no task cached, create one and initialize the connections.
|
ConnectionEventHandler |
getConnectionEventHandler()
Getter method for property connectionEventHandler.
|
ConnectionEventListener |
getConnectionEventListener()
Getter method for property connectionEventListener.
|
ConnectionFactory |
getConnectionFactory()
Getter method for property connctionFactory.
|
ConnectionSelectStrategy |
getConnectionSelectStrategy()
Getter method for property connectionSelectStrategy.
|
ConcurrentHashMap<String,RunStateRecordedFutureTask<ConnectionPool>> |
getConnPools()
Getter method for property connPools.
|
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()
Warning!
|
void |
scan()
in case of cache pollution and connection leak, to do schedule scan
|
void |
setAddressParser(RemotingAddressParser addressParser)
Setter method for property addressParser.
|
void |
setConnectionEventHandler(ConnectionEventHandler connectionEventHandler)
Setter method for property connectionEventHandler.
|
void |
setConnectionEventListener(ConnectionEventListener connectionEventListener)
Setter method for property connectionEventListener.
|
void |
setConnectionFactory(ConnectionFactory connectionFactory)
Setter method for property connctionFactory.
|
void |
setConnectionSelectStrategy(ConnectionSelectStrategy connectionSelectStrategy)
Setter method for property connectionSelectStrategy.
|
protected ConcurrentHashMap<String,RunStateRecordedFutureTask<ConnectionPool>> connTasks
protected ConcurrentHashMap<String,FutureTask<Integer>> healTasks
protected ConnectionSelectStrategy connectionSelectStrategy
protected RemotingAddressParser addressParser
protected ConnectionFactory connectionFactory
protected ConnectionEventHandler connectionEventHandler
protected ConnectionEventListener connectionEventListener
public DefaultConnectionManager()
public DefaultConnectionManager(ConnectionSelectStrategy connectionSelectStrategy)
connectionSelectStrategy - public DefaultConnectionManager(ConnectionSelectStrategy connectionSelectStrategy, ConnectionFactory connectionFactory)
connectionSelectStrategy - connectionFactory - public DefaultConnectionManager(ConnectionFactory connectionFactory, RemotingAddressParser addressParser, ConnectionEventHandler connectionEventHandler)
connectionFactory - addressParser - connectionEventHandler - public DefaultConnectionManager(ConnectionSelectStrategy connectionSelectStrategy, ConnectionFactory connectionFactory, ConnectionEventHandler connectionEventHandler, ConnectionEventListener connectionEventListener)
connectionSelectStrategy - connectionFactory - connectionEventHandler - connectionEventListener - public DefaultConnectionManager(ConnectionSelectStrategy connectionSelectStrategy, ConnectionFactory connctionFactory, ConnectionEventHandler connectionEventHandler, ConnectionEventListener connectionEventListener, GlobalSwitch globalSwitch)
connectionSelectStrategy - connctionFactory - connectionEventHandler - connectionEventListener - globalSwitch - public void init()
ConnectionManagerinit 在接口中 ConnectionManagerConnectionManager.init()public void add(Connection connection)
ConnectionManagerConnectionPool.
If it contains multiple pool keys, this connection will be added to multiple ConnectionPool too.add 在接口中 ConnectionManagerconnection - an available connection, you should ConnectionManager.check(Connection) this connection before addConnectionManager.add(com.alipay.remoting.Connection)public void add(Connection connection, String poolKey)
ConnectionManagerConnectionPool with the specified poolKey.add 在接口中 ConnectionManagerconnection - an available connection, you should ConnectionManager.check(Connection) this connection before addpoolKey - unique key of a ConnectionPoolConnectionManager.add(com.alipay.remoting.Connection, java.lang.String)public Connection get(String poolKey)
ConnectionManagerConnectionPool with the specified poolKey.get 在接口中 ConnectionManagerpoolKey - unique key of a ConnectionPoolConnection selected by ConnectionSelectStrategynull if there is no ConnectionPool mapping with poolKeynull if there is no Connection in ConnectionPool.ConnectionManager.get(String)public List<Connection> getAll(String poolKey)
ConnectionManagerConnectionPool with the specified poolKey.getAll 在接口中 ConnectionManagerpoolKey - unique key of a ConnectionPoolConnectionConnectionPool mapping with poolKey.ConnectionManager.getAll(java.lang.String)public Map<String,List<Connection>> getAll()
getAll 在接口中 ConnectionManagerpublic void remove(Connection connection)
ConnectionManagerpublic void remove(Connection connection, String poolKey)
ConnectionManagerConnection from ConnectionPool with the specified poolKey.remove 在接口中 ConnectionManagerconnection - target connectionpoolKey - unique key of a ConnectionPoolConnectionManager.remove(com.alipay.remoting.Connection, java.lang.String)public void remove(String poolKey)
ConnectionManagerConnectionPool with the specified poolKey.remove 在接口中 ConnectionManagerpoolKey - unique key of a ConnectionPoolConnectionManager.remove(java.lang.String)public void removeAll()
ConcurrentHashMap.removeAll 在接口中 ConnectionManagerConnectionManager.removeAll()public void check(Connection connection) throws RemotingException
ConnectionManagercheck 在接口中 ConnectionManagerconnection - target connectionRemotingExceptionConnectionManager.check(com.alipay.remoting.Connection)public int count(String poolKey)
ConnectionManagerConnection in ConnectionPool with the specified pool keycount 在接口中 ConnectionManagerpoolKey - unique key of a ConnectionPoolConnectionManager.count(java.lang.String)public void scan()
scan 在接口中 ScannableScannable.scan()public Connection getAndCreateIfAbsent(Url url) throws InterruptedException, RemotingException
getAndCreateIfAbsent 在接口中 ConnectionManagerurl - Url contains connect infos.Connection.InterruptedException - if interruptedRemotingException - if create failed.ConnectionManager.getAndCreateIfAbsent(Url)public void createConnectionAndHealIfNeed(Url url) throws InterruptedException, RemotingException
createConnectionAndHealIfNeed 在接口中 ConnectionManagerurl - InterruptedExceptionRemotingExceptionpublic Connection create(Url url) throws RemotingException
ConnectionManagerUrl.create 在接口中 ConnectionManagerurl - Url contains connect infos.RemotingExceptionConnectionManager.create(com.alipay.remoting.Url)public Connection create(String ip, int port, int connectTimeout) throws RemotingException
ConnectionManagercreate 在接口中 ConnectionManagerip - connect ip, e.g. 127.0.0.1port - connect port, e.g. 1111connectTimeout - an int connect timeout valueConnectionRemotingExceptionConnectionManager.create(java.lang.String, int, int)public Connection create(String address, int connectTimeout) throws RemotingException
ConnectionManagerString address.create 在接口中 ConnectionManageraddress - a String address, e.g. 127.0.0.1:1111connectTimeout - an int connect timeout valueConnectionRemotingException - if create failedConnectionManager.create(java.lang.String, int)public void disableHeartbeat(Connection connection)
ConnectionHeartbeatManagerpublic void enableHeartbeat(Connection connection)
ConnectionHeartbeatManagerpublic ConnectionSelectStrategy getConnectionSelectStrategy()
public void setConnectionSelectStrategy(ConnectionSelectStrategy connectionSelectStrategy)
connectionSelectStrategy - value to be assigned to property connectionSelectStrategypublic RemotingAddressParser getAddressParser()
public void setAddressParser(RemotingAddressParser addressParser)
addressParser - value to be assigned to property addressParserpublic ConnectionFactory getConnectionFactory()
public void setConnectionFactory(ConnectionFactory connectionFactory)
connectionFactory - value to be assigned to property connctionFactorypublic ConnectionEventHandler getConnectionEventHandler()
public void setConnectionEventHandler(ConnectionEventHandler connectionEventHandler)
connectionEventHandler - value to be assigned to property connectionEventHandlerpublic ConnectionEventListener getConnectionEventListener()
public void setConnectionEventListener(ConnectionEventListener connectionEventListener)
connectionEventListener - value to be assigned to property connectionEventListenerpublic ConcurrentHashMap<String,RunStateRecordedFutureTask<ConnectionPool>> getConnPools()
Copyright © 2021. All rights reserved.