GigaSpaces XAP 9.1 API

com.gigaspaces.server.eviction
Class SpaceEvictionStrategy

java.lang.Object
  extended by com.gigaspaces.server.eviction.SpaceEvictionStrategy

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:
AllInCacheSpaceEvictionStrategy, ConcurrentLruSpaceEvictionStrategy

Constructor Summary
SpaceEvictionStrategy()
           
 
Method Summary
 void close()
          Called when the space is closed.
abstract  int evict(int numOfEntries)
          Called when the space requires entries to be evicted.
protected  SpaceEvictionStrategyConfig getEvictionConfig()
          Returns the eviction configuration provided during initialization.
protected  SpaceEvictionManager getEvictionManager()
          Returns the eviction manager provided during initialization.
 void initialize(SpaceEvictionManager evictionManager, SpaceEvictionStrategyConfig config)
          Called during the space initialization.
protected  boolean isClosed()
          Returns true if the space is closed, false otherwise.
 void onInsert(EvictableServerEntry entry)
          Called when a new entry is written to the space.
 void onLoad(EvictableServerEntry entry)
          Called when an entry is loaded into the space from an external data source.
 void onRead(EvictableServerEntry entry)
          Called when an entry is read from the space.
 void onRemove(EvictableServerEntry entry)
          Called when an entry is removed from the space.
 void onUpdate(EvictableServerEntry entry)
          Called when an entry is updated in the space.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpaceEvictionStrategy

public SpaceEvictionStrategy()
Method Detail

initialize

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

Parameters:
evictionManager -
config -

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.


GigaSpaces XAP 9.1 API

Copyright © GigaSpaces.