Package org.infinispan.affinity
Class KeyAffinityServiceFactory
java.lang.Object
org.infinispan.affinity.KeyAffinityServiceFactory
Factory for
KeyAffinityService
.
Services build by this factory have the following characteristics:
- are run asynchronously by a thread that can be plugged through an
ExecutorFactory
- for key generation, the
ConsistentHash
function of a distributed cache is used. Service does not make sense for replicated caches. - for each address cluster member (identified by an
Address
member, a fixed number of keys is generated
- Since:
- 4.1
- Author:
- Mircea.Markus@jboss.com
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,
V> KeyAffinityService <K> newKeyAffinityService
(Cache<K, V> cache, Collection<Address> filter, KeyGenerator<K> keyGenerator, Executor ex, int keyBufferSize) static <K,
V> KeyAffinityService <K> newKeyAffinityService
(Cache<K, V> cache, Collection<Address> filter, KeyGenerator<K> keyGenerator, Executor ex, int keyBufferSize, boolean start) Creates a service that would only generate keys for addresses specified in filter.static <K,
V> KeyAffinityService <K> newKeyAffinityService
(Cache<K, V> cache, Executor ex, KeyGenerator<K> keyGenerator, int keyBufferSize) Same asnewKeyAffinityService(org.infinispan.Cache, java.util.concurrent.Executor, KeyGenerator, int, boolean)
with start == true;static <K,
V> KeyAffinityService <K> newKeyAffinityService
(Cache<K, V> cache, Executor ex, KeyGenerator<K> keyGenerator, int keyBufferSize, boolean start) Creates anKeyAffinityService
instance that generates keys mapped to all addresses in the cluster.static <K,
V> KeyAffinityService <K> newLocalKeyAffinityService
(Cache<K, V> cache, KeyGenerator<K> keyGenerator, Executor ex, int keyBufferSize) Same asnewLocalKeyAffinityService(org.infinispan.Cache, KeyGenerator, java.util.concurrent.Executor, int, boolean)
with start == true.static <K,
V> KeyAffinityService <K> newLocalKeyAffinityService
(Cache<K, V> cache, KeyGenerator<K> keyGenerator, Executor ex, int keyBufferSize, boolean start) Created an service that only generates keys for the local address.
-
Constructor Details
-
KeyAffinityServiceFactory
public KeyAffinityServiceFactory()
-
-
Method Details
-
newKeyAffinityService
public static <K,V> KeyAffinityService<K> newKeyAffinityService(Cache<K, V> cache, Executor ex, KeyGenerator<K> keyGenerator, int keyBufferSize, boolean start) Creates anKeyAffinityService
instance that generates keys mapped to all addresses in the cluster. Changes in topology would also noticed: by adding a new node, the service will automatically start generating keys for it.- Parameters:
cache
- the distributed cache for which this service runsex
- used for running async key generation process. On service shutdown, the executor won't be stopped; i.e. it's user responsibility manage it's lifecycle.keyGenerator
- allows one to control how the generated keys look like.keyBufferSize
- the number of generated keys perAddress
.start
- weather to start the service or not- Returns:
- an
KeyAffinityService
implementation. - Throws:
IllegalStateException
- if the supplied cache is not DIST.
-
newKeyAffinityService
public static <K,V> KeyAffinityService<K> newKeyAffinityService(Cache<K, V> cache, Executor ex, KeyGenerator<K> keyGenerator, int keyBufferSize) Same asnewKeyAffinityService(org.infinispan.Cache, java.util.concurrent.Executor, KeyGenerator, int, boolean)
with start == true; -
newKeyAffinityService
public static <K,V> KeyAffinityService<K> newKeyAffinityService(Cache<K, V> cache, Collection<Address> filter, KeyGenerator<K> keyGenerator, Executor ex, int keyBufferSize, boolean start) Creates a service that would only generate keys for addresses specified in filter.- Parameters:
filter
- the set of addresses for which to generate keys
-
newKeyAffinityService
public static <K,V> KeyAffinityService<K> newKeyAffinityService(Cache<K, V> cache, Collection<Address> filter, KeyGenerator<K> keyGenerator, Executor ex, int keyBufferSize) -
newLocalKeyAffinityService
public static <K,V> KeyAffinityService<K> newLocalKeyAffinityService(Cache<K, V> cache, KeyGenerator<K> keyGenerator, Executor ex, int keyBufferSize, boolean start) Created an service that only generates keys for the local address. -
newLocalKeyAffinityService
public static <K,V> KeyAffinityService<K> newLocalKeyAffinityService(Cache<K, V> cache, KeyGenerator<K> keyGenerator, Executor ex, int keyBufferSize) Same asnewLocalKeyAffinityService(org.infinispan.Cache, KeyGenerator, java.util.concurrent.Executor, int, boolean)
with start == true.
-