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
@@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user