Class SegmentedEviction

    • Constructor Detail

      • SegmentedEviction

        public SegmentedEviction​(Eviction[] segments)
    • Method Detail

      • updateWeight

        public boolean updateWeight​(Entry e)
        Description copied from interface: Eviction
        Updates the weight on the entry and recalculates the total weight if needed.

        Expected not to hold the entry lock, which means, that this does not run in sync with the actual update. That is okay as long as its runs after every update.

        Since we need to lock the eviction structure, this could happen async in a separate thread.

        Specified by:
        updateWeight in interface Eviction
        Returns:
        hint whether eviction should be run. for bulk operations do eviction once. so not do it within this method
      • submitWithoutTriggeringEviction

        public boolean submitWithoutTriggeringEviction​(Entry e)
        Description copied from interface: Eviction
        Submit to eviction for inserting or removing from the replacement list. However, eviction should not be triggered (which in turn triggers a hash table update) since the hash segment lock is hold at the moment.
        Specified by:
        submitWithoutTriggeringEviction in interface Eviction
      • evictEventuallyBeforeInsertOnSegment

        public void evictEventuallyBeforeInsertOnSegment​(int hashCodeHint)
        Description copied from interface: Eviction
        Evict if needed, focused on the segment addressed by the hash code. Called before a new entry is inserted (changed from after in v1.4)
        Specified by:
        evictEventuallyBeforeInsertOnSegment in interface Eviction
      • evictEventuallyBeforeInsert

        public void evictEventuallyBeforeInsert()
        Description copied from interface: Eviction
        Evict if needed, checks all segments. Called before a new entry is inserted (changed from after in v1.4)
        Specified by:
        evictEventuallyBeforeInsert in interface Eviction
      • evictEventually

        public void evictEventually()
        Description copied from interface: Eviction
        Evict if needed, checks all segments.
        Specified by:
        evictEventually in interface Eviction
      • removeAll

        public long removeAll()
        Description copied from interface: Eviction
        Remove all entries from the eviction data structure.
        Specified by:
        removeAll in interface Eviction
        Returns:
        entry count
      • start

        public void start()
        Description copied from interface: Eviction
        Start concurrent eviction threads.
        Specified by:
        start in interface Eviction
      • stop

        public void stop()
        Description copied from interface: Eviction
        Stop concurrent threads that may access the eviction data structures. Needs to be called before checkIntegrity or accessing the counter values.
        Specified by:
        stop in interface Eviction
      • close

        public void close()
        Description copied from interface: Eviction
        Free resources, for example thread pool or queue.
        Specified by:
        close in interface Eviction
      • drain

        public boolean drain()
        Description copied from interface: Eviction
        Drain eviction queue and do updates in the eviction data structures. Does no eviction when size limit is reached.
        Specified by:
        drain in interface Eviction
        Returns:
        true, if eviction is needed
      • runLocked

        public <T> T runLocked​(Supplier<T> j)
        Description copied from interface: Eviction
        Runs job making sure concurrent evictions operations pause.
        Specified by:
        runLocked in interface Eviction
      • getSize

        public long getSize()
        Description copied from interface: EvictionMetrics
        Number of entries in the eviction data structure
        Specified by:
        getSize in interface EvictionMetrics
      • getTotalWeight

        public long getTotalWeight()
        Description copied from interface: EvictionMetrics
        Accumulated weight of all entries currently controlled by eviction.
        Specified by:
        getTotalWeight in interface EvictionMetrics
      • changeCapacity

        public void changeCapacity​(long entryCountOrWeight)
        Description copied from interface: Eviction
        Change the capacity. If capacity is reduced, it will evict entries before returning.
        Specified by:
        changeCapacity in interface Eviction