Class NonSegmentedLocalPublisherManagerImpl<K,​V>

  • All Implemented Interfaces:
    LocalPublisherManager<K,​V>

    public class NonSegmentedLocalPublisherManagerImpl<K,​V>
    extends LocalPublisherManagerImpl<K,​V>
    LocalPublisherManager that handles cases when a non segmented store are present. In this case we optimize the retrieval to not use individual segments as this would cause multiple full scans of the underlying store. In this case we submit a task for all segments requested and process the results concurrently if requested.
    Since:
    10.0
    Author:
    wburns
    • Constructor Detail

      • NonSegmentedLocalPublisherManagerImpl

        public NonSegmentedLocalPublisherManagerImpl()
    • Method Detail

      • exactlyOnceParallel

        protected <I,​R> io.reactivex.rxjava3.core.Flowable<R> exactlyOnceParallel​(CacheSet<I> set,
                                                                                        Set<K> keysToExclude,
                                                                                        Function<I,​K> toKeyFunction,
                                                                                        org.infinispan.commons.util.IntSet segments,
                                                                                        Function<? super org.reactivestreams.Publisher<I>,​? extends CompletionStage<R>> transformer,
                                                                                        org.infinispan.reactive.publisher.impl.LocalPublisherManagerImpl.SegmentListener listener,
                                                                                        org.infinispan.commons.util.IntSet concurrentSegments)
        Description copied from class: LocalPublisherManagerImpl
        This method iteratively submits a task to operate on the cpu bound thread pool up to the number of cores - 1. The tasks perform a type of work stealing where they attempt to retrieve the next available segment and process them as fast as possible. It is entirely possible that a given task is never submitted due to the other tasks completing all the segments asynchronously. After the main thread has submitted all the tasks it will attempt to steal a segment and run it if possible and if it can will subsequently attempt to complete all remaining segments in the same fashion as the other threads. NOTE that this behavior is not normally how reactive streams are done as given operations are not normally performed until the returned Flowable is subscribed to, but for performance reasons this method eagerly publishes entries. This is because we do not have to context switch an additional thread and we know that it is subscribed to immediately after.

        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.

        Overrides:
        exactlyOnceParallel in class LocalPublisherManagerImpl<K,​V>
        Type Parameters:
        I - input type of the data
        R - resulting value
        Parameters:
        set - 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)
        transformer - 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 segment
        Returns:
        Flowable that publishes a result for each segment
      • exactlyOnceSequential

        protected <I,​R> io.reactivex.rxjava3.core.Flowable<R> exactlyOnceSequential​(CacheSet<I> set,
                                                                                          Set<K> keysToExclude,
                                                                                          Function<I,​K> toKeyFunction,
                                                                                          org.infinispan.commons.util.IntSet segments,
                                                                                          Function<? super org.reactivestreams.Publisher<I>,​? extends CompletionStage<R>> transformer,
                                                                                          org.infinispan.reactive.publisher.impl.LocalPublisherManagerImpl.SegmentListener listener,
                                                                                          org.infinispan.commons.util.IntSet concurrentSegments)
        Overrides:
        exactlyOnceSequential in class LocalPublisherManagerImpl<K,​V>