Package com.gigaspaces.server.eviction
Class SpaceEvictionStrategy
java.lang.Object
com.gigaspaces.server.eviction.SpaceEvictionStrategy
- Direct Known Subclasses:
AllInCacheSpaceEvictionStrategy,ConcurrentLruSpaceEvictionStrategy,TimeBasedSpaceEvictionStrategy
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Called when the space is closed.abstract intevict(int numOfEntries) Called when the space requires entries to be evicted.protected SpaceEvictionStrategyConfigReturns the eviction configuration provided during initialization.protected SpaceEvictionManagerReturns the eviction manager provided during initialization.voidinitialize(SpaceEvictionManager evictionManager, SpaceEvictionStrategyConfig config) Called during the space initialization.protected booleanisClosed()Returns true if the space is closed, false otherwise.voidonInsert(EvictableServerEntry entry) Called when a new entry is written to the space.voidonLoad(EvictableServerEntry entry) Called when an entry is loaded into the space from an external data source.voidonRead(EvictableServerEntry entry) Called when an entry is read from the space.voidonRemove(EvictableServerEntry entry) Called when an entry is removed from the space.voidonUpdate(EvictableServerEntry entry) Called when an entry is updated in the space.booleanDue to the nature of the system, calls toonRemove(EvictableServerEntry)can occur in concurrent with eitheronRead(EvictableServerEntry)oronUpdate(EvictableServerEntry)or even before them.
-
Constructor Details
-
SpaceEvictionStrategy
public SpaceEvictionStrategy()
-
-
Method Details
-
initialize
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 toonRemove(EvictableServerEntry)can occur in concurrent with eitheronRead(EvictableServerEntry)oronUpdate(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
Called when a new entry is written to the space.- Parameters:
entry- The new entry
-
onLoad
Called when an entry is loaded into the space from an external data source.- Parameters:
entry- The loaded entry
-
onRead
Called when an entry is read from the space.- Parameters:
entry- The read entry
-
onUpdate
Called when an entry is updated in the space.- Parameters:
entry- The updated entry
-
onRemove
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
Returns the eviction manager provided during initialization. -
getEvictionConfig
Returns the eviction configuration provided during initialization. -
isClosed
protected boolean isClosed()Returns true if the space is closed, false otherwise.
-