org.infinispan.distribution.ch
Class UnionConsistentHash

java.lang.Object
  extended by org.infinispan.distribution.ch.AbstractConsistentHash
      extended by 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

Nested Class Summary
static class UnionConsistentHash.Externalizer
           
 
Field Summary
 
Fields inherited from class org.infinispan.distribution.ch.AbstractConsistentHash
groupManager
 
Constructor Summary
UnionConsistentHash(ConsistentHash oldCH, ConsistentHash newCH)
           
 
Method Summary
 Set<Address> getCaches()
          Should return a collection of cache addresses in the cluster.
 List<Integer> getHashIds(Address a)
          Returns a list of values between 0 and the hash space limit, or hash id, for a particular address.
 ConsistentHash getNewConsistentHash()
           
 ConsistentHash getOldConsistentHash()
           
 List<Address> locate(Object key, int replCount)
          Locates a key, given a replication count (number of copies).
 void setCaches(Set<Address> caches)
          Sets the collection of cache addresses in the cluster.
 
Methods inherited from class org.infinispan.distribution.ch.AbstractConsistentHash
getBackupsForNode, getGrouping, getStateProvidersOnJoin, getStateProvidersOnLeave, isKeyLocalToAddress, locateAll, primaryLocation, setGroupManager, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UnionConsistentHash

public UnionConsistentHash(ConsistentHash oldCH,
                           ConsistentHash newCH)
Method Detail

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 locate
replCount - 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.