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:
Runnable

public 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
static class Evictor.EvictProfile
           
 
Field Summary
(package private)  Evictor.EvictProfile evictProfile
           
static String SOURCE_CRITICAL
           
static String SOURCE_DAEMON
           
static String SOURCE_MANUAL
           
 
Fields inherited from class com.sleepycat.je.utilint.DaemonThread
name, nWakeupRequests, workQueue, workQueueLatch
 
Constructor Summary
Evictor(EnvironmentImpl envImpl, String name)
           
 
Method Summary
 void addToQueue(Object o)
          Evictor doesn't have a work queue so just throw an exception if it's ever called.
 void alert()
          Wakeup the evictor only if it's not already active.
 void clearEnv()
           
 void doCriticalEviction()
          Do a check on whether synchronous eviction is needed.
 void doEvict(String source)
          May be called by the evictor thread on wakeup or programatically.
(package private)  long evictBatch(String source, long requiredEvictBytes)
          Each iteration will latch and unlatch the major INList, and will attempt to evict requiredEvictBytes, but will give up after a complete pass over the major INList.
(package private)  IN getNextNode()
          Used by unit tests.
(package private)  boolean isRunnable(String source)
          Return true if eviction should happen.
 void loadStats(StatsConfig config, EnvironmentStats stat)
          Load stats.
protected  int 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.
 void onWakeup()
          Called whenever the daemon thread wakes up from a sleep.
 String toString()
           
 
Methods inherited from class com.sleepycat.je.utilint.DaemonThread
addToQueueAlreadyLatched, getNWakeupRequests, getQueueSize, getThread, isRunning, isShutdownRequested, requestShutdown, run, runOrPause, shutdown, 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 String SOURCE_DAEMON
See Also:
Constant Field Values

SOURCE_MANUAL

public static final String SOURCE_MANUAL
See Also:
Constant Field Values

SOURCE_CRITICAL

public static final String SOURCE_CRITICAL
See Also:
Constant Field Values

evictProfile

Evictor.EvictProfile evictProfile
Constructor Detail

Evictor

public Evictor(EnvironmentImpl envImpl,
               String name)
        throws DatabaseException
Throws:
DatabaseException
Method Detail

toString

public String toString()
Overrides:
toString in class DaemonThread

addToQueue

public void addToQueue(Object o)
                throws DatabaseException
Evictor doesn't have a work queue so just throw an exception if it's ever called.

Overrides:
addToQueue in class DaemonThread
Throws:
DatabaseException

loadStats

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

Throws:
DatabaseException

clearEnv

public void clearEnv()

nDeadlockRetries

protected int 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(String source)
             throws DatabaseException
May be called by the evictor thread on wakeup or programatically.

Throws:
DatabaseException

doCriticalEviction

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

Throws:
DatabaseException

evictBatch

long evictBatch(String source,
                long requiredEvictBytes)
          throws DatabaseException
Each iteration will latch and unlatch the major INList, and will attempt to evict requiredEvictBytes, but will give up after a complete pass over the major INList. Releasing the latch is important because it provides an opportunity for to add the minor INList to the major INList.

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

isRunnable

boolean isRunnable(String source)
             throws DatabaseException
Return true if eviction should happen.

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.


getNextNode

IN getNextNode()
Used by unit tests.



Copyright 2004-2005 Sleepycat, Inc. All Rights Reserved.