com.sleepycat.je.cleaner
Class BaseUtilizationTracker

java.lang.Object
  extended by com.sleepycat.je.cleaner.BaseUtilizationTracker
Direct Known Subclasses:
BaseLocalUtilizationTracker, UtilizationTracker

public abstract class BaseUtilizationTracker
extends Object

Shared implementation for all utilization trackers. The base implementation keeps track of per-file utilization info only. Subclasses keep track of per-database info.


Field Summary
(package private)  long bytesSinceActivate
          Bytes written to the log since the cleaner was last awoken.
(package private)  Cleaner cleaner
           
(package private)  EnvironmentImpl env
           
 
Constructor Summary
BaseUtilizationTracker(EnvironmentImpl env, Cleaner cleaner)
           
 
Method Summary
(package private)  void close()
          Update memory budgets when this tracker is closed and will never be accessed again.
(package private)  boolean countNew(long lsn, Object databaseKey, LogEntryType type, int size)
          Counts the addition of all new log entries including LNs, and returns whether the cleaner should be woken.
(package private)  void countObsolete(long lsn, Object databaseKey, LogEntryType type, int size, boolean countPerFile, boolean countPerDb, boolean trackOffset, boolean checkDupOffsets)
          Counts an obsolete node by incrementing the obsolete count and size.
 void countObsoleteDb(DbFileSummaryMap dbFileSummaries, long mapLnLsn)
          Counts all active LSNs in a database as obsolete in the per-file utilization summaries.
(package private) abstract  DbFileSummary getDbFileSummary(Object databaseKey, long fileNum)
          Returns a DbFileSummary for the given database key and file number, adding an empty one if the file is not already being tracked.
 EnvironmentImpl getEnvironment()
           
(package private)  TrackedFileSummary getFileSummary(long fileNum)
          Returns a tracked file for the given file number, adding an empty one if the file is not already being tracked.
 TrackedFileSummary getTrackedFile(long fileNum)
          Returns one file from the snapshot of tracked files, or null if the given file number is not in the snapshot array.
 Collection<TrackedFileSummary> getTrackedFiles()
          Returns a snapshot of the files being tracked as of the last time a log entry was added.
(package private)  boolean isFileUncounted(Long fileNum, long lsn)
          Returns whether file summary information for the given LSN is not already counted.
static boolean isLNType(LogEntryType type)
          Returns whether the given type is an LN; a null type is assumed to be an LN.
(package private)  void resetFile(TrackedFileSummary fileSummary)
          Called after the FileSummaryLN is written to the log during checkpoint.
static boolean trackObsoleteInfo(LogEntryType type)
          Returns whether obsoleteness is tracked for the given type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

env

EnvironmentImpl env

cleaner

Cleaner cleaner

bytesSinceActivate

volatile long bytesSinceActivate
Bytes written to the log since the cleaner was last awoken. This field is incremented under the log write latch, which is safe. However, it is also set to zero by UtilizationTracker.activateCleaner, outside the log write latch, and therefore it must be volatile here. [#21106]

Constructor Detail

BaseUtilizationTracker

BaseUtilizationTracker(EnvironmentImpl env,
                       Cleaner cleaner)
Method Detail

getEnvironment

public EnvironmentImpl getEnvironment()

getTrackedFiles

public Collection<TrackedFileSummary> getTrackedFiles()
Returns a snapshot of the files being tracked as of the last time a log entry was added. The summary info returned is the delta since the last checkpoint, not the grand totals, and is approximate since it is changing in real time. This method may be called without holding the log write latch.

If files are added or removed from the collection of tracked files in real time, the returned collection will not be changed since it is a snapshot. But the objects contained in the collection are live and will be updated in real time under the log write latch. The collection and the objects in the collection should not be modified by the caller.


getTrackedFile

public TrackedFileSummary getTrackedFile(long fileNum)
Returns one file from the snapshot of tracked files, or null if the given file number is not in the snapshot array.

See Also:
getTrackedFiles()

countNew

final boolean countNew(long lsn,
                       Object databaseKey,
                       LogEntryType type,
                       int size)
Counts the addition of all new log entries including LNs, and returns whether the cleaner should be woken.

For the global tracker, must be called under the log write latch.


countObsolete

final void countObsolete(long lsn,
                         Object databaseKey,
                         LogEntryType type,
                         int size,
                         boolean countPerFile,
                         boolean countPerDb,
                         boolean trackOffset,
                         boolean checkDupOffsets)
Counts an obsolete node by incrementing the obsolete count and size. Tracks the LSN offset if trackOffset is true and the offset is non-zero.

For the global tracker, must be called under the log write latch.


countObsoleteDb

public void countObsoleteDb(DbFileSummaryMap dbFileSummaries,
                            long mapLnLsn)
Counts all active LSNs in a database as obsolete in the per-file utilization summaries. This method is called during database remove/truncate or when replaying those operations during recovery.

For the global tracker, must be called under the log write latch.

Parameters:
dbFileSummaries - the map of Long file number to DbFileSummary for a database that is being deleted.
mapLnLsn - is the LSN of the MapLN when recovery is replaying the truncate/remove, or NULL_LSN when called outside of recovery; obsolete totals should only be counted when this LSN is prior to the LSN of the FileSummaryLN for the file being counted.

isFileUncounted

boolean isFileUncounted(Long fileNum,
                        long lsn)
Returns whether file summary information for the given LSN is not already counted. Outside of recovery, always returns true. For recovery, is overridden by RecoveryUtilizationTracker and returns whether the FileSummaryLN for the given file is prior to the given LSN. .


getDbFileSummary

abstract DbFileSummary getDbFileSummary(Object databaseKey,
                                        long fileNum)
Returns a DbFileSummary for the given database key and file number, adding an empty one if the file is not already being tracked.

This method is implemented by subclasses which interpret the databaseKey as either the DatabaseImpl or a DatabaseId.

For the global tracker, must be called under the log write latch.

Returns:
the summary, or null if the DB should not be tracked because the file has been deleted.

getFileSummary

TrackedFileSummary getFileSummary(long fileNum)
Returns a tracked file for the given file number, adding an empty one if the file is not already being tracked.

For the global tracker, must be called under the log write latch.


resetFile

void resetFile(TrackedFileSummary fileSummary)
Called after the FileSummaryLN is written to the log during checkpoint.

We keep the active file summary in the tracked file map, but we remove older files to prevent unbounded growth of the map.

Must be called under the log write latch.


trackObsoleteInfo

public static boolean trackObsoleteInfo(LogEntryType type)
Returns whether obsoleteness is tracked for the given type. Obsoleteness is tracked for node types and BINDeltas. A null type is assumed to be an LN.


isLNType

public static boolean isLNType(LogEntryType type)
Returns whether the given type is an LN; a null type is assumed to be an LN.


close

void close()
Update memory budgets when this tracker is closed and will never be accessed again.



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