public class RedisClusterClient extends AbstractRedisClient
RedisClusterClient
is an expensive resource. It holds a set of netty's EventLoopGroup
's that
consist of up to Number of CPU's * 4
threads. Reuse this instance as much as possible.Modifier and Type | Field and Description |
---|---|
protected AtomicBoolean |
clusterTopologyRefreshActivated |
BUF_ALLOCATOR, channels, clientOptions, closeableResources, connectionEvents, eventLoopGroup, eventLoopGroups, genericWorkerPool, timeout, timer, unit
Constructor and Description |
---|
RedisClusterClient(List<RedisURI> initialUris)
Initialize the client with a list of cluster URI's.
|
RedisClusterClient(RedisURI initialUri)
Initialize the client with an initial cluster URI.
|
Modifier and Type | Method and Description |
---|---|
protected RedisAsyncConnectionImpl<String,String> |
connectAsyncImpl(SocketAddress socketAddress) |
RedisAdvancedClusterConnection<String,String> |
connectCluster()
Open a new synchronous connection to a Redis Cluster that treats keys and values as UTF-8 strings.
|
<K,V> RedisAdvancedClusterConnection<K,V> |
connectCluster(RedisCodec<K,V> codec)
Open a new synchronous connection to a Redis Cluster.
|
RedisAdvancedClusterAsyncConnection<String,String> |
connectClusterAsync()
Open a new asynchronous connection to a Redis Cluster that treats keys and values as UTF-8 strings.
|
<K,V> RedisAdvancedClusterAsyncConnection<K,V> |
connectClusterAsync(RedisCodec<K,V> codec)
Open a new asynchronous connection to a Redis Cluster.
|
protected <T extends Closeable> |
forEachCloseable(Predicate<? super Closeable> selector,
Predicate<T> function) |
protected void |
forEachClusterConnection(Predicate<RedisAdvancedClusterAsyncConnectionImpl<?,?>> function) |
protected RedisURI |
getFirstUri() |
Partitions |
getPartitions()
Retrieve the cluster view.
|
protected void |
initializePartitions() |
protected boolean |
isEventLoopActive()
Check if the
AbstractRedisClient.genericWorkerPool is active |
protected Partitions |
loadPartitions()
Retrieve partitions.
|
protected <K,V> RedisAdvancedClusterAsyncConnectionImpl<K,V> |
newRedisAdvancedClusterAsyncConnectionImpl(RedisChannelWriter<K,V> channelWriter,
RedisCodec<K,V> codec,
long timeout,
TimeUnit unit)
Construct a new
RedisAdvancedClusterAsyncConnectionImpl . |
protected <K,V> RedisAsyncConnectionImpl<K,V> |
newRedisAsyncConnectionImpl(RedisChannelWriter<K,V> channelWriter,
RedisCodec<K,V> codec,
long timeout,
TimeUnit unit)
Construct a new
RedisAsyncConnectionImpl . |
protected Utf8StringCodec |
newStringStringCodec() |
void |
reloadPartitions()
Reload partitions and re-initialize the distribution table.
|
void |
setOptions(ClusterClientOptions clientOptions)
Set the
ClusterClientOptions for the client. |
void |
setPartitions(Partitions partitions)
Sets the new cluster topology.
|
protected void |
updatePartitionsInConnections() |
addListener, channelType, connectAsyncImpl, connectionBuilder, getChannelCount, getOptions, getResourceCount, initializeChannel, removeListener, setDefaultTimeout, setOptions, shutdown, shutdown, syncHandler
protected AtomicBoolean clusterTopologyRefreshActivated
public RedisClusterClient(RedisURI initialUri)
initialUri
- initial cluster URIpublic RedisClusterClient(List<RedisURI> initialUris)
initialUris
- list of initial cluster URIspublic RedisAdvancedClusterConnection<String,String> connectCluster()
public <K,V> RedisAdvancedClusterConnection<K,V> connectCluster(RedisCodec<K,V> codec)
codec
to encode/decode keys and
values.K
- Key type.V
- Value type.codec
- Use this codec to encode/decode keys and values.public RedisAdvancedClusterAsyncConnection<String,String> connectClusterAsync()
public <K,V> RedisAdvancedClusterAsyncConnection<K,V> connectClusterAsync(RedisCodec<K,V> codec)
codec
to encode/decode keys
and values.K
- Key type.V
- Value type.codec
- Use this codec to encode/decode keys and values.protected RedisAsyncConnectionImpl<String,String> connectAsyncImpl(SocketAddress socketAddress)
public void reloadPartitions()
protected void updatePartitionsInConnections()
protected void initializePartitions()
public Partitions getPartitions()
protected Partitions loadPartitions()
protected boolean isEventLoopActive()
AbstractRedisClient.genericWorkerPool
is activeprotected <K,V> RedisAsyncConnectionImpl<K,V> newRedisAsyncConnectionImpl(RedisChannelWriter<K,V> channelWriter, RedisCodec<K,V> codec, long timeout, TimeUnit unit)
RedisAsyncConnectionImpl
. Can be overridden in order to construct a subclass of
RedisAsyncConnectionImpl
. These connections are the "inner" connections used by the
ClusterDistributionChannelWriter
.K
- Key type.V
- Value type.channelWriter
- the channel writercodec
- the codec to usetimeout
- Timeout valueunit
- Timeout unitprotected <K,V> RedisAdvancedClusterAsyncConnectionImpl<K,V> newRedisAdvancedClusterAsyncConnectionImpl(RedisChannelWriter<K,V> channelWriter, RedisCodec<K,V> codec, long timeout, TimeUnit unit)
RedisAdvancedClusterAsyncConnectionImpl
. Can be overridden in order to construct a subclass of
RedisAdvancedClusterAsyncConnectionImpl
K
- Key type.V
- Value type.channelWriter
- the channel writercodec
- the codec to usetimeout
- Timeout valueunit
- Timeout unitprotected RedisURI getFirstUri()
protected Utf8StringCodec newStringStringCodec()
public void setPartitions(Partitions partitions)
partitions
- partitions objectprotected void forEachClusterConnection(Predicate<RedisAdvancedClusterAsyncConnectionImpl<?,?>> function)
protected <T extends Closeable> void forEachCloseable(Predicate<? super Closeable> selector, Predicate<T> function)
public void setOptions(ClusterClientOptions clientOptions)
ClusterClientOptions
for the client.clientOptions
- client options for the client and connections that are created after setting the optionsCopyright © 2015. All rights reserved.