Interface ClusterPublisherManager<K,V>
- Type Parameters:
K
- The key type for the underlying cacheV
- the value type for the underlying cache
- All Known Implementing Classes:
ClusterPublisherManagerImpl
,LocalClusterPublisherManagerImpl
,PartitionAwareClusterPublisherManager
- Since:
- 10.0
- Author:
- wburns
-
Method Summary
Modifier and TypeMethodDescription<R> SegmentPublisherSupplier
<R> entryPublisher
(IntSet segments, Set<K> keysToInclude, InvocationContext invocationContext, long explicitFlags, DeliveryGuarantee deliveryGuarantee, int batchSize, Function<? super org.reactivestreams.Publisher<CacheEntry<K, V>>, ? extends org.reactivestreams.Publisher<R>> transformer) Performs the given transformer on data in the cache, resulting in multiple values.<R> CompletionStage
<R> entryReduction
(boolean parallelPublisher, IntSet segments, Set<K> keysToInclude, InvocationContext invocationContext, long explicitFlags, DeliveryGuarantee deliveryGuarantee, Function<? super org.reactivestreams.Publisher<CacheEntry<K, V>>, ? extends CompletionStage<R>> transformer, Function<? super org.reactivestreams.Publisher<R>, ? extends CompletionStage<R>> finalizer) Performs the given transformer and finalizer on data in the cache, resulting in a single value.<R> SegmentPublisherSupplier
<R> keyPublisher
(IntSet segments, Set<K> keysToInclude, InvocationContext invocationContext, long explicitFlags, DeliveryGuarantee deliveryGuarantee, int batchSize, Function<? super org.reactivestreams.Publisher<K>, ? extends org.reactivestreams.Publisher<R>> transformer) Same asentryPublisher(IntSet, Set, InvocationContext, long, DeliveryGuarantee, int, Function)
except that the source publisher provided to the transformer is made up of keys only.<R> CompletionStage
<R> keyReduction
(boolean parallelPublisher, IntSet segments, Set<K> keysToInclude, InvocationContext invocationContext, long explicitFlags, DeliveryGuarantee deliveryGuarantee, Function<? super org.reactivestreams.Publisher<K>, ? extends CompletionStage<R>> transformer, Function<? super org.reactivestreams.Publisher<R>, ? extends CompletionStage<R>> finalizer) Same asentryReduction(boolean, IntSet, Set, InvocationContext, long, DeliveryGuarantee, Function, Function)
except that the source publisher provided to the transformer is made up of keys only.sizePublisher
(IntSet segments, InvocationContext ctx, long flags)
-
Method Details
-
keyReduction
<R> CompletionStage<R> keyReduction(boolean parallelPublisher, IntSet segments, Set<K> keysToInclude, InvocationContext invocationContext, long explicitFlags, DeliveryGuarantee deliveryGuarantee, Function<? super org.reactivestreams.Publisher<K>, ? extends CompletionStage<R>> transformer, Function<? super org.reactivestreams.Publisher<R>, ? extends CompletionStage<R>> finalizer) Same asentryReduction(boolean, IntSet, Set, InvocationContext, long, DeliveryGuarantee, Function, Function)
except that the source publisher provided to the transformer is made up of keys only.- Type Parameters:
R
- return value type- Returns:
- CompletionStage that contains the resulting value when complete
-
entryReduction
<R> CompletionStage<R> entryReduction(boolean parallelPublisher, IntSet segments, Set<K> keysToInclude, InvocationContext invocationContext, long explicitFlags, DeliveryGuarantee deliveryGuarantee, Function<? super org.reactivestreams.Publisher<CacheEntry<K, V>>, ? extends CompletionStage<R>> transformer, Function<? super org.reactivestreams.Publisher<R>, ? extends CompletionStage<R>> finalizer) Performs the given transformer and finalizer on data in the cache, resulting in a single value. Depending on the deliveryGuarantee the transformer may be invoked 1..numSegments times. It could be that the transformer is invoked for every segment and produces a result. All of these results are then fed into the finalizer to produce a final result. If publisher is parallel the finalizer will be invoked on each node to ensure there is only a single result per node.If the provided transformer internally uses a reduction with a default value, that value must be its identity value. This is the same as can be seen at
Stream.reduce(Object, BinaryOperator)
. Then as long as the finalizer can handle the identity value it will be properly reduced.- Type Parameters:
R
- return value type- Parameters:
parallelPublisher
- Whether on each node the publisher should be parallelized remotely and locallysegments
- determines what entries should be evaluated by only using ones that map to the given segments (if null assumes all segments)keysToInclude
- set of keys that should only be used (if null all entries for the given segments will be evaluated)invocationContext
- context of the invoking operation, context entries override the values in the cache (may be null)explicitFlags
- cache flags, which are passed toKeySetCommand
orEntrySetCommand
deliveryGuarantee
- delivery guarantee for given entriestransformer
- 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. Must not be null.- Returns:
- CompletionStage that contains the resulting value when complete
-
keyPublisher
<R> SegmentPublisherSupplier<R> keyPublisher(IntSet segments, Set<K> keysToInclude, InvocationContext invocationContext, long explicitFlags, DeliveryGuarantee deliveryGuarantee, int batchSize, Function<? super org.reactivestreams.Publisher<K>, ? extends org.reactivestreams.Publisher<R>> transformer) Same asentryPublisher(IntSet, Set, InvocationContext, long, DeliveryGuarantee, int, Function)
except that the source publisher provided to the transformer is made up of keys only.- Type Parameters:
R
- return value type- Returns:
- Publisher that when subscribed to will return the results and notify of segment completion if necessary
-
entryPublisher
<R> SegmentPublisherSupplier<R> entryPublisher(IntSet segments, Set<K> keysToInclude, InvocationContext invocationContext, long explicitFlags, DeliveryGuarantee deliveryGuarantee, int batchSize, Function<? super org.reactivestreams.Publisher<CacheEntry<K, V>>, ? extends org.reactivestreams.Publisher<R>> transformer) Performs the given transformer on data in the cache, resulting in multiple values. If a single value is desired, the user should useentryReduction(boolean, IntSet, Set, InvocationContext, long, DeliveryGuarantee, Function, Function)
instead as it can optimize some things. Depending on the deliveryGuarantee the transformer may be invoked 1..numSegments times per node. Results from a given node will retrieve values up tobatchSize
values until some are consumed.For example when using RxJava and using an intermediate operation such as
Flowable.switchIfEmpty(Publisher)
this can add elements if the given Publisher is empty, and it is very possible that a segment may not have entries and therefore may add the elements the switched Publisher returns multiple times.Methods that add elements to the returned Publisher are fine as long as they are tied to a specific entry, for example
Flowable.flatMap(io.reactivex.rxjava3.functions.Function)
which can reproduce the same elements when provided the same input entry from the cache.- Type Parameters:
R
- return value type- Parameters:
segments
- determines what entries should be evaluated by only using ones that map to the given segments (if null assumes all segments)keysToInclude
- set of keys that should only be used (if null all entries for the given segments will be evaluated)invocationContext
- context of the invoking operation, context entries override the values in the cache (may be null)explicitFlags
- cache flagsdeliveryGuarantee
- delivery guarantee for given entriesbatchSize
- how many entries to be returned at a given timetransformer
- transform the given stream of data into something else (requires non null)- Returns:
- Publisher that when subscribed to will return the results and notify of segment completion if necessary
-
sizePublisher
-