public class LocalPublisherManagerImpl<K,V> extends Object implements LocalPublisherManager<K,V>
segmentsLost(IntSet) method.| Modifier and Type | Field and Description |
|---|---|
protected AdvancedCache<K,V> |
cache |
protected Set<IntConsumer> |
changeListener |
protected int |
cpuCount |
protected CacheSet<CacheEntry<K,V>> |
entrySet |
protected CacheSet<CacheEntry<K,V>> |
entrySetWithoutLoader |
protected CacheSet<K> |
keySet |
protected CacheSet<K> |
keySetWithoutLoader |
protected int |
maxSegment |
protected io.reactivex.rxjava3.core.Scheduler |
nonBlockingScheduler |
protected AdvancedCache<K,V> |
remoteCache |
| Constructor and Description |
|---|
LocalPublisherManagerImpl() |
| Modifier and Type | Method and Description |
|---|---|
protected <R> io.reactivex.rxjava3.core.Flowable<R> |
combineStages(io.reactivex.rxjava3.core.Flowable<? extends CompletionStage<R>> stagePublisher,
boolean parallel) |
protected <R> CompletionStage<R> |
combineStages(io.reactivex.rxjava3.core.Flowable<? extends CompletionStage<R>> stagePublisher,
Function<? super org.reactivestreams.Publisher<R>,? extends CompletionStage<R>> finalizer,
boolean parallel) |
<R> SegmentAwarePublisher<R> |
entryPublisher(IntSet segments,
Set<K> keysToInclude,
Set<K> keysToExclude,
boolean includeLoader,
DeliveryGuarantee deliveryGuarantee,
Function<? super org.reactivestreams.Publisher<CacheEntry<K,V>>,? extends org.reactivestreams.Publisher<R>> transformer)
Performs the given transformer on data in the cache that is local, resulting in a stream of values of
possibly varying size.
|
<R> CompletionStage<PublisherResult<R>> |
entryReduction(boolean parallelPublisher,
IntSet segments,
Set<K> keysToInclude,
Set<K> keysToExclude,
boolean includeLoader,
DeliveryGuarantee deliveryGuarantee,
Function<? super org.reactivestreams.Publisher<CacheEntry<K,V>>,? extends CompletionStage<R>> collator,
Function<? super org.reactivestreams.Publisher<R>,? extends CompletionStage<R>> finalizer)
Performs the given transformer and finalizer on data in the cache that is local, resulting in a
single value.
|
protected <R> CompletionStage<PublisherResult<R>> |
exactlyOnceHandleLostSegments(CompletionStage<R> finalValue,
org.infinispan.reactive.publisher.impl.LocalPublisherManagerImpl.SegmentListener listener) |
protected <I,R> io.reactivex.rxjava3.core.Flowable<R> |
exactlyOnceParallel(CacheSet<I> set,
Set<K> keysToExclude,
Function<I,K> toKeyFunction,
IntSet segments,
Function<? super org.reactivestreams.Publisher<I>,? extends CompletionStage<R>> collator,
org.infinispan.reactive.publisher.impl.LocalPublisherManagerImpl.SegmentListener listener,
IntSet concurrentSegments)
This method iteratively submits a task to operate on the cpu bound thread pool up to the number of cores - 1.
|
protected <I,R> io.reactivex.rxjava3.core.Flowable<R> |
exactlyOnceSequential(CacheSet<I> set,
Set<K> keysToExclude,
Function<I,K> toKeyFunction,
IntSet segments,
Function<? super org.reactivestreams.Publisher<I>,? extends CompletionStage<R>> collator,
org.infinispan.reactive.publisher.impl.LocalPublisherManagerImpl.SegmentListener listener,
IntSet concurrentSegments) |
protected <R> CompletionStage<PublisherResult<R>> |
handleLostSegments(CompletionStage<R> stage,
org.infinispan.reactive.publisher.impl.LocalPublisherManagerImpl.SegmentListener segmentListener) |
void |
inject(ExecutorService nonBlockingExecutor)
Injects the cache - unfortunately this cannot be in start.
|
<R> SegmentAwarePublisher<R> |
keyPublisher(IntSet segments,
Set<K> keysToInclude,
Set<K> keysToExclude,
boolean includeLoader,
DeliveryGuarantee deliveryGuarantee,
Function<? super org.reactivestreams.Publisher<K>,? extends org.reactivestreams.Publisher<R>> transformer)
Same as
LocalPublisherManager.entryPublisher(IntSet, Set, Set, boolean, DeliveryGuarantee, Function)
except that the source publisher provided to the transformer is made up of keys only. |
<R> CompletionStage<PublisherResult<R>> |
keyReduction(boolean parallelPublisher,
IntSet segments,
Set<K> keysToInclude,
Set<K> keysToExclude,
boolean includeLoader,
DeliveryGuarantee deliveryGuarantee,
Function<? super org.reactivestreams.Publisher<K>,? extends CompletionStage<R>> collator,
Function<? super org.reactivestreams.Publisher<R>,? extends CompletionStage<R>> finalizer)
Same as
LocalPublisherManager.entryReduction(boolean, IntSet, Set, Set, boolean, DeliveryGuarantee, Function, Function)
except that the source publisher provided to the transformer is made up of keys only. |
void |
segmentsLost(IntSet lostSegments)
Method to invoke when a set of segments are being removed from this node.
|
void |
start() |
protected AdvancedCache<K,V> remoteCache
protected AdvancedCache<K,V> cache
protected io.reactivex.rxjava3.core.Scheduler nonBlockingScheduler
protected int maxSegment
protected final int cpuCount
protected CacheSet<CacheEntry<K,V>> entrySet
protected CacheSet<CacheEntry<K,V>> entrySetWithoutLoader
protected final Set<IntConsumer> changeListener
public void inject(ExecutorService nonBlockingExecutor)
public void start()
public <R> CompletionStage<PublisherResult<R>> keyReduction(boolean parallelPublisher, IntSet segments, Set<K> keysToInclude, Set<K> keysToExclude, boolean includeLoader, DeliveryGuarantee deliveryGuarantee, Function<? super org.reactivestreams.Publisher<K>,? extends CompletionStage<R>> collator, Function<? super org.reactivestreams.Publisher<R>,? extends CompletionStage<R>> finalizer)
LocalPublisherManagerLocalPublisherManager.entryReduction(boolean, IntSet, Set, Set, boolean, DeliveryGuarantee, Function, Function)
except that the source publisher provided to the transformer is made up of keys only.keyReduction in interface LocalPublisherManager<K,V>R - return value typepublic <R> CompletionStage<PublisherResult<R>> entryReduction(boolean parallelPublisher, IntSet segments, Set<K> keysToInclude, Set<K> keysToExclude, boolean includeLoader, DeliveryGuarantee deliveryGuarantee, Function<? super org.reactivestreams.Publisher<CacheEntry<K,V>>,? extends CompletionStage<R>> collator, Function<? super org.reactivestreams.Publisher<R>,? extends CompletionStage<R>> finalizer)
LocalPublisherManagerThe effects of the provided deliveryGuarantee are as follows:
| Guarantee | Parallel | Behavior> |
|---|---|---|
| AT_MOST_ONCE | TRUE | Each segment is a publisher passed to the transformer individually. Each result of the transformer is supplied to the finalizer. All segments are always complete, ignoring loss of data |
| AT_MOST_ONCE | FALSE | A single publisher for all segments is created and passed to the transformer. That result is returned, finalizer is never used All segments are always complete, ignoring loss of data |
| AT_LEAST_ONCE | TRUE | Same as AT_MOST_ONCE, but if a segment is lost in the middle it is returned as a suspected segment always returning all values |
| AT_LEAST_ONCE | FALSE | Same as AT_MOST_ONCE, but if a segment is lost in the middle it is returned as a suspected segment always returning all values |
| EXACTLY_ONCE | TRUE | Each segment is a publisher passed to the transformer individually. Each result is only accepted if the segment was owned the entire duration of the Subscription. |
| EXACTLY_ONCE | FALSE | Same as EXACTLY_ONCE/TRUE, except the publishers are consumed one at a time. |
entryReduction in interface LocalPublisherManager<K,V>R - return value typeparallelPublisher - Whether the publisher should be parallelizedsegments - determines what entries should be evaluated by only using ones that map to the given segments (must not be null)keysToInclude - set of keys that should only be used. May be null, in which case all provided entries for the given segments will be evaluatedkeysToExclude - set of keys that should not be used. May be null, in which case all provided entries will be evaluatedincludeLoader - whether to include entries from the underlying cache loader if anydeliveryGuarantee - delivery guarantee for given entriescollator - reduces the given publisher of data eventually into a single value. Must not be null.finalizer - reduces all of the single values produced by the transformer or this finalizer into one final value. May be null if not parallelpublic <R> SegmentAwarePublisher<R> keyPublisher(IntSet segments, Set<K> keysToInclude, Set<K> keysToExclude, boolean includeLoader, DeliveryGuarantee deliveryGuarantee, Function<? super org.reactivestreams.Publisher<K>,? extends org.reactivestreams.Publisher<R>> transformer)
LocalPublisherManagerLocalPublisherManager.entryPublisher(IntSet, Set, Set, boolean, DeliveryGuarantee, Function)
except that the source publisher provided to the transformer is made up of keys only.keyPublisher in interface LocalPublisherManager<K,V>R - return value typepublic <R> SegmentAwarePublisher<R> entryPublisher(IntSet segments, Set<K> keysToInclude, Set<K> keysToExclude, boolean includeLoader, DeliveryGuarantee deliveryGuarantee, Function<? super org.reactivestreams.Publisher<CacheEntry<K,V>>,? extends org.reactivestreams.Publisher<R>> transformer)
LocalPublisherManagerThe effects of the provided deliveryGuarantee are as follows:
| Guarantee | Behavior> |
|---|---|
| AT_MOST_ONCE | For each segment a publisher passed to the transformer sequentially. All segments are always complete, ignoring loss of data | AT_LEAST_ONCE | Same as AT_MOST_ONCE, but if a segment is lost in the middle it is returned as a suspected segment possibly dropping values in that segment. | EXACTLY_ONCE | Same as AT_LEAST_ONCE except whenever as segment is lost the value(s) collected in the same response for that segment are always dropped. |
entryPublisher in interface LocalPublisherManager<K,V>R - return value typesegments - determines what entries should be evaluated by only using ones that map to the given segments (must not be null)keysToInclude - set of keys that should only be used. May be null, in which case all provided entries for the given segments will be evaluatedkeysToExclude - set of keys that should not be used. May be null, in which case all provided entries will be evaluatedincludeLoader - whether to include entries from the underlying cache loader if anydeliveryGuarantee - delivery guarantee for given entriestransformer - transforms the values to another value (0 to many). Must not be null.public void segmentsLost(IntSet lostSegments)
LocalPublisherManagersegmentsLost in interface LocalPublisherManager<K,V>lostSegments - the segments that are being removed from this nodeprotected <R> CompletionStage<PublisherResult<R>> exactlyOnceHandleLostSegments(CompletionStage<R> finalValue, org.infinispan.reactive.publisher.impl.LocalPublisherManagerImpl.SegmentListener listener)
protected <I,R> io.reactivex.rxjava3.core.Flowable<R> exactlyOnceParallel(CacheSet<I> set, Set<K> keysToExclude, Function<I,K> toKeyFunction, IntSet segments, Function<? super org.reactivestreams.Publisher<I>,? extends CompletionStage<R>> collator, org.infinispan.reactive.publisher.impl.LocalPublisherManagerImpl.SegmentListener listener, IntSet concurrentSegments)
The results of each segment data will then be published each as a single result in the returned Flowable. Due to the results being retrieved eagerly it is entirely possible that if the Subscriber of the Flowable is slow that that results queue up. But due to that the fact that results are reduced to single values for each segment this shouldn't become an issue.
I - input type of the dataR - resulting valueset - CacheSet to retrieve the publisher for (non-nullable)keysToExclude - whether given keys should be excluded from the processing (nullable)toKeyFunction - function to convert an entry to a key to determine if it is excluded (must be non null if keysToExclude is)segments - the segments to process results for (non-nullable)collator - reducer to collate all the entries for a given segment into a single result (non-nullable)listener - listener that handles segments being lost and determining what results should be discarded (non-nullable)concurrentSegments - segments map of semgnets left to complete. remove an entry when a segment is completed to
prevent a data rehash causing a retry for the given segmentprotected <I,R> io.reactivex.rxjava3.core.Flowable<R> exactlyOnceSequential(CacheSet<I> set, Set<K> keysToExclude, Function<I,K> toKeyFunction, IntSet segments, Function<? super org.reactivestreams.Publisher<I>,? extends CompletionStage<R>> collator, org.infinispan.reactive.publisher.impl.LocalPublisherManagerImpl.SegmentListener listener, IntSet concurrentSegments)
protected <R> CompletionStage<PublisherResult<R>> handleLostSegments(CompletionStage<R> stage, org.infinispan.reactive.publisher.impl.LocalPublisherManagerImpl.SegmentListener segmentListener)
protected <R> CompletionStage<R> combineStages(io.reactivex.rxjava3.core.Flowable<? extends CompletionStage<R>> stagePublisher, Function<? super org.reactivestreams.Publisher<R>,? extends CompletionStage<R>> finalizer, boolean parallel)
protected <R> io.reactivex.rxjava3.core.Flowable<R> combineStages(io.reactivex.rxjava3.core.Flowable<? extends CompletionStage<R>> stagePublisher, boolean parallel)
Copyright © 2022 JBoss by Red Hat. All rights reserved.