com.sleepycat.je.cleaner
Class Cleaner

java.lang.Object
  extended by com.sleepycat.je.cleaner.Cleaner
All Implemented Interfaces:
EnvConfigObserver, DaemonRunner

public class Cleaner
extends java.lang.Object
implements DaemonRunner, EnvConfigObserver

The Cleaner is responsible for effectively garbage collecting the JE log. It looks through log files and locates log records (IN's and LN's of all flavors) that are superceded by later versions. Those that are "current" are propagated to a newer log file so that older log files can be deleted.


Constructor Summary
Cleaner(EnvironmentImpl env, java.lang.String name)
           
 
Method Summary
 void clearDeleteProhibited()
           
 void close()
          Release resources and update memory budget.
 int doClean(boolean cleanMultipleFiles, boolean forceCleaning)
          Cleans selected files and returns the number of files cleaned.
 void envConfigUpdate(DbConfigManager cm, EnvironmentMutableConfig ignore)
          Process notifications of mutable property changes.
 boolean getFetchObsoleteSize()
           
 FileSelector.CheckpointStartCleanerState getFilesAtCheckpointStart()
          Returns a copy of the cleaned and processed files at the time a checkpoint starts.
 int getNWakeupRequests()
           
 UtilizationProfile getUtilizationProfile()
           
 UtilizationTracker getUtilizationTracker()
           
 boolean isEvictable(BIN bin, int index)
          Returns whether the given BIN entry may be stripped by the evictor.
 void lazyMigrateDupCountLN(DIN din, ChildReference dclRef, boolean proactiveMigration)
          This method should be called just before logging a root DIN.
 void lazyMigrateLNs(BIN bin, boolean proactiveMigration, boolean backgroundIO)
          This method should be called just before logging a BIN.
 void loadStats(StatsConfig config, EnvironmentStats stat)
          Load stats.
 void requestShutdown()
           
 void runOrPause(boolean run)
           
 void setDeleteProhibited()
           
 void setExceptionListener(ExceptionListener exceptionListener)
           
 void shutdown()
           
 void updateFilesAtCheckpointEnd(FileSelector.CheckpointStartCleanerState info)
          When a checkpoint is complete, update the files that were returned at the beginning of the checkpoint.
 void updateReadOnlyFileCollections()
          Update the lowUtilizationFiles and mustBeCleanedFiles fields with new read-only collections, and update the backlog file count.
 void wakeup()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cleaner

public Cleaner(EnvironmentImpl env,
               java.lang.String name)
        throws DatabaseException
Throws:
DatabaseException
Method Detail

envConfigUpdate

public void envConfigUpdate(DbConfigManager cm,
                            EnvironmentMutableConfig ignore)
                     throws DatabaseException
Process notifications of mutable property changes.

Specified by:
envConfigUpdate in interface EnvConfigObserver
Throws:
DatabaseException

getUtilizationTracker

public UtilizationTracker getUtilizationTracker()

getUtilizationProfile

public UtilizationProfile getUtilizationProfile()

getFetchObsoleteSize

public boolean getFetchObsoleteSize()

runOrPause

public void runOrPause(boolean run)
Specified by:
runOrPause in interface DaemonRunner

wakeup

public void wakeup()

requestShutdown

public void requestShutdown()
Specified by:
requestShutdown in interface DaemonRunner

shutdown

public void shutdown()
Specified by:
shutdown in interface DaemonRunner

getNWakeupRequests

public int getNWakeupRequests()
Specified by:
getNWakeupRequests in interface DaemonRunner

setExceptionListener

public void setExceptionListener(ExceptionListener exceptionListener)
Specified by:
setExceptionListener in interface DaemonRunner

doClean

public int doClean(boolean cleanMultipleFiles,
                   boolean forceCleaning)
            throws DatabaseException
Cleans selected files and returns the number of files cleaned. This method is not invoked by a deamon thread, it is programatically.

Parameters:
cleanMultipleFiles - is true to clean until we're under budget, or false to clean at most one file.
forceCleaning - is true to clean even if we're not under the utilization threshold.
Returns:
the number of files cleaned, not including files cleaned unsuccessfully.
Throws:
DatabaseException

loadStats

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

Throws:
DatabaseException

setDeleteProhibited

public void setDeleteProhibited()

clearDeleteProhibited

public void clearDeleteProhibited()

getFilesAtCheckpointStart

public FileSelector.CheckpointStartCleanerState getFilesAtCheckpointStart()
                                                                   throws DatabaseException
Returns a copy of the cleaned and processed files at the time a checkpoint starts.

If non-null is returned, the checkpoint should flush an extra level, and addCheckpointedFiles() should be called when the checkpoint is complete.

Throws:
DatabaseException

updateFilesAtCheckpointEnd

public void updateFilesAtCheckpointEnd(FileSelector.CheckpointStartCleanerState info)
                                throws DatabaseException
When a checkpoint is complete, update the files that were returned at the beginning of the checkpoint.

Throws:
DatabaseException

updateReadOnlyFileCollections

public void updateReadOnlyFileCollections()
Update the lowUtilizationFiles and mustBeCleanedFiles fields with new read-only collections, and update the backlog file count.


isEvictable

public boolean isEvictable(BIN bin,
                           int index)
Returns whether the given BIN entry may be stripped by the evictor. True is always returned if the BIN is not dirty. False is returned if the BIN is dirty and the entry will be migrated soon. Note that the BIN may or may not be latched when this method is called. Returning the wrong answer is OK in that case (it will be called again later when latched), but an exception should not occur.


lazyMigrateLNs

public void lazyMigrateLNs(BIN bin,
                           boolean proactiveMigration,
                           boolean backgroundIO)
                    throws DatabaseException
This method should be called just before logging a BIN. LNs will be migrated if the MIGRATE flag is set, or if they are in a file to be cleaned, or if the LNs qualify according to the rules for cluster and clusterAll.

On return this method guarantees that no MIGRATE flag will be set on any child entry. If this method is *not* called before logging a BIN, then the addPendingLNs method must be called.

Parameters:
bin - is the latched BIN. The latch will not be released by this method.
proactiveMigration - perform proactive migration if needed; this is false during a split, to reduce the delay in the user operation.
Throws:
DatabaseException

lazyMigrateDupCountLN

public void lazyMigrateDupCountLN(DIN din,
                                  ChildReference dclRef,
                                  boolean proactiveMigration)
                           throws DatabaseException
This method should be called just before logging a root DIN. The DupCountLN will be migrated if the MIGRATE flag is set, or if it is in a file to be cleaned, or if the LN qualifies according to the rules for cluster and clusterAll.

On return this method guarantees that the MIGRATE flag will not be set on the child entry. If this method is *not* called before logging a root DIN, then the addPendingDupCountLN method must be called.

Parameters:
din - is the latched DIN. The latch will not be released by this method.
dclRef - is the reference to the DupCountLN.
proactiveMigration - perform proactive migration if needed; this is false during a split, to reduce the delay in the user operation.
Throws:
DatabaseException

close

public void close()
Release resources and update memory budget. Should only be called when this environment is closed and will never be accessed again.