Class AsyncInlineCachingRegionConfigurer<T,ID>

java.lang.Object
org.springframework.geode.cache.AsyncInlineCachingRegionConfigurer<T,ID>
All Implemented Interfaces:
org.springframework.core.Ordered, org.springframework.data.gemfire.config.annotation.RegionConfigurer, org.springframework.data.gemfire.config.annotation.support.Configurer<org.springframework.data.gemfire.client.ClientRegionFactoryBean<?,?>>

public class AsyncInlineCachingRegionConfigurer<T,ID> extends Object implements org.springframework.data.gemfire.config.annotation.RegionConfigurer
A Spring Data for Apache Geode RegionConfigurer implementation used to configure a target Region to use Asynchronous Inline Caching based on the Spring Data Repositories abstraction.
Since:
1.4.0
See Also:
  • Field Details

    • DEFAULT_REGION_BEAN_NAME_PREDICATE

      protected static final Predicate<String> DEFAULT_REGION_BEAN_NAME_PREDICATE
  • Constructor Details

    • AsyncInlineCachingRegionConfigurer

      public AsyncInlineCachingRegionConfigurer(@NonNull org.springframework.data.repository.CrudRepository<T,ID> repository, @Nullable Predicate<String> regionBeanName)
      Constructs a new instance of AsyncInlineCachingRegionConfigurer initialized with the given CrudRepository and Predicate identifying the Region on which Asynchronous Inline Caching will be configured.
      Parameters:
      repository - CrudRepository used to perform data access operations on an external data source triggered by cache events and operations on the identified Region; must not be null.
      regionBeanName - Predicate used to identify the Region by name on which Asynchronous Inline Caching will be configured.
      Throws:
      IllegalArgumentException - if CrudRepository is null.
      See Also:
  • Method Details

    • create

      public static <T, ID> AsyncInlineCachingRegionConfigurer<T,ID> create(@NonNull org.springframework.data.repository.CrudRepository<T,ID> repository, @Nullable Predicate<String> regionBeanName)
      Factory method used to construct a new instance of AsyncInlineCachingRegionConfigurer initialized with the given Spring Data CrudRepository and Predicate identifying the target Region on which to configure Asynchronous Inline Caching.
      Type Parameters:
      T - type of the entity.
      ID - type of the identifier, or Region key.
      Parameters:
      repository - CrudRepository used to perform data access operations on an external data source triggered by cache events and operations on the identified Region; must not be null.
      regionBeanName - Predicate used to identify the Region by name on which Asynchronous Inline Caching will be configured.
      Returns:
      a new AsyncInlineCachingRegionConfigurer.
      Throws:
      IllegalArgumentException - if CrudRepository is null.
      See Also:
    • create

      public static <T, ID> AsyncInlineCachingRegionConfigurer<T,ID> create(@NonNull org.springframework.data.repository.CrudRepository<T,ID> repository, @Nullable String regionBeanName)
      Factory method used to construct a new instance of AsyncInlineCachingRegionConfigurer initialized with the given Spring Data CrudRepository and String identifying the target Region on which to configure Asynchronous Inline Caching.
      Type Parameters:
      T - type of the entity.
      ID - type of the identifier, or Region key.
      Parameters:
      repository - CrudRepository used to perform data access operations on an external data source triggered by cache events and operations on the identified Region; must not be null.
      regionBeanName - String used to identify the Region by name on which Asynchronous Inline Caching will be configured.
      Returns:
      a new AsyncInlineCachingRegionConfigurer.
      Throws:
      IllegalArgumentException - if CrudRepository is null.
      See Also:
    • getRegionBeanName

      @NonNull protected Predicate<String> getRegionBeanName()
      Gets the Predicate identifying the Region on which Asynchronous Inline Caching will be configured.
      Returns:
      the Predicate used to match the Region by name on which Asynchronous Inline Caching will be configured; never null.
      See Also:
    • getRepository

      @NonNull protected org.springframework.data.repository.CrudRepository<T,ID> getRepository()
      Gets the Spring Data CrudRepository used to perform data access operations on an external data source triggered cache events and operations on the target Region.
      Returns:
      the Spring Data CrudRepository used to perform data access operations on an external data source triggered cache events and operations on the target Region; never null.
      See Also:
      • CrudRepository
    • configure

      public void configure(String beanName, org.springframework.data.gemfire.PeerRegionFactoryBean<?,?> bean)
      Configures the target Region by name with Asynchronous Inline Caching functionality. Effectively, this Configurer creates an AsyncEventQueue attached to the target Region with a registered RepositoryAsyncEventListener to perform asynchronous data access operations triggered by cache operations to an external, backend data source using a Spring Data CrudRepository.
      Specified by:
      configure in interface org.springframework.data.gemfire.config.annotation.RegionConfigurer
      Parameters:
      beanName - String specifying the name of the target Region and bean name in the Spring container.
      bean - PeerRegionFactoryBean containing the configuration of the target Region in the Spring container.
      See Also:
    • generateId

      @NonNull protected String generateId(@NonNull String regionBeanName)
      Generates a new ID for the AsyncEventQueue.
      Parameters:
      regionBeanName - name of the target Region.
      Returns:
      a new ID for the AsyncEventQueue.
    • newAsyncEventQueue

      protected org.apache.geode.cache.asyncqueue.AsyncEventQueue newAsyncEventQueue(@NonNull org.apache.geode.cache.Cache peerCache, @NonNull String regionBeanName)
      Constructs a new instance of an AsyncEventQueue to attach to the target Region configured for Asynchronous Inline Caching.
      Parameters:
      peerCache - reference to the peer cache; must not be null.
      regionBeanName - name of the target Region; must not be null.
      Returns:
      a new AsyncEventQueue.
      See Also:
    • newAsyncEventQueue

      @NonNull protected org.apache.geode.cache.asyncqueue.AsyncEventQueue newAsyncEventQueue(@NonNull org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory factory, @NonNull String asyncEventQueueId, @NonNull org.apache.geode.cache.asyncqueue.AsyncEventListener listener)
      Constructs (creates) a new instance of AsyncEventQueue using the given AsyncEventQueueFactory with the given AEQ ID and AsyncEventListener.
      Parameters:
      factory - AsyncEventQueueFactory used to create the AsyncEventQueue; must not be null.
      asyncEventQueueId - String containing the ID for the AsyncEventQueue; must not be null.
      listener - AsyncEventListener registered with the AsyncEventQueue to process cache events from the AsyncEventQueue attached to the Region.
      Returns:
      a new AsyncEventQueue with the ID and registered AsyncEventListener.
      See Also:
      • AsyncEventQueueFactory
      • AsyncEventQueue
      • AsyncEventListener
    • newAsyncEventQueueFactory

      @NonNull protected org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory newAsyncEventQueueFactory(@NonNull org.apache.geode.cache.Cache peerCache)
      Constructs (creates) a new instance of the AsyncEventQueueFactory from the given peer Cache.
      Parameters:
      peerCache - Peer Cache instance used to create an instance of the AsyncEventQueueFactory; must not be null.
      Returns:
      a new instance of AsyncEventQueueFactory to create a AsyncEventQueue.
      See Also:
      • AsyncEventQueueFactory
      • Cache
    • newRepositoryAsyncEventListener

      @NonNull protected org.apache.geode.cache.asyncqueue.AsyncEventListener newRepositoryAsyncEventListener()
      Constructs a new Apache Geode AsyncEventListener to register on an AsyncEventQueue attached to the target Region, which uses the CrudRepository to perform data access operations on an external backend data source asynchronously when cache events and operations occur on the target Region.
      Returns:
      a new RepositoryAsyncEventListener.
      See Also:
    • newRepositoryAsyncEventListener

      @NonNull protected org.apache.geode.cache.asyncqueue.AsyncEventListener newRepositoryAsyncEventListener(@NonNull org.springframework.data.repository.CrudRepository<T,ID> repository)
      Constructs a new Apache Geode AsyncEventListener to register on an AsyncEventQueue attached to the target Region, which uses the given CrudRepository to perform data access operations on an external, backend data source asynchronously when cache events and operations occur on the target Region.
      Parameters:
      repository - Spring Data CrudRepository used to perform data access operations on the external, backend data source; must not be null.
      Returns:
      a new RepositoryAsyncEventListener.
      See Also:
    • postProcess

      @NonNull protected org.apache.geode.cache.asyncqueue.AsyncEventListener postProcess(@NonNull org.apache.geode.cache.asyncqueue.AsyncEventListener asyncEventListener)
      Applies the user-defined Function to the framework constructed/provided AsyncEventListener for post processing.
      Parameters:
      asyncEventListener - AsyncEventListener constructed by the framework and post processed by end-user code encapsulated in the configured Function.
      Returns:
      the post-processed AsyncEventListener.
      See Also:
    • postProcess

      @NonNull protected org.apache.geode.cache.asyncqueue.AsyncEventQueue postProcess(@NonNull org.apache.geode.cache.asyncqueue.AsyncEventQueue asyncEventQueue)
      Applies the user-defined Function to the framework constructed/provided AsyncEventQueue for post processing.
      Parameters:
      asyncEventQueue - AsyncEventQueue constructed by the framework and post processed by end-user code encapsulated in the configured Function.
      Returns:
      the post-processed AsyncEventQueue.
      See Also:
    • postProcess

      @NonNull protected org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory postProcess(@NonNull org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory asyncEventQueueFactory)
      Applies the user-defined Function to the framework constructed/provided AsyncEventQueueFactory for post processing.
      Parameters:
      asyncEventQueueFactory - AsyncEventQueueFactory constructed by the framework and post processed by end-user code encapsulated in the configured Function.
      Returns:
      the post-processed AsyncEventQueueFactory.
      See Also:
    • applyToListener

      public AsyncInlineCachingRegionConfigurer<T,ID> applyToListener(@Nullable Function<org.apache.geode.cache.asyncqueue.AsyncEventListener,org.apache.geode.cache.asyncqueue.AsyncEventListener> asyncEventListenerPostProcessor)
      Builder method used to configure the given user-defined Function applied to the framework constructed and provided AsyncEventListener for post processing.
      Parameters:
      asyncEventListenerPostProcessor - user-defined Function encapsulating the logic applied to the framework constructed/provided AsyncEventListener for post-processing.
      Returns:
      this AsyncInlineCachingRegionConfigurer.
      See Also:
    • applyToQueue

      public AsyncInlineCachingRegionConfigurer<T,ID> applyToQueue(@Nullable Function<org.apache.geode.cache.asyncqueue.AsyncEventQueue,org.apache.geode.cache.asyncqueue.AsyncEventQueue> asyncEventQueuePostProcessor)
      Builder method used to configure the given user-defined Function applied to the framework constructed and provided AsyncEventQueue for post processing.
      Parameters:
      asyncEventQueuePostProcessor - user-defined Function encapsulating the logic applied to the framework constructed AsyncEventQueue for post-processing.
      Returns:
      this AsyncInlineCachingRegionConfigurer.
      See Also:
    • applyToQueueFactory

      public AsyncInlineCachingRegionConfigurer<T,ID> applyToQueueFactory(@Nullable Function<org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory,org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory> asyncEventQueueFactoryPostProcessor)
      Builder method used to configure the given user-defined Function applied to the framework constructed and provided AsyncEventQueueFactory for post processing.
      Parameters:
      asyncEventQueueFactoryPostProcessor - user-defined Function encapsulating the logic applied to the framework constructed AsyncEventQueueFactory for post-processing.
      Returns:
      this AsyncInlineCachingRegionConfigurer.
      See Also:
    • withAsyncEventErrorHandler

      public AsyncInlineCachingRegionConfigurer<T,ID> withAsyncEventErrorHandler(@Nullable RepositoryAsyncEventListener.AsyncEventErrorHandler errorHandler)
      Builder method used to configure a RepositoryAsyncEventListener.AsyncEventErrorHandler to handle errors thrown while processing AsyncEvents in the AsyncEventListener.
      Parameters:
      errorHandler - RepositoryAsyncEventListener.AsyncEventErrorHandler used to handle errors thrown while processing AsyncEvents in the AsyncEventListener.
      Returns:
      this AsyncInlineCachingRegionConfigurer.
      See Also:
    • withParallelQueue

      public AsyncInlineCachingRegionConfigurer<T,ID> withParallelQueue()
      Builder method used to enable all AEQs attached to Regions hosted and distributed across the cache cluster to process cache events. Default is false, or serial.
      Returns:
      this AsyncInlineCachingRegionConfigurer.
      See Also:
    • withPersistentQueue

      public AsyncInlineCachingRegionConfigurer<T,ID> withPersistentQueue()
      Builder method used to enable the AsyncEventQueue to persist cache events to disk in order to preserve unprocessed cache events while offline. Keep in mind that the AsyncEventQueue must be persistent if the data Region to which the AEQ is attached is persistent. Default is false.
      Returns:
      this AsyncInlineCachingRegionConfigurer.
    • withQueueBatchConflationEnabled

      public AsyncInlineCachingRegionConfigurer<T,ID> withQueueBatchConflationEnabled()
      Builder method used to configure the AsyncEventQueue to conflate cache events in the queue. When conflation is enabled, the AEQ listener will only receive the latest update in the AEQ for cache entry based on key. Defaults to false.
      Returns:
      this AsyncInlineCachingRegionConfigurer.
    • withQueueBatchSize

      public AsyncInlineCachingRegionConfigurer<T,ID> withQueueBatchSize(int batchSize)
      Builder method used to configure the AsyncEventQueue batch size, which determines the number (i.e. threshold) of cache events that will trigger the AEQ listener, before any set period of time. The batch size is often used in tandem with the batch time interval, which determines when the AEQ listener will be invoked after a period of time if the batch size is not reached within the period so that cache events can also be processed in a timely manner if they are occurring infrequently. Defaults to 100.
      Parameters:
      batchSize - the number of cache events in the queue before the AEQ listener is called.
      Returns:
      this AsyncInlineCachingRegionConfigurer.
      See Also:
    • withQueueBatchTimeInterval

      public AsyncInlineCachingRegionConfigurer<T,ID> withQueueBatchTimeInterval(Duration batchTimeInterval)
      Builder method used to configure the AsyncEventQueue batch time interval determining when the AEQ listener will be trigger before the number of cache events reaches any set size. The Duration is converted to milliseconds (ms), as expected by the configuration of the AsyncEventQueue. The batch time interval is often used in tandem with batch size, which determines for how many cache events in the queue will trigger the AEQ listener. If cache events are occurring rather frequently, then the batch size can help reduce memory consumption by processing the cache events before the batch time interval expires. Defaults to 5 ms.
      Parameters:
      batchTimeInterval - Duration of time to determine when the AEQ listener should be invoked with any existing cache events in the queue.
      Returns:
      this AsyncInlineCachingRegionConfigurer.
    • withQueueDiskStore

      public AsyncInlineCachingRegionConfigurer<T,ID> withQueueDiskStore(String diskStoreName)
      Builder method used to configure the name of the DiskStore used by the AsyncEventQueue to persist or overflow cache events. By default, the AEQ will write cache events to the DEFAULT DiskStore.
      Parameters:
      diskStoreName - name of the DiskStore.
      Returns:
      this AsyncInlineCachingRegionConfigurer.
    • withQueueDiskSynchronizationEnabled

      public AsyncInlineCachingRegionConfigurer<T,ID> withQueueDiskSynchronizationEnabled()
      Builder method used to configure the AsyncEventQueue to perform all disk write operations synchronously. Default is true.
      Returns:
      this AsyncInlineCachingRegionConfigurer.
    • withQueueDispatcherThreadCount

      public AsyncInlineCachingRegionConfigurer<T,ID> withQueueDispatcherThreadCount(int dispatcherThreadCount)
      Builder method to configure the number of Threads to process the cache events (contents) in the AsyncEventQueue when the queue is parallel. When a queue is parallel, the total number of queues is determined by the number of Geode members hosting the Region to which the queue is attached. When a queue is serial and multiple dispatcher threads are configured, Geode creates an additional copy of the queue for each thread on each Geode member that hosts the queue. When the queue is serial and multiple dispatcher threads are configure, then you can use the GatewaySender GatewaySender.OrderPolicy to control the distribution of cache events from the queue by the threads. Default is 5.
      Parameters:
      dispatcherThreadCount - number of dispatcher Threads processing cache events in the queue.
      Returns:
      this AsyncInlineCachingRegionConfigurer.
    • withQueueEventDispatchingPaused

      public AsyncInlineCachingRegionConfigurer<T,ID> withQueueEventDispatchingPaused()
      Builder method used to configure whether the AsyncEventQueue is currently processing cache events or is paused. When paused, cache events will not be dispatched to the AEQ listener for processing. Call the AsyncEventQueue.resumeEventDispatching() to resume cache event processing and AEQ listener callbacks.
      Returns:
      this AsyncInlineCachingRegionConfigurer.
    • withQueueEventFilters

      public AsyncInlineCachingRegionConfigurer<T,ID> withQueueEventFilters(List<org.apache.geode.cache.wan.GatewayEventFilter> eventFilters)
      Builder method to configure the AsyncEventQueue with a List of GatewayEventFilters to filter cache events sent to the configured AEQ listener.
      Parameters:
      eventFilters - List of GatewayEventFilters used to control and filter the cache events sent to the configured AEQ listener.
      Returns:
      this AsyncInlineCachingRegionConfigurer.
      See Also:
      • GatewayEventFilter
      • List
    • withQueueEventSubstitutionFilter

      public AsyncInlineCachingRegionConfigurer<T,ID> withQueueEventSubstitutionFilter(@Nullable org.apache.geode.cache.wan.GatewayEventSubstitutionFilter<ID,T> eventSubstitutionFilter)
      Builder method used to configure the AsyncEventQueue with a cache event substitution filter used to replace (or "substitute") the original cache entry event value enqueued in the AEQ.
      Parameters:
      eventSubstitutionFilter - GatewayEventSubstitutionFilter used to replace/substitute the value in the enqueued cache entry event.
      Returns:
      this AsyncInlineCachingRegionConfigurer.
      See Also:
      • GatewayEventSubstitutionFilter
    • withQueueForwardedExpirationDestroyEvents

      public AsyncInlineCachingRegionConfigurer<T,ID> withQueueForwardedExpirationDestroyEvents()
      Builder method used to configure whether cache Region entry destroyed events due to expiration are forwarded to the AsyncEventQueue.
      Returns:
      this AsyncInlineCachingRegionConfigurer.
    • withQueueMaxMemory

      public AsyncInlineCachingRegionConfigurer<T,ID> withQueueMaxMemory(int maximumMemory)
      Builder method used to configure the maximum JVM Heap memory in megabytes used by the AsyncEventQueue. After the maximum memory threshold is reached then the AEQ overflows cache events to disk. Default to 100 MB.
      Parameters:
      maximumMemory - Integer value specifying the maximum amount of memory in megabytes used by the AEQ to capture cache events.
      Returns:
      this AsyncInlineCachingRegionConfigurer.
    • withQueueOrderPolicy

      public AsyncInlineCachingRegionConfigurer<T,ID> withQueueOrderPolicy(@Nullable org.apache.geode.cache.wan.GatewaySender.OrderPolicy orderPolicy)
      Builder method used to configure the AsyncEventQueue order of processing for cache events when the AEQ is serial and the AEQ is using multiple dispatcher threads.
      Parameters:
      orderPolicy - GatewaySender GatewaySender.OrderPolicy used to determine the order of processing for cache events when the AEQ is serial and uses multiple dispatcher threads.
      Returns:
      this AsyncInlineCachingRegionConfigurer.
      See Also:
      • GatewaySender.OrderPolicy
    • withSerialQueue

      public AsyncInlineCachingRegionConfigurer<T,ID> withSerialQueue()
      Builder method used to enable a single AEQ attached to a Region (possibly) hosted and distributed across the cache cluster to process cache events. Default is false, or serial.
      Returns:
      this AsyncInlineCachingRegionConfigurer.
      See Also: