Class SpaceEvictionStrategy

java.lang.Object
com.gigaspaces.server.eviction.SpaceEvictionStrategy
Direct Known Subclasses:
AllInCacheSpaceEvictionStrategy, ConcurrentLruSpaceEvictionStrategy, TimeBasedSpaceEvictionStrategy

public abstract class SpaceEvictionStrategy extends Object
Base class for space eviction strategy implementations. When the space memory manager detects that memory is becoming scarce, it will try to evict entries from the space. The eviction strategy can be altered by using different SpaceEvictionStrategy implementations.
Since:
9.1
Author:
Yechiel Feffer
See Also:
  • Constructor Details

    • SpaceEvictionStrategy

      public SpaceEvictionStrategy()
  • Method Details

    • initialize

      public void initialize(SpaceEvictionManager evictionManager, SpaceEvictionStrategyConfig config)
      Called during the space initialization.
    • close

      public void close()
      Called when the space is closed.
    • requiresConcurrencyProtection

      public boolean requiresConcurrencyProtection()
      Due to the nature of the system, calls to onRemove(EvictableServerEntry) can occur in concurrent with either onRead(EvictableServerEntry) or onUpdate(EvictableServerEntry) or even before them. In order to prevent this behavior this property should return true (This is the default) and the system will guard this with locks. This should only be set to false by advanced usages which needs to be able to work under this behavior.
    • onInsert

      public void onInsert(EvictableServerEntry entry)
      Called when a new entry is written to the space.
      Parameters:
      entry - The new entry
    • onLoad

      public void onLoad(EvictableServerEntry entry)
      Called when an entry is loaded into the space from an external data source.
      Parameters:
      entry - The loaded entry
    • onRead

      public void onRead(EvictableServerEntry entry)
      Called when an entry is read from the space.
      Parameters:
      entry - The read entry
    • onUpdate

      public void onUpdate(EvictableServerEntry entry)
      Called when an entry is updated in the space.
      Parameters:
      entry - The updated entry
    • onRemove

      public void onRemove(EvictableServerEntry entry)
      Called when an entry is removed from the space.
      Parameters:
      entry - The removed entry
    • evict

      public abstract int evict(int numOfEntries)
      Called when the space requires entries to be evicted.
      Parameters:
      numOfEntries - Number of entries to be evicted
      Returns:
      The number of entries actually evicted
    • getEvictionManager

      protected SpaceEvictionManager getEvictionManager()
      Returns the eviction manager provided during initialization.
    • getEvictionConfig

      protected SpaceEvictionStrategyConfig getEvictionConfig()
      Returns the eviction configuration provided during initialization.
    • isClosed

      protected boolean isClosed()
      Returns true if the space is closed, false otherwise.