public class UtilizationProfile extends java.lang.Object implements EnvConfigObserver
Unlike the UtilizationTracker, the UP is not accessed under the log write latch and is instead synchronized on itself for protecting the cache. It is not accessed during the primary data access path, except for when flushing (writing) file summary LNs. This occurs in the following cases:
The cache is populated by the RecoveryManager just before performing the initial checkpoint. The UP must be open and populated in order to respond to requests to flush summaries and to evict tracked detail, even if the cleaner is disabled.
WARNING: While synchronized on this object, eviction is not permitted. If it were, this could cause deadlocks because the order of locking would be the UP object and then the evictor. During normal eviction the order is to first lock the evictor and then the UP, when evicting tracked detail.
The methods in this class synchronize to protect the cached summary information. Some methods also access the UP database. However, because eviction must not occur while synchronized, UP database access is not performed while synchronized except in one case: when inserting a new summary record. In that case we disallow eviction during the database operation.
| Modifier and Type | Field and Description |
|---|---|
(package private) int |
minAge
Minumum age to qualify for cleaning.
|
(package private) int |
minFileUtilization
Minimum utilization threshold for an individual log file that triggers
cleaning.
|
(package private) int |
minUtilization
Minimum overall utilization threshold that triggers cleaning.
|
| Constructor and Description |
|---|
UtilizationProfile(EnvironmentImpl env,
UtilizationTracker tracker)
Creates an empty UP.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearCache()
Clears the cache of file summary info.
|
(package private) void |
close()
Update memory budgets when this profile is closed and will never be
accessed again.
|
void |
envConfigUpdate(DbConfigManager cm,
EnvironmentMutableConfig ignore)
Process notifications of mutable property changes.
|
void |
flushFileSummary(TrackedFileSummary tfs)
Updates and stores the FileSummary for a given tracked file, if flushing
of the summary is allowed.
|
void |
flushFileUtilization(java.util.Collection<TrackedFileSummary> activeFiles)
Flush a FileSummaryLN node for each TrackedFileSummary that is currently
active in the given tracker.
|
void |
flushLocalTracker(LocalUtilizationTracker localTracker)
Count the given locally tracked info as obsolete and then log the file
and database info..
|
(package private) java.lang.Long |
getBestFileForCleaning(FileSelector fileSelector,
boolean forceCleaning,
java.util.Set<java.lang.Long> lowUtilizationFiles,
boolean isBacklog)
Returns the best file that qualifies for cleaning, or null if no file
qualifies.
|
(package private) java.lang.Long |
getCheapestFileToClean(java.util.SortedSet<java.lang.Long> files)
Returns the cheapest file to clean from the given list of files.
|
DatabaseImpl |
getFileSummaryDb()
For unit testing.
|
java.util.SortedMap<java.lang.Long,FileSummary> |
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) TrackedFileSummary |
getObsoleteDetail(java.lang.Long fileNum,
PackedOffsets packedOffsets,
boolean logUpdate)
Returns the stored/packed obsolete offsets and the tracked obsolete
offsets for the given file.
|
(package private) long |
getTotalLogSize()
Returns an approximation of the total log size.
|
boolean |
isRMWFixEnabled() |
boolean |
populateCache()
Populate the profile for file selection.
|
(package private) void |
removeFile(java.lang.Long fileNum,
java.util.Set<DatabaseId> databases)
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.
|
boolean |
verifyFileSummaryDatabase()
Checks that all FSLN offsets are indeed obsolete.
|
int minUtilization
int minFileUtilization
int minAge
public UtilizationProfile(EnvironmentImpl env, UtilizationTracker tracker) throws DatabaseException
DatabaseExceptionpublic void envConfigUpdate(DbConfigManager cm, EnvironmentMutableConfig ignore) throws DatabaseException
envConfigUpdate in interface EnvConfigObserverDatabaseExceptionpublic boolean isRMWFixEnabled()
int getNumberOfFiles()
throws DatabaseException
DatabaseExceptionlong getTotalLogSize()
java.lang.Long getCheapestFileToClean(java.util.SortedSet<java.lang.Long> files)
throws DatabaseException
DatabaseExceptionjava.lang.Long getBestFileForCleaning(FileSelector fileSelector, boolean forceCleaning, java.util.Set<java.lang.Long> lowUtilizationFiles, boolean isBacklog) throws DatabaseException
fileSelector - is used to determine valid cleaning candidates.forceCleaning - is true to always select a file, even if its
utilization is above the minimum utilization threshold.lowUtilizationFiles - is a returned set of files that are below the
minimum utilization threshold.DatabaseExceptionpublic static int utilization(long obsoleteSize,
long totalSize)
public void flushLocalTracker(LocalUtilizationTracker localTracker) throws DatabaseException
DatabaseExceptionpublic void flushFileUtilization(java.util.Collection<TrackedFileSummary> activeFiles) throws DatabaseException
DatabaseExceptionpublic java.util.SortedMap<java.lang.Long,FileSummary> getFileSummaryMap(boolean includeTrackedFiles) throws DatabaseException
DatabaseExceptionpublic void clearCache()
void removeFile(java.lang.Long fileNum,
java.util.Set<DatabaseId> databases)
throws DatabaseException
DatabaseExceptionpublic void flushFileSummary(TrackedFileSummary tfs) throws DatabaseException
DatabaseExceptionTrackedFileSummary getObsoleteDetail(java.lang.Long fileNum, PackedOffsets packedOffsets, boolean logUpdate) throws DatabaseException
logUpdate - if true, log any updates to the utilization profile. If
false, only retrieve the new information.DatabaseExceptionpublic boolean populateCache()
throws DatabaseException
DatabaseExceptionpublic DatabaseImpl getFileSummaryDb()
public boolean verifyFileSummaryDatabase()
throws DatabaseException
DatabaseExceptionvoid close()
Copyright (c) 2004,2008 Oracle. All rights reserved.