com.sleepycat.je.cleaner
Class FileSelector

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

public class FileSelector
extends Object

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


Nested Class Summary
static class FileSelector.CheckpointStartCleanerState
          Holds copy of all checkpoint-dependent cleaner state.
 
Constructor Summary
FileSelector()
           
 
Method Summary
(package private)  void addCleanedFile(Long fileNum, Set<DatabaseId> databases, VLSN lastVlsn, MemoryBudget budget)
          When cleaning is complete, move the file from the BEING_CLEANED to CLEANED.
(package private)  boolean addPendingDB(DatabaseId dbId)
          Adds the given DatabaseId to the pending DB set.
(package private)  boolean addPendingLN(long originalLsn, LN ln, DatabaseId dbId, byte[] key)
          Adds the given LN info to the pending LN set.
(package private)  void close(MemoryBudget budget)
          Update memory budgets when the environment is closed and will never be accessed again.
(package private)  SortedSet<Long> copySafeToDeleteFiles()
          Returns a copy of the SAFE_TO_DELETE files, or null if there are none.
(package private)  int getBacklog()
          Returns the number of files waiting TO_BE_CLEANED.
(package private)  Set<DatabaseId> getCleanedDatabases(Collection<Long> fileNums)
          Returns a copy of the databases for a collection of cleaned files, or null if there are none.
(package private)  FileSelector.CheckpointStartCleanerState getFilesAtCheckpointStart()
          Returns a copy of the CLEANED and FULLY_PROCESSED files at the time a checkpoint starts.
(package private)  VLSN getLastVLSN(Long fileNum)
          Returns the last VLSN for a cleaned file.
(package private)  Set<Long> getLowUtilizationFiles()
          Returns a read-only set of low utilization 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)  Map<Long,LNInfo> getPendingLNs()
          Returns a map of LNInfo for LNs that could not be migrated in a prior cleaning attempt, or null if no LNs are pending.
(package private)  Set<Long> getToBeCleanedFiles()
          Returns a read-only copy of TO_BE_CLEANED files that can be accessed without synchronization.
 void injectFileForCleaning(Long fileNum)
          For unit testing.
(package private)  boolean isFileCleaningInProgress(Long fileNum)
          Returns whether the file is in any stage of the cleaning process.
(package private)  StatGroup loadStats()
          Loads file selection stats.
(package private)  void putBackFileForCleaning(Long fileNum)
          When file cleaning is aborted, move the file back from BEING_CLEANED to TO_BE_CLEANED.
(package private)  void removeAllFileReferences(Long fileNum, MemoryBudget budget)
          Removes all references to a file.
(package private)  void removeDeletedFile(Long fileNum, MemoryBudget budget)
          Removes file information after the log 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 originalLsn)
          Removes the LN for the given LSN from the pending LN set.
(package private)  Long selectFileForCleaning(UtilizationCalculator calculator, SortedMap<Long,FileSummary> fileSummaryMap, boolean forceCleaning, boolean calcLowUtilizationFiles, int maxBatchFiles)
          Returns the best file that qualifies for cleaning, or null if no file qualifies.
(package private)  Long selectFileForCorrection(UtilizationCalculator calculator, SortedMap<Long,FileSummary> fileSummaryMap)
          Returns the best file for correcting utilization, or null if correction is not needed.
 String toString()
           
(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 status.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileSelector

FileSelector()
Method Detail

selectFileForCleaning

Long selectFileForCleaning(UtilizationCalculator calculator,
                           SortedMap<Long,FileSummary> fileSummaryMap,
                           boolean forceCleaning,
                           boolean calcLowUtilizationFiles,
                           int maxBatchFiles)
Returns the best file that qualifies for cleaning, or null if no file qualifies.

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.

selectFileForCorrection

Long selectFileForCorrection(UtilizationCalculator calculator,
                             SortedMap<Long,FileSummary> fileSummaryMap)
Returns the best file for correcting utilization, or null if correction is not needed. Should only be called when selectFileForCleaning returns null.


isFileCleaningInProgress

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


removeAllFileReferences

void removeAllFileReferences(Long fileNum,
                             MemoryBudget budget)
Removes all references to a file.


putBackFileForCleaning

void putBackFileForCleaning(Long fileNum)
When file cleaning is aborted, move the file back from BEING_CLEANED to TO_BE_CLEANED.


injectFileForCleaning

public void injectFileForCleaning(Long fileNum)
For unit testing.


addCleanedFile

void addCleanedFile(Long fileNum,
                    Set<DatabaseId> databases,
                    VLSN lastVlsn,
                    MemoryBudget budget)
When cleaning is complete, move the file from the BEING_CLEANED to CLEANED.


getLowUtilizationFiles

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


getToBeCleanedFiles

Set<Long> getToBeCleanedFiles()
Returns a read-only copy of TO_BE_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 status.


addPendingLN

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


getPendingLNs

Map<Long,LNInfo> getPendingLNs()
Returns a map 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 originalLsn)
Removes the LN for the given LSN 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

SortedSet<Long> copySafeToDeleteFiles()
Returns a copy of the SAFE_TO_DELETE files, or null if there are none.


getCleanedDatabases

Set<DatabaseId> getCleanedDatabases(Collection<Long> fileNums)
Returns a copy of the databases for a collection of cleaned files, or null if there are none.


getLastVLSN

VLSN getLastVLSN(Long fileNum)
Returns the last VLSN for a cleaned file.


removeDeletedFile

void removeDeletedFile(Long fileNum,
                       MemoryBudget budget)
Removes file information after the log file itself has finally been deleted.


close

void close(MemoryBudget budget)
Update memory budgets when the environment is closed and will never be accessed again.


loadStats

StatGroup loadStats()
Loads file selection stats.


toString

public String toString()
Overrides:
toString in class Object


Copyright (c) 2004-2012 Oracle. All rights reserved.