|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sleepycat.je.evictor.Evictor
public abstract class Evictor
The Evictor is responsible for maintaining the JE cache. Since object sizes are not directly manipulated in a Java application, the cache is actually a collection of in-memory btree nodes, implemented by com.sleepycat.je.dbi.INList. Nodes are selected from the INList for removal, which is done by detaching them from the in-memory tree, and by removing them from the INList. Once all references to them are removed, they can be GC'd by the JVM. There are three main components. Arbiter: queries the memory budget to decide whether eviction is needed TargetSelector : chooses a target node Evictor: does the work of detaching the node. The TargetSelector and Evictor classes are subclassed to provide private/shared cache implementations. A shared cache is used by multiple environments within a single JVM, and is seen logically as a single INList collection, although it is implemented by an umbrella over multiple INLists. The Evictor owns a thread pool which is available to handle eviction tasks. Eviction is carried out by three types of threads: 1. The application thread, in the course of doing critical eviction 2. Daemon threads, such as the cleaner or INCompressor, in the course of doing their respective duties 3. Eviction pool threads We prefer that the eviction pool threads do as much of the eviction as possible, and that the application threads do as little, because eviction adds latency to the perceived application response time. To date, it has been impossible to completely remove eviction responsiblities from the application threads, because the process doesn't have sufficient feedback, and can incur an OutOfMemoryException. The eviction pool is a standard java.util.concurrent thread pool, and can be mutably configured in terms of core threads, max threads, and keepalive times. Since three types of threads can concurrently do eviction, it's important that eviction is both thread safe and as parallel as possible. Memory thresholds are generally accounted for in an unsynchronized fashion, and are seen as advisory. The only point of true synchronization is around the selection of a node for eviction. The act of eviction itself can be done concurrently. The eviction method is not reentrant, and a simple concurrent hash map of threads is used to prevent recursive calls.
Nested Class Summary | |
---|---|
(package private) static class |
Evictor.BackgroundEvictTask
|
(package private) static interface |
Evictor.DbCache
Caches DatabaseImpls to reduce DbTree.getDb overhead. |
static class |
Evictor.EvictionSource
|
(package private) static class |
Evictor.RejectEvictHandler
|
Field Summary | |
---|---|
(package private) int |
dbCacheClearCount
|
(package private) EnvironmentImpl |
envImpl
|
Constructor Summary | |
---|---|
Evictor(EnvironmentImpl envImpl)
|
Method Summary | |
---|---|
void |
addEnvironment(EnvironmentImpl additionalEnvImpl)
|
void |
alert()
Let the eviction pool know there's work to do. |
boolean |
checkEnv(EnvironmentImpl env)
Only supported by SharedEvictor. |
(package private) abstract Evictor.DbCache |
createDbCache()
|
void |
doCriticalEviction(boolean backgroundIO)
Do some eviction before proceeding on with another operation. |
void |
doDaemonEviction(boolean backgroundIO)
Do a check on whether synchronous eviction is needed. |
(package private) void |
doEvict(Evictor.EvictionSource source,
boolean backgroundIO)
Can execute concurrently, called by app threads or by background evictor |
void |
doEvictOneIN(IN target,
Evictor.EvictionSource source)
Evict a specific IN, used by cache modes. |
void |
doManualEvict()
|
void |
envConfigUpdate(DbConfigManager configManager,
EnvironmentMutableConfig ignore)
Respond to config updates. |
(package private) long |
evictBatch(Evictor.EvictionSource source,
boolean backgroundIO,
long maxEvictBytes)
Each iteration will attempt to evict maxEvictBytes, but will give up after a complete pass over the INList, or if there is nothing more to evict, due to actions by concurrently executing threads. |
AtomicLong |
getNINCompactKey()
|
AtomicLong |
getNINNoTarget()
|
AtomicLong |
getNINSparseTarget()
|
(package private) TargetSelector |
getSelector()
|
StatGroup |
getStatsGroup()
|
ThreadPoolExecutor |
getThreadPool()
|
void |
incBINEvictStats(Evictor.EvictionSource source)
|
void |
incBINFetchStats(boolean isMiss)
|
void |
incINEvictStats(Evictor.EvictionSource source)
|
void |
incINFetchStats(boolean isMiss)
|
void |
incLNFetchStats(boolean isMiss)
Update the appropriate fetch stat, based on node type. |
boolean |
isCacheFull()
|
StatGroup |
loadStats(StatsConfig config)
Load stats. |
(package private) abstract TargetSelector |
makeSelector()
|
void |
noteINListChange(int nINs)
Called whenever INs are added to, or removed from, the INList. |
void |
removeEnvironment(EnvironmentImpl targetEnvImpl)
|
void |
requestShutdownPool()
|
void |
setEvictProfileHook(TestHook<IN> hook)
|
void |
setPreEvictINHook(TestHook<Object> hook)
|
void |
setRunnableHook(TestHook<Boolean> hook)
|
void |
shutdown()
Request and wait for a shutdown of all running eviction tasks. |
boolean |
wasCacheEverFull()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
final EnvironmentImpl envImpl
int dbCacheClearCount
Constructor Detail |
---|
Evictor(EnvironmentImpl envImpl) throws DatabaseException
DatabaseException
Method Detail |
---|
public void envConfigUpdate(DbConfigManager configManager, EnvironmentMutableConfig ignore) throws DatabaseException
envConfigUpdate
in interface EnvConfigObserver
DatabaseException
abstract TargetSelector makeSelector()
public StatGroup loadStats(StatsConfig config)
public void doCriticalEviction(boolean backgroundIO)
public void doDaemonEviction(boolean backgroundIO)
public void doManualEvict() throws DatabaseException
DatabaseException
public void doEvictOneIN(IN target, Evictor.EvictionSource source)
public void alert()
public ThreadPoolExecutor getThreadPool()
void doEvict(Evictor.EvictionSource source, boolean backgroundIO) throws DatabaseException
DatabaseException
long evictBatch(Evictor.EvictionSource source, boolean backgroundIO, long maxEvictBytes) throws DatabaseException
DatabaseException
public void incBINEvictStats(Evictor.EvictionSource source)
public void incINEvictStats(Evictor.EvictionSource source)
public void incLNFetchStats(boolean isMiss)
public void incBINFetchStats(boolean isMiss)
public void incINFetchStats(boolean isMiss)
public AtomicLong getNINSparseTarget()
public AtomicLong getNINNoTarget()
public AtomicLong getNINCompactKey()
public void addEnvironment(EnvironmentImpl additionalEnvImpl)
public void removeEnvironment(EnvironmentImpl targetEnvImpl)
public void setPreEvictINHook(TestHook<Object> hook)
public void setEvictProfileHook(TestHook<IN> hook)
public void noteINListChange(int nINs)
public boolean checkEnv(EnvironmentImpl env)
public StatGroup getStatsGroup()
public void setRunnableHook(TestHook<Boolean> hook)
public boolean isCacheFull()
public boolean wasCacheEverFull()
TargetSelector getSelector()
public void shutdown()
public void requestShutdownPool()
abstract Evictor.DbCache createDbCache()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |