public class DistributedEntryRetriever<K,V> extends LocalEntryRetriever<K,V>
The way this works is when a new entry retriever is acquired it first calculates the remote node that has the most segments and sends a request to it (this is done asynchronously). Also another thread is spawned off that processes the local data asynchronously. When either is done (remote sends response) then it will process the entries found and complete all segments that were marked as completed. If it is a remote invocation then it will send a new remote request to the node that now has the most remaining segments. If it is local it will complete those segments and stop running, unless a rehash has caused it to regain new local segments. If a rehash occurs during a remote node processing then those segments will automatically marked as suspect to not complete them.
Values retrieved for suspect segments are sent to the iterator and it is noted that they were raised. When these segments are requested again the noted keys are sent along to reduce value payload size.
| Modifier and Type | Class and Description |
|---|---|
protected class |
DistributedEntryRetriever.DistributedItr<C> |
LocalEntryRetriever.BatchHandler<K,C>, LocalEntryRetriever.DataContainerIterator<C>, LocalEntryRetriever.Itr<C>, LocalEntryRetriever.ItrQueuerHandler<C>, LocalEntryRetriever.KeyValueActionForCacheLoaderTask, LocalEntryRetriever.PartitionListener, LocalEntryRetriever.PassivationListener<K,V>EntryRetriever.SegmentListenerbatchSize, cache, componentRegistry, dataContainer, entryFactory, executorService, keyEquivalence, log, partitionListener, timeout, timeService, unit, withinThreadExecutor| Constructor and Description |
|---|
DistributedEntryRetriever(int batchSize,
long timeout,
TimeUnit unit) |
| Modifier and Type | Method and Description |
|---|---|
void |
dataRehashed(DataRehashedEvent<K,V> event)
We need to listen to data rehash events in case if data moves while we are iterating over it.
|
void |
initialize(DistributionManager distributionManager,
PersistenceManager persistenceManager,
CommandsFactory commandsFactory,
RpcManager rpcManager,
ExecutorService remoteExecutorService) |
<C> void |
receiveResponse(UUID identifier,
Address origin,
Set<Integer> completedSegments,
Set<Integer> inDoubtSegments,
Collection<CacheEntry<K,C>> entries,
CacheException e)
This method is invoked on the local node who started the iteration process for each batch of values.
|
<C> CloseableIterator<CacheEntry<K,C>> |
retrieveEntries(KeyValueFilter<? super K,? super V> filter,
Converter<? super K,? super V,? extends C> converter,
Set<Flag> flags,
EntryRetriever.SegmentListener listener)
This is invoked locally on the node that requested the iteration process.
|
void |
start() |
<C> void |
startRetrievingValues(UUID identifier,
Address origin,
Set<Integer> segments,
Set<K> keysToFilter,
KeyValueFilter<? super K,? super V> filter,
Converter<? super K,? super V,C> converter,
Set<Flag> flags)
This method is intended to be ran remotely on a node who has segments that the values have been requested.
|
void |
topologyChanged(TopologyChangedEvent<K,V> event)
We need to listen for topology change events.
|
inject, registerIterator, shouldUseLoader, unwrapMarshalledvalue, wireFilterAndConverterDependenciespublic DistributedEntryRetriever(int batchSize,
long timeout,
TimeUnit unit)
public void dataRehashed(DataRehashedEvent<K,V> event)
event - The data rehash eventpublic void topologyChanged(TopologyChangedEvent<K,V> event)
event - The topology change eventpublic void initialize(DistributionManager distributionManager, PersistenceManager persistenceManager, CommandsFactory commandsFactory, RpcManager rpcManager, ExecutorService remoteExecutorService)
public void start()
start in class LocalEntryRetriever<K,V>public <C> void startRetrievingValues(UUID identifier, Address origin, Set<Integer> segments, Set<K> keysToFilter, KeyValueFilter<? super K,? super V> filter, Converter<? super K,? super V,C> converter, Set<Flag> flags)
EntryRetrieverstartRetrievingValues in interface EntryRetriever<K,V>startRetrievingValues in class LocalEntryRetriever<K,V>C - The resulting type of the Converteridentifier - The unique identifier of the iteration requestorigin - The node that sent the iteration requestsegments - The segments this node wantskeysToFilter - The keys to filter out (can be null)filter - The filter to be applied to determine if a value should be usedconverter - The converter to run on the values retrieved before returningpublic <C> CloseableIterator<CacheEntry<K,C>> retrieveEntries(KeyValueFilter<? super K,? super V> filter, Converter<? super K,? super V,? extends C> converter, Set<Flag> flags, EntryRetriever.SegmentListener listener)
EntryRetrieverretrieveEntries in interface EntryRetriever<K,V>retrieveEntries in class LocalEntryRetriever<K,V>C - The type of the resulting values from the converterfilter - An optional filter that will be ran on each key/value to determine if it should be returned.converter - An optional converter that will be ran on each key/value that will be returned to transform
the value to a different value if desiredflags - An optional set of flags to modify behavior. For example Flag.CACHE_MODE_LOCAL will prevent
the retriever from retrieving remote values and Flag.SKIP_CACHE_LOAD will prevent the
retriever from getting values from the configured loader if present.listener - An optional segment listener that can be used to tell the invoker when segments and the iteration
process is completedpublic <C> void receiveResponse(UUID identifier, Address origin, Set<Integer> completedSegments, Set<Integer> inDoubtSegments, Collection<CacheEntry<K,C>> entries, CacheException e)
EntryRetrievercompletedSegments or inDoubtSegments is not empty (not both could be as well) then the
iteration process on this node is complete.receiveResponse in interface EntryRetriever<K,V>receiveResponse in class LocalEntryRetriever<K,V>C - The type of entries values sent backidentifier - The unique identifier of the iteration requestorigin - The node where the response came fromcompletedSegments - Which segments have been completedinDoubtSegments - Which segments are now in doubt due to a rehashentries - The entries retrievede - If an exception handled while processing the data on the remote nodeCopyright © 2024 JBoss, a division of Red Hat. All rights reserved.