public class SchoonerSockIOPool extends Object
static {
String[] serverlist = { "cache0.server.com:12345", "cache1.server.com:12345" };
SockIOPool pool = SockIOPool.getInstance();
pool.setServers(serverlist);
pool.initialize();
}
static {
String[] serverlist = { "cache0.server.com:12345", "cache1.server.com:12345" };
Integer[] weights = { new Integer(5), new Integer(2) };
SockIOPool pool = SockIOPool.getInstance();
pool.setServers(serverlist);
pool.setWeights(weights);
pool.initialize();
}
static {
String[] serverlist = { "cache0.server.com:12345", "cache1.server.com:12345" };
Integer[] weights = { new Integer(5), new Integer(2) };
pool.setInitConn(5);
pool.setMinConn(5);
pool.setMaxConn(10);
pool.setMaintSleep(0);
pool.setNagle(false);
pool.initialize();
}
SchoonerSockIOPool| Modifier and Type | Class and Description |
|---|---|
static class |
SchoonerSockIOPool.TCPSockIO
MemCached Java client, utility class for Socket IO.
|
static class |
SchoonerSockIOPool.UDPSockIO |
| Modifier and Type | Field and Description |
|---|---|
static int |
CONSISTENT_HASH |
static long |
MAX_RETRY_DELAY |
static int |
NATIVE_HASH |
static int |
NEW_COMPAT_HASH |
static int |
OLD_COMPAT_HASH |
| Modifier | Constructor and Description |
|---|---|
protected |
SchoonerSockIOPool(boolean isTcp) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
clearHostFromPool(String host)
Closes and removes all sockets from specified pool for host.
|
protected void |
closeSocketPool()
Closes all sockets in the passed in pool.
|
boolean |
getAliveCheck()
Returns the current status of the aliveCheck flag.
|
int |
getBufferSize() |
SchoonerSockIO |
getConnection(String host)
Returns a SockIO object from the pool for the passed in host.
|
boolean |
getFailback()
Returns current state of failover flag.
|
boolean |
getFailover()
Returns current state of failover flag.
|
int |
getHashingAlg()
Returns current status of customHash flag
|
String |
getHost(String key)
Gets the host that a particular key / hashcode resides on.
|
String |
getHost(String key,
Integer hashcode)
Gets the host that a particular key / hashcode resides on.
|
int |
getInitConn()
Returns the current setting for the initial number of connections per
server in the available pool.
|
static SchoonerSockIOPool |
getInstance()
Single argument version of factory used for back compat.
|
static SchoonerSockIOPool |
getInstance(AuthInfo authInfo) |
static SchoonerSockIOPool |
getInstance(boolean isTcp) |
static SchoonerSockIOPool |
getInstance(String poolName)
Factory to create/retrieve new pools given a unique poolName.
|
static SchoonerSockIOPool |
getInstance(String poolName,
AuthInfo authInfo) |
static SchoonerSockIOPool |
getInstance(String poolName,
boolean isTcp) |
boolean |
getLifo() |
long |
getMaintSleep()
Returns the current maint thread sleep time.
|
long |
getMaxBusy()
Returns the current max busy setting.
|
int |
getMaxConn() |
int |
getMaxIdle()
Returns the current max idle setting.
|
long |
getMaxWait() |
int |
getMinConn() |
long |
getMinEvictableIdleTimeMillis() |
int |
getMinIdle() |
boolean |
getNagle()
Returns current status of nagle flag
|
int |
getNumTestsPerEvictionRun() |
String[] |
getServers()
Returns the current list of all cache servers.
|
SchoonerSockIO |
getSock(String key)
Returns appropriate SockIO object given string cache key.
|
SchoonerSockIO |
getSock(String key,
Integer hashCode)
Returns appropriate SockIO object given string cache key and optional
hashcode.
|
int |
getSocketConnectTO()
Returns the socket timeout for connect.
|
int |
getSocketTO()
Returns the socket timeout for reads.
|
long |
getSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis) |
boolean |
getTestOnBorrow() |
boolean |
getTestOnReturn() |
boolean |
getTestWhileIdle() |
long |
getTimeBetweenEvictionRunsMillis() |
Integer[] |
getWeights()
Returns the current list of weights.
|
void |
initialize()
Initializes the pool.
|
boolean |
isInitialized()
Returns state of pool.
|
boolean |
isTcp() |
void |
setAliveCheck(boolean aliveCheck)
Sets the aliveCheck flag for the pool.
|
void |
setBufferSize(int bufferSize) |
void |
setFailback(boolean failback)
Sets the failback flag for the pool.
|
void |
setFailover(boolean failover)
Sets the failover flag for the pool.
|
void |
setHashingAlg(int alg)
Sets the hashing algorithm we will use.
|
void |
setInitConn(int initConn)
Sets the initial number of connections per server in the available pool.
|
void |
setLifo(boolean lifo) |
void |
setMaintSleep(long maintSleep)
Set the sleep time between runs of the pool maintenance thread.
|
void |
setMaxBusyTime(long maxBusyTime)
Sets the max busy time for threads in the busy pool.
|
void |
setMaxConn(int maxConn) |
void |
setMaxIdle(int maxIdle)
Sets the max idle time for threads in the available pool.
|
void |
setMaxWait(long maxWait) |
void |
setMinConn(int minConn) |
void |
setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) |
void |
setMinIdle(int minIdle) |
void |
setNagle(boolean nagle)
Sets the Nagle alg flag for the pool.
|
void |
setNumTestsPerEvictionRun(int numTestsPerEvictionRun) |
void |
setServers(String[] servers)
Sets the list of all cache servers.
|
void |
setSocketConnectTO(int socketConnectTO)
Sets the socket timeout for connect.
|
void |
setSocketTO(int socketTO)
Sets the socket timeout for reads.
|
void |
setSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis) |
void |
setTestOnBorrow(boolean testOnBorrow) |
void |
setTestOnReturn(boolean testOnReturn) |
void |
setTestWhileIdle(boolean testWhileIdle) |
void |
setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) |
void |
setWeights(Integer[] weights)
Sets the list of weights to apply to the server list.
|
void |
shutDown()
Shuts down the pool.
|
public static final int NATIVE_HASH
public static final int OLD_COMPAT_HASH
public static final int NEW_COMPAT_HASH
public static final int CONSISTENT_HASH
public static final long MAX_RETRY_DELAY
public static SchoonerSockIOPool getInstance(String poolName)
poolName - unique name of the poolpublic static SchoonerSockIOPool getInstance(String poolName, AuthInfo authInfo)
public static SchoonerSockIOPool getInstance(String poolName, boolean isTcp)
public static SchoonerSockIOPool getInstance()
public static SchoonerSockIOPool getInstance(AuthInfo authInfo)
public static SchoonerSockIOPool getInstance(boolean isTcp)
public void initialize()
public boolean isTcp()
protected void clearHostFromPool(String host)
pool - pool to clearhost - host to clearpublic final String getHost(String key)
key - public final String getHost(String key, Integer hashcode)
key - hashcode - public final SchoonerSockIO getSock(String key)
key - hashcode for cache keypublic final SchoonerSockIO getSock(String key, Integer hashCode)
key - hashcode for cache keyhashCode - if not null, then the int hashcode to usepublic final SchoonerSockIO getConnection(String host)
host - host from which to retrieve objectprotected final void closeSocketPool()
pool - pool to closepublic void shutDown()
public final boolean isInitialized()
true if initialized.public final void setServers(String[] servers)
servers - String array of servers [host:port]public final String[] getServers()
public final void setWeights(Integer[] weights)
weights - Integer array of weightspublic final Integer[] getWeights()
public final void setInitConn(int initConn)
initConn - int number of connectionspublic final int getInitConn()
public final void setMaxBusyTime(long maxBusyTime)
maxBusyTime - idle time in mspublic final long getMaxBusy()
public void setMaintSleep(long maintSleep)
maintSleep - sleep time in mspublic long getMaintSleep()
public final void setSocketTO(int socketTO)
socketTO - timeout in mspublic final int getSocketTO()
public final void setSocketConnectTO(int socketConnectTO)
socketConnectTO - timeout in mspublic final int getSocketConnectTO()
public void setMaxIdle(int maxIdle)
maxIdle - idle time in mspublic int getMaxIdle()
public final long getMaxWait()
public final void setMaxWait(long maxWait)
public final int getMinIdle()
public final void setMinIdle(int minIdle)
public final boolean getTestOnBorrow()
public final void setTestOnBorrow(boolean testOnBorrow)
public final boolean getTestOnReturn()
public final void setTestOnReturn(boolean testOnReturn)
public final long getTimeBetweenEvictionRunsMillis()
public final void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)
public final int getNumTestsPerEvictionRun()
public final void setNumTestsPerEvictionRun(int numTestsPerEvictionRun)
public final long getMinEvictableIdleTimeMillis()
public final void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)
public final boolean getTestWhileIdle()
public final void setTestWhileIdle(boolean testWhileIdle)
public final long getSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis)
public final void setSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis)
public final boolean getLifo()
public final void setLifo(boolean lifo)
public final void setFailover(boolean failover)
failover - true/falsepublic final boolean getFailover()
public void setFailback(boolean failback)
failback - true/falsepublic boolean getFailback()
public final void setAliveCheck(boolean aliveCheck)
aliveCheck - true/falsepublic final boolean getAliveCheck()
public final void setNagle(boolean nagle)
nagle - true/falsepublic final boolean getNagle()
public final void setHashingAlg(int alg)
alg - int value representing hashing algorithmpublic final int getHashingAlg()
public void setMaxConn(int maxConn)
public int getMaxConn()
public void setMinConn(int minConn)
public int getMinConn()
public void setBufferSize(int bufferSize)
public int getBufferSize()
Copyright © 2013 Schooner Information Technology. All Rights Reserved.