org.infinispan.distribution.ch
Class UnionConsistentHash
java.lang.Object
org.infinispan.distribution.ch.AbstractConsistentHash
org.infinispan.distribution.ch.UnionConsistentHash
- All Implemented Interfaces:
- ConsistentHash
public class UnionConsistentHash
- extends AbstractConsistentHash
A delegating wrapper that locates keys by getting a union of locations reported by two other ConsistentHash
implementations it delegates to.
- Since:
- 4.0
- Author:
- Manik Surtani
UnionConsistentHash
public UnionConsistentHash(ConsistentHash oldCH,
ConsistentHash newCH)
setCaches
public void setCaches(Set<Address> caches)
- Description copied from interface:
ConsistentHash
- Sets the collection of cache addresses in the cluster. The implementation should store these internally and use
these to locate keys.
- Parameters:
caches
- A set of unique caches in cluster.
getCaches
public Set<Address> getCaches()
- Description copied from interface:
ConsistentHash
- Should return a collection of cache addresses in the cluster.
- Returns:
- set of unique of cache addresses
locate
public List<Address> locate(Object key,
int replCount)
- Description copied from interface:
ConsistentHash
- Locates a key, given a replication count (number of copies).
- Parameters:
key
- key to locatereplCount
- replication count (number of copies)
- Returns:
- a list of addresses where the key resides, where this list is a subset of the addresses set in
ConsistentHash.setCaches(java.util.Set)
. Should never be null, and should contain replCount elements or the max
number of caches available, whichever is smaller.
getHashIds
public List<Integer> getHashIds(Address a)
- Description copied from interface:
ConsistentHash
- Returns a list of values between 0 and the hash space limit, or hash id,
for a particular address. If virtual nodes are disabled, the list will
only contain a single element, whereas if virtual nodes are enabled, this
list's size will be the number of virtual nodes configured. If there are
no hash ids for that address, it returns an empty list.
- Returns:
- A list of N size where N is the configured number of virtual
nodes, or an empty list if there're no hash ids associated with
the address.
getNewConsistentHash
public ConsistentHash getNewConsistentHash()
getOldConsistentHash
public ConsistentHash getOldConsistentHash()
Copyright © 2012 JBoss, a division of Red Hat. All Rights Reserved.