public class KSocketConnectionPool extends KObjectPool<java.net.Socket>
KObjectPool,
SocketcleanupPeriod, recyclePeriod, shrinkTime, TIMEOUT_UNDEFINED, TIMEOUT_UNLIMITED| Constructor and Description |
|---|
KSocketConnectionPool(java.lang.String host,
int port,
int initialSize)
Constructs the KSocketConnectionPool instance with the specified parameters
|
| Modifier and Type | Method and Description |
|---|---|
java.net.Socket |
borrowSocket()
Gets a free socket from the connection pool
|
java.net.Socket |
borrowSocket(long timeout,
java.util.concurrent.TimeUnit unit)
Gets a free socket from the connection pool
|
java.net.Socket |
create()
Creates an new socket with the appropriate port and host
|
void |
expire(java.net.Socket socket)
Closes the specified socket
|
void |
returnSocket(java.net.Socket s)
This method will free up the specified Socket instance to be used later
|
boolean |
validate(java.net.Socket socket)
This method checks if the object qualifies for connections
|
apply, checkIn, checkOut, checkOut, close, createUnlockedInstance, getDefaultTimeout, getId, getMonitoringInfo, getPoolMaximumSize, getPoolSize, getPoolUsageCount, getPoolUsagePeak, getSystemDefaultTimeout, initialize, initialize, initialize, internalErrorOccurred, reset, resourceAdded, schCallback, setDefaultTimeout, setPoolMaximumSize, setPoolMinimumSizepublic KSocketConnectionPool(java.lang.String host,
int port,
int initialSize)
throws java.lang.Exception
host - the corresponding hostport - the port used for connectioninitialSize - the initial number of connectionsjava.lang.Exceptionpublic java.net.Socket create()
throws java.io.IOException
create in class KObjectPool<java.net.Socket>java.io.IOExceptionpublic boolean validate(java.net.Socket socket)
validate in class KObjectPool<java.net.Socket>socket - the socket instancepublic void expire(java.net.Socket socket)
expire in class KObjectPool<java.net.Socket>socket - the socket instancepublic java.net.Socket borrowSocket()
throws java.io.IOException
java.io.IOExceptionpublic java.net.Socket borrowSocket(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.io.IOException
timeout - the maximum time to waitunit - the time unit of the timeout argumentjava.io.IOExceptionpublic void returnSocket(java.net.Socket s)
s - the corresponding Socket instance to be freed