Package net.rubyeye.xmemcached.aws
Class AWSElasticCacheClient
- java.lang.Object
-
- net.rubyeye.xmemcached.XMemcachedClient
-
- net.rubyeye.xmemcached.aws.AWSElasticCacheClient
-
- All Implemented Interfaces:
ConfigUpdateListener,MemcachedClient,XMemcachedClientMBean
public class AWSElasticCacheClient extends XMemcachedClient implements ConfigUpdateListener
AWS ElasticCache Client.- Since:
- 2.3.0
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.net.InetSocketAddress>configAddrsprivate ConfigurationPollerconfigPollerprivate ClusterConfigurationcurrentClusterConfigurationstatic longDEFAULT_POLL_CONFIG_INTERVAL_MSDefault elasticcache configuration poll interval, it's one minute.private booleanfirstTimeUpdateprivate static org.slf4j.Loggerlog-
Fields inherited from class net.rubyeye.xmemcached.XMemcachedClient
commandFactory, connectionPoolSize, connector, maxQueuedNoReplyOperations, NAMESPACE_LOCAL, opTimeout, resolveInetAddresses, serverOrderCount, sessionComparator, sessionLocator
-
Fields inherited from interface net.rubyeye.xmemcached.MemcachedClient
DEFAULT_CONNECT_TIMEOUT, DEFAULT_CONNECTION_POOL_SIZE, DEFAULT_HEAL_SESSION_INTERVAL, DEFAULT_MAX_QUEUED_NOPS, DEFAULT_MAX_TIMEOUTEXCEPTION_THRESHOLD, DEFAULT_OP_TIMEOUT, DEFAULT_READ_THREAD_COUNT, DEFAULT_SESSION_IDLE_TIMEOUT, DEFAULT_SESSION_READ_BUFF_SIZE, DEFAULT_TCP_KEEPLIVE, DEFAULT_TCP_NO_DELAY, DEFAULT_TCP_RECV_BUFF_SIZE, DEFAULT_TCP_SEND_BUFF_SIZE, DYNAMIC_MAX_QUEUED_NOPS, MAX_QUEUED_NOPS
-
-
Constructor Summary
Constructors Constructor Description AWSElasticCacheClient(java.net.InetSocketAddress addr)Construct an AWSElasticCacheClient instance with one config address and default poll interval.AWSElasticCacheClient(java.net.InetSocketAddress addr, long pollConfigIntervalMills)Construct an AWSElasticCacheClient instance with one config address and poll interval.AWSElasticCacheClient(java.net.InetSocketAddress addr, long pollConfigIntervalMills, CommandFactory cmdFactory)AWSElasticCacheClient(java.util.List<java.net.InetSocketAddress> addrs)Construct an AWSElasticCacheClient instance with config server addresses and default config poll interval.AWSElasticCacheClient(java.util.List<java.net.InetSocketAddress> addrs, long pollConfigIntervalMills)Construct an AWSElasticCacheClient instance with config server addresses.AWSElasticCacheClient(java.util.List<java.net.InetSocketAddress> addrs, long pollConfigIntervalMills, CommandFactory commandFactory)Construct an AWSElasticCacheClient instance with config server addresses.AWSElasticCacheClient(MemcachedSessionLocator locator, MemcachedSessionComparator comparator, BufferAllocator allocator, Configuration conf, java.util.Map<SocketOption,java.lang.Object> socketOptions, CommandFactory commandFactory, Transcoder transcoder, java.util.List<MemcachedClientStateListener> stateListeners, java.util.Map<java.net.InetSocketAddress,AuthInfo> map, int poolSize, long connectTimeout, java.lang.String name, boolean failureMode, boolean resolveInetAddresses, java.util.List<java.net.InetSocketAddress> configAddrs, long pollConfigIntervalMills)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.util.List<java.net.InetSocketAddress>asList(java.net.InetSocketAddress addr)private static java.util.Map<java.net.InetSocketAddress,java.net.InetSocketAddress>getAddressMapFromConfigAddrs(java.util.List<java.net.InetSocketAddress> configAddrs)ClusterConfigurationgetConfig()Get cluster config from cache node by network command.ClusterConfigurationgetConfig(java.lang.String key)Get config by key from cache node by network command.ClusterConfigurationgetCurrentConfig()Get the current using configuration in memory.voidonUpdate(ClusterConfiguration config)Called when config is changed.private voidremoveConfigAddrs()protected voidshutdown0()For subclass override.-
Methods inherited from class net.rubyeye.xmemcached.XMemcachedClient
add, add, add, add, addOneServerWithWeight, addServer, addServer, addServer, addServer, addServer, addStateListener, addWithNoReply, addWithNoReply, append, append, appendWithNoReply, beginWithNamespace, cas, cas, cas, cas, cas, cas, cas, cas, cas, cas, casWithNoReply, casWithNoReply, casWithNoReply, casWithNoReply, checkException, connect, decr, decr, decr, decr, decrWithNoReply, delete, delete, delete, delete, deleteWithNoReply, deleteWithNoReply, endWithNamespace, flushAll, flushAll, flushAll, flushAll, flushAll, flushAll, flushAll, flushAllWithNoReply, flushAllWithNoReply, flushAllWithNoReply, flushAllWithNoReply, get, get, get, get, get, get, get, get, getAndTouch, getAndTouch, getAuthInfoMap, getAuthInfoStringMap, getAvailableServers, getAvaliableServers, getCommandFactory, getConnectionSizeBySocketAddress, getConnector, getConnectTimeout, getCounter, getCounter, getHealSessionInterval, getKeyIterator, getKeyProvider, getName, getNamespace, getOpTimeout, getProtocol, getReconnectRequestQueue, gets, gets, gets, gets, gets, gets, gets, gets, getServersDescription, getSessionComparator, getSessionLocator, getStateListeners, getStats, getStats, getStatsByItem, getStatsByItem, getTimeoutExceptionThreshold, getTranscoder, getVersions, getVersions, incr, incr, incr, incr, incrWithNoReply, invalidateNamespace, invalidateNamespace, isFailureMode, isSanitizeKeys, isShutdown, latchWait, newConnector, newSocketAddress, prepend, prepend, prependWithNoReply, removeServer, removeServer, removeStateListener, replace, replace, replace, replace, replaceWithNoReply, replaceWithNoReply, sendCommand, set, set, set, set, setAuthInfoMap, setBufferAllocator, setConnectionPoolSize, setConnectTimeout, setEnableHealSession, setEnableHeartBeat, setFailureMode, setHealSessionInterval, setKeyProvider, setLoggingLevelVerbosity, setLoggingLevelVerbosityWithNoReply, setMergeFactor, setName, setOpTimeout, setOptimizeGet, setOptimizeMergeBuffer, setPrimitiveAsString, setSanitizeKeys, setServerWeight, setTimeoutExceptionThreshold, setTranscoder, setWithNoReply, setWithNoReply, shutdown, stats, stats, touch, touch, withNamespace
-
-
-
-
Field Detail
-
log
private static final org.slf4j.Logger log
-
firstTimeUpdate
private boolean firstTimeUpdate
-
configAddrs
private java.util.List<java.net.InetSocketAddress> configAddrs
-
configPoller
private final ConfigurationPoller configPoller
-
DEFAULT_POLL_CONFIG_INTERVAL_MS
public static final long DEFAULT_POLL_CONFIG_INTERVAL_MS
Default elasticcache configuration poll interval, it's one minute.- See Also:
- Constant Field Values
-
currentClusterConfiguration
private volatile ClusterConfiguration currentClusterConfiguration
-
-
Constructor Detail
-
AWSElasticCacheClient
public AWSElasticCacheClient(java.net.InetSocketAddress addr) throws java.io.IOExceptionConstruct an AWSElasticCacheClient instance with one config address and default poll interval.- Parameters:
addr- config server address.- Throws:
java.io.IOException- Since:
- 2.3.0
-
AWSElasticCacheClient
public AWSElasticCacheClient(java.net.InetSocketAddress addr, long pollConfigIntervalMills) throws java.io.IOExceptionConstruct an AWSElasticCacheClient instance with one config address and poll interval.- Parameters:
addr- config server address.pollConfigIntervalMills- config poll interval in milliseconds.- Throws:
java.io.IOException- Since:
- 2.3.0
-
AWSElasticCacheClient
public AWSElasticCacheClient(java.net.InetSocketAddress addr, long pollConfigIntervalMills, CommandFactory cmdFactory) throws java.io.IOException- Throws:
java.io.IOException
-
AWSElasticCacheClient
public AWSElasticCacheClient(java.util.List<java.net.InetSocketAddress> addrs) throws java.io.IOExceptionConstruct an AWSElasticCacheClient instance with config server addresses and default config poll interval.- Parameters:
addrs- config server list.- Throws:
java.io.IOException- Since:
- 2.3.0
-
AWSElasticCacheClient
public AWSElasticCacheClient(java.util.List<java.net.InetSocketAddress> addrs, long pollConfigIntervalMills) throws java.io.IOExceptionConstruct an AWSElasticCacheClient instance with config server addresses.- Parameters:
addrs-pollConfigIntervalMills-- Throws:
java.io.IOException- Since:
- 2.3.0
-
AWSElasticCacheClient
public AWSElasticCacheClient(java.util.List<java.net.InetSocketAddress> addrs, long pollConfigIntervalMills, CommandFactory commandFactory) throws java.io.IOExceptionConstruct an AWSElasticCacheClient instance with config server addresses.- Parameters:
addrs- config server list.pollConfigIntervalMills- config poll interval in milliseconds.commandFactory- protocol command factory.- Throws:
java.io.IOException- Since:
- 2.3.0
-
AWSElasticCacheClient
AWSElasticCacheClient(MemcachedSessionLocator locator, MemcachedSessionComparator comparator, BufferAllocator allocator, Configuration conf, java.util.Map<SocketOption,java.lang.Object> socketOptions, CommandFactory commandFactory, Transcoder transcoder, java.util.List<MemcachedClientStateListener> stateListeners, java.util.Map<java.net.InetSocketAddress,AuthInfo> map, int poolSize, long connectTimeout, java.lang.String name, boolean failureMode, boolean resolveInetAddresses, java.util.List<java.net.InetSocketAddress> configAddrs, long pollConfigIntervalMills) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
onUpdate
public void onUpdate(ClusterConfiguration config)
Description copied from interface:ConfigUpdateListenerCalled when config is changed.- Specified by:
onUpdatein interfaceConfigUpdateListener- Parameters:
config- the new config
-
removeConfigAddrs
private void removeConfigAddrs()
-
asList
private static java.util.List<java.net.InetSocketAddress> asList(java.net.InetSocketAddress addr)
-
getAddressMapFromConfigAddrs
private static java.util.Map<java.net.InetSocketAddress,java.net.InetSocketAddress> getAddressMapFromConfigAddrs(java.util.List<java.net.InetSocketAddress> configAddrs)
-
getConfig
public ClusterConfiguration getConfig() throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
Get cluster config from cache node by network command.- Returns:
- Throws:
MemcachedExceptionjava.lang.InterruptedExceptionjava.util.concurrent.TimeoutException
-
getConfig
public ClusterConfiguration getConfig(java.lang.String key) throws MemcachedException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
Get config by key from cache node by network command.- Returns:
- clusetr config.
- Throws:
MemcachedExceptionjava.lang.InterruptedExceptionjava.util.concurrent.TimeoutException- Since:
- 2.3.0
-
shutdown0
protected void shutdown0()
Description copied from class:XMemcachedClientFor subclass override.- Overrides:
shutdown0in classXMemcachedClient
-
getCurrentConfig
public ClusterConfiguration getCurrentConfig()
Get the current using configuration in memory.- Returns:
- current cluster config.
- Since:
- 2.3.0
-
-