Class CountEvictionPolicy<T>

  • Type Parameters:
    T - the type of event tracked by this policy.
    All Implemented Interfaces:
    EvictionPolicy<T,​Long>

    public class CountEvictionPolicy<T>
    extends Object
    implements EvictionPolicy<T,​Long>
    An eviction policy that tracks event counts and can evict based on a threshold count.
    • Field Detail

      • threshold

        protected final int threshold
      • currentCount

        protected final AtomicLong currentCount
    • Constructor Detail

      • CountEvictionPolicy

        public CountEvictionPolicy​(int count)
    • Method Detail

      • setContext

        public void setContext​(EvictionContext context)
        Description copied from interface: EvictionPolicy
        Sets a context in the eviction policy that can be used while evicting the events. E.g. For TimeEvictionPolicy, this could be used to set the reference timestamp.
        Specified by:
        setContext in interface EvictionPolicy<T,​Long>
        Parameters:
        context - the eviction context
      • getState

        public Long getState()
        Description copied from interface: EvictionPolicy
        Return runtime state to be checkpointed by the framework for restoring the eviction policy in case of failures.
        Specified by:
        getState in interface EvictionPolicy<T,​Long>
        Returns:
        the state
      • restoreState

        public void restoreState​(Long state)
        Description copied from interface: EvictionPolicy
        Restore the eviction policy from the state that was earlier checkpointed by the framework.
        Specified by:
        restoreState in interface EvictionPolicy<T,​Long>
        Parameters:
        state - the state