com.sleepycat.je.cleaner
Class UtilizationProfile

java.lang.Object
  extended bycom.sleepycat.je.cleaner.UtilizationProfile

public class UtilizationProfile
extends Object

The UP tracks utilization summary information for all log files.

Unlike the UtilizationTracker, the UP is not accessed under the log write latch and is instead synchronized on itself. It is accessed by four other entities: the cleaner, the checkpointer, the compressor, and the recovery manager. It is not accessed during the primary data access path, except for when committing the Database truncate and remove operations.

The recovery manager calls cacheFileSummary when it reads a file summary LN. The cleaner will ask the UP to populate its cache in order to determine the total log size or to select the best file for cleaning. The UP will then read all records in the UP database that are not already cached. The checkpointer calls putFileSummary to write file summary LNs to the log.

Because this object is synchronized it is possible that the cleaner will hold up the checkpointer if the cleaner is populating its cache or calculating the best file, and the checkpointer tries to write the file summary LNs to the log. This blocking is acceptable. Deadlocks will not occur since calls are always from the checkpointer or cleaner to the UP, and not in the other direction.


Constructor Summary
UtilizationProfile(EnvironmentImpl env, UtilizationTracker tracker)
          Creates an empty UP.
 
Method Summary
 void clearCache()
          Clears the cache of file summary info.
(package private)  Long getBestFileForCleaning(Set excludeFiles, boolean aggressive)
          Returns the best file that qualifies for cleaning, or null if no file qualifies.
 SortedMap getFileSummaryMap(boolean includeTrackedFiles)
          Returns a copy of the current file summary map, optionally including tracked summary information, for use by the DbSpace utility and by unit tests.
(package private)  int getNumberOfFiles()
          Returns the number of files in the profile.
(package private)  int getObsoleteAge()
          Returns the IN obsolete age config setting.
 long getTotalLogSize(boolean calcIfNecessary)
          Returns the total byte size of all log files in the environment, or -1 if the size is not available and calcIfNecessary is false.
 FileSummary putFileSummary(TrackedFileSummary trackedSummary)
          Updates and stores the FileSummary for a given tracked file and returns the updated summary.
(package private)  void removeFile(Long fileNum)
          Removes a file from the utilization database and the profile, after it has been deleted by the cleaner.
static int utilization(long obsoleteSize, long totalSize)
          Calculate the utilization percentage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UtilizationProfile

public UtilizationProfile(EnvironmentImpl env,
                          UtilizationTracker tracker)
                   throws DatabaseException
Creates an empty UP.

Method Detail

getObsoleteAge

final int getObsoleteAge()
Returns the IN obsolete age config setting.


getNumberOfFiles

int getNumberOfFiles()
               throws DatabaseException
Returns the number of files in the profile.

Throws:
DatabaseException

getBestFileForCleaning

Long getBestFileForCleaning(Set excludeFiles,
                            boolean aggressive)
                      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.

Throws:
DatabaseException

utilization

public static int utilization(long obsoleteSize,
                              long totalSize)
Calculate the utilization percentage.


getTotalLogSize

public long getTotalLogSize(boolean calcIfNecessary)
                     throws DatabaseException
Returns the total byte size of all log files in the environment, or -1 if the size is not available and calcIfNecessary is false. FindBugs will complain about this not being synchronized, but it's ok.

Throws:
DatabaseException

getFileSummaryMap

public SortedMap getFileSummaryMap(boolean includeTrackedFiles)
                            throws DatabaseException
Returns a copy of the current file summary map, optionally including tracked summary information, for use by the DbSpace utility and by unit tests. The returned map's key is a Long file number and its value is a FileSummary.

Throws:
DatabaseException

clearCache

public void clearCache()
Clears the cache of file summary info. The cache starts out unpopulated and is populated on the first call to getBestFileForCleaning.


removeFile

void removeFile(Long fileNum)
          throws DatabaseException
Removes a file from the utilization database and the profile, after it has been deleted by the cleaner.

Throws:
DatabaseException

putFileSummary

public FileSummary putFileSummary(TrackedFileSummary trackedSummary)
                           throws DatabaseException
Updates and stores the FileSummary for a given tracked file and returns the updated summary.

Throws:
DatabaseException


Copyright 2004 Sleepycat, Inc. All Rights Reserved.