public class RedisClusterNode extends Object implements Serializable, RedisNodeDescription
RedisClusterNode is identified by its nodeId.
A RedisClusterNode can be a responsible master or replica. Masters can be responsible for zero to
16384 slots. Each replica refers to exactly one master. Nodes can have different flags assigned.
This class is mutable and not thread-safe if mutated by multiple threads concurrently.
| Modifier and Type | Class and Description |
|---|---|
static class |
RedisClusterNode.NodeFlag
Redis Cluster node flags.
|
RedisInstance.Role| Constructor and Description |
|---|
RedisClusterNode() |
RedisClusterNode(RedisClusterNode redisClusterNode) |
RedisClusterNode(RedisURI uri,
String nodeId,
boolean connected,
String slaveOf,
long pingSentTimestamp,
long pongReceivedTimestamp,
long configEpoch,
List<Integer> slots,
Set<RedisClusterNode.NodeFlag> flags) |
| Modifier and Type | Method and Description |
|---|---|
void |
addAlias(RedisURI alias)
Add an alias to
RedisClusterNode. |
RedisClusterNode |
clone()
Clone
this RedisClusterNode. |
boolean |
equals(Object o) |
void |
forEachSlot(IntConsumer consumer)
Performs the given action for each slot of this
RedisClusterNode until all elements have been processed or the
action throws an exception. |
List<RedisURI> |
getAliases() |
long |
getConfigEpoch() |
Set<RedisClusterNode.NodeFlag> |
getFlags()
Return the
NodeFlags. |
String |
getNodeId() |
long |
getPingSentTimestamp() |
long |
getPongReceivedTimestamp() |
RedisInstance.Role |
getRole()
Returns the
Role of the Redis Cluster node based on the flags. |
String |
getSlaveOf() |
List<Integer> |
getSlots()
Return the slots as
List. |
RedisURI |
getUri() |
int |
hashCode() |
boolean |
hasSameSlotsAs(RedisClusterNode other)
|
boolean |
hasSlot(int slot) |
boolean |
is(RedisClusterNode.NodeFlag nodeFlag) |
boolean |
isConnected() |
static RedisClusterNode |
of(String nodeId)
Create a new instance of
RedisClusterNode by passing the nodeId. |
void |
setConfigEpoch(long configEpoch)
Sets the
configEpoch. |
void |
setConnected(boolean connected)
Sets the
connected flag. |
void |
setFlags(Set<RedisClusterNode.NodeFlag> flags)
Set of
node flags. |
void |
setNodeId(String nodeId)
Sets
nodeId. |
void |
setPingSentTimestamp(long pingSentTimestamp)
Sets the last
pingSentTimestamp. |
void |
setPongReceivedTimestamp(long pongReceivedTimestamp)
Sets the last
pongReceivedTimestamp. |
void |
setSlaveOf(String slaveOf)
Sets the replication source.
|
void |
setSlots(List<Integer> slots)
Sets the list of slots for which this
RedisClusterNode is the
RedisClusterNode.NodeFlag.MASTER. |
void |
setUri(RedisURI uri)
Sets the connection point details.
|
String |
toString() |
public RedisClusterNode()
public RedisClusterNode(RedisURI uri, String nodeId, boolean connected, String slaveOf, long pingSentTimestamp, long pongReceivedTimestamp, long configEpoch, List<Integer> slots, Set<RedisClusterNode.NodeFlag> flags)
public RedisClusterNode(RedisClusterNode redisClusterNode)
public static RedisClusterNode of(String nodeId)
RedisClusterNode by passing the nodeId.nodeId - the nodeId.RedisClusterNode.public RedisClusterNode clone()
this RedisClusterNode.clone in class Objectthis RedisClusterNode.public RedisURI getUri()
getUri in interface RedisNodeDescriptionpublic void setUri(RedisURI uri)
uri - the RedisURI, must not be null.public String getNodeId()
public void setNodeId(String nodeId)
nodeId.nodeId - the nodeId.public boolean isConnected()
public void setConnected(boolean connected)
connected flag. The connected flag describes whether the node which provided details about the
node is connected to the particular RedisClusterNode.connected - the connected flag.public String getSlaveOf()
public void setSlaveOf(String slaveOf)
slaveOf - the replication source, can be null.public long getPingSentTimestamp()
public void setPingSentTimestamp(long pingSentTimestamp)
pingSentTimestamp.pingSentTimestamp - the last pingSentTimestamp.public long getPongReceivedTimestamp()
public void setPongReceivedTimestamp(long pongReceivedTimestamp)
pongReceivedTimestamp.pongReceivedTimestamp - the last pongReceivedTimestamp.public long getConfigEpoch()
public void setConfigEpoch(long configEpoch)
configEpoch.configEpoch - the configEpoch.public void forEachSlot(IntConsumer consumer)
RedisClusterNode until all elements have been processed or the
action throws an exception. Unless otherwise specified by the implementing class, actions are performed in the order of
iteration (if an iteration order is specified). Exceptions thrown by the action are relayed to the caller.consumer - public void setSlots(List<Integer> slots)
RedisClusterNode is the
RedisClusterNode.NodeFlag.MASTER. The list is empty if this node is not
a master or the node is not responsible for any slots at all.slots - list of slots, must not be null but may be empty.public boolean hasSameSlotsAs(RedisClusterNode other)
other - the node to compare with.true if the other node contains the same slots as this node.public Set<RedisClusterNode.NodeFlag> getFlags()
NodeFlags.NodeFlags.public void setFlags(Set<RedisClusterNode.NodeFlag> flags)
node flags.flags - the set of node flags.public boolean is(RedisClusterNode.NodeFlag nodeFlag)
nodeFlag - the node flag.true if the RedisClusterNode.NodeFlag is contained within the flags.public void addAlias(RedisURI alias)
RedisClusterNode.alias - must not be null.public boolean hasSlot(int slot)
slot - the slot hash.true if the slot is contained within the handled slots.public RedisInstance.Role getRole()
Role of the Redis Cluster node based on the flags.getRole in interface RedisInstanceCopyright © 2020 lettuce.io. All rights reserved.