Package com.kheops.jmap.net
Class JMapNetworkConnectionPool
- All Implemented Interfaces:
KSchedulerClient
This class manage a pool of JMapNetworkConnection.
It extends KObjectPool
- See Also:
-
Field Summary
Fields inherited from class com.kheops.util.KObjectPool
cleanupPeriod, recyclePeriod, shrinkTime, TIMEOUT_UNDEFINED, TIMEOUT_UNLIMITED -
Constructor Summary
ConstructorsConstructorDescriptionJMapNetworkConnectionPool(String host, int port, int initialSize) Constructs a JMapNetworkConnectionPool instance.JMapNetworkConnectionPool(String protocol, String host, int port, int httpPort, String proxyPath, String serverId, int connectionMode, int initialSize) Constructs a JMapNetworkConnectionPool instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConnectionListener(JMapConnectionListener listener) Gets a free connection from the connection poolborrowConnection(long timeout, TimeUnit unit) Gets a free connection from the connection poolvoidclose()This method closes one by one all the objects currently opened for this the poolcreate()Constructs a new instance of JMapNetworkConnection and opens a connectionvoidexpire(JMapNetworkConnection connection) Closes the specified connection objectintvoidvoidreturnConnection(JMapNetworkConnection connection) This method will free up the specified JMapSvrConnection instancevoidsetReadTimeout(int readTimeout) booleanvalidate(JMapNetworkConnection connection) This method checks if the specified object qualifies for connectionsMethods inherited from class com.kheops.util.KObjectPool
apply, checkIn, checkOut, checkOut, createUnlockedInstance, getDefaultTimeout, getId, getMonitoringInfo, getPoolMaximumSize, getPoolSize, getPoolUsageCount, getPoolUsagePeak, getSystemDefaultTimeout, initialize, initialize, initialize, internalErrorOccurred, reset, resourceAdded, schCallback, setDefaultTimeout, setPoolMaximumSize, setPoolMinimumSize
-
Constructor Details
-
JMapNetworkConnectionPool
public JMapNetworkConnectionPool() -
JMapNetworkConnectionPool
Constructs a JMapNetworkConnectionPool instance.- Parameters:
host- the url to connect to the JMap Serverport- the port to connect to the JMap ServerinitialSize- the initial pool size- Throws:
Exception
-
JMapNetworkConnectionPool
public JMapNetworkConnectionPool(String protocol, String host, int port, int httpPort, String proxyPath, String serverId, int connectionMode, int initialSize) throws Exception Constructs a JMapNetworkConnectionPool instance.- Parameters:
protocol- the protocol (http, https)host- the url to connect to the JMap Serverport- the port to connect to the JMap ServerhttpPort- the http port to connect to the JMap ServerproxyPath- the path of the proxy servletserverId- the server to connect to behind the proxyconnectionModeconnectionMode- the connection mode (proxy, direct)initialSize- the initial pool size- Throws:
Exception
-
-
Method Details
-
create
Constructs a new instance of JMapNetworkConnection and opens a connection- Specified by:
createin classKObjectPool<JMapNetworkConnection>- Returns:
- the newly created connection
- Throws:
IOException
-
validate
This method checks if the specified object qualifies for connections- Specified by:
validatein classKObjectPool<JMapNetworkConnection>- Parameters:
connection- the corresponding object- Returns:
- true if the object qualifies for connection false otherwise
-
expire
Closes the specified connection object- Specified by:
expirein classKObjectPool<JMapNetworkConnection>- Parameters:
connection- the connection object to be closed
-
borrowConnection
Gets a free connection from the connection pool- Returns:
- a free JMapNetworkConnection instance from the connection pool
- Throws:
IOException
-
borrowConnection
Gets a free connection from the connection pool- Parameters:
timeout- the maximum time to waitunit- the time unit of the timeout argument- Returns:
- a free JMapNetworkConnection instance from the connection pool
- Throws:
IOException
-
returnConnection
This method will free up the specified JMapSvrConnection instance- Parameters:
connection- the corresponding JMapSvrConnection instance to be freed
-
addConnectionListener
-
removeConnectionListener
-
close
public void close()Description copied from class:KObjectPoolThis method closes one by one all the objects currently opened for this the pool- Overrides:
closein classKObjectPool<JMapNetworkConnection>
-
getReadTimeout
public int getReadTimeout() -
setReadTimeout
public void setReadTimeout(int readTimeout)
-