Remove usage of oppressive language.
The API exposes now the renamed command terminology (replica) only and no longer the deprecated one. Closes: #2195 See: #2274 Original Pull Request: #2276
This commit is contained in:
committed by
Christoph Strobl
parent
69205c56bb
commit
f1d528ffef
@@ -115,6 +115,7 @@
|
||||
|RANDOMKEY |X
|
||||
|RENAME |X
|
||||
|RENAMENX |X
|
||||
|REPLICAOF |X
|
||||
|RESTORE |X
|
||||
|ROLE |-
|
||||
|RPOP |X
|
||||
|
||||
@@ -55,8 +55,8 @@ public class ClusterTopology {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all nodes (master and slave) in cluster where {@code link-state} is {@literal connected} and {@code flags} does
|
||||
* not contain {@literal fail} or {@literal fail?}.
|
||||
* Get all nodes (master and replica) in cluster where {@code link-state} is {@literal connected} and {@code flags}
|
||||
* does not contain {@literal fail} or {@literal fail?}.
|
||||
*
|
||||
* @return never {@literal null}.
|
||||
*/
|
||||
@@ -105,7 +105,7 @@ public class ClusterTopology {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link RedisClusterNode}s (master and slave) serving s specific slot.
|
||||
* Get the {@link RedisClusterNode}s (master and replica) serving s specific slot.
|
||||
*
|
||||
* @param slot
|
||||
* @return never {@literal null}.
|
||||
|
||||
@@ -2444,13 +2444,13 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco
|
||||
}
|
||||
|
||||
@Override
|
||||
public void slaveOf(String host, int port) {
|
||||
this.delegate.slaveOf(host, port);
|
||||
public void replicaOf(String host, int port) {
|
||||
this.delegate.replicaOf(host, port);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void slaveOfNoOne() {
|
||||
this.delegate.slaveOfNoOne();
|
||||
public void replicaOfNoOne() {
|
||||
this.delegate.replicaOfNoOne();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1755,15 +1755,15 @@ public interface DefaultedRedisConnection extends RedisConnection {
|
||||
/** @deprecated in favor of {@link RedisConnection#serverCommands()}. */
|
||||
@Override
|
||||
@Deprecated
|
||||
default void slaveOf(String host, int port) {
|
||||
serverCommands().slaveOf(host, port);
|
||||
default void replicaOf(String host, int port) {
|
||||
serverCommands().replicaOf(host, port);
|
||||
}
|
||||
|
||||
/** @deprecated in favor of {@link RedisConnection#serverCommands()}. */
|
||||
@Override
|
||||
@Deprecated
|
||||
default void slaveOfNoOne() {
|
||||
serverCommands().slaveOfNoOne();
|
||||
default void replicaOfNoOne() {
|
||||
serverCommands().replicaOfNoOne();
|
||||
}
|
||||
|
||||
/** @deprecated in favor of {@link RedisConnection#serverCommands()}. */
|
||||
|
||||
@@ -46,22 +46,22 @@ public interface ReactiveClusterCommands {
|
||||
Flux<RedisClusterNode> clusterGetNodes();
|
||||
|
||||
/**
|
||||
* Retrieve information about connected slaves for given master node.
|
||||
* Retrieve information about connected replicas for given master node.
|
||||
*
|
||||
* @param master must not be {@literal null}.
|
||||
* @return a {@link Flux} emitting {@link RedisClusterNode cluster nodes}, an {@link Flux#empty() empty one} if none
|
||||
* found.
|
||||
* @see <a href="https://redis.io/commands/cluster-slaves">Redis Documentation: CLUSTER SLAVES</a>
|
||||
* @see <a href="https://redis.io/commands/cluster-replicas">Redis Documentation: CLUSTER REPLICAS</a>
|
||||
*/
|
||||
Flux<RedisClusterNode> clusterGetSlaves(RedisClusterNode master);
|
||||
Flux<RedisClusterNode> clusterGetReplicas(RedisClusterNode master);
|
||||
|
||||
/**
|
||||
* Retrieve information about masters and their connected slaves.
|
||||
* Retrieve information about masters and their connected replicas.
|
||||
*
|
||||
* @return never {@literal null}.
|
||||
* @see <a href="https://redis.io/commands/cluster-slaves">Redis Documentation: CLUSTER SLAVES</a>
|
||||
* @see <a href="https://redis.io/commands/cluster-replicas">Redis Documentation: CLUSTER REPLICAS</a>
|
||||
*/
|
||||
Mono<Map<RedisClusterNode, Collection<RedisClusterNode>>> clusterGetMasterSlaveMap();
|
||||
Mono<Map<RedisClusterNode, Collection<RedisClusterNode>>> clusterGetMasterReplicaMap();
|
||||
|
||||
/**
|
||||
* Find the slot for a given {@code key}.
|
||||
@@ -184,7 +184,7 @@ public interface ReactiveClusterCommands {
|
||||
Flux<ByteBuffer> clusterGetKeysInSlot(int slot, int count);
|
||||
|
||||
/**
|
||||
* Assign a {@literal slave} to given {@literal master}.
|
||||
* Assign a {@literal replica} to given {@literal master}.
|
||||
*
|
||||
* @param master must not be {@literal null}.
|
||||
* @param replica must not be {@literal null}.
|
||||
|
||||
@@ -41,21 +41,21 @@ public interface RedisClusterCommands {
|
||||
Iterable<RedisClusterNode> clusterGetNodes();
|
||||
|
||||
/**
|
||||
* Retrieve information about connected slaves for given master node.
|
||||
* Retrieve information about connected replicas for given master node.
|
||||
*
|
||||
* @param master must not be {@literal null}.
|
||||
* @return never {@literal null}.
|
||||
* @see <a href="https://redis.io/commands/cluster-slaves">Redis Documentation: CLUSTER SLAVES</a>
|
||||
* @see <a href="https://redis.io/commands/cluster-replicas">Redis Documentation: CLUSTER REPLICAS</a>
|
||||
*/
|
||||
Collection<RedisClusterNode> clusterGetSlaves(RedisClusterNode master);
|
||||
Collection<RedisClusterNode> clusterGetReplicas(RedisClusterNode master);
|
||||
|
||||
/**
|
||||
* Retrieve information about masters and their connected slaves.
|
||||
* Retrieve information about masters and their connected replicas.
|
||||
*
|
||||
* @return never {@literal null}.
|
||||
* @see <a href="https://redis.io/commands/cluster-slaves">Redis Documentation: CLUSTER SLAVES</a>
|
||||
* @see <a href="https://redis.io/commands/cluster-replicas">Redis Documentation: CLUSTER REPLICAS</a>
|
||||
*/
|
||||
Map<RedisClusterNode, Collection<RedisClusterNode>> clusterGetMasterSlaveMap();
|
||||
Map<RedisClusterNode, Collection<RedisClusterNode>> clusterGetMasterReplicaMap();
|
||||
|
||||
/**
|
||||
* Find the slot for a given {@code key}.
|
||||
@@ -171,7 +171,7 @@ public interface RedisClusterCommands {
|
||||
List<byte[]> clusterGetKeysInSlot(int slot, Integer count);
|
||||
|
||||
/**
|
||||
* Assign a {@literal slave} to given {@literal master}.
|
||||
* Assign a {@literal replica} to given {@literal master}.
|
||||
*
|
||||
* @param master must not be {@literal null}.
|
||||
* @param replica must not be {@literal null}.
|
||||
|
||||
@@ -242,7 +242,7 @@ public class RedisClusterNode extends RedisNode {
|
||||
*/
|
||||
public static enum Flag {
|
||||
|
||||
MYSELF("myself"), MASTER("master"), SLAVE("slave"), FAIL("fail"), PFAIL("fail?"), HANDSHAKE("handshake"), NOADDR(
|
||||
MYSELF("myself"), MASTER("master"), REPLICA("slave"), FAIL("fail"), PFAIL("fail?"), HANDSHAKE("handshake"), NOADDR(
|
||||
"noaddr"), NOFLAGS("noflags");
|
||||
|
||||
private String raw;
|
||||
@@ -297,11 +297,6 @@ public class RedisClusterNode extends RedisNode {
|
||||
return this;
|
||||
}
|
||||
|
||||
public RedisClusterNodeBuilder slaveOf(String masterId) {
|
||||
super.slaveOf(masterId);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisClusterNodeBuilder replicaOf(String masterId) {
|
||||
super.replicaOf(masterId);
|
||||
|
||||
@@ -482,8 +482,7 @@ public interface RedisConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration interface suitable for Redis master/slave environments with fixed hosts. <br/>
|
||||
* Redis is undergoing a nomenclature change where the term replica is used synonymously to slave.
|
||||
* Configuration interface suitable for Redis master/replica environments with fixed hosts.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
|
||||
@@ -142,20 +142,12 @@ public class RedisNode implements NamedNode {
|
||||
return ObjectUtils.nullSafeEquals(NodeType.MASTER, getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @since 1.7
|
||||
*/
|
||||
public boolean isSlave() {
|
||||
return isReplica();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @since 2.1
|
||||
*/
|
||||
public boolean isReplica() {
|
||||
return ObjectUtils.nullSafeEquals(NodeType.SLAVE, getType());
|
||||
return ObjectUtils.nullSafeEquals(NodeType.REPLICA, getType());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,7 +206,7 @@ public class RedisNode implements NamedNode {
|
||||
* @since 1.7
|
||||
*/
|
||||
public enum NodeType {
|
||||
MASTER, SLAVE
|
||||
MASTER, REPLICA
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -279,17 +271,6 @@ public class RedisNode implements NamedNode {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the id of the master node.
|
||||
*
|
||||
* @param masterId
|
||||
* @return
|
||||
* @since 1.7
|
||||
*/
|
||||
public RedisNodeBuilder slaveOf(String masterId) {
|
||||
return replicaOf(masterId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the id of the master node.
|
||||
*
|
||||
|
||||
@@ -42,12 +42,12 @@ public interface RedisSentinelCommands {
|
||||
Collection<RedisServer> masters();
|
||||
|
||||
/**
|
||||
* Show list of slaves for given {@literal master}.
|
||||
* Show list of replicas for given {@literal master}.
|
||||
*
|
||||
* @param master must not be {@literal null}.
|
||||
* @return Collection of {@link RedisServer}s. Never {@literal null}.
|
||||
*/
|
||||
Collection<RedisServer> slaves(NamedNode master);
|
||||
Collection<RedisServer> replicas(NamedNode master);
|
||||
|
||||
/**
|
||||
* Removes given {@literal master}. The server will no longer be monitored and will no longer be returned by
|
||||
|
||||
@@ -165,10 +165,6 @@ public class RedisServer extends RedisNode {
|
||||
return getLongValueOf(INFO.CONFIG_EPOCH);
|
||||
}
|
||||
|
||||
public Long getNumberSlaves() {
|
||||
return getNumberReplicas();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of connected replicas.
|
||||
*
|
||||
|
||||
@@ -274,18 +274,18 @@ public interface RedisServerCommands {
|
||||
*
|
||||
* @param host must not be {@literal null}.
|
||||
* @param port
|
||||
* @since 1.3
|
||||
* @see <a href="https://redis.io/commands/slaveof">Redis Documentation: SLAVEOF</a>
|
||||
* @since 3.0
|
||||
* @see <a href="https://redis.io/commands/replicaof">Redis Documentation: REPLICAOF</a>
|
||||
*/
|
||||
void slaveOf(String host, int port);
|
||||
void replicaOf(String host, int port);
|
||||
|
||||
/**
|
||||
* Change server into master.
|
||||
*
|
||||
* @since 1.3
|
||||
* @see <a href="https://redis.io/commands/slaveof">Redis Documentation: SLAVEOF</a>
|
||||
* @see <a href="https://redis.io/commands/replicaof">Redis Documentation: REPLICAOF</a>
|
||||
*/
|
||||
void slaveOfNoOne();
|
||||
void replicaOfNoOne();
|
||||
|
||||
/**
|
||||
* Atomically transfer a key from a source Redis instance to a destination Redis instance. On success the key is
|
||||
|
||||
@@ -28,8 +28,7 @@ import org.springframework.util.ObjectUtils;
|
||||
* Configuration class used for setting up {@link RedisConnection} via {@link RedisConnectionFactory} using the provided
|
||||
* Master / Replica configuration to nodes know to not change address. Eg. when connecting to
|
||||
* <a href="https://aws.amazon.com/documentation/elasticache/">AWS ElastiCache with Read Replicas</a>. <br/>
|
||||
* Note: Redis is undergoing a nomenclature change where the term replica is used synonymously to slave. Please also
|
||||
* note that a Master/Replica connection cannot be used for Pub/Sub operations.
|
||||
* Please also note that a Master/Replica connection cannot be used for Pub/Sub operations.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
|
||||
@@ -570,13 +570,13 @@ abstract public class Converters {
|
||||
RedisClusterNodeBuilder nodeBuilder = RedisClusterNode.newRedisClusterNode()
|
||||
.listeningAt(hostAndPort[0], Integer.valueOf(portPart)) //
|
||||
.withId(args[ID_INDEX]) //
|
||||
.promotedAs(flags.contains(Flag.MASTER) ? NodeType.MASTER : NodeType.SLAVE) //
|
||||
.promotedAs(flags.contains(Flag.MASTER) ? NodeType.MASTER : NodeType.REPLICA) //
|
||||
.serving(range) //
|
||||
.withFlags(flags) //
|
||||
.linkState(parseLinkState(args));
|
||||
|
||||
if (!args[MASTER_ID_INDEX].isEmpty() && !args[MASTER_ID_INDEX].startsWith("-")) {
|
||||
nodeBuilder.slaveOf(args[MASTER_ID_INDEX]);
|
||||
nodeBuilder.replicaOf(args[MASTER_ID_INDEX]);
|
||||
}
|
||||
|
||||
return nodeBuilder.build();
|
||||
|
||||
@@ -563,7 +563,7 @@ public class JedisClusterConnection implements DefaultedRedisClusterConnection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RedisClusterNode> clusterGetSlaves(RedisClusterNode master) {
|
||||
public Set<RedisClusterNode> clusterGetReplicas(RedisClusterNode master) {
|
||||
|
||||
Assert.notNull(master, "Master cannot be null!");
|
||||
|
||||
@@ -576,7 +576,7 @@ public class JedisClusterConnection implements DefaultedRedisClusterConnection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<RedisClusterNode, Collection<RedisClusterNode>> clusterGetMasterSlaveMap() {
|
||||
public Map<RedisClusterNode, Collection<RedisClusterNode>> clusterGetMasterReplicaMap() {
|
||||
|
||||
List<NodeResult<Collection<RedisClusterNode>>> nodeResults = clusterCommandExecutor.executeCommandAsyncOnNodes(
|
||||
(JedisClusterCommandCallback<Collection<RedisClusterNode>>) client -> JedisConverters
|
||||
|
||||
@@ -375,15 +375,15 @@ class JedisClusterServerCommands implements RedisClusterServerCommands {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void slaveOf(String host, int port) {
|
||||
public void replicaOf(String host, int port) {
|
||||
throw new InvalidDataAccessApiUsageException(
|
||||
"SlaveOf is not supported in cluster environment. Please use CLUSTER REPLICATE.");
|
||||
"REPLICAOF is not supported in cluster environment. Please use CLUSTER REPLICATE.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void slaveOfNoOne() {
|
||||
public void replicaOfNoOne() {
|
||||
throw new InvalidDataAccessApiUsageException(
|
||||
"SlaveOf is not supported in cluster environment. Please use CLUSTER REPLICATE.");
|
||||
"REPLICAOF is not supported in cluster environment. Please use CLUSTER REPLICATE.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -64,21 +64,21 @@ public class JedisSentinelConnection implements RedisSentinelConnection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RedisServer> slaves(NamedNode master) {
|
||||
public List<RedisServer> replicas(NamedNode master) {
|
||||
|
||||
Assert.notNull(master, "Master node cannot be 'null' when loading slaves.");
|
||||
return slaves(master.getName());
|
||||
Assert.notNull(master, "Master node cannot be 'null' when loading replicas.");
|
||||
return replicas(master.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param masterName
|
||||
* @see RedisSentinelCommands#slaves(NamedNode)
|
||||
* @see RedisSentinelCommands#replicas(NamedNode)
|
||||
* @return
|
||||
*/
|
||||
public List<RedisServer> slaves(String masterName) {
|
||||
public List<RedisServer> replicas(String masterName) {
|
||||
|
||||
Assert.hasText(masterName, "Name of redis master cannot be 'null' or empty when loading slaves.");
|
||||
return JedisConverters.toListOfRedisServer(jedis.sentinelSlaves(masterName));
|
||||
Assert.hasText(masterName, "Name of redis master cannot be 'null' or empty when loading replicas.");
|
||||
return JedisConverters.toListOfRedisServer(jedis.sentinelReplicas(masterName));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -205,22 +205,22 @@ class JedisServerCommands implements RedisServerCommands {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void slaveOf(String host, int port) {
|
||||
public void replicaOf(String host, int port) {
|
||||
|
||||
Assert.hasText(host, "Host must not be null for 'SLAVEOF' command.");
|
||||
Assert.hasText(host, "Host must not be null for 'REPLICAOF' command.");
|
||||
|
||||
if (isQueueing() || isPipelined()) {
|
||||
throw new UnsupportedOperationException("'SLAVEOF' cannot be called in pipline / transaction mode.");
|
||||
throw new UnsupportedOperationException("'REPLICAOF' cannot be called in pipeline / transaction mode.");
|
||||
}
|
||||
|
||||
connection.invokeStatus().just(it -> it.slaveof(host, port));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void slaveOfNoOne() {
|
||||
public void replicaOfNoOne() {
|
||||
|
||||
if (isQueueing() || isPipelined()) {
|
||||
throw new UnsupportedOperationException("'SLAVEOF' cannot be called in pipline / transaction mode.");
|
||||
throw new UnsupportedOperationException("'REPLICAOF' cannot be called in pipeline / transaction mode.");
|
||||
}
|
||||
|
||||
connection.invokeStatus().just(BinaryJedis::slaveofNoOne);
|
||||
|
||||
@@ -89,8 +89,6 @@ public interface LettuceClientConfiguration {
|
||||
Optional<String> getClientName();
|
||||
|
||||
/**
|
||||
* Note: Redis is undergoing a nomenclature change where the term replica is used synonymously to slave.
|
||||
*
|
||||
* @return the optional {@link io.lettuce.core.ReadFrom} setting.
|
||||
* @since 2.1
|
||||
*/
|
||||
@@ -240,8 +238,7 @@ public interface LettuceClientConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure {@link ReadFrom}. Enables Master/Replica operations if configured. <br/>
|
||||
* Note: Redis is undergoing a nomenclature change where the term replica is used synonymously to slave.
|
||||
* Configure {@link ReadFrom}. Enables Master/Replica operations if configured.
|
||||
*
|
||||
* @param readFrom must not be {@literal null}.
|
||||
* @return {@literal this} builder.
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.redis.connection.lettuce;
|
||||
|
||||
import io.lettuce.core.RedisException;
|
||||
import io.lettuce.core.RedisURI;
|
||||
import io.lettuce.core.api.sync.BaseRedisCommands;
|
||||
import io.lettuce.core.cluster.RedisClusterClient;
|
||||
@@ -33,9 +32,9 @@ import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.DataAccessResourceFailureException;
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.data.redis.ExceptionTranslationStrategy;
|
||||
import org.springframework.data.redis.PassThroughExceptionTranslationStrategy;
|
||||
@@ -275,7 +274,7 @@ public class LettuceClusterConnection extends LettuceConnection implements Defau
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RedisClusterNode> clusterGetSlaves(RedisClusterNode master) {
|
||||
public Set<RedisClusterNode> clusterGetReplicas(RedisClusterNode master) {
|
||||
|
||||
Assert.notNull(master, "Master must not be null!");
|
||||
|
||||
@@ -288,7 +287,7 @@ public class LettuceClusterConnection extends LettuceConnection implements Defau
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<RedisClusterNode, Collection<RedisClusterNode>> clusterGetMasterSlaveMap() {
|
||||
public Map<RedisClusterNode, Collection<RedisClusterNode>> clusterGetMasterReplicaMap() {
|
||||
|
||||
List<NodeResult<Collection<RedisClusterNode>>> nodeResults = clusterCommandExecutor.executeCommandAsyncOnNodes(
|
||||
(LettuceClusterCommandCallback<Collection<RedisClusterNode>>) client -> Converters
|
||||
|
||||
@@ -279,15 +279,15 @@ class LettuceClusterServerCommands extends LettuceServerCommands implements Redi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void slaveOf(String host, int port) {
|
||||
public void replicaOf(String host, int port) {
|
||||
throw new InvalidDataAccessApiUsageException(
|
||||
"SlaveOf is not supported in cluster environment. Please use CLUSTER REPLICATE.");
|
||||
"REPLICAOF is not supported in cluster environment. Please use CLUSTER REPLICATE.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void slaveOfNoOne() {
|
||||
public void replicaOfNoOne() {
|
||||
throw new InvalidDataAccessApiUsageException(
|
||||
"SlaveOf is not supported in cluster environment. Please use CLUSTER REPLICATE.");
|
||||
"REPLICAOF is not supported in cluster environment. Please use CLUSTER REPLICATE.");
|
||||
}
|
||||
|
||||
private <T> NodeResult<T> executeCommandOnSingleNode(LettuceClusterCommandCallback<T> command,
|
||||
|
||||
@@ -478,7 +478,7 @@ public abstract class LettuceConverters extends Converters {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param source List of Maps containing node details from SENTINEL SLAVES or SENTINEL MASTERS. May be empty or
|
||||
* @param source List of Maps containing node details from SENTINEL REPLICAS or SENTINEL MASTERS. May be empty or
|
||||
* {@literal null}.
|
||||
* @return List of {@link RedisServer}'s. List is empty if List of Maps is empty.
|
||||
* @since 1.5
|
||||
@@ -724,9 +724,9 @@ public abstract class LettuceConverters extends Converters {
|
||||
Set<Flag> flags = parseFlags(source.getFlags());
|
||||
|
||||
return RedisClusterNode.newRedisClusterNode().listeningAt(source.getUri().getHost(), source.getUri().getPort())
|
||||
.withId(source.getNodeId()).promotedAs(flags.contains(Flag.MASTER) ? NodeType.MASTER : NodeType.SLAVE)
|
||||
.withId(source.getNodeId()).promotedAs(flags.contains(Flag.MASTER) ? NodeType.MASTER : NodeType.REPLICA)
|
||||
.serving(new SlotRange(source.getSlots())).withFlags(flags)
|
||||
.linkState(source.isConnected() ? LinkState.CONNECTED : LinkState.DISCONNECTED).slaveOf(source.getSlaveOf())
|
||||
.linkState(source.isConnected() ? LinkState.CONNECTED : LinkState.DISCONNECTED).replicaOf(source.getSlaveOf())
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -757,7 +757,8 @@ public abstract class LettuceConverters extends Converters {
|
||||
flags.add(Flag.NOADDR);
|
||||
break;
|
||||
case SLAVE:
|
||||
flags.add(Flag.SLAVE);
|
||||
case REPLICA:
|
||||
flags.add(Flag.REPLICA);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ class LettuceReactiveRedisClusterConnection extends LettuceReactiveRedisConnecti
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<RedisClusterNode> clusterGetSlaves(RedisClusterNode master) {
|
||||
public Flux<RedisClusterNode> clusterGetReplicas(RedisClusterNode master) {
|
||||
|
||||
Assert.notNull(master, "Master must not be null!");
|
||||
|
||||
@@ -178,7 +178,7 @@ class LettuceReactiveRedisClusterConnection extends LettuceReactiveRedisConnecti
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Map<RedisClusterNode, Collection<RedisClusterNode>>> clusterGetMasterSlaveMap() {
|
||||
public Mono<Map<RedisClusterNode, Collection<RedisClusterNode>>> clusterGetMasterReplicaMap() {
|
||||
|
||||
return Flux.fromStream(() -> topologyProvider.getTopology().getActiveMasterNodes().stream()) //
|
||||
.flatMap(node -> {
|
||||
|
||||
@@ -164,20 +164,20 @@ public class LettuceSentinelConnection implements RedisSentinelConnection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RedisServer> slaves(NamedNode master) {
|
||||
public List<RedisServer> replicas(NamedNode master) {
|
||||
|
||||
Assert.notNull(master, "Master node cannot be 'null' when loading slaves.");
|
||||
Assert.notNull(master, "Master node cannot be 'null' when loading replicas.");
|
||||
return slaves(master.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param masterName
|
||||
* @see org.springframework.data.redis.connection.RedisSentinelCommands#slaves(org.springframework.data.redis.connection.NamedNode)
|
||||
* @see org.springframework.data.redis.connection.RedisSentinelCommands#replicas(org.springframework.data.redis.connection.NamedNode)
|
||||
* @return
|
||||
*/
|
||||
public List<RedisServer> slaves(String masterName) {
|
||||
|
||||
Assert.hasText(masterName, "Name of redis master cannot be 'null' or empty when loading slaves.");
|
||||
Assert.hasText(masterName, "Name of redis master cannot be 'null' or empty when loading replicas.");
|
||||
try {
|
||||
return LettuceConverters.toListOfRedisServer(getSentinelCommands().slaves(masterName));
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -202,15 +202,15 @@ class LettuceServerCommands implements RedisServerCommands {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void slaveOf(String host, int port) {
|
||||
public void replicaOf(String host, int port) {
|
||||
|
||||
Assert.hasText(host, "Host must not be null for 'SLAVEOF' command.");
|
||||
Assert.hasText(host, "Host must not be null for 'REPLICAOF' command.");
|
||||
|
||||
connection.invoke().just(RedisServerAsyncCommands::slaveof, host, port);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void slaveOfNoOne() {
|
||||
public void replicaOfNoOne() {
|
||||
connection.invoke().just(RedisServerAsyncCommands::slaveofNoOne);
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ public interface ClusterOperations<K, V> {
|
||||
* @param node must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
Collection<RedisClusterNode> getSlaves(RedisClusterNode node);
|
||||
Collection<RedisClusterNode> getReplicas(RedisClusterNode node);
|
||||
|
||||
/**
|
||||
* Synchronous save current db snapshot on server.
|
||||
|
||||
@@ -163,11 +163,11 @@ class DefaultClusterOperations<K, V> extends AbstractOperations<K, V> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<RedisClusterNode> getSlaves(RedisClusterNode node) {
|
||||
public Collection<RedisClusterNode> getReplicas(final RedisClusterNode node) {
|
||||
|
||||
Assert.notNull(node, "ClusterNode must not be null.");
|
||||
|
||||
return doInCluster(connection -> connection.clusterGetSlaves(node));
|
||||
return doInCluster(connection -> connection.clusterGetReplicas(node));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -145,6 +145,7 @@ public enum RedisCommand {
|
||||
RANAME("w", 2, 2), //
|
||||
RENAME("w", 2, 2), //
|
||||
RENAMENX("w", 2, 2), //
|
||||
REPLICAOF("w", 2), //
|
||||
RESTORE("w", 3, 3), //
|
||||
RPOP("rw", 1, 1), //
|
||||
RPOPLPUSH("rw", 2, 2), //
|
||||
|
||||
@@ -576,17 +576,17 @@ public interface RedisOperations<K, V> {
|
||||
* @param host must not be {@literal null}.
|
||||
* @param port
|
||||
* @since 1.3
|
||||
* @see <a href="https://redis.io/commands/slaveof">Redis Documentation: SLAVEOF</a>
|
||||
* @see <a href="https://redis.io/commands/replicaof">Redis Documentation: REPLICAOF</a>
|
||||
*/
|
||||
void slaveOf(String host, int port);
|
||||
void replicaOf(String host, int port);
|
||||
|
||||
/**
|
||||
* Change server into master.
|
||||
*
|
||||
* @since 1.3
|
||||
* @see <a href="https://redis.io/commands/slaveof">Redis Documentation: SLAVEOF</a>
|
||||
* @see <a href="https://redis.io/commands/replicaof">Redis Documentation: REPLICAOF</a>
|
||||
*/
|
||||
void slaveOfNoOne();
|
||||
void replicaOfNoOne();
|
||||
|
||||
/**
|
||||
* Publishes the given message to the given channel.
|
||||
|
||||
@@ -1023,23 +1023,23 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.springframework.data.redis.core.RedisOperations#slaveOf(java.lang.String, int)
|
||||
* @see org.springframework.data.redis.core.RedisOperations#replicaOf(java.lang.String, int)
|
||||
*/
|
||||
@Override
|
||||
public void slaveOf(final String host, final int port) {
|
||||
public void replicaOf(final String host, final int port) {
|
||||
|
||||
execute((RedisCallback<Void>) connection -> {
|
||||
|
||||
connection.slaveOf(host, port);
|
||||
connection.replicaOf(host, port);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void slaveOfNoOne() {
|
||||
public void replicaOfNoOne() {
|
||||
|
||||
execute((RedisCallback<Void>) connection -> {
|
||||
connection.slaveOfNoOne();
|
||||
connection.replicaOfNoOne();
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -62,10 +62,10 @@ public interface ClusterConnectionTests {
|
||||
void clientListShouldGetInfosForAllClients();
|
||||
|
||||
// DATAREDIS-315
|
||||
void clusterGetMasterSlaveMapShouldListMastersAndSlavesCorrectly();
|
||||
void clusterGetMasterReplicaMapShouldListMastersAndReplicasCorrectly();
|
||||
|
||||
// DATAREDIS-315
|
||||
void clusterGetSlavesShouldReturnSlaveCorrectly();
|
||||
void clusterGetReplicasShouldReturnReplicaCorrectly();
|
||||
|
||||
// DATAREDIS-315
|
||||
void countKeysShouldReturnNumberOfKeysInSlot();
|
||||
|
||||
@@ -38,12 +38,12 @@ public abstract class ClusterTestVariables {
|
||||
public static final int MASTER_NODE_1_PORT = 7379;
|
||||
public static final int MASTER_NODE_2_PORT = 7380;
|
||||
public static final int MASTER_NODE_3_PORT = 7381;
|
||||
public static final int SLAVEOF_NODE_1_PORT = 7382;
|
||||
public static final int REPLICAOF_NODE_1_PORT = 7382;
|
||||
|
||||
public static final String MASTER_NODE_1_ID = "ef570f86c7b1a953846668debc177a3a16733420";
|
||||
public static final String MASTER_NODE_2_ID = "0f2ee5df45d18c50aca07228cc18b1da96fd5e84";
|
||||
public static final String MASTER_NODE_3_ID = "3b9b8192a874fa8f1f09dbc0ee20afab5738eee7";
|
||||
public static final String SLAVEOF_NODE_1_ID = "b8b5ee73b1d1997abff694b3fe8b2397d2138b6d";
|
||||
public static final String REPLICAOF_NODE_1_ID = "b8b5ee73b1d1997abff694b3fe8b2397d2138b6d";
|
||||
|
||||
public static final RedisClusterNode CLUSTER_NODE_1 = RedisClusterNode.newRedisClusterNode()
|
||||
.listeningAt(CLUSTER_HOST, MASTER_NODE_1_PORT).withId(MASTER_NODE_1_ID).promotedAs(NodeType.MASTER).build();
|
||||
@@ -51,8 +51,9 @@ public abstract class ClusterTestVariables {
|
||||
.listeningAt(CLUSTER_HOST, MASTER_NODE_2_PORT).withId(MASTER_NODE_2_ID).promotedAs(NodeType.MASTER).build();
|
||||
public static final RedisClusterNode CLUSTER_NODE_3 = RedisClusterNode.newRedisClusterNode()
|
||||
.listeningAt(CLUSTER_HOST, MASTER_NODE_3_PORT).withId(MASTER_NODE_3_ID).promotedAs(NodeType.MASTER).build();
|
||||
public static final RedisClusterNode SLAVE_OF_NODE_1 = RedisClusterNode.newRedisClusterNode()
|
||||
.listeningAt(CLUSTER_HOST, SLAVEOF_NODE_1_PORT).withId(SLAVEOF_NODE_1_ID).promotedAs(NodeType.SLAVE).build();
|
||||
public static final RedisClusterNode REPLICA_OF_NODE_1 = RedisClusterNode.newRedisClusterNode()
|
||||
.listeningAt(CLUSTER_HOST, REPLICAOF_NODE_1_PORT).withId(REPLICAOF_NODE_1_ID).promotedAs(NodeType.REPLICA)
|
||||
.build();
|
||||
|
||||
public static final RedisClusterNode UNKNOWN_CLUSTER_NODE = new RedisClusterNode("8.8.8.8", 6379);
|
||||
|
||||
|
||||
@@ -778,8 +778,8 @@ class RedisConnectionUnitTests {
|
||||
return delegate.getBit(key, offset);
|
||||
}
|
||||
|
||||
public void slaveOf(String host, int port) {
|
||||
delegate.slaveOf(host, port);
|
||||
public void replicaOf(String host, int port) {
|
||||
delegate.replicaOf(host, port);
|
||||
}
|
||||
|
||||
public byte[] rPopLPush(byte[] srcKey, byte[] dstKey) {
|
||||
@@ -798,8 +798,8 @@ class RedisConnectionUnitTests {
|
||||
return delegate.setBit(key, offset, value);
|
||||
}
|
||||
|
||||
public void slaveOfNoOne() {
|
||||
delegate.slaveOfNoOne();
|
||||
public void replicaOfNoOne() {
|
||||
delegate.replicaOfNoOne();
|
||||
}
|
||||
|
||||
public void restore(byte[] key, long ttlInMillis, byte[] serializedValue, boolean replace) {
|
||||
|
||||
@@ -103,10 +103,10 @@ class ConvertersUnitTests {
|
||||
assertThat(node.getId()).isEqualTo("8cad73f63eb996fedba89f041636f17d88cda075");
|
||||
assertThat(node.getHost()).isEqualTo("127.0.0.1");
|
||||
assertThat(node.getPort()).isEqualTo(7369);
|
||||
assertThat(node.getType()).isEqualTo(NodeType.SLAVE);
|
||||
assertThat(node.getType()).isEqualTo(NodeType.REPLICA);
|
||||
assertThat(node.getMasterId()).isEqualTo("ef570f86c7b1a953846668debc177a3a16733420");
|
||||
assertThat(node.getSlotRange()).isNotNull();
|
||||
assertThat(node.getFlags()).contains(Flag.SLAVE);
|
||||
assertThat(node.getFlags()).contains(Flag.REPLICA);
|
||||
assertThat(node.getLinkState()).isEqualTo(LinkState.CONNECTED);
|
||||
}
|
||||
|
||||
@@ -153,10 +153,10 @@ class ConvertersUnitTests {
|
||||
assertThat(node.getId()).isEqualTo("8cad73f63eb996fedba89f041636f17d88cda075");
|
||||
assertThat(node.getHost()).isEqualTo("127.0.0.1");
|
||||
assertThat(node.getPort()).isEqualTo(7369);
|
||||
assertThat(node.getType()).isEqualTo(NodeType.SLAVE);
|
||||
assertThat(node.getType()).isEqualTo(NodeType.REPLICA);
|
||||
assertThat(node.getMasterId()).isEqualTo("ef570f86c7b1a953846668debc177a3a16733420");
|
||||
assertThat(node.getSlotRange()).isNotNull();
|
||||
assertThat(node.getFlags()).contains(Flag.SLAVE);
|
||||
assertThat(node.getFlags()).contains(Flag.REPLICA);
|
||||
assertThat(node.getLinkState()).isEqualTo(LinkState.CONNECTED);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,6 @@ import org.springframework.data.redis.connection.RedisStringCommands.BitOperatio
|
||||
import org.springframework.data.redis.connection.RedisStringCommands.SetOption;
|
||||
import org.springframework.data.redis.connection.ReturnType;
|
||||
import org.springframework.data.redis.connection.ValueEncoding.RedisValueEncoding;
|
||||
import org.springframework.data.redis.connection.RedisListCommands.*;
|
||||
import org.springframework.data.redis.core.Cursor;
|
||||
import org.springframework.data.redis.core.ScanOptions;
|
||||
import org.springframework.data.redis.core.script.DigestUtils;
|
||||
@@ -124,7 +123,7 @@ public class JedisClusterConnectionTests implements ClusterConnectionTests {
|
||||
try (Jedis jedis = pool.getResource()) {
|
||||
jedis.flushAll();
|
||||
} catch (Exception e) {
|
||||
// ignore this one since we cannot remove data from slaves
|
||||
// ignore this one since we cannot remove data from replicas
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -236,26 +235,27 @@ public class JedisClusterConnectionTests implements ClusterConnectionTests {
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-315
|
||||
public void clusterGetMasterSlaveMapShouldListMastersAndSlavesCorrectly() {
|
||||
public void clusterGetMasterReplicaMapShouldListMastersAndReplicasCorrectly() {
|
||||
|
||||
Map<RedisClusterNode, Collection<RedisClusterNode>> masterSlaveMap = clusterConnection.clusterGetMasterSlaveMap();
|
||||
Map<RedisClusterNode, Collection<RedisClusterNode>> masterReplicaMap = clusterConnection
|
||||
.clusterGetMasterReplicaMap();
|
||||
|
||||
assertThat(masterSlaveMap).isNotNull();
|
||||
assertThat(masterSlaveMap.size()).isEqualTo(3);
|
||||
assertThat(masterSlaveMap.get(new RedisClusterNode(CLUSTER_HOST, MASTER_NODE_1_PORT)))
|
||||
.contains(new RedisClusterNode(CLUSTER_HOST, SLAVEOF_NODE_1_PORT));
|
||||
assertThat(masterSlaveMap.get(new RedisClusterNode(CLUSTER_HOST, MASTER_NODE_2_PORT)).isEmpty()).isTrue();
|
||||
assertThat(masterSlaveMap.get(new RedisClusterNode(CLUSTER_HOST, MASTER_NODE_3_PORT)).isEmpty()).isTrue();
|
||||
assertThat(masterReplicaMap).isNotNull();
|
||||
assertThat(masterReplicaMap.size()).isEqualTo(3);
|
||||
assertThat(masterReplicaMap.get(new RedisClusterNode(CLUSTER_HOST, MASTER_NODE_1_PORT)))
|
||||
.contains(new RedisClusterNode(CLUSTER_HOST, REPLICAOF_NODE_1_PORT));
|
||||
assertThat(masterReplicaMap.get(new RedisClusterNode(CLUSTER_HOST, MASTER_NODE_2_PORT)).isEmpty()).isTrue();
|
||||
assertThat(masterReplicaMap.get(new RedisClusterNode(CLUSTER_HOST, MASTER_NODE_3_PORT)).isEmpty()).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-315
|
||||
public void clusterGetSlavesShouldReturnSlaveCorrectly() {
|
||||
public void clusterGetReplicasShouldReturnReplicaCorrectly() {
|
||||
|
||||
Set<RedisClusterNode> slaves = clusterConnection
|
||||
.clusterGetSlaves(new RedisClusterNode(CLUSTER_HOST, MASTER_NODE_1_PORT));
|
||||
Set<RedisClusterNode> replicas = clusterConnection
|
||||
.clusterGetReplicas(new RedisClusterNode(CLUSTER_HOST, MASTER_NODE_1_PORT));
|
||||
|
||||
assertThat(slaves.size()).isEqualTo(1);
|
||||
assertThat(slaves).contains(new RedisClusterNode(CLUSTER_HOST, SLAVEOF_NODE_1_PORT));
|
||||
assertThat(replicas.size()).isEqualTo(1);
|
||||
assertThat(replicas).contains(new RedisClusterNode(CLUSTER_HOST, REPLICAOF_NODE_1_PORT));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-315
|
||||
@@ -790,7 +790,7 @@ public class JedisClusterConnectionTests implements ClusterConnectionTests {
|
||||
@Test // DATAREDIS-315, DATAREDIS-661
|
||||
public void getConfigShouldLoadConfigurationOfSpecificNode() {
|
||||
|
||||
Properties result = clusterConnection.getConfig(new RedisClusterNode(CLUSTER_HOST, SLAVEOF_NODE_1_PORT), "*");
|
||||
Properties result = clusterConnection.getConfig(new RedisClusterNode(CLUSTER_HOST, REPLICAOF_NODE_1_PORT), "*");
|
||||
|
||||
assertThat(result.getProperty("slaveof")).endsWith("7379");
|
||||
}
|
||||
|
||||
@@ -257,10 +257,10 @@ class JedisClusterConnectionUnitTests {
|
||||
void shouldFailWithUnknownNode() {
|
||||
|
||||
try {
|
||||
connection.serverCommands().dbSize(new RedisClusterNode(CLUSTER_HOST, SLAVEOF_NODE_1_PORT));
|
||||
connection.serverCommands().dbSize(new RedisClusterNode(CLUSTER_HOST, REPLICAOF_NODE_1_PORT));
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage())
|
||||
.contains("Node " + CLUSTER_HOST + ":" + SLAVEOF_NODE_1_PORT + " is unknown to cluster");
|
||||
.contains("Node " + CLUSTER_HOST + ":" + REPLICAOF_NODE_1_PORT + " is unknown to cluster");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,21 +103,21 @@ class JedisConnectionUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-277
|
||||
void slaveOfShouldThrowExectpionWhenCalledForNullHost() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> connection.slaveOf(null, 0));
|
||||
void replicaOfShouldThrowExectpionWhenCalledForNullHost() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> connection.replicaOf(null, 0));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-277
|
||||
public void slaveOfShouldBeSentCorrectly() {
|
||||
public void replicaOfShouldBeSentCorrectly() {
|
||||
|
||||
connection.slaveOf("127.0.0.1", 1001);
|
||||
connection.replicaOf("127.0.0.1", 1001);
|
||||
verifyNativeConnectionInvocation().slaveof(eq("127.0.0.1"), eq(1001));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-277
|
||||
public void slaveOfNoOneShouldBeSentCorrectly() {
|
||||
public void replicaOfNoOneShouldBeSentCorrectly() {
|
||||
|
||||
connection.slaveOfNoOne();
|
||||
connection.replicaOfNoOne();
|
||||
verifyNativeConnectionInvocation().slaveofNoOne();
|
||||
}
|
||||
|
||||
@@ -296,15 +296,15 @@ class JedisConnectionUnitTests {
|
||||
@Test
|
||||
@Override
|
||||
// DATAREDIS-277
|
||||
public void slaveOfShouldBeSentCorrectly() {
|
||||
public void replicaOfShouldBeSentCorrectly() {
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class)
|
||||
.isThrownBy(() -> super.slaveOfShouldBeSentCorrectly());
|
||||
.isThrownBy(() -> super.replicaOfShouldBeSentCorrectly());
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-277
|
||||
public void slaveOfNoOneShouldBeSentCorrectly() {
|
||||
public void replicaOfNoOneShouldBeSentCorrectly() {
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class)
|
||||
.isThrownBy(() -> super.slaveOfNoOneShouldBeSentCorrectly());
|
||||
.isThrownBy(() -> super.replicaOfNoOneShouldBeSentCorrectly());
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-531
|
||||
|
||||
@@ -87,32 +87,32 @@ class JedisSentinelConnectionUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-330
|
||||
void shouldReadSlavesCorrectly() {
|
||||
void shouldReadReplicasCorrectly() {
|
||||
|
||||
connection.slaves("mymaster");
|
||||
verify(jedisMock, times(1)).sentinelSlaves(eq("mymaster"));
|
||||
connection.replicas("mymaster");
|
||||
verify(jedisMock, times(1)).sentinelReplicas(eq("mymaster"));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-330
|
||||
void shouldReadSlavesCorrectlyWhenGivenNamedNode() {
|
||||
void shouldReadReplicasCorrectlyWhenGivenNamedNode() {
|
||||
|
||||
connection.slaves(new RedisNodeBuilder().withName("mymaster").build());
|
||||
verify(jedisMock, times(1)).sentinelSlaves(eq("mymaster"));
|
||||
connection.replicas(new RedisNodeBuilder().withName("mymaster").build());
|
||||
verify(jedisMock, times(1)).sentinelReplicas(eq("mymaster"));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-330
|
||||
void readSlavesShouldThrowExceptionWhenGivenEmptyMasterName() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> connection.slaves(""));
|
||||
void readReplicasShouldThrowExceptionWhenGivenEmptyMasterName() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> connection.replicas(""));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-330
|
||||
void readSlavesShouldThrowExceptionWhenGivenNull() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> connection.slaves((RedisNode) null));
|
||||
void readReplicasShouldThrowExceptionWhenGivenNull() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> connection.replicas((RedisNode) null));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-330
|
||||
void readSlavesShouldThrowExceptionWhenNodeWithoutName() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> connection.slaves(new RedisNodeBuilder().build()));
|
||||
void readReplicasShouldThrowExceptionWhenNodeWithoutName() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> connection.replicas(new RedisNodeBuilder().build()));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-330
|
||||
|
||||
@@ -46,8 +46,8 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
@EnabledOnRedisSentinelAvailable
|
||||
public class JedisSentinelIntegrationTests extends AbstractConnectionIntegrationTests {
|
||||
|
||||
private static final RedisServer SLAVE_0 = new RedisServer("127.0.0.1", 6380);
|
||||
private static final RedisServer SLAVE_1 = new RedisServer("127.0.0.1", 6381);
|
||||
private static final RedisServer REPLICA_0 = new RedisServer("127.0.0.1", 6380);
|
||||
private static final RedisServer REPLICA_1 = new RedisServer("127.0.0.1", 6381);
|
||||
|
||||
public JedisSentinelIntegrationTests(@RedisSentinel JedisConnectionFactory connectionFactory) {
|
||||
this.connectionFactory = connectionFactory;
|
||||
@@ -70,15 +70,15 @@ public class JedisSentinelIntegrationTests extends AbstractConnectionIntegration
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-330
|
||||
void shouldReadSlavesOfMastersCorrectly() {
|
||||
void shouldReadReplicaOfMastersCorrectly() {
|
||||
|
||||
RedisSentinelConnection sentinelConnection = connectionFactory.getSentinelConnection();
|
||||
|
||||
List<RedisServer> servers = (List<RedisServer>) sentinelConnection.masters();
|
||||
assertThat(servers).hasSize(1);
|
||||
|
||||
Collection<RedisServer> slaves = sentinelConnection.slaves(servers.get(0));
|
||||
assertThat(slaves).hasSize(2).contains(SLAVE_0, SLAVE_1);
|
||||
Collection<RedisServer> replicas = sentinelConnection.replicas(servers.get(0));
|
||||
assertThat(replicas).hasSize(2).contains(REPLICA_0, REPLICA_1);
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-552
|
||||
|
||||
@@ -287,26 +287,27 @@ public class LettuceClusterConnectionTests implements ClusterConnectionTests {
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-315
|
||||
public void clusterGetMasterSlaveMapShouldListMastersAndSlavesCorrectly() {
|
||||
public void clusterGetMasterReplicaMapShouldListMastersAndReplicasCorrectly() {
|
||||
|
||||
Map<RedisClusterNode, Collection<RedisClusterNode>> masterSlaveMap = clusterConnection.clusterGetMasterSlaveMap();
|
||||
Map<RedisClusterNode, Collection<RedisClusterNode>> masterReplicaMap = clusterConnection
|
||||
.clusterGetMasterReplicaMap();
|
||||
|
||||
assertThat(masterSlaveMap).isNotNull();
|
||||
assertThat(masterSlaveMap).hasSize(3);
|
||||
assertThat(masterSlaveMap.get(new RedisClusterNode(CLUSTER_HOST, MASTER_NODE_1_PORT)))
|
||||
.contains(new RedisClusterNode(CLUSTER_HOST, SLAVEOF_NODE_1_PORT));
|
||||
assertThat(masterSlaveMap.get(new RedisClusterNode(CLUSTER_HOST, MASTER_NODE_2_PORT)).isEmpty()).isTrue();
|
||||
assertThat(masterSlaveMap.get(new RedisClusterNode(CLUSTER_HOST, MASTER_NODE_3_PORT)).isEmpty()).isTrue();
|
||||
assertThat(masterReplicaMap).isNotNull();
|
||||
assertThat(masterReplicaMap).hasSize(3);
|
||||
assertThat(masterReplicaMap.get(new RedisClusterNode(CLUSTER_HOST, MASTER_NODE_1_PORT)))
|
||||
.contains(new RedisClusterNode(CLUSTER_HOST, REPLICAOF_NODE_1_PORT));
|
||||
assertThat(masterReplicaMap.get(new RedisClusterNode(CLUSTER_HOST, MASTER_NODE_2_PORT)).isEmpty()).isTrue();
|
||||
assertThat(masterReplicaMap.get(new RedisClusterNode(CLUSTER_HOST, MASTER_NODE_3_PORT)).isEmpty()).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-315
|
||||
public void clusterGetSlavesShouldReturnSlaveCorrectly() {
|
||||
public void clusterGetReplicasShouldReturnReplicaCorrectly() {
|
||||
|
||||
Set<RedisClusterNode> slaves = clusterConnection
|
||||
.clusterGetSlaves(new RedisClusterNode(CLUSTER_HOST, MASTER_NODE_1_PORT));
|
||||
Set<RedisClusterNode> replicas = clusterConnection
|
||||
.clusterGetReplicas(new RedisClusterNode(CLUSTER_HOST, MASTER_NODE_1_PORT));
|
||||
|
||||
assertThat(slaves).hasSize(1);
|
||||
assertThat(slaves).contains(new RedisClusterNode(CLUSTER_HOST, SLAVEOF_NODE_1_PORT));
|
||||
assertThat(replicas).hasSize(1);
|
||||
assertThat(replicas).contains(new RedisClusterNode(CLUSTER_HOST, REPLICAOF_NODE_1_PORT));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-315
|
||||
@@ -821,7 +822,7 @@ public class LettuceClusterConnectionTests implements ClusterConnectionTests {
|
||||
@Test // DATAREDIS-315, DATAREDIS-661
|
||||
public void getConfigShouldLoadConfigurationOfSpecificNode() {
|
||||
|
||||
Properties result = clusterConnection.getConfig(new RedisClusterNode(CLUSTER_HOST, SLAVEOF_NODE_1_PORT), "*");
|
||||
Properties result = clusterConnection.getConfig(new RedisClusterNode(CLUSTER_HOST, REPLICAOF_NODE_1_PORT), "*");
|
||||
|
||||
assertThat(result.getProperty("slaveof")).endsWith("7379");
|
||||
}
|
||||
|
||||
@@ -426,7 +426,7 @@ class LettuceConnectionFactoryTests {
|
||||
assumeTrue(String.format("No replicas connected to %s:%s.", SettingsUtils.getHost(), SettingsUtils.getPort()),
|
||||
connection.info("replication").getProperty("connected_slaves", "0").compareTo("0") > 0);
|
||||
|
||||
LettuceClientConfiguration configuration = LettuceTestClientConfiguration.builder().readFrom(ReadFrom.SLAVE)
|
||||
LettuceClientConfiguration configuration = LettuceTestClientConfiguration.builder().readFrom(ReadFrom.REPLICA)
|
||||
.clientResources(LettuceTestClientResources.getSharedClientResources()).build();
|
||||
|
||||
RedisStaticMasterReplicaConfiguration elastiCache = new RedisStaticMasterReplicaConfiguration(
|
||||
|
||||
@@ -116,21 +116,21 @@ public class LettuceConnectionUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-277
|
||||
void slaveOfShouldThrowExectpionWhenCalledForNullHost() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> connection.slaveOf(null, 0));
|
||||
void replicaOfShouldThrowExectpionWhenCalledForNullHost() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> connection.replicaOf(null, 0));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-277
|
||||
public void slaveOfShouldBeSentCorrectly() {
|
||||
public void replicaOfShouldBeSentCorrectly() {
|
||||
|
||||
connection.slaveOf("127.0.0.1", 1001);
|
||||
connection.replicaOf("127.0.0.1", 1001);
|
||||
verify(syncCommandsMock, times(1)).slaveof(eq("127.0.0.1"), eq(1001));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-277
|
||||
public void slaveOfNoOneShouldBeSentCorrectly() {
|
||||
public void replicaOfNoOneShouldBeSentCorrectly() {
|
||||
|
||||
connection.slaveOfNoOne();
|
||||
connection.replicaOfNoOne();
|
||||
verify(syncCommandsMock, times(1)).slaveofNoOne();
|
||||
}
|
||||
|
||||
@@ -280,9 +280,9 @@ public class LettuceConnectionUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-528
|
||||
public void slaveOfShouldBeSentCorrectly() {
|
||||
public void replicaOfShouldBeSentCorrectly() {
|
||||
|
||||
connection.slaveOf("127.0.0.1", 1001);
|
||||
connection.replicaOf("127.0.0.1", 1001);
|
||||
verify(asyncCommandsMock, times(1)).slaveof(eq("127.0.0.1"), eq(1001));
|
||||
}
|
||||
|
||||
@@ -302,9 +302,9 @@ public class LettuceConnectionUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-528
|
||||
public void slaveOfNoOneShouldBeSentCorrectly() {
|
||||
public void replicaOfNoOneShouldBeSentCorrectly() {
|
||||
|
||||
connection.slaveOfNoOne();
|
||||
connection.replicaOfNoOne();
|
||||
verify(asyncCommandsMock, times(1)).slaveofNoOne();
|
||||
}
|
||||
|
||||
|
||||
@@ -60,11 +60,11 @@ class LettuceReactiveClusterCommandsIntegrationTests extends LettuceReactiveClus
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-1150
|
||||
void clusterGetSlavesShouldReturnNodes() {
|
||||
void clusterGetReplicasShouldReturnNodes() {
|
||||
|
||||
connection.clusterGetNodes().filter(RedisClusterNode::isMaster)
|
||||
.filter(node -> (node.getPort() == 7379 || node.getPort() == 7382))
|
||||
.flatMap(it -> connection.clusterGetSlaves(it)) //
|
||||
.flatMap(it -> connection.clusterGetReplicas(it)) //
|
||||
.collectList() //
|
||||
.as(StepVerifier::create) //
|
||||
.consumeNextWith(actual -> {
|
||||
@@ -74,9 +74,9 @@ class LettuceReactiveClusterCommandsIntegrationTests extends LettuceReactiveClus
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-1150
|
||||
void clusterGetMasterSlaveMapShouldReportTopology() {
|
||||
void clusterGetMasterReplicaMapShouldReportTopology() {
|
||||
|
||||
connection.clusterGetMasterSlaveMap() //
|
||||
connection.clusterGetMasterReplicaMap() //
|
||||
.as(StepVerifier::create) //
|
||||
.consumeNextWith(actual -> {
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ class LettuceSentinelConnectionUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-348
|
||||
void shouldReadSlavesCorrectly() {
|
||||
void shouldReadReplicasCorrectly() {
|
||||
|
||||
when(sentinelCommandsMock.slaves(MASTER_ID)).thenReturn(Collections.<Map<String, String>> emptyList());
|
||||
connection.slaves(MASTER_ID);
|
||||
@@ -105,26 +105,26 @@ class LettuceSentinelConnectionUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-348
|
||||
void shouldReadSlavesCorrectlyWhenGivenNamedNode() {
|
||||
void shouldReadReplicasCorrectlyWhenGivenNamedNode() {
|
||||
|
||||
when(sentinelCommandsMock.slaves(MASTER_ID)).thenReturn(Collections.<Map<String, String>> emptyList());
|
||||
connection.slaves(new RedisNodeBuilder().withName(MASTER_ID).build());
|
||||
connection.replicas(new RedisNodeBuilder().withName(MASTER_ID).build());
|
||||
verify(sentinelCommandsMock, times(1)).slaves(eq(MASTER_ID));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-348
|
||||
void readSlavesShouldThrowExceptionWhenGivenEmptyMasterName() {
|
||||
void readReplicasShouldThrowExceptionWhenGivenEmptyMasterName() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> connection.slaves(""));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-348
|
||||
void readSlavesShouldThrowExceptionWhenGivenNull() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> connection.slaves((RedisNode) null));
|
||||
void readReplicasShouldThrowExceptionWhenGivenNull() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> connection.replicas((RedisNode) null));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-348
|
||||
void readSlavesShouldThrowExceptionWhenNodeWithoutName() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> connection.slaves(new RedisNodeBuilder().build()));
|
||||
void readReplicasShouldThrowExceptionWhenNodeWithoutName() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> connection.replicas(new RedisNodeBuilder().build()));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-348
|
||||
|
||||
@@ -56,8 +56,8 @@ public class LettuceSentinelIntegrationTests extends AbstractConnectionIntegrati
|
||||
private static final RedisServer SENTINEL_0 = new RedisServer("127.0.0.1", 26379);
|
||||
private static final RedisServer SENTINEL_1 = new RedisServer("127.0.0.1", 26380);
|
||||
|
||||
private static final RedisServer SLAVE_0 = new RedisServer("127.0.0.1", 6380);
|
||||
private static final RedisServer SLAVE_1 = new RedisServer("127.0.0.1", 6381);
|
||||
private static final RedisServer REPLICA_0 = new RedisServer("127.0.0.1", 6380);
|
||||
private static final RedisServer REPLICA_1 = new RedisServer("127.0.0.1", 6381);
|
||||
|
||||
private static final RedisSentinelConfiguration SENTINEL_CONFIG;
|
||||
static {
|
||||
@@ -159,15 +159,15 @@ public class LettuceSentinelIntegrationTests extends AbstractConnectionIntegrati
|
||||
|
||||
@Test
|
||||
// DATAREDIS-348
|
||||
void shouldReadSlavesOfMastersCorrectly() {
|
||||
void shouldReadReplicasOfMastersCorrectly() {
|
||||
|
||||
RedisSentinelConnection sentinelConnection = connectionFactory.getSentinelConnection();
|
||||
|
||||
List<RedisServer> servers = (List<RedisServer>) sentinelConnection.masters();
|
||||
assertThat(servers.size()).isEqualTo(1);
|
||||
|
||||
Collection<RedisServer> slaves = sentinelConnection.slaves(servers.get(0));
|
||||
assertThat(slaves).containsAnyOf(SLAVE_0, SLAVE_1);
|
||||
Collection<RedisServer> replicas = sentinelConnection.replicas(servers.get(0));
|
||||
assertThat(replicas).containsAnyOf(REPLICA_0, REPLICA_1);
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-462
|
||||
@@ -228,10 +228,10 @@ public class LettuceSentinelIntegrationTests extends AbstractConnectionIntegrati
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-580
|
||||
void factoryWithReadFromSlaveSettings() {
|
||||
void factoryWithReadFromReplicaSettings() {
|
||||
|
||||
LettuceConnectionFactory factory = new LettuceConnectionFactory(SENTINEL_CONFIG,
|
||||
LettuceTestClientConfiguration.builder().readFrom(ReadFrom.SLAVE).build());
|
||||
LettuceTestClientConfiguration.builder().readFrom(ReadFrom.REPLICA).build());
|
||||
factory.afterPropertiesSet();
|
||||
|
||||
ConnectionFactoryTracker.add(factory);
|
||||
@@ -247,7 +247,7 @@ public class LettuceSentinelIntegrationTests extends AbstractConnectionIntegrati
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-580
|
||||
void factoryUsesMasterSlaveConnections() {
|
||||
void factoryUsesMasterReplicaConnections() {
|
||||
|
||||
LettuceClientConfiguration configuration = LettuceTestClientConfiguration.builder().readFrom(ReadFrom.SLAVE)
|
||||
.build();
|
||||
|
||||
@@ -232,16 +232,16 @@ class DefaultClusterOperationsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-315
|
||||
void getSlavesShouldDelegateToConnection() {
|
||||
void getReplicasShouldDelegateToConnection() {
|
||||
|
||||
clusterOps.getSlaves(NODE_1);
|
||||
clusterOps.getReplicas(NODE_1);
|
||||
|
||||
verify(connection, times(1)).clusterGetSlaves(eq(NODE_1));
|
||||
verify(connection, times(1)).clusterGetReplicas(eq(NODE_1));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-315
|
||||
void getSlavesShouldThrowExceptionWhenNodeIsNull() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> clusterOps.getSlaves(null));
|
||||
void getReplicasShouldThrowExceptionWhenNodeIsNull() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> clusterOps.getReplicas(null));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-315
|
||||
|
||||
@@ -60,17 +60,17 @@ class RedisTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-277
|
||||
void slaveOfIsDelegatedToConnectionCorrectly() {
|
||||
void replicaOfIsDelegatedToConnectionCorrectly() {
|
||||
|
||||
template.slaveOf("127.0.0.1", 1001);
|
||||
verify(redisConnectionMock, times(1)).slaveOf(eq("127.0.0.1"), eq(1001));
|
||||
template.replicaOf("127.0.0.1", 1001);
|
||||
verify(redisConnectionMock, times(1)).replicaOf(eq("127.0.0.1"), eq(1001));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-277
|
||||
void slaveOfNoOneIsDelegatedToConnectionCorrectly() {
|
||||
void replicaOfNoOneIsDelegatedToConnectionCorrectly() {
|
||||
|
||||
template.slaveOfNoOne();
|
||||
verify(redisConnectionMock, times(1)).slaveOfNoOne();
|
||||
template.replicaOfNoOne();
|
||||
verify(redisConnectionMock, times(1)).replicaOfNoOne();
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-501
|
||||
|
||||
Reference in New Issue
Block a user