|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sleepycat.je.dbi.DatabaseImpl
public class DatabaseImpl
The underlying object for a given database.
Nested Class Summary | |
---|---|
(package private) static class |
DatabaseImpl.ComparatorReader
|
(package private) static class |
DatabaseImpl.StatsAccumulator
|
Field Summary | |
---|---|
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 Summary | |
---|---|
DatabaseImpl()
Create an empty database object for initialization from the log. |
|
DatabaseImpl(String dbName,
DatabaseId id,
EnvironmentImpl envImpl,
DatabaseConfig dbConfig)
Create a database object for a new database. |
Method Summary | |
---|---|
void |
addReferringHandle(Database db)
Add a referring handle |
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. |
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(StringBuilder sb,
boolean verbose,
byte flags)
|
void |
dumpLog(StringBuilder sb,
boolean verbose)
Write the object into the string buffer for log dumping. |
String |
dumpString(int nSpaces)
|
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()
|
Comparator<byte[]> |
getBtreeComparator()
|
boolean |
getBtreeComparatorByClass()
|
EnvironmentImpl |
getDbEnvironment()
|
DbFileSummaryMap |
getDbFileSummaries()
For unit testing. |
DbFileSummary |
getDbFileSummary(Long fileNum,
boolean willModify)
Returns the DbFileSummary for the given file, allocates it if necessary and budgeted memory for any changes. |
String |
getDebugName()
|
CacheMode |
getDefaultCacheMode()
Returns the default cache mode for this database. |
Comparator<byte[]> |
getDuplicateComparator()
|
boolean |
getDuplicateComparatorByClass()
|
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()
|
long |
getEofNodeId()
|
DatabaseId |
getId()
|
boolean |
getKeyPrefixing()
|
int |
getLogSize()
This log entry type is configured to perform marshaling (getLogSize and writeToLog) under the write log mutex. |
String |
getName()
|
int |
getNodeMaxDupTreeEntries()
|
int |
getNodeMaxEntries()
|
(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()
|
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. |
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. |
(package private) void |
incrementUseCount()
Increments the use count of this DB to prevent it from being evicted. |
static Comparator<byte[]> |
instantiateComparator(Class<? extends Comparator<byte[]>> comparatorClass,
String comparatorType)
Used both to read from the log and to validate a comparator when set in DatabaseConfig. |
static Comparator<byte[]> |
instantiateComparator(Comparator<byte[]> comparator,
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. |
boolean |
isDeferredWriteMode()
|
boolean |
isDeleted()
|
boolean |
isDeleteFinished()
|
boolean |
isDirtyUtilization()
Returns whether this database has new (unflushed) utilization info. |
boolean |
isDurableDeferredWrite()
|
(package private) 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)
|
static byte[] |
objectToBytes(Object obj,
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(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 |
removeDbFileSummary(Long fileNum)
Removes the DbFileSummary for the given file. |
void |
removeReferringHandle(Database db)
Decrement the reference count. |
boolean |
setBtreeComparator(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 |
setDebugDatabaseName(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(Comparator<byte[]> comparator,
boolean byClassName)
Set the duplicate comparison function for this database. |
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 |
setPendingDeletedHook(TestHook hook)
|
void |
setSortedDuplicates()
|
void |
setTransactional(boolean transactional)
Sets the transactional property for the first opened handle. |
(package private) void |
setTree(Tree tree)
|
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(ByteBuffer logBuffer)
Serialize this object into the buffer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static boolean forceTreeWalkForTruncateAndRemove
Constructor Detail |
---|
public DatabaseImpl(String dbName, DatabaseId id, EnvironmentImpl envImpl, DatabaseConfig dbConfig) throws DatabaseException
DatabaseException
public DatabaseImpl()
Method Detail |
---|
public void setDebugDatabaseName(String debugName)
public String getDebugName()
public void setPendingDeletedHook(TestHook hook)
public DatabaseImpl cloneDatabase()
public Tree getTree()
void setTree(Tree tree)
public DatabaseId getId()
void setId(DatabaseId id)
public long getEofNodeId()
public boolean isTransactional()
public void setTransactional(boolean transactional)
public boolean isTemporary()
public static boolean isTemporary(byte flagVal)
boolean isInternalDb()
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 getKeyPrefixing()
public void setKeyPrefixing()
public void clearKeyPrefixing()
public boolean isReplicated()
public boolean unknownReplicated()
public void setIsReplicatedBit()
public boolean getUtilizationRepairDone()
public void clearUtilizationRepairDone()
public int getNodeMaxEntries()
public int getNodeMaxDupTreeEntries()
public void setCacheMode(CacheMode mode)
public void setCacheModeStrategy(CacheModeStrategy strategy)
public CacheMode getDefaultCacheMode()
public CacheMode getEffectiveCacheMode(CacheMode cacheModeParam)
public int getAdditionalTreeMemorySize()
public boolean setDuplicateComparator(Comparator<byte[]> comparator, boolean byClassName) throws DatabaseException
duplicateComparator
- - The Duplicate Comparison function.
DatabaseException
public boolean setBtreeComparator(Comparator<byte[]> comparator, boolean byClassName) throws DatabaseException
btreeComparator
- - The btree Comparison function.
DatabaseException
public Comparator<byte[]> getBtreeComparator()
public Comparator<byte[]> getDuplicateComparator()
public boolean getBtreeComparatorByClass()
public boolean getDuplicateComparatorByClass()
public void setEnvironmentImpl(EnvironmentImpl envImpl)
public EnvironmentImpl getDbEnvironment()
public boolean hasOpenHandles()
public void addReferringHandle(Database db)
public void removeReferringHandle(Database db)
public Set<Database> getReferringHandles()
public void handleClosed(boolean doSyncDw, boolean deleteTempDb) throws DatabaseException
DatabaseException
public long getTreeAdminMemory()
public void releaseTreeAdminMemory()
int getReferringHandleCount()
void incrementUseCount()
void decrementUseCount()
public boolean isInUse()
boolean isInUseDuringDbRemove()
public void sync(boolean flushLog) throws DatabaseException
UnsupportedOperationException
- via Database.sync.
DatabaseException
public Database findPrimaryDatabase()
public String getName() throws DatabaseException
DatabaseException
public DbFileSummary getDbFileSummary(Long fileNum, boolean willModify)
Must be called under the log write latch.
willModify
- if true, the caller will modify the utilization info.public boolean removeDbFileSummary(Long fileNum)
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
IllegalArgumentException
- via Database.preload
DatabaseException
public long count() throws DatabaseException
DatabaseException
public String dumpString(int nSpaces)
public int getLogSize()
getLogSize
in interface Loggable
Loggable.getLogSize()
public void writeToLog(ByteBuffer logBuffer)
Loggable
writeToLog
in interface Loggable
logBuffer
- is the destination bufferLoggable.writeToLog(java.nio.ByteBuffer)
public void readFromLog(ByteBuffer itemBuffer, int entryVersion)
Loggable
readFromLog
in interface Loggable
Loggable.readFromLog(java.nio.ByteBuffer, int)
public void dumpLog(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(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 Comparator<byte[]> instantiateComparator(Class<? extends Comparator<byte[]>> comparatorClass, String comparatorType)
public static Comparator<byte[]> instantiateComparator(Comparator<byte[]> comparator, String comparatorType) throws DatabaseException
DatabaseException
public static byte[] objectToBytes(Object obj, String comparatorType)
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)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |