Package org.infinispan.distribution.impl
Class DistributionManagerImpl
- java.lang.Object
-
- org.infinispan.distribution.impl.DistributionManagerImpl
-
- All Implemented Interfaces:
DistributionManager
public class DistributionManagerImpl extends Object implements DistributionManager
The default distribution manager implementation- Since:
- 4.0
- Author:
- Manik Surtani, Vladimir Blagojevic, Mircea.Markus@jboss.com, Bela Ban, Dan Berindei
, anistor@redhat.com
-
-
Constructor Summary
Constructors Constructor Description DistributionManagerImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LocalizedCacheTopology
createLocalizedCacheTopology(CacheTopology cacheTopology)
LocalizedCacheTopology
getCacheTopology()
DataLocality
getLocality(Object key)
Returns the data locality characteristics of a given key.Address
getPrimaryLocation(Object key)
Returns the first Address containing the key.ConsistentHash
getReadConsistentHash()
ConsistentHash
getWriteConsistentHash()
boolean
isAffectedByRehash(Object key)
Tests whether a given key is affected by a rehash that may be in progress.boolean
isJoinComplete()
Tests whether the current instance has completed joining the clusterboolean
isLocatedLocally(String key)
boolean
isRehashInProgress()
Tests whether a rehash is in progressList<Address>
locate(Object key)
Locates a key in a cluster.Set<Address>
locateAll(Collection<Object> keys)
Locates a list of keys in a cluster.List<String>
locateKey(String key)
static LocalizedCacheTopology
makeSingletonTopology(CacheMode cacheMode, KeyPartitioner keyPartitioner, int numSegments, Address localAddress)
void
setCacheTopology(CacheTopology cacheTopology)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.infinispan.distribution.DistributionManager
getConsistentHash
-
-
-
-
Method Detail
-
getLocality
public DataLocality getLocality(Object key)
Description copied from interface:DistributionManager
Returns the data locality characteristics of a given key.- Specified by:
getLocality
in interfaceDistributionManager
- Parameters:
key
- key to test- Returns:
- a DataLocality that allows you to test whether a key is mapped to the local node or not, and the degree of certainty of such a result.
-
locate
public List<Address> locate(Object key)
Description copied from interface:DistributionManager
Locates a key in a cluster. The returned addresses may not be owners of the keys if a rehash happens to be in progress or is pending, so when querying these servers, invalid responses should be checked for and the next address checked accordingly.- Specified by:
locate
in interfaceDistributionManager
- Parameters:
key
- key to test- Returns:
- a list of addresses where the key may reside
-
getPrimaryLocation
public Address getPrimaryLocation(Object key)
Description copied from interface:DistributionManager
Returns the first Address containing the key. Equivalent to returning the first element ofDistributionManager.locate(Object)
- Specified by:
getPrimaryLocation
in interfaceDistributionManager
- Parameters:
key
- key to test- Returns:
- the first address on which the key may reside
-
locateAll
public Set<Address> locateAll(Collection<Object> keys)
Description copied from interface:DistributionManager
Locates a list of keys in a cluster. LikeDistributionManager.locate(Object)
the returned addresses may not be owners of the keys if a rehash happens to be in progress or is pending, so when querying these servers, invalid responses should be checked for and the next address checked accordingly.- Specified by:
locateAll
in interfaceDistributionManager
- Parameters:
keys
- list of keys to locate- Returns:
- all the nodes that would need to write a copy of one of the keys.
-
getReadConsistentHash
public ConsistentHash getReadConsistentHash()
- Specified by:
getReadConsistentHash
in interfaceDistributionManager
- Returns:
- the consistent hash used for reading.
-
getWriteConsistentHash
public ConsistentHash getWriteConsistentHash()
- Specified by:
getWriteConsistentHash
in interfaceDistributionManager
- Returns:
- the consistent hash used for writing.
-
isAffectedByRehash
public boolean isAffectedByRehash(Object key)
Description copied from interface:DistributionManager
Tests whether a given key is affected by a rehash that may be in progress. If no rehash is in progress, this method returns false. Helps determine whether additional steps are necessary in handling an operation with a given key.- Specified by:
isAffectedByRehash
in interfaceDistributionManager
- Parameters:
key
- key to test- Returns:
- whether a key is affected by a rehash
-
isRehashInProgress
public boolean isRehashInProgress()
Tests whether a rehash is in progress- Specified by:
isRehashInProgress
in interfaceDistributionManager
- Returns:
- true if a rehash is in progress, false otherwise
-
isJoinComplete
public boolean isJoinComplete()
Description copied from interface:DistributionManager
Tests whether the current instance has completed joining the cluster- Specified by:
isJoinComplete
in interfaceDistributionManager
- Returns:
- true if join is in progress, false otherwise
-
isLocatedLocally
public boolean isLocatedLocally(String key)
-
getCacheTopology
public LocalizedCacheTopology getCacheTopology()
- Specified by:
getCacheTopology
in interfaceDistributionManager
- Returns:
- the current cache topology, which includes the read and write consistent hashes.
-
setCacheTopology
public void setCacheTopology(CacheTopology cacheTopology)
- Specified by:
setCacheTopology
in interfaceDistributionManager
-
createLocalizedCacheTopology
public LocalizedCacheTopology createLocalizedCacheTopology(CacheTopology cacheTopology)
- Specified by:
createLocalizedCacheTopology
in interfaceDistributionManager
-
makeSingletonTopology
public static LocalizedCacheTopology makeSingletonTopology(CacheMode cacheMode, KeyPartitioner keyPartitioner, int numSegments, Address localAddress)
-
-