public class DefaultKeyAffinityService<K> extends Object implements org.infinispan.affinity.KeyAffinityService<K>, Supplier<BlockingQueue<K>>
org.infinispan.affinity.impl.KeyAffinityServiceImpl):
getKeyForAddress(Address) will return a random key (instead of throwing an ISE) if the specified address does not own any segments.getKeyForAddress(Address) calls will not block during topology change events.| Constructor and Description |
|---|
DefaultKeyAffinityService(org.infinispan.Cache<? extends K,?> cache,
org.infinispan.affinity.KeyGenerator<? extends K> generator,
Predicate<org.infinispan.remoting.transport.Address> filter)
Constructs a key affinity service that generates keys hashing to the members matching the specified filter.
|
| Modifier and Type | Method and Description |
|---|---|
BlockingQueue<K> |
get() |
K |
getCollocatedKey(K otherKey) |
K |
getKeyForAddress(org.infinispan.remoting.transport.Address address) |
boolean |
isStarted() |
void |
setPollTimeout(Duration timeout)
Overrides the duration of time for which calls to
getKeyForAddress(Address) will wait for an available pre-generated key,
after which a random key will be returned. |
void |
setQueueSize(int size)
Overrides the maximum number of keys with affinity to a given member to pre-generate.
|
void |
start() |
void |
stop() |
CompletionStage<Void> |
topologyChanged(org.infinispan.notifications.cachelistener.event.TopologyChangedEvent<?,?> event) |
public DefaultKeyAffinityService(org.infinispan.Cache<? extends K,?> cache, org.infinispan.affinity.KeyGenerator<? extends K> generator, Predicate<org.infinispan.remoting.transport.Address> filter)
cache - the target cachegenerator - a key generatorpublic void setQueueSize(int size)
size - a queue size thresholdpublic void setPollTimeout(Duration timeout)
getKeyForAddress(Address) will wait for an available pre-generated key,
after which a random key will be returned.timeout - a queue poll timeoutpublic BlockingQueue<K> get()
get in interface Supplier<BlockingQueue<K>>public boolean isStarted()
isStarted in interface org.infinispan.affinity.KeyAffinityService<K>public void start()
start in interface org.infinispan.commons.api.Lifecyclepublic void stop()
stop in interface org.infinispan.commons.api.Lifecyclepublic K getCollocatedKey(K otherKey)
getCollocatedKey in interface org.infinispan.affinity.KeyAffinityService<K>public K getKeyForAddress(org.infinispan.remoting.transport.Address address)
getKeyForAddress in interface org.infinispan.affinity.KeyAffinityService<K>public CompletionStage<Void> topologyChanged(org.infinispan.notifications.cachelistener.event.TopologyChangedEvent<?,?> event)
Copyright © 2021 JBoss by Red Hat. All rights reserved.