DATAREDIS-681 - Polishing.

Reduce constructor visibility of driver-specific commands classes. Upate Javadoc.

Original Pull Request: #267
This commit is contained in:
Christoph Strobl
2017-09-08 13:16:34 +02:00
parent cdb3e2437d
commit 50b5bd69af
3 changed files with 32 additions and 28 deletions

View File

@@ -152,8 +152,8 @@ public class ClusterCommandExecutor implements DisposableBean {
/**
* Lookup node from the topology.
*
* @param node
* @return
* @param node must not be {@literal null}.
* @return never {@literal null}.
* @throws IllegalArgumentException in case the node could not be resolved to a topology-known node
*/
private RedisClusterNode lookupNode(RedisClusterNode node) {
@@ -167,8 +167,8 @@ public class ClusterCommandExecutor implements DisposableBean {
/**
* Run {@link ClusterCommandCallback} on all reachable master nodes.
*
* @param cmd
* @return
* @param cmd must not be {@literal null}.
* @return never {@literal null}.
* @throws ClusterCommandExecutionFailureException
*/
public <S, T> MultiNodeResult<T> executeCommandOnAllNodes(final ClusterCommandCallback<S, T> cmd) {
@@ -176,9 +176,9 @@ public class ClusterCommandExecutor implements DisposableBean {
}
/**
* @param callback
* @param nodes
* @return
* @param callback must not be {@literal null}.
* @param nodes must not be {@literal null}.
* @return never {@literal null}.
* @throws ClusterCommandExecutionFailureException
* @throws IllegalArgumentException in case the node could not be resolved to a topology-known node
*/
@@ -263,8 +263,8 @@ public class ClusterCommandExecutor implements DisposableBean {
/**
* Run {@link MultiKeyClusterCommandCallback} with on a curated set of nodes serving one or more keys.
*
* @param cmd
* @return
* @param cmd must not be {@literal null}.
* @return never {@literal null}.
* @throws ClusterCommandExecutionFailureException
*/
public <S, T> MultiNodeResult<T> executeMultiKeyCommand(MultiKeyClusterCommandCallback<S, T> cmd,
@@ -390,7 +390,7 @@ public class ClusterCommandExecutor implements DisposableBean {
private RedisClusterNode node;
private Object[] args;
public NodeExecution(RedisClusterNode node, Object... args) {
NodeExecution(RedisClusterNode node, Object... args) {
this.node = node;
this.args = args;
@@ -399,7 +399,7 @@ public class ClusterCommandExecutor implements DisposableBean {
/**
* Get the {@link RedisClusterNode} the execution happens on.
*/
public RedisClusterNode getNode() {
RedisClusterNode getNode() {
return node;
}
@@ -556,7 +556,7 @@ public class ClusterCommandExecutor implements DisposableBean {
}
/**
* @param returnValue
* @param returnValue can be {@literal null}.
* @return
*/
public T getFirstNonNullNotEmptyOrDefault(T returnValue) {

View File

@@ -40,7 +40,7 @@ public class ClusterTopology {
* @param nodes can be {@literal null}.
*/
public ClusterTopology(Set<RedisClusterNode> nodes) {
this.nodes = nodes != null ? nodes : Collections.<RedisClusterNode> emptySet();
this.nodes = nodes != null ? nodes : Collections.emptySet();
}
/**
@@ -123,7 +123,7 @@ public class ClusterTopology {
* Get the {@link RedisClusterNode} that is the current master serving the given key.
*
* @param key must not be {@literal null}.
* @return
* @return never {@literal null}.
* @throws ClusterStateFailureException
*/
public RedisClusterNode getKeyServingMasterNode(byte[] key) {
@@ -131,13 +131,15 @@ public class ClusterTopology {
Assert.notNull(key, "Key for node lookup must not be null!");
int slot = ClusterSlotHashUtil.calculateSlot(key);
for (RedisClusterNode node : nodes) {
if (node.isMaster() && node.servesSlot(slot)) {
return node;
}
}
throw new ClusterStateFailureException(String.format("Could not find master node serving slot %s for key '%s',",
slot, key));
throw new ClusterStateFailureException(
String.format("Could not find master node serving slot %s for key '%s',", slot, key));
}
/**
@@ -145,7 +147,7 @@ public class ClusterTopology {
*
* @param host must not be {@literal null}.
* @param port
* @return
* @return never {@literal null}.
* @throws ClusterStateFailureException
*/
public RedisClusterNode lookup(String host, int port) {
@@ -155,15 +157,16 @@ public class ClusterTopology {
return node;
}
}
throw new ClusterStateFailureException(String.format(
"Could not find node at %s:%s. Is your cluster info up to date?", host, port));
throw new ClusterStateFailureException(
String.format("Could not find node at %s:%s. Is your cluster info up to date?", host, port));
}
/**
* Get the {@link RedisClusterNode} matching given {@literal nodeId}.
*
* @param nodeId must not be {@literal null}.
* @return
* @return never {@literal null}.
* @throws ClusterStateFailureException
*/
public RedisClusterNode lookup(String nodeId) {
@@ -175,23 +178,24 @@ public class ClusterTopology {
return node;
}
}
throw new ClusterStateFailureException(String.format(
"Could not find node at %s. Is your cluster info up to date?", nodeId));
throw new ClusterStateFailureException(
String.format("Could not find node at %s. Is your cluster info up to date?", nodeId));
}
/**
* Get the {@link RedisClusterNode} matching matching either {@link RedisClusterNode#getHost() host} and {@link RedisClusterNode#getPort() port}
* or {@link RedisClusterNode#getId() nodeId}
* Get the {@link RedisClusterNode} matching matching either {@link RedisClusterNode#getHost() host} and
* {@link RedisClusterNode#getPort() port} or {@link RedisClusterNode#getId() nodeId}
*
* @param node must not be {@literal null}
* @return
* @throws ClusterStateFailureException
* @return never {@literal null}.
* @throws ClusterStateFailureException
*/
public RedisClusterNode lookup(RedisClusterNode node) {
Assert.notNull(node, "RedisClusterNode must not be null!");
if(nodes.contains(node) && StringUtils.hasText(node.getHost()) && StringUtils.hasText(node.getId())){
if (nodes.contains(node) && StringUtils.hasText(node.getHost()) && StringUtils.hasText(node.getId())) {
return node;
}

View File

@@ -38,7 +38,7 @@ class JedisZSetCommands implements RedisZSetCommands {
private final JedisConnection connection;
public JedisZSetCommands(JedisConnection connection) {
JedisZSetCommands(JedisConnection connection) {
this.connection = connection;
}