public class ClusterCommandExecutor extends Object implements DisposableBean
ClusterCommandExecutor
takes care of running commands across the known cluster nodes. By providing an
AsyncTaskExecutor
the execution behavior can be influenced.Modifier and Type | Class and Description |
---|---|
static interface |
ClusterCommandExecutor.ClusterCommandCallback<T,S>
Callback interface for Redis 'low level' code using the cluster client directly.
|
static interface |
ClusterCommandExecutor.MultiKeyClusterCommandCallback<T,S>
Callback interface for Redis 'low level' code using the cluster client to execute multi key commands.
|
static class |
ClusterCommandExecutor.MultiNodeResult<T>
ClusterCommandExecutor.MultiNodeResult holds all ClusterCommandExecutor.NodeResult of a command executed on multiple RedisClusterNode . |
static class |
ClusterCommandExecutor.NodeResult<T>
ClusterCommandExecutor.NodeResult encapsulates the actual value returned by a ClusterCommandExecutor.ClusterCommandCallback on a given
RedisClusterNode . |
Constructor and Description |
---|
ClusterCommandExecutor(ClusterTopologyProvider topologyProvider,
ClusterNodeResourceProvider resourceProvider,
ExceptionTranslationStrategy exceptionTranslation)
Create a new instance of
ClusterCommandExecutor . |
ClusterCommandExecutor(ClusterTopologyProvider topologyProvider,
ClusterNodeResourceProvider resourceProvider,
ExceptionTranslationStrategy exceptionTranslation,
AsyncTaskExecutor executor) |
public ClusterCommandExecutor(ClusterTopologyProvider topologyProvider, ClusterNodeResourceProvider resourceProvider, ExceptionTranslationStrategy exceptionTranslation)
ClusterCommandExecutor
.topologyProvider
- must not be null.resourceProvider
- must not be null.exceptionTranslation
- must not be null.public ClusterCommandExecutor(ClusterTopologyProvider topologyProvider, ClusterNodeResourceProvider resourceProvider, ExceptionTranslationStrategy exceptionTranslation, @Nullable AsyncTaskExecutor executor)
topologyProvider
- must not be null.resourceProvider
- must not be null.exceptionTranslation
- must not be null.executor
- can be null. Defaulted to ThreadPoolTaskExecutor
.public <T> ClusterCommandExecutor.NodeResult<T> executeCommandOnArbitraryNode(ClusterCommandExecutor.ClusterCommandCallback<?,T> cmd)
ClusterCommandExecutor.ClusterCommandCallback
on a random node.cmd
- must not be null.public <S,T> ClusterCommandExecutor.NodeResult<T> executeCommandOnSingleNode(ClusterCommandExecutor.ClusterCommandCallback<S,T> cmd, RedisClusterNode node)
cmd
- must not be null.node
- must not be null.IllegalArgumentException
- in case no resource can be acquired for given node.public <S,T> ClusterCommandExecutor.MultiNodeResult<T> executeCommandOnAllNodes(ClusterCommandExecutor.ClusterCommandCallback<S,T> cmd)
ClusterCommandExecutor.ClusterCommandCallback
on all reachable master nodes.cmd
- must not be null.ClusterCommandExecutionFailureException
public <S,T> ClusterCommandExecutor.MultiNodeResult<T> executeCommandAsyncOnNodes(ClusterCommandExecutor.ClusterCommandCallback<S,T> callback, Iterable<RedisClusterNode> nodes)
callback
- must not be null.nodes
- must not be null.ClusterCommandExecutionFailureException
IllegalArgumentException
- in case the node could not be resolved to a topology-known nodepublic <S,T> ClusterCommandExecutor.MultiNodeResult<T> executeMultiKeyCommand(ClusterCommandExecutor.MultiKeyClusterCommandCallback<S,T> cmd, Iterable<byte[]> keys)
ClusterCommandExecutor.MultiKeyClusterCommandCallback
with on a curated set of nodes serving one or more keys.cmd
- must not be null.ClusterCommandExecutionFailureException
public void setMaxRedirects(int maxRedirects)
MOVED
or ASK
.maxRedirects
- set to zero to suspend redirects.public void destroy() throws Exception
destroy
in interface DisposableBean
Exception
Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.