com.sleepycat.je.cleaner
Class Cleaner

java.lang.Object
  extended by com.sleepycat.je.utilint.DaemonThread
      extended by com.sleepycat.je.cleaner.Cleaner
All Implemented Interfaces:
Runnable

public class Cleaner
extends DaemonThread

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.


Field Summary
 
Fields inherited from class com.sleepycat.je.utilint.DaemonThread
name, nWakeupRequests, workQueue, workQueueLatch
 
Constructor Summary
Cleaner(EnvironmentImpl env, long waitTime, String name)
           
 
Method Summary
 void addToQueue(Object o)
          Cleaner doesn't have a work queue so just throw an exception if it's ever called.
 void clearEnv()
           
 int doClean(boolean invokedFromDaemon, boolean cleanMultipleFiles, boolean forceCleaning)
          Cleans selected files and returns the number of files cleaned.
 Set[] getFilesAtCheckpointStart()
          Returns a copy of the cleaned and processed files at the time a checkpoint starts.
 void handleNoMigrationLogging(BIN bin)
          Add a BIN entry to the pending LN set.
 boolean isEvictable(BIN bin, int index)
          Returns whether the given BIN entry may be stripped by the evictor.
 void loadStats(StatsConfig config, EnvironmentStats stat)
          Load stats.
 void migrateLNs(BIN bin)
          This method should be called just before logging a BIN.
protected  int nDeadlockRetries()
          Return the number of retries when a deadlock exception occurs.
 void onWakeup()
          Called whenever the daemon thread wakes up from a sleep.
 String toString()
           
 void updateFilesAtCheckpointEnd(Set[] files)
          When a checkpoint is complete, update the files that were returned at the beginning of the checkpoint.
 
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
 

Constructor Detail

Cleaner

public Cleaner(EnvironmentImpl env,
               long waitTime,
               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
Cleaner 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

onWakeup

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

Specified by:
onWakeup in class DaemonThread
Throws:
DatabaseException

doClean

public int doClean(boolean invokedFromDaemon,
                   boolean cleanMultipleFiles,
                   boolean forceCleaning)
            throws DatabaseException
Cleans selected files and returns the number of files cleaned. May be called by the daemon thread or programatically.

Parameters:
invokedFromDaemon - currently has no effect.
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 deleted, not including files cleaned unsuccessfully.
Throws:
DatabaseException

getFilesAtCheckpointStart

public Set[] 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(Set[] files)
                                throws DatabaseException
When a checkpoint is complete, update the files that were returned at the beginning of the checkpoint.

Throws:
DatabaseException

handleNoMigrationLogging

public void handleNoMigrationLogging(BIN bin)
                              throws DatabaseException
Add a BIN entry to the pending LN set. This is used in the case where a split occurs, and we don't want to migrate the LN during the split for performance reasons.

Throws:
DatabaseException

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.


migrateLNs

public void migrateLNs(BIN bin)
                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 handleNoMigrationLogging method must be called.

Parameters:
bin - is the latched BIN. The latch will not be released by this method.
Throws:
DatabaseException


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