Package org.infinispan.affinity.impl
Class KeyAffinityServiceImpl<K>
- java.lang.Object
-
- org.infinispan.affinity.impl.KeyAffinityServiceImpl<K>
-
- All Implemented Interfaces:
KeyAffinityService<K>,org.infinispan.commons.api.Lifecycle
@ThreadSafe public class KeyAffinityServiceImpl<K> extends Object implements KeyAffinityService<K>
Implementation of KeyAffinityService.- Since:
- 4.1
- Author:
- Mircea.Markus@jboss.com
-
-
Field Summary
Fields Modifier and Type Field Description static floatTHRESHOLD
-
Constructor Summary
Constructors Constructor Description KeyAffinityServiceImpl(Executor executor, Cache<? extends K,?> cache, KeyGenerator<? extends K> keyGenerator, int bufferSize, Collection<Address> filter, boolean start)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<Address,BlockingQueue<K>>getAddress2KeysMapping()KgetCollocatedKey(K otherKey)Returns a key that will be distributed on the same node as the supplied key.KgetKeyForAddress(Address address)Returns a key that will be distributed on the cluster node identified by address.intgetMaxNumberOfKeys()voidhandleCacheStopped(CacheStoppedEvent cse)voidhandleViewChange(TopologyChangedEvent<?,?> vce)booleanisKeyGeneratorThreadActive()booleanisKeyGeneratorThreadAlive()booleanisStarted()Checks weather or not the service is started.voidstart()voidstop()
-
-
-
Field Detail
-
THRESHOLD
public static final float THRESHOLD
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
KeyAffinityServiceImpl
public KeyAffinityServiceImpl(Executor executor, Cache<? extends K,?> cache, KeyGenerator<? extends K> keyGenerator, int bufferSize, Collection<Address> filter, boolean start)
-
-
Method Detail
-
getCollocatedKey
public K getCollocatedKey(K otherKey)
Description copied from interface:KeyAffinityServiceReturns a key that will be distributed on the same node as the supplied key.- Specified by:
getCollocatedKeyin interfaceKeyAffinityService<K>- Parameters:
otherKey- the key for which we need a collocation- Returns:
- a key object
-
getKeyForAddress
public K getKeyForAddress(Address address)
Description copied from interface:KeyAffinityServiceReturns a key that will be distributed on the cluster node identified by address.- Specified by:
getKeyForAddressin interfaceKeyAffinityService<K>- Parameters:
address- identifying the cluster node.- Returns:
- a key object
-
start
public void start()
- Specified by:
startin interfaceorg.infinispan.commons.api.Lifecycle
-
stop
public void stop()
- Specified by:
stopin interfaceorg.infinispan.commons.api.Lifecycle
-
handleViewChange
public void handleViewChange(TopologyChangedEvent<?,?> vce)
-
isKeyGeneratorThreadAlive
public boolean isKeyGeneratorThreadAlive()
-
handleCacheStopped
public void handleCacheStopped(CacheStoppedEvent cse)
-
getAddress2KeysMapping
public Map<Address,BlockingQueue<K>> getAddress2KeysMapping()
-
getMaxNumberOfKeys
public int getMaxNumberOfKeys()
-
isKeyGeneratorThreadActive
public boolean isKeyGeneratorThreadActive()
-
isStarted
public boolean isStarted()
Description copied from interface:KeyAffinityServiceChecks weather or not the service is started.- Specified by:
isStartedin interfaceKeyAffinityService<K>
-
-