|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.alipay.remoting.DefaultConnectionManager
public class DefaultConnectionManager
Abstract implementation of connection manager
| Field Summary | |
|---|---|
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 |
| Constructor Summary | |
|---|---|
DefaultConnectionManager()
Default constructor |
|
DefaultConnectionManager(ConnectionFactory connectionFactory,
RemotingAddressParser addressParser,
ConnectionEventHandler connectionEventHandler)
|
|
DefaultConnectionManager(ConnectionSelectStrategy connectionSelectStrategy)
|
|
DefaultConnectionManager(ConnectionSelectStrategy connectionSelectStrategy,
ConnectionFactory connctionFactory)
|
|
DefaultConnectionManager(ConnectionSelectStrategy connectionSelectStrategy,
ConnectionFactory connctionFactory,
ConnectionEventHandler connectionEventHandler,
ConnectionEventListener connectionEventListener)
|
|
DefaultConnectionManager(ConnectionSelectStrategy connectionSelectStrategy,
ConnectionFactory connctionFactory,
ConnectionEventHandler connectionEventHandler,
ConnectionEventListener connectionEventListener,
GlobalSwitch globalSwitch)
|
|
| Method Summary | |
|---|---|
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)
Remove a Connection from all ConnectionPool with the poolKeys in Connection, and close it. |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
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
| Constructor Detail |
|---|
public DefaultConnectionManager()
public DefaultConnectionManager(ConnectionSelectStrategy connectionSelectStrategy)
connectionSelectStrategy -
public DefaultConnectionManager(ConnectionSelectStrategy connectionSelectStrategy,
ConnectionFactory connctionFactory)
connectionSelectStrategy - connctionFactory -
public DefaultConnectionManager(ConnectionFactory connectionFactory,
RemotingAddressParser addressParser,
ConnectionEventHandler connectionEventHandler)
connectionFactory - addressParser - connectionEventHandler -
public DefaultConnectionManager(ConnectionSelectStrategy connectionSelectStrategy,
ConnectionFactory connctionFactory,
ConnectionEventHandler connectionEventHandler,
ConnectionEventListener connectionEventListener)
connectionSelectStrategy - connctionFactory - connectionEventHandler - connectionEventListener -
public DefaultConnectionManager(ConnectionSelectStrategy connectionSelectStrategy,
ConnectionFactory connctionFactory,
ConnectionEventHandler connectionEventHandler,
ConnectionEventListener connectionEventListener,
GlobalSwitch globalSwitch)
connectionSelectStrategy - connctionFactory - connectionEventHandler - connectionEventListener - globalSwitch - | Method Detail |
|---|
public void init()
ConnectionManager
init in interface ConnectionManagerConnectionManager.init()public void add(Connection connection)
ConnectionManagerConnectionPool.
If it contains multiple pool keys, this connection will be added to multiple ConnectionPool too.
add in interface 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 in interface 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 in interface ConnectionManagerpoolKey - unique key of a ConnectionPool
Connection 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 in interface ConnectionManagerpoolKey - unique key of a ConnectionPool
ConnectionConnectionPool mapping with poolKey.ConnectionManager.getAll(java.lang.String)public Map<String,List<Connection>> getAll()
getAll in interface ConnectionManagerpublic void remove(Connection connection)
ConnectionManagerConnection from all ConnectionPool with the poolKeys in Connection, and close it.
remove in interface ConnectionManagerConnectionManager.remove(com.alipay.remoting.Connection)
public void remove(Connection connection,
String poolKey)
ConnectionManagerConnection from ConnectionPool with the specified poolKey.
remove in interface ConnectionManagerpoolKey - unique key of a ConnectionPoolConnectionManager.remove(com.alipay.remoting.Connection, java.lang.String)public void remove(String poolKey)
ConnectionManagerConnectionPool with the specified poolKey.
remove in interface ConnectionManagerpoolKey - unique key of a ConnectionPoolConnectionManager.remove(java.lang.String)public void removeAll()
ConcurrentHashMap.
removeAll in interface ConnectionManagerConnectionManager.removeAll()
public void check(Connection connection)
throws RemotingException
ConnectionManager
check in interface ConnectionManagerRemotingExceptionConnectionManager.check(com.alipay.remoting.Connection)public int count(String poolKey)
ConnectionManagerConnection in ConnectionPool with the specified pool key
count in interface ConnectionManagerpoolKey - unique key of a ConnectionPool
ConnectionManager.count(java.lang.String)public void scan()
scan in interface ScannableScannable.scan()
public Connection getAndCreateIfAbsent(Url url)
throws InterruptedException,
RemotingException
getAndCreateIfAbsent in interface ConnectionManagerurl - Url contains connect infos.
Connection.
InterruptedException - if interrupted
RemotingException - if create failed.ConnectionManager.getAndCreateIfAbsent(Url)
public void createConnectionAndHealIfNeed(Url url)
throws InterruptedException,
RemotingException
createConnectionAndHealIfNeed in interface ConnectionManagerurl -
InterruptedException
RemotingException
public Connection create(Url url)
throws RemotingException
ConnectionManagerUrl.
create in interface ConnectionManagerurl - Url contains connect infos.
RemotingExceptionConnectionManager.create(com.alipay.remoting.Url)
public Connection create(String ip,
int port,
int connectTimeout)
throws RemotingException
ConnectionManager
create in interface ConnectionManagerip - connect ip, e.g. 127.0.0.1port - connect port, e.g. 1111connectTimeout - an int connect timeout value
Connection
RemotingExceptionConnectionManager.create(java.lang.String, int, int)
public Connection create(String address,
int connectTimeout)
throws RemotingException
ConnectionManagerString address.
create in interface ConnectionManageraddress - a String address, e.g. 127.0.0.1:1111connectTimeout - an int connect timeout value
Connection
RemotingException - if create failedConnectionManager.create(java.lang.String, int)public void disableHeartbeat(Connection connection)
ConnectionHeartbeatManager
disableHeartbeat in interface ConnectionHeartbeatManagerConnectionHeartbeatManager.disableHeartbeat(com.alipay.remoting.Connection)public void enableHeartbeat(Connection connection)
ConnectionHeartbeatManager
enableHeartbeat in interface ConnectionHeartbeatManagerConnectionHeartbeatManager.enableHeartbeat(com.alipay.remoting.Connection)public 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()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||