Interface PoolAccessor<T extends PoolParticipant>

  • Type Parameters:
    T - Type representing this "other" side of this accessor (i.e. a store), so the evictor can interact with it
    All Known Implementing Classes:
    AbstractPoolAccessor

    public interface PoolAccessor<T extends PoolParticipant>
    PoolAccessors are used by stores to tell the pools about their resource consumption
    Author:
    Ludovic Orban, Alex Snaps
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      long add​(java.lang.Object key, java.lang.Object value, java.lang.Object container, boolean force)
      Add an element to the pool.
      boolean canAddWithoutEvicting​(java.lang.Object key, java.lang.Object value, java.lang.Object container)
      Check if there is enough room in the pool to add an element without provoking any eviction
      void clear()
      Free resources used by this accessor.
      long delete​(long size)
      Delete a fixed number of bytes from the pool.
      T getParticipant()
      Return the store that uses this accessor
      long getPoolOccupancy()
      Returns the occupied size for this pool.
      long getPoolSize()
      Returns the size of this pool.
      long getSize()
      Return how many bytes this accessor consumes from the pool.
      boolean hasAbortedSizeOf()
      Check if the store may contain elements which the SizeOf engine could not fully size.
      long replace​(long currentSize, java.lang.Object key, java.lang.Object value, java.lang.Object container, boolean force)
      Delete a fixed number of bytes from the pool with the given objects.
      void setMaxSize​(long newValue)
      Sets the max size for this pool
      void unlink()
      unlink this PoolAccessor from its pool.
    • Method Detail

      • add

        long add​(java.lang.Object key,
                 java.lang.Object value,
                 java.lang.Object container,
                 boolean force)
        Add an element to the pool.
        Parameters:
        key - the key of the element
        value - the value of the element
        container - the element-container object
        force - true if the pool should accept adding the element, even if it's out of resources
        Returns:
        how many bytes have been added to the pool or -1 if add failed.
      • canAddWithoutEvicting

        boolean canAddWithoutEvicting​(java.lang.Object key,
                                      java.lang.Object value,
                                      java.lang.Object container)
        Check if there is enough room in the pool to add an element without provoking any eviction
        Parameters:
        key - the key of the element
        value - the value of the element
        container - the element-container object
        Returns:
        true if there is enough room left
      • delete

        long delete​(long size)
             throws java.lang.IllegalArgumentException
        Delete a fixed number of bytes from the pool.
        Parameters:
        size - number of bytes
        Returns:
        how many bytes have been freed from the pool.
        Throws:
        java.lang.IllegalArgumentException - when sizeOf is negative
      • replace

        long replace​(long currentSize,
                     java.lang.Object key,
                     java.lang.Object value,
                     java.lang.Object container,
                     boolean force)
        Delete a fixed number of bytes from the pool with the given objects.
        Parameters:
        currentSize - the size of the object(s) being replaced
        key - the key of the element
        value - the value of the element
        container - the element-container object
        force - true if the pool should accept replacing the element, even if it's out of resources
        Returns:
        the change in size of the pool, or Long.MIN_VALUE if replace failed.
      • getSize

        long getSize()
        Return how many bytes this accessor consumes from the pool.
        Returns:
        how many bytes this accessor consumes from the pool.
      • unlink

        void unlink()
        unlink this PoolAccessor from its pool.
      • clear

        void clear()
        Free resources used by this accessor.
      • getParticipant

        T getParticipant()
        Return the store that uses this accessor
        Returns:
        store using this accessor
      • setMaxSize

        void setMaxSize​(long newValue)
        Sets the max size for this pool
        Parameters:
        newValue - the value in bytes
      • getPoolOccupancy

        long getPoolOccupancy()
        Returns the occupied size for this pool.
        Returns:
        occupied pool size
      • getPoolSize

        long getPoolSize()
        Returns the size of this pool.
        Returns:
        pool size
      • hasAbortedSizeOf

        boolean hasAbortedSizeOf()
        Check if the store may contain elements which the SizeOf engine could not fully size.
        Returns:
        true if the store may contain partially sized objects