public class Partitions extends Object implements Collection<RedisClusterNode>
Partitions
provides access to the partitions of a Redis Cluster. A partition is
represented by a Redis Cluster node that has a nodeId
and
connection point details
.
Partitions can be looked up by nodeId
or slot
(masters only). A nodeId can be migrated to a different host.
Partitions are cached to ensure a cheap lookup by slot
. Users of Partitions
are required to call
updateCache()
after topology changes occur.
RedisClusterNode.NodeFlag.MASTER
/
RedisClusterNode.NodeFlag.SLAVE
stateRedisClusterNode.getSlots()
responsibilityslave replication source
(the master of a slave)RedisClusterNode.getUri()
() connection point}Constructor and Description |
---|
Partitions() |
Modifier and Type | Method and Description |
---|---|
boolean |
add(RedisClusterNode redisClusterNode) |
boolean |
addAll(Collection<? extends RedisClusterNode> c) |
void |
addPartition(RedisClusterNode partition) |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
RedisClusterNode |
getPartition(int index) |
RedisClusterNode |
getPartitionByNodeId(String nodeId)
Retrieve a
RedisClusterNode by its node id. |
RedisClusterNode |
getPartitionBySlot(int slot)
Retrieve a
RedisClusterNode by its slot number. |
List<RedisClusterNode> |
getPartitions() |
boolean |
isEmpty() |
Iterator<RedisClusterNode> |
iterator() |
void |
reload(List<RedisClusterNode> partitions)
Update partitions and rebuild slot cache.
|
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
String |
toString() |
void |
updateCache()
Update the partition cache.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
equals, hashCode, parallelStream, removeIf, spliterator, stream
public RedisClusterNode getPartitionBySlot(int slot)
RedisClusterNode
by its slot number. This method does not distinguish between masters and slaves.slot
- the slotpublic RedisClusterNode getPartitionByNodeId(String nodeId)
RedisClusterNode
by its node id.nodeId
- the nodeIdpublic void updateCache()
public Iterator<RedisClusterNode> iterator()
iterator
in interface Iterable<RedisClusterNode>
iterator
in interface Collection<RedisClusterNode>
public List<RedisClusterNode> getPartitions()
public void addPartition(RedisClusterNode partition)
public int size()
size
in interface Collection<RedisClusterNode>
public RedisClusterNode getPartition(int index)
public void reload(List<RedisClusterNode> partitions)
partitions
- list of new partitionspublic boolean isEmpty()
isEmpty
in interface Collection<RedisClusterNode>
public boolean contains(Object o)
contains
in interface Collection<RedisClusterNode>
public boolean addAll(Collection<? extends RedisClusterNode> c)
addAll
in interface Collection<RedisClusterNode>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<RedisClusterNode>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<RedisClusterNode>
public void clear()
clear
in interface Collection<RedisClusterNode>
public Object[] toArray()
toArray
in interface Collection<RedisClusterNode>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<RedisClusterNode>
public boolean add(RedisClusterNode redisClusterNode)
add
in interface Collection<RedisClusterNode>
public boolean remove(Object o)
remove
in interface Collection<RedisClusterNode>
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<RedisClusterNode>
Copyright © 2016. All rights reserved.