Modifier and Type | Class and Description |
---|---|
(package private) static class |
DatabaseImpl.ComparatorReader
Utility class for converting bytes to compartor or Class.
|
(package private) static class |
DatabaseImpl.StatsAccumulator |
Modifier and Type | Field and Description |
---|---|
static boolean |
forceTreeWalkForTruncateAndRemove
For unit testing, setting this field to true will force a walk of the
tree to count utilization during truncate/remove, rather than using the
per-database info.
|
Constructor and Description |
---|
DatabaseImpl()
Create an empty database object for initialization from the log.
|
DatabaseImpl(Locker locker,
java.lang.String dbName,
DatabaseId id,
EnvironmentImpl envImpl,
DatabaseConfig dbConfig)
Create a database object for a new database.
|
Modifier and Type | Method and Description |
---|---|
void |
addReferringHandle(Database db)
Add a referring handle
|
boolean |
allowReplicaWrite()
Used to determine whether to throw ReplicaWriteException when a write to
this database is attempted.
|
(package private) static java.lang.Object |
bytesToObject(byte[] bytes,
java.lang.String comparatorType,
java.lang.ClassLoader loader)
Converts an arbitrary serialized byte array to an object.
|
void |
clearKeyPrefixing() |
void |
clearUtilizationRepairDone()
Is public for unit testing.
|
DatabaseImpl |
cloneDatabase()
Create a clone of this database that can be used as the new empty
database when truncating this database.
|
static byte[] |
comparatorToBytes(java.util.Comparator<byte[]> comparator,
boolean byClassName,
java.lang.String comparatorType)
Converts a comparator object to a serialized byte array, converting to
a class name String object if byClassName is true.
|
int |
compareEntries(DatabaseEntry entry1,
DatabaseEntry entry2,
boolean duplicates) |
long |
count()
Count entries in the database including dups, but don't dirty the cache.
|
void |
countObsoleteDb(BaseUtilizationTracker tracker,
long mapLnLsn)
Counts all active LSNs in a database as obsolete.
|
(package private) void |
decrementUseCount()
Decrements the use count of this DB, allowing it to be evicted if the
use count reaches zero.
|
(package private) static void |
dumpFlags(java.lang.StringBuilder sb,
boolean verbose,
byte flags) |
void |
dumpLog(java.lang.StringBuilder sb,
boolean verbose)
Write the object into the string buffer for log dumping.
|
java.lang.String |
dumpString(int nSpaces) |
int |
estimateDataSize(byte[] key)
Returns an estimate of the data size for LNs in this database, or -1 if
an estimate is unknown.
|
Database |
findPrimaryDatabase()
For this secondary database return the primary that it is associated
with, or null if not associated with any primary.
|
void |
finishDeleteProcessing()
Release the INs for the deleted database, count all log entries for this
database as obsolete, delete the MapLN, and set the state to DELETED.
|
(package private) void |
finishedINListHarvest()
Should be called by the SortedLSNTreeWalker when it is finished with
the INList.
|
int |
getAdditionalTreeMemorySize()
Returns the tree memory size that should be added to MAPLN_OVERHEAD.
|
int |
getBinDeltaPercent() |
int |
getBinMaxDeltas() |
java.util.Comparator<byte[]> |
getBtreeComparator()
This comparator should not be used directly for comparisons.
|
boolean |
getBtreeComparatorByClass() |
EnvironmentImpl |
getDbEnvironment() |
DbFileSummaryMap |
getDbFileSummaries()
For unit testing.
|
DbFileSummary |
getDbFileSummary(java.lang.Long fileNum,
boolean willModify)
Returns the DbFileSummary for the given file, allocates it if necessary
and budgeted memory for any changes.
|
DbType |
getDbType() |
java.lang.String |
getDebugName()
Returns the DB name for debugging and error messages.
|
CacheMode |
getDefaultCacheMode()
Returns the default cache mode for this database.
|
java.util.Comparator<byte[]> |
getDuplicateComparator()
This comparator should not be used directly for comparisons.
|
boolean |
getDuplicateComparatorByClass() |
boolean |
getDupsConverted() |
CacheMode |
getEffectiveCacheMode(CacheMode cacheModeParam)
Returns the effective cache mode to use for a cursor operation, based on
the given non-null cache mode parameter.
|
DatabaseStats |
getEmptyStats() |
EnvironmentImpl |
getEnvironmentImpl() |
long |
getEofLsn() |
DatabaseId |
getId() |
java.util.Comparator<byte[]> |
getKeyComparator()
Should always be used when comparing keys for this database.
|
boolean |
getKeyPrefixing() |
static boolean |
getKeyPrefixing(byte flagVal)
Returns true if the flagVal enables the KeyPrefixing, used to create
ReplicatedDatabaseConfig after reading a NameLNLogEntry.
|
int |
getLogSize()
This log entry type is configured to perform marshaling (getLogSize and
writeToLog) under the write log mutex.
|
java.lang.String |
getName() |
int |
getNodeMaxTreeEntries() |
(package private) DbOpReplicationContext |
getOperationRepContext(DbOperationType operationType)
Convenience overloading.
|
(package private) DbOpReplicationContext |
getOperationRepContext(DbOperationType operationType,
DatabaseId oldDbId)
Return a ReplicationContext that includes information on how to
logically replicate database operations.
|
(package private) int |
getReferringHandleCount() |
java.util.Set<Database> |
getReferringHandles()
Returns a copy of the referring database handles.
|
ReplicationContext |
getRepContext()
Return a ReplicationContext that will indicate if this operation
should broadcast data records for this database as part the replication
stream.
|
boolean |
getSortedDuplicates() |
static boolean |
getSortedDuplicates(byte flagVal) |
long |
getTransactionId() |
Tree |
getTree() |
long |
getTreeAdminMemory()
Figure out how much memory is used by the DbFileSummaryMap.
|
java.util.List<Trigger> |
getTriggers()
This method should be the only method used to obtain triggers after
reading the MapLN from the log.
|
boolean |
getUtilizationRepairDone()
Is public for unit testing.
|
void |
handleClosed(boolean doSyncDw,
boolean deleteTempDb)
Called after a handle onto this DB is closed.
|
boolean |
hasOpenHandles()
Returns whether one or more handles are open.
|
boolean |
hasUserTriggers() |
(package private) void |
incrementUseCount()
Increments the use count of this DB to prevent it from being evicted.
|
static java.util.Comparator<byte[]> |
instantiateComparator(java.lang.Class<? extends java.util.Comparator<byte[]>> comparatorClass,
java.lang.String comparatorType)
Used both to read from the log and to validate a comparator when set in
DatabaseConfig.
|
java.util.Comparator<byte[]> |
instantiateComparator(java.util.Comparator<byte[]> comparator,
java.lang.String comparatorType)
Used to validate a comparator when set in DatabaseConfig.
|
boolean |
isCheckpointNeeded()
Returns whether this database's MapLN must be flushed during a
checkpoint.
|
(package private) boolean |
isDebugNameAvailable()
Returns whether getDebugName returns a DB name rather than a DB ID.
|
boolean |
isDeferredWriteMode() |
boolean |
isDeleted() |
boolean |
isDeleteFinished() |
boolean |
isDirtyUtilization()
Returns whether this database has new (unflushed) utilization info.
|
boolean |
isDurableDeferredWrite() |
boolean |
isInternalDb() |
boolean |
isInUse()
Returns whether this DB is in use and cannot be evicted.
|
(package private) boolean |
isInUseDuringDbRemove()
Checks whether a database is in use during a remove or truncate database
operation.
|
boolean |
isReplicated() |
boolean |
isTemporary() |
static boolean |
isTemporary(byte flagVal) |
boolean |
isTransactional() |
boolean |
logicalEquals(Loggable other) |
int |
noteWriteHandleClose()
Decrements the write count and returns the updated value.
|
int |
noteWriteHandleOpen()
Increments the write count and returns the updated value.
|
static byte[] |
objectToBytes(java.lang.Object obj,
java.lang.String comparatorType)
Converts an arbitrary object to a serialized byte array.
|
PreloadStats |
preload(PreloadConfig config)
Preload the cache, using up to maxBytes bytes or maxMillsecs msec.
|
void |
readFromLog(java.nio.ByteBuffer itemBuffer,
int entryVersion)
Initialize this object from the data in itemBuf.
|
void |
releaseTreeAdminMemory()
Update memory budgets when this databaseImpl is closed and will never be
accessed again or when it is still open when its owning MapLN will be
garbage collected, due to eviction or recovery.
|
boolean |
removeDbFileSummaries(java.util.Collection<java.lang.Long> fileNums)
Removes the DbFileSummary for the given set of files.
|
void |
removeReferringHandle(Database db)
Decrement the reference count.
|
boolean |
setBtreeComparator(java.util.Comparator<byte[]> comparator,
boolean byClassName)
Set the btree comparison function for this database.
|
void |
setCacheMode(CacheMode mode)
Sets the default mode for this database (all handles).
|
void |
setCacheModeStrategy(CacheModeStrategy strategy)
Sets the default strategy for this database (all handles).
|
void |
setConfigProperties(Locker locker,
java.lang.String dbName,
DatabaseConfig dbConfig,
EnvironmentImpl envImpl) |
void |
setDebugDatabaseName(java.lang.String debugName) |
void |
setDeferredWrite(boolean durableDeferredWrite)
Sets the deferred write property for the first opened handle.
|
void |
setDirtyUtilization()
Sets utilization dirty in order to force the MapLN to be flushed later.
|
boolean |
setDuplicateComparator(java.util.Comparator<byte[]> comparator,
boolean byClassName)
Set the duplicate comparison function for this database.
|
void |
setDupsConverted() |
void |
setEnvironmentImpl(EnvironmentImpl envImpl)
Set the db environment after reading in the DatabaseImpl from the log.
|
(package private) void |
setId(DatabaseId id) |
void |
setIsReplicatedBit() |
void |
setKeyPrefixing() |
void |
setNodeMaxTreeEntries(int newNodeMaxTreeEntries) |
void |
setPendingDeletedHook(TestHook<?> hook) |
void |
setSortedDuplicates() |
void |
setTransactional(boolean transactional)
Sets the transactional property for the first opened handle.
|
(package private) void |
setTree(Tree tree) |
boolean |
setTriggers(Locker locker,
java.lang.String dbName,
java.util.List<Trigger> newTriggers,
boolean overridePersistentTriggers)
Sets the list of triggers associated with the database.
|
void |
startAndFinishDelete()
Perform the entire two-step database deletion.
|
void |
startDeleteProcessing()
The delete cleanup is starting.
|
DatabaseStats |
stat(StatsConfig config) |
void |
sync(boolean flushLog)
Flush all dirty nodes for this database to disk.
|
boolean |
unknownReplicated() |
boolean |
verify(VerifyConfig config,
DatabaseStats emptyStats) |
void |
writeToLog(java.nio.ByteBuffer logBuffer)
Serialize this object into the buffer.
|
public static boolean forceTreeWalkForTruncateAndRemove
public DatabaseImpl(Locker locker, java.lang.String dbName, DatabaseId id, EnvironmentImpl envImpl, DatabaseConfig dbConfig) throws DatabaseException
DatabaseException
public DatabaseImpl()
public void setConfigProperties(Locker locker, java.lang.String dbName, DatabaseConfig dbConfig, EnvironmentImpl envImpl)
public void setDebugDatabaseName(java.lang.String debugName)
public java.lang.String getDebugName()
boolean isDebugNameAvailable()
public void setPendingDeletedHook(TestHook<?> hook)
public DatabaseImpl cloneDatabase()
public Tree getTree()
void setTree(Tree tree)
public DatabaseId getId()
void setId(DatabaseId id)
public long getEofLsn()
public boolean isTransactional()
public void setTransactional(boolean transactional)
public boolean isTemporary()
public static boolean isTemporary(byte flagVal)
public boolean isInternalDb()
public DbType getDbType()
public boolean isDurableDeferredWrite()
public boolean isDeferredWriteMode()
public void setDeferredWrite(boolean durableDeferredWrite)
public boolean getSortedDuplicates()
public static boolean getSortedDuplicates(byte flagVal)
public void setSortedDuplicates()
public boolean getDupsConverted()
public void setDupsConverted()
public java.util.List<Trigger> getTriggers()
public boolean hasUserTriggers()
public boolean getKeyPrefixing()
public static boolean getKeyPrefixing(byte flagVal)
public void setKeyPrefixing()
public void clearKeyPrefixing()
public boolean isReplicated()
public boolean unknownReplicated()
public void setIsReplicatedBit()
public boolean getUtilizationRepairDone()
public void clearUtilizationRepairDone()
public int getNodeMaxTreeEntries()
public void setNodeMaxTreeEntries(int newNodeMaxTreeEntries)
public boolean allowReplicaWrite()
public int estimateDataSize(byte[] key)
public void setCacheMode(CacheMode mode)
public void setCacheModeStrategy(CacheModeStrategy strategy)
public CacheMode getDefaultCacheMode()
public CacheMode getEffectiveCacheMode(CacheMode cacheModeParam)
public int getAdditionalTreeMemorySize()
public boolean setDuplicateComparator(java.util.Comparator<byte[]> comparator, boolean byClassName) throws DatabaseException
comparator
- - The Duplicate Comparison function.DatabaseException
public boolean setTriggers(Locker locker, java.lang.String dbName, java.util.List<Trigger> newTriggers, boolean overridePersistentTriggers)
dbName
- pass it in since it may not be available during database
creationnewTriggers
- the triggers to associate with the databaseoverridePersistentTriggers
- whether to overwrite persistent
triggersPersistentTrigger
was changed, and therefore
may need to be stored.public boolean setBtreeComparator(java.util.Comparator<byte[]> comparator, boolean byClassName) throws DatabaseException
comparator
- - The btree Comparison function.DatabaseException
public java.util.Comparator<byte[]> getBtreeComparator()
public java.util.Comparator<byte[]> getDuplicateComparator()
public java.util.Comparator<byte[]> getKeyComparator()
public boolean getBtreeComparatorByClass()
public boolean getDuplicateComparatorByClass()
public void setEnvironmentImpl(EnvironmentImpl envImpl)
public EnvironmentImpl getEnvironmentImpl()
public EnvironmentImpl getDbEnvironment()
public boolean hasOpenHandles()
public void addReferringHandle(Database db)
public void removeReferringHandle(Database db)
public java.util.Set<Database> getReferringHandles()
public void handleClosed(boolean doSyncDw, boolean deleteTempDb) throws DatabaseException
DatabaseException
public long getTreeAdminMemory()
public void releaseTreeAdminMemory()
int getReferringHandleCount()
void incrementUseCount()
public int noteWriteHandleOpen()
public int noteWriteHandleClose()
void decrementUseCount()
public boolean isInUse()
boolean isInUseDuringDbRemove()
public void sync(boolean flushLog) throws DatabaseException
java.lang.UnsupportedOperationException
- via Database.sync.DatabaseException
public Database findPrimaryDatabase()
public java.lang.String getName() throws DatabaseException
DatabaseException
public DbFileSummary getDbFileSummary(java.lang.Long fileNum, boolean willModify)
Must be called under the log write latch.
willModify
- if true, the caller will modify the utilization info.public boolean removeDbFileSummaries(java.util.Collection<java.lang.Long> fileNums)
Must be called under the log write latch.
public DbFileSummaryMap getDbFileSummaries()
public boolean isDirtyUtilization()
public void setDirtyUtilization()
public boolean isCheckpointNeeded()
public boolean isDeleted()
public boolean isDeleteFinished()
public void startDeleteProcessing()
void finishedINListHarvest()
public void startAndFinishDelete() throws DatabaseException
DatabaseException
public void finishDeleteProcessing() throws DatabaseException
DatabaseException
public void countObsoleteDb(BaseUtilizationTracker tracker, long mapLnLsn)
mapLnLsn
- is the LSN of the MapLN when called via recovery,
otherwise is NULL_LSN.
Must be called under the log write latch or during recovery.
public DatabaseStats stat(StatsConfig config) throws DatabaseException
DatabaseException
public boolean verify(VerifyConfig config, DatabaseStats emptyStats) throws DatabaseException
DatabaseException
public DatabaseStats getEmptyStats()
public PreloadStats preload(PreloadConfig config) throws DatabaseException
java.lang.IllegalArgumentException
- via Database.preloadDatabaseException
public long count() throws DatabaseException
DatabaseException
public java.lang.String dumpString(int nSpaces)
public int getLogSize()
getLogSize
in interface Loggable
Loggable.getLogSize()
public void writeToLog(java.nio.ByteBuffer logBuffer)
Loggable
writeToLog
in interface Loggable
logBuffer
- is the destination bufferLoggable.writeToLog(java.nio.ByteBuffer)
public void readFromLog(java.nio.ByteBuffer itemBuffer, int entryVersion)
Loggable
readFromLog
in interface Loggable
Loggable.readFromLog(java.nio.ByteBuffer, int)
public void dumpLog(java.lang.StringBuilder sb, boolean verbose)
Loggable
dumpLog
in interface Loggable
sb
- destination string bufferverbose
- if true, dump the full, verbose versionLoggable.dumpLog(java.lang.StringBuilder, boolean)
static void dumpFlags(java.lang.StringBuilder sb, boolean verbose, byte flags)
public long getTransactionId()
getTransactionId
in interface Loggable
Loggable.getTransactionId()
public boolean logicalEquals(Loggable other)
logicalEquals
in interface Loggable
Always return false, this item should never be compared.
public static java.util.Comparator<byte[]> instantiateComparator(java.lang.Class<? extends java.util.Comparator<byte[]>> comparatorClass, java.lang.String comparatorType)
public java.util.Comparator<byte[]> instantiateComparator(java.util.Comparator<byte[]> comparator, java.lang.String comparatorType) throws DatabaseException
DatabaseException
public static byte[] comparatorToBytes(java.util.Comparator<byte[]> comparator, boolean byClassName, java.lang.String comparatorType)
EnvironmentFailureException
- if the object cannot be serialized.public static byte[] objectToBytes(java.lang.Object obj, java.lang.String comparatorType)
static java.lang.Object bytesToObject(byte[] bytes, java.lang.String comparatorType, java.lang.ClassLoader loader)
public int compareEntries(DatabaseEntry entry1, DatabaseEntry entry2, boolean duplicates)
public int getBinDeltaPercent()
public int getBinMaxDeltas()
public ReplicationContext getRepContext()
DbOpReplicationContext getOperationRepContext(DbOperationType operationType, DatabaseId oldDbId)
DbOpReplicationContext getOperationRepContext(DbOperationType operationType)
operationType
- getOperationRepContext(DbOperationType, DatabaseId)
Copyright (c) 2004-2012 Oracle. All rights reserved.