com.sleepycat.je.evictor
Class Evictor

java.lang.Object
  extended by com.sleepycat.je.utilint.DaemonThread
      extended by com.sleepycat.je.evictor.Evictor
All Implemented Interfaces:
DaemonRunner, java.lang.Runnable
Direct Known Subclasses:
PrivateEvictor, SharedEvictor

public abstract class Evictor
extends DaemonThread

The Evictor looks through the INList for IN's and BIN's that are worthy of eviction. Once the nodes are selected, it removes all references to them so that they can be GC'd by the JVM.


Nested Class Summary
(package private) static class Evictor.EvictProfile
           
 
Field Summary
(package private)  Evictor.EvictProfile evictProfile
           
static java.lang.String SOURCE_CRITICAL
           
static java.lang.String SOURCE_DAEMON
           
static java.lang.String SOURCE_MANUAL
           
 
Fields inherited from class com.sleepycat.je.utilint.DaemonThread
name, nWakeupRequests, stifleExceptionChatter
 
Constructor Summary
Evictor(EnvironmentImpl envImpl, java.lang.String name)
           
 
Method Summary
abstract  void addEnvironment(EnvironmentImpl envImpl)
          Only supported by SharedEvictor.
 void alert()
          Wakeup the evictor only if it's not already active.
abstract  boolean checkEnvs(java.util.Set<EnvironmentImpl> envs)
          Only supported by SharedEvictor.
abstract  void clearEnv()
          Standard daemon method to set envImpl to null.
 void doCriticalEviction(boolean backgroundIO)
          Do a check on whether synchronous eviction is needed.
 void doEvict(java.lang.String source)
          May be called by the evictor thread on wakeup or programatically.
(package private)  long evictBatch(java.lang.String source, boolean backgroundIO, long requiredEvictBytes)
          Each iteration will attempt to evict requiredEvictBytes, but will give up after a complete pass over the INList.
(package private) abstract  java.util.logging.Logger getLogger()
           
(package private) abstract  int getMaxINsPerBatch()
          Returns the approximate number of total INs in the INList(s).
(package private) abstract  IN getNextIN()
          Returns the next IN in the INList(s), wrapping if necessary.
(package private) abstract  java.util.Iterator<IN> getScanIterator()
           
 void loadStats(StatsConfig config, EnvironmentStats stat)
          Load stats.
protected  long nDeadlockRetries()
          Return the number of retries when a deadlock exception occurs.
 int normalizeLevel(IN in, int evictType)
          Normalize the tree level of the given IN.
abstract  void noteINListChange(int nINs)
          Called whenever INs are added to, or removed from, the INList.
 void onWakeup()
          Called whenever the daemon thread wakes up from a sleep.
abstract  void removeEnvironment(EnvironmentImpl envImpl)
          Only supported by SharedEvictor.
 void setRunnableHook(TestHook hook)
           
(package private) abstract  void setScanIterator(java.util.Iterator<IN> iter)
           
(package private) abstract  long startBatch()
          Perform class-specific batch processing: Initialize iterator, perform UtilizationTracker eviction, etc.
 
Methods inherited from class com.sleepycat.je.utilint.DaemonThread
checkErrorListener, getExceptionListener, getNWakeupRequests, getThread, isPaused, isRunning, isShutdownRequested, requestShutdown, run, runOrPause, setExceptionListener, shutdown, toString, wakeup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SOURCE_DAEMON

public static final java.lang.String SOURCE_DAEMON
See Also:
Constant Field Values

SOURCE_MANUAL

public static final java.lang.String SOURCE_MANUAL
See Also:
Constant Field Values

SOURCE_CRITICAL

public static final java.lang.String SOURCE_CRITICAL
See Also:
Constant Field Values

evictProfile

Evictor.EvictProfile evictProfile
Constructor Detail

Evictor

Evictor(EnvironmentImpl envImpl,
        java.lang.String name)
  throws DatabaseException
Throws:
DatabaseException
Method Detail

loadStats

public void loadStats(StatsConfig config,
                      EnvironmentStats stat)
               throws DatabaseException
Load stats.

Throws:
DatabaseException

nDeadlockRetries

protected long nDeadlockRetries()
                         throws DatabaseException
Return the number of retries when a deadlock exception occurs.

Overrides:
nDeadlockRetries in class DaemonThread
Throws:
DatabaseException

alert

public void alert()
Wakeup the evictor only if it's not already active.


onWakeup

public void onWakeup()
              throws DatabaseException
Called whenever the daemon thread wakes up from a sleep.

Specified by:
onWakeup in class DaemonThread
Throws:
DatabaseException

doEvict

public void doEvict(java.lang.String source)
             throws DatabaseException
May be called by the evictor thread on wakeup or programatically.

Throws:
DatabaseException

doCriticalEviction

public void doCriticalEviction(boolean backgroundIO)
                        throws DatabaseException
Do a check on whether synchronous eviction is needed.

Throws:
DatabaseException

evictBatch

long evictBatch(java.lang.String source,
                boolean backgroundIO,
                long requiredEvictBytes)
          throws DatabaseException
Each iteration will attempt to evict requiredEvictBytes, but will give up after a complete pass over the INList.

Returns:
the number of bytes evicted, or zero if no progress was made.
Throws:
DatabaseException

normalizeLevel

public int normalizeLevel(IN in,
                          int evictType)
Normalize the tree level of the given IN. Is public for unit testing. A BIN containing evictable LNs is given level 0, so it will be stripped first. For non-duplicate and DBMAP trees, the high order bits are cleared to make their levels correspond; that way, all bottom level nodes (BINs and DBINs) are given the same eviction priority. Note that BINs in a duplicate tree are assigned the same level as BINs in a non-duplicate tree. This isn't always optimimal, but is the best we can do considering that BINs in duplicate trees may contain a mix of LNs and DINs. BINs in the mapping tree are also assigned the same level as user DB BINs. When doing by-level eviction (lruOnly=false), this seems counter-intuitive since we should evict user DB nodes before mapping DB nodes. But that does occur because mapping DB INs referencing an open DB are unevictable. The level is only used for selecting among evictable nodes. If we did NOT normalize the level for the mapping DB, then INs for closed evictable DBs would not be evicted until after all nodes in all user DBs were evicted. If there were large numbers of closed DBs, this would have a negative performance impact.


setRunnableHook

public void setRunnableHook(TestHook hook)

clearEnv

public abstract void clearEnv()
Standard daemon method to set envImpl to null.


noteINListChange

public abstract void noteINListChange(int nINs)
Called whenever INs are added to, or removed from, the INList.


addEnvironment

public abstract void addEnvironment(EnvironmentImpl envImpl)
Only supported by SharedEvictor.


removeEnvironment

public abstract void removeEnvironment(EnvironmentImpl envImpl)
Only supported by SharedEvictor.


checkEnvs

public abstract boolean checkEnvs(java.util.Set<EnvironmentImpl> envs)
Only supported by SharedEvictor.


getLogger

abstract java.util.logging.Logger getLogger()

startBatch

abstract long startBatch()
                  throws DatabaseException
Perform class-specific batch processing: Initialize iterator, perform UtilizationTracker eviction, etc. No latches may be held when this method is called. startBatch must be called before getMaxINsPerBatch.

Throws:
DatabaseException

getMaxINsPerBatch

abstract int getMaxINsPerBatch()
Returns the approximate number of total INs in the INList(s). One eviction batch will scan at most this number of INs. If zero is returned, selectIN will not be called. startBatch must be called before getMaxINsPerBatch.


getNextIN

abstract IN getNextIN()
Returns the next IN in the INList(s), wrapping if necessary.


getScanIterator

abstract java.util.Iterator<IN> getScanIterator()

setScanIterator

abstract void setScanIterator(java.util.Iterator<IN> iter)


Copyright (c) 2004,2008 Oracle. All rights reserved.