com.sleepycat.je.cleaner
Class RecoveryUtilizationTracker

java.lang.Object
  extended by com.sleepycat.je.cleaner.BaseUtilizationTracker
      extended by com.sleepycat.je.cleaner.BaseLocalUtilizationTracker
          extended by com.sleepycat.je.cleaner.RecoveryUtilizationTracker

public class RecoveryUtilizationTracker
extends BaseLocalUtilizationTracker

Accumulates changes to the utilization profile during recovery.

Per-database information is keyed by DatabaseId because the DatabaseImpl is not always available during recovery. In fact this is the only reason that a "local" tracker is used during recovery -- to avoid requiring that the DatabaseImpl is available, which is necessary to use the "global" UtilizationTracker. There is no requirement to accumulate totals locally, since recovery is single threaded.

When finished with this object, its information should be added to the Environment's UtilizationTracker and DatabaseImpl objects by calling transferToUtilizationTracker. This is done at the end of recovery, just prior to the checkpoint. It does not have to be done under the log write latch, since recovery is single threaded.


Field Summary
 
Fields inherited from class com.sleepycat.je.cleaner.BaseUtilizationTracker
bytesSinceActivate, cleaner, env
 
Constructor Summary
RecoveryUtilizationTracker(EnvironmentImpl env)
           
 
Method Summary
 void countNewLogEntry(long lsn, LogEntryType type, int size, DatabaseId dbId)
          Counts the addition of all new log entries including LNs.
 boolean countObsoleteIfUncounted(long oldLsn, long newLsn, LogEntryType type, int size, DatabaseId dbId, boolean countExact)
          Counts the oldLsn of a node obsolete if it has not already been counted at the point of newLsn in the log.
 void countObsoleteUnconditional(long lsn, LogEntryType type, int size, DatabaseId dbId, boolean countExact)
          Counts the LSN of a node obsolete unconditionally.
(package private)  DatabaseImpl databaseKeyToDatabaseImpl(Object databaseKey)
          Returns the DatabaseImpl from the database key, which in this case is the DatabaseId.
 int fetchLNSize(int size, long lsn)
          Fetches the LN to get its size only if necessary and so configured.
(package private)  boolean isFileUncounted(Long fileNum, long lsn)
          Overrides this method for recovery and returns whether the FileSummaryLN for the given file is prior to the given LSN.
(package private)  void releaseDatabaseImpl(DatabaseImpl db)
          Must release the database, since DbTree.getDb was called by databaseKeyToDatabaseImpl.
 void resetDbInfo(DatabaseId dbId)
          Clears all accmulated utilization info for the given database.
 void resetFileInfo(long fileNum)
          Clears all accmulated utilization info for the given file.
 void saveLastLoggedFileSummaryLN(long fileNum, long lsn)
          Saves the LSN of the last logged FileSummaryLN.
 void saveLastLoggedMapLN(DatabaseId dbId, long lsn)
          Saves the LSN of the last logged MapLN.
 
Methods inherited from class com.sleepycat.je.cleaner.BaseLocalUtilizationTracker
getDatabaseMap, getDbFileSummary, removeDbFileSummaries, transferToUtilizationTracker
 
Methods inherited from class com.sleepycat.je.cleaner.BaseUtilizationTracker
close, countNew, countObsolete, countObsoleteDb, getEnvironment, getFileSummary, getTrackedFile, getTrackedFiles, isLNType, isNodeType, resetFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RecoveryUtilizationTracker

public RecoveryUtilizationTracker(EnvironmentImpl env)
Method Detail

saveLastLoggedFileSummaryLN

public void saveLastLoggedFileSummaryLN(long fileNum,
                                        long lsn)
Saves the LSN of the last logged FileSummaryLN.


saveLastLoggedMapLN

public void saveLastLoggedMapLN(DatabaseId dbId,
                                long lsn)
Saves the LSN of the last logged MapLN.


countNewLogEntry

public void countNewLogEntry(long lsn,
                             LogEntryType type,
                             int size,
                             DatabaseId dbId)
Counts the addition of all new log entries including LNs.


countObsoleteUnconditional

public void countObsoleteUnconditional(long lsn,
                                       LogEntryType type,
                                       int size,
                                       DatabaseId dbId,
                                       boolean countExact)
Counts the LSN of a node obsolete unconditionally.

Even when countExact is true, duplicate offsets are not checked (no assertion is fired) because recovery is known to count the same LSN offset twice in certain circumstances.


countObsoleteIfUncounted

public boolean countObsoleteIfUncounted(long oldLsn,
                                        long newLsn,
                                        LogEntryType type,
                                        int size,
                                        DatabaseId dbId,
                                        boolean countExact)
Counts the oldLsn of a node obsolete if it has not already been counted at the point of newLsn in the log.

Even when countExact is true, duplicate offsets are not checked (no assertion is fired) because recovery is known to count the same LSN offset twice in certain circumstances.

Returns:
whether the file was previously uncounted.

fetchLNSize

public int fetchLNSize(int size,
                       long lsn)
                throws DatabaseException
Fetches the LN to get its size only if necessary and so configured.

Throws:
DatabaseException

isFileUncounted

boolean isFileUncounted(Long fileNum,
                        long lsn)
Overrides this method for recovery and returns whether the FileSummaryLN for the given file is prior to the given LSN.

Overrides:
isFileUncounted in class BaseUtilizationTracker

resetFileInfo

public void resetFileInfo(long fileNum)
Clears all accmulated utilization info for the given file.


resetDbInfo

public void resetDbInfo(DatabaseId dbId)
Clears all accmulated utilization info for the given database.


databaseKeyToDatabaseImpl

DatabaseImpl databaseKeyToDatabaseImpl(Object databaseKey)
                                 throws DatabaseException
Returns the DatabaseImpl from the database key, which in this case is the DatabaseId.

Specified by:
databaseKeyToDatabaseImpl in class BaseLocalUtilizationTracker
Throws:
DatabaseException

releaseDatabaseImpl

void releaseDatabaseImpl(DatabaseImpl db)
Must release the database, since DbTree.getDb was called by databaseKeyToDatabaseImpl.

Specified by:
releaseDatabaseImpl in class BaseLocalUtilizationTracker


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