Class ScheduledDataLoaderRegistry

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    @ExperimentalApi
    public class ScheduledDataLoaderRegistry
    extends DataLoaderRegistry
    implements java.lang.AutoCloseable
    This DataLoaderRegistry will use a DispatchPredicate when dispatchAll() is called to test (for each DataLoader in the registry) if a dispatch should proceed. If the predicate returns false, then a task is scheduled to perform that predicate dispatch again via the ScheduledExecutorService.

    This will continue to loop (test false and reschedule) until such time as the predicate returns true, in which case no rescheduling will occur and you will need to call dispatch again to restart the process.

    If you wanted to create a ScheduledDataLoaderRegistry that started a rescheduling immediately, just create one and call rescheduleNow().

    This code is currently marked as ExperimentalApi

    • Field Detail

      • scheduledExecutorService

        private final java.util.concurrent.ScheduledExecutorService scheduledExecutorService
      • schedule

        private final java.time.Duration schedule
      • closed

        private volatile boolean closed
    • Method Detail

      • close

        public void close()
        Once closed this registry will never again reschedule checks
        Specified by:
        close in interface java.lang.AutoCloseable
      • getScheduleDuration

        public java.time.Duration getScheduleDuration()
        Returns:
        how long the ScheduledExecutorService task will wait before checking the predicate again
      • dispatchAllImmediately

        public void dispatchAllImmediately()
        This will immediately dispatch the DataLoaders in the registry without testing the predicate
      • dispatchAllWithCountImmediately

        public int dispatchAllWithCountImmediately()
        This will immediately dispatch the DataLoaders in the registry without testing the predicate
        Returns:
        total number of entries that were dispatched from registered DataLoaders.
      • rescheduleNow

        public void rescheduleNow()
        This will schedule a task to check the predicate and dispatch if true right now. It will not do a pre check of the preodicate like dispatchAll() would
      • reschedule

        private void reschedule​(java.lang.String key,
                                DataLoader<?,​?> dataLoader)
      • dispatchOrReschedule

        private void dispatchOrReschedule​(java.lang.String key,
                                          DataLoader<?,​?> dataLoader)