com.sleepycat.je.cleaner
Class FileSelector

java.lang.Object
  extended by com.sleepycat.je.cleaner.FileSelector

public class FileSelector
extends java.lang.Object

Keeps track of the status of files for which cleaning is in progres.


Nested Class Summary
static class FileSelector.CheckpointStartCleanerState
           
 
Constructor Summary
FileSelector()
           
 
Method Summary
(package private)  void addCleanedFile(java.lang.Long fileNum, java.util.Set deferredWriteDbs)
          When cleaning is complete, move the file from the being-cleaned set to the cleaned set.
(package private)  boolean addPendingDB(DatabaseId dbId)
          Adds the given DatabaseId to the pending DB set.
(package private)  boolean addPendingLN(LN ln, DatabaseId dbId, byte[] key, byte[] dupKey)
          Adds the given LN info to the pending LN set.
(package private)  java.util.Set copySafeToDeleteFiles()
          Returns a copy of the safe-to-delete files.
(package private)  int getBacklog()
          Returns the number of files waiting to-be-cleaned.
(package private)  FileSelector.CheckpointStartCleanerState getFilesAtCheckpointStart()
          Returns a copy of the cleaned and fully-processed files at the time a checkpoint starts.
(package private)  java.util.Set getLowUtilizationFiles()
          Returns a read-only set of low utilization files that can be accessed without synchronization.
(package private)  java.util.Set getMustBeCleanedFiles()
          Returns a read-only copy of to-be-cleaned and being-cleaned files that can be accessed without synchronization.
(package private)  DatabaseId[] getPendingDBs()
          Returns an array of DatabaseIds for DBs that were pending deletion in a prior cleaning attempt, or null if no DBs are pending.
(package private)  LNInfo[] getPendingLNs()
          Returns an array of LNInfo for LNs that could not be migrated in a prior cleaning attempt, or null if no LNs are pending.
(package private)  boolean isFileCleaningInProgress(java.lang.Long file)
          Returns whether the file is in any stage of the cleaning process.
(package private)  void putBackFileForCleaning(java.lang.Long fileNum)
          When file cleaning is aborted, move the file back from the being-cleaned set to the to-be-cleaned set.
(package private)  void removeAllFileReferences(java.lang.Long file)
          Removes all references to a file.
(package private)  void removeDeletedFile(java.lang.Long fileNum)
          Removes file from the safe-to-delete set after the file itself has finally been deleted.
(package private)  void removePendingDB(DatabaseId dbId)
          Removes the DatabaseId from the pending DB set.
(package private)  void removePendingLN(long nodeId)
          Removes the LN for the given node ID from the pending LN set.
(package private)  java.lang.Long selectFileForCleaning(UtilizationProfile profile, boolean forceCleaning, boolean calcLowUtilizationFiles, int maxBatchFiles)
          Returns the best file that qualifies for cleaning, or null if no file qualifies.
(package private)  void updateFilesAtCheckpointEnd(FileSelector.CheckpointStartCleanerState info)
          When a checkpoint is complete, move the previously cleaned and fully-processed files to the checkpointed and safe-to-delete sets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSelector

FileSelector()
Method Detail

selectFileForCleaning

java.lang.Long selectFileForCleaning(UtilizationProfile profile,
                                     boolean forceCleaning,
                                     boolean calcLowUtilizationFiles,
                                     int maxBatchFiles)
                               throws DatabaseException
Returns the best file that qualifies for cleaning, or null if no file qualifies. This method is not thread safe and should only be called from the cleaner thread.

Parameters:
forceCleaning - is true to always select a file, even if its utilization is above the minimum utilization threshold.
calcLowUtilizationFiles - whether to recalculate the set of files that are below the minimum utilization threshold.
maxBatchFiles - is the maximum number of files to be selected at one time, or zero if there is no limit.
Returns:
the next file to be cleaned, or null if no file needs cleaning.
Throws:
DatabaseException

isFileCleaningInProgress

boolean isFileCleaningInProgress(java.lang.Long file)
Returns whether the file is in any stage of the cleaning process.


removeAllFileReferences

void removeAllFileReferences(java.lang.Long file)
Removes all references to a file.


putBackFileForCleaning

void putBackFileForCleaning(java.lang.Long fileNum)
When file cleaning is aborted, move the file back from the being-cleaned set to the to-be-cleaned set.


addCleanedFile

void addCleanedFile(java.lang.Long fileNum,
                    java.util.Set deferredWriteDbs)
When cleaning is complete, move the file from the being-cleaned set to the cleaned set.


getLowUtilizationFiles

java.util.Set getLowUtilizationFiles()
Returns a read-only set of low utilization files that can be accessed without synchronization.


getMustBeCleanedFiles

java.util.Set getMustBeCleanedFiles()
Returns a read-only copy of to-be-cleaned and being-cleaned files that can be accessed without synchronization.


getBacklog

int getBacklog()
Returns the number of files waiting to-be-cleaned.


getFilesAtCheckpointStart

FileSelector.CheckpointStartCleanerState getFilesAtCheckpointStart()
Returns a copy of the cleaned and fully-processed files at the time a checkpoint starts.


updateFilesAtCheckpointEnd

void updateFilesAtCheckpointEnd(FileSelector.CheckpointStartCleanerState info)
When a checkpoint is complete, move the previously cleaned and fully-processed files to the checkpointed and safe-to-delete sets. Also take the dbs that have been synced through this checkpoint off their place at the top of the deferredWriteDb list


addPendingLN

boolean addPendingLN(LN ln,
                     DatabaseId dbId,
                     byte[] key,
                     byte[] dupKey)
Adds the given LN info to the pending LN set.


getPendingLNs

LNInfo[] getPendingLNs()
Returns an array of LNInfo for LNs that could not be migrated in a prior cleaning attempt, or null if no LNs are pending.


removePendingLN

void removePendingLN(long nodeId)
Removes the LN for the given node ID from the pending LN set.


addPendingDB

boolean addPendingDB(DatabaseId dbId)
Adds the given DatabaseId to the pending DB set.


getPendingDBs

DatabaseId[] getPendingDBs()
Returns an array of DatabaseIds for DBs that were pending deletion in a prior cleaning attempt, or null if no DBs are pending.


removePendingDB

void removePendingDB(DatabaseId dbId)
Removes the DatabaseId from the pending DB set.


copySafeToDeleteFiles

java.util.Set copySafeToDeleteFiles()
Returns a copy of the safe-to-delete files.


removeDeletedFile

void removeDeletedFile(java.lang.Long fileNum)
Removes file from the safe-to-delete set after the file itself has finally been deleted.



Copyright 2004,2008 Oracle. All rights reserved.