public class RedisClusterNode extends Object implements Serializable, RedisNodeDescription
RedisClusterNode is identified by its nodeId.
A RedisClusterNode can be a responsible master or slave. Masters can be responsible for zero to
16384 slots. Each slave 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() |
boolean |
equals(Object o) |
List<RedisURI> |
getAliases() |
long |
getConfigEpoch() |
Set<RedisClusterNode.NodeFlag> |
getFlags() |
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() |
RedisURI |
getUri() |
int |
hashCode() |
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 nodeIdnodeId - the nodeIdRedisClusterNodepublic RedisClusterNode clone()
public RedisURI getUri()
getUri in interface RedisNodeDescriptionpublic void setUri(RedisURI uri)
uri - the RedisURI, must not be nullpublic String getNodeId()
public void setNodeId(String nodeId)
nodeId.nodeId - the nodeIdpublic 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 flagpublic String getSlaveOf()
public void setSlaveOf(String slaveOf)
slaveOf - the replication source, can be nullpublic long getPingSentTimestamp()
public void setPingSentTimestamp(long pingSentTimestamp)
pingSentTimestamp.pingSentTimestamp - the last pingSentTimestamppublic long getPongReceivedTimestamp()
public void setPongReceivedTimestamp(long pongReceivedTimestamp)
pongReceivedTimestamp.pongReceivedTimestamp - the last pongReceivedTimestamppublic long getConfigEpoch()
public void setConfigEpoch(long configEpoch)
configEpoch.configEpoch - the configEpochpublic 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 emptypublic Set<RedisClusterNode.NodeFlag> getFlags()
public void setFlags(Set<RedisClusterNode.NodeFlag> flags)
node flags.flags - the set of node flags.public boolean is(RedisClusterNode.NodeFlag nodeFlag)
nodeFlag - the node flagpublic void addAlias(RedisURI alias)
RedisClusterNode.alias - must not be null.public boolean hasSlot(int slot)
slot - the slot hashpublic RedisInstance.Role getRole()
Role of the Redis Cluster node based on the flags.getRole in interface RedisInstanceCopyright © 2019 lettuce.io. All rights reserved.