Class AbstractComponentTracker<C>

    • Constructor Detail

      • AbstractComponentTracker

        public AbstractComponentTracker()
    • Method Detail

      • processPriorToRemoval

        protected abstract void processPriorToRemoval​(C component)
        Stop or clean the component.
        Parameters:
        component -
      • buildComponent

        protected abstract C buildComponent​(java.lang.String key)
        Build a component based on the key.
        Parameters:
        key -
        Returns:
      • isComponentStale

        protected abstract boolean isComponentStale​(C c)
        Components can declare themselves stale. Such components may be removed before they time out.
        Parameters:
        c -
        Returns:
      • getFromEitherMap

        private AbstractComponentTracker.Entry<C> getFromEitherMap​(java.lang.String key)
        Get an entry from the liveMap, if not found search the lingerersMap.
        Parameters:
        key -
        Returns:
      • find

        public C find​(java.lang.String key)
        Find the component identified by 'key', without updating the timestamp. Returns null if no corresponding component could be found.

        Note that this method is synchronized.

        Specified by:
        find in interface ComponentTracker<C>
        Parameters:
        key -
        Returns:
        corresponding component, may be null
      • getOrCreate

        public C getOrCreate​(java.lang.String key,
                             long timestamp)
        Get the component identified by 'key', updating its timestamp in the process. If the corresponding component could not be found, it is created.

        Note that this method is atomic, i.e. synchronized.

        Specified by:
        getOrCreate in interface ComponentTracker<C>
        Parameters:
        key -
        timestamp -
        Returns:
      • endOfLife

        public void endOfLife​(java.lang.String key)
        Mark component identified by 'key' as having reached its end-of-life.
        Specified by:
        endOfLife in interface ComponentTracker<C>
        Parameters:
        key -
      • removeStaleComponents

        public void removeStaleComponents​(long now)
        Clear (and detach) components which are stale. Components which have not been accessed for more than a user-specified duration are deemed stale.
        Specified by:
        removeStaleComponents in interface ComponentTracker<C>
        Parameters:
        now -
      • removeExcedentComponents

        private void removeExcedentComponents()
      • removeStaleComponentsFromMainMap

        private void removeStaleComponentsFromMainMap​(long now)
      • removeStaleComponentsFromLingerersMap

        private void removeStaleComponentsFromLingerersMap​(long now)
      • isTooSoonForRemovalIteration

        private boolean isTooSoonForRemovalIteration​(long now)
      • allKeys

        public java.util.Set<java.lang.String> allKeys()
        Description copied from interface: ComponentTracker
        Set of all keys in this tracker in no particular order.
        Specified by:
        allKeys in interface ComponentTracker<C>
        Returns:
      • allComponents

        public java.util.Collection<C> allComponents()
        Description copied from interface: ComponentTracker
        Returns the collection of all components tracked by this instance.
        Specified by:
        allComponents in interface ComponentTracker<C>
        Returns:
        collection of components
      • getTimeout

        public long getTimeout()
      • setTimeout

        public void setTimeout​(long timeout)
      • getMaxComponents

        public int getMaxComponents()
      • setMaxComponents

        public void setMaxComponents​(int maxComponents)