Class AbstractIteratorHandler<T,​I,​N>

  • Type Parameters:
    T - The type of the handled iterators.
    I - The type of the initial data provided when requesting the iterator.
    N - The type of the data when iterating.
    Direct Known Subclasses:
    IncWorklistHandler, IncWorklistUpdateHandler, RemoteIteratorHandler

    public class AbstractIteratorHandler<T,​I,​N>
    extends Object
    This class handles provides the basic means for handling iterators. This includes the data structure containing the iterators, runnables for removing iterators from the data structure and dropping them as well as the corresponding scheduled executor service.
    Usually the iterators need some additional meta data. Use a small wrapper for this and let this class handle the wrapper classes.

    Iterators and their handling classes are generic classes whereas the generic type specifies the elements of the iterator. However, Java's type system may become a problem for other languages. Therefore the ILM removes the generic type and makes it explicit. At runtime this handler needs to create and provide the concrete types without generics, so instantiation is delegated to Suppliers provided when instantiating this handler.

    Due to the API of iterators being rather specific, this class is a mere sketch and a lot of logic has to happen in subclasses.

    See Also:
    RemoteIterator, IncrementalWorklist, IncrementalWorklistUpdate
    • Field Detail

      • iterators

        protected final Map<UUID,​T> iterators
        The map containing iterators while they are active. The key is a random UUID identifying the iterator.
      • removerService

        protected final ScheduledExecutorService removerService
        The scheduler service which drops and removes all registered iterators after their alive time has elapsed from this handler.
      • initDataCreator

        protected final Supplier<I> initDataCreator
        The creator for data provided initially when requesting the iterator.
      • dataCreator

        protected final Supplier<N> dataCreator
        The creator for data provided when iterating.
      • aliveTimeExtension

        protected final long aliveTimeExtension
        The time in milliseconds to extend the alive time of the iterator implicitly. Iterators with explicit alive time handling may ignore this.
    • Constructor Detail

      • AbstractIteratorHandler

        public AbstractIteratorHandler​(Supplier<I> initDataCreator,
                                       Supplier<N> dataCreator,
                                       long aliveTimeExtension,
                                       String name,
                                       LogService logService)
        Creates a new iteration handler.
        Parameters:
        initDataCreator - The creator for data provided initially when requesting the iterator.
        dataCreator - The creator for data provided when iterating.
        aliveTimeExtension - The time in milliseconds to extend the alive time of the iterator implicitly.
        name - The name for the executor.
        logService - The log service to retrieve the logger for the executor from.
    • Method Detail

      • shutdown

        public void shutdown()
        Shuts the executor service down and waits for the termination of running threads.
      • getIterator

        protected T getIterator​(UUID iteratorId)
        Gets the iterator (with metadata) with the designated ID.
        Parameters:
        iteratorId - The ID of the iterator with metadata to retrieve.
        Returns:
        The iterator (with metadata) with the designated ID.
        Throws:
        IllegalArgumentException - If the designated ID does not refer to an iterator known by this handler, an IllegalArgumentException will be thrown.