public class DbTree extends Object implements Loggable
| Modifier and Type | Class and Description |
|---|---|
static class |
DbTree.NeedRepLockerException
Thrown by lockNameLN when an incorrect locker was used via auto-commit.
|
static class |
DbTree.TruncateDbResult |
| Modifier and Type | Field and Description |
|---|---|
static DatabaseId |
ID_DB_ID |
static DatabaseId |
NAME_DB_ID |
static long |
NEG_DB_ID_START |
| Constructor and Description |
|---|
DbTree()
Create a dbTree from the log.
|
DbTree(EnvironmentImpl env,
boolean replicationIntended,
boolean preserveVLSN)
Create a new dbTree for a new environment.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearAutoRepairReservedFilesDone() |
void |
close()
Release resources and update memory budget.
|
DatabaseImpl |
createDb(Locker locker,
String databaseName,
DatabaseConfig dbConfig,
HandleLocker handleLocker)
Creates a new database object given a database name.
|
DatabaseImpl |
createInternalDb(Locker locker,
String databaseName,
DatabaseConfig dbConfig)
Create a database for internal use.
|
DatabaseImpl |
createReplicaDb(Locker locker,
String databaseName,
DatabaseConfig dbConfig,
NameLN replicatedLN,
ReplicationContext repContext)
Create a replicated database on this replica node.
|
DatabaseImpl |
dbRemove(Locker locker,
String databaseName,
DatabaseId checkId)
Stand alone and Master invocations.
|
DatabaseImpl |
dbRename(Locker locker,
String databaseName,
String newName)
Stand alone and Master invocations.
|
void |
deleteMapLN(DatabaseId id) |
void |
dump()
For debugging.
|
void |
dumpLog(StringBuilder sb,
boolean verbose)
Write the object into the string buffer for log dumping.
|
DatabaseImpl |
getDb(DatabaseId dbId)
Get a database object based on an id only.
|
DatabaseImpl |
getDb(DatabaseId dbId,
long lockTimeout)
Get a database object based on an id only.
|
DatabaseImpl |
getDb(DatabaseId dbId,
long lockTimeout,
Map<DatabaseId,DatabaseImpl> dbCache)
Get a database object based on an id only, caching the id-db mapping in
the given map.
|
DatabaseImpl |
getDb(Locker nameLocker,
String databaseName,
HandleLocker handleLocker,
boolean writeLock)
Get a database object given a database name.
|
DatabaseId |
getDbIdFromName(Locker nameLocker,
String databaseName,
HandleLocker handleLocker,
boolean writeLock)
Get a database ID given a database name.
|
List<String> |
getDbNames() |
Map<DatabaseId,String> |
getDbNamesAndIds() |
int |
getHighestLevel(DatabaseImpl dbImpl) |
DatabaseImpl |
getIdDatabaseImpl() |
int |
getInitialLogVersion()
Returns the initial log version at the time the env was created, or -1
if the env was created prior to log version 15.
|
long |
getLastLocalDbId()
The last allocated local and replicated db ids are used for ckpts.
|
long |
getLastReplicatedDbId() |
int |
getLogSize() |
DatabaseImpl |
getNameDatabaseImpl() |
long |
getTransactionId() |
boolean |
isAutoRepairReservedFilesDone() |
static boolean |
isReservedDbName(String name)
Returns true if the name is a reserved JE database name.
|
boolean |
logicalEquals(Loggable other) |
void |
modifyDbRoot(DatabaseImpl db)
Write the MapLN to disk.
|
void |
modifyDbRoot(DatabaseImpl db,
long ifBeforeLsn,
boolean mustExist)
Write a MapLN to the log in order to:
- propagate a root change
- save per-db utilization information
- save database config information.
|
DatabaseImpl |
openNonRepInternalDB(DbType dbType)
Opens (or creates if it does not exist) an internal, non-replicated DB.
|
void |
optionalModifyDbRoot(DatabaseImpl db)
Check deferred write settings before writing the MapLN.
|
void |
readFromLog(ByteBuffer itemBuffer,
int entryVersion)
Initialize this object from the data in itemBuf.
|
void |
rebuildINListMapDb()
Rebuild the IN list after recovery.
|
void |
releaseDb(DatabaseImpl db)
Decrements the use count of the given DB, allowing it to be evicted if
the use count reaches zero.
|
void |
releaseDbs(Map<DatabaseId,DatabaseImpl> dbCache)
Calls releaseDb for all DBs in the given map of DatabaseId to
DatabaseImpl.
|
void |
removeReplicaDb(Locker locker,
String databaseName,
DatabaseId checkId,
DbOpReplicationContext repContext)
Replica invocations.
|
DatabaseImpl |
renameReplicaDb(Locker locker,
String databaseName,
String newName,
NameLN replicatedLN,
DbOpReplicationContext repContext)
Replica invocations.
|
void |
setAutoRepairReservedFilesDone() |
void |
setLastDbId(long lastReplicatedDbId,
long lastLocalDbId)
Initialize the db ids, from recovery.
|
String |
toString() |
DbTree.TruncateDbResult |
truncate(Locker locker,
String databaseName,
boolean returnCount) |
DbTree.TruncateDbResult |
truncateReplicaDb(Locker locker,
String databaseName,
boolean returnCount,
NameLN replicatedLN,
DbOpReplicationContext repContext) |
void |
updateFromReplay(DatabaseId replayDbId) |
void |
updateNameLN(Locker locker,
String dbName,
DbOpReplicationContext repContext)
Update the NameLN for the DatabaseImpl when the DatabaseConfig changes.
|
void |
writeToLog(ByteBuffer logBuffer)
This log entry type is configured to perform marshaling (getLogSize and
writeToLog) under the write log mutex.
|
public static final DatabaseId ID_DB_ID
public static final DatabaseId NAME_DB_ID
public static final long NEG_DB_ID_START
public DbTree()
public DbTree(EnvironmentImpl env, boolean replicationIntended, boolean preserveVLSN) throws DatabaseException
DatabaseExceptionpublic long getLastLocalDbId()
public long getLastReplicatedDbId()
public void setLastDbId(long lastReplicatedDbId,
long lastLocalDbId)
public void updateFromReplay(DatabaseId replayDbId)
public DatabaseImpl createDb(Locker locker, String databaseName, DatabaseConfig dbConfig, HandleLocker handleLocker) throws DatabaseException
DatabaseExceptionpublic DatabaseImpl createInternalDb(Locker locker, String databaseName, DatabaseConfig dbConfig) throws DatabaseException
DatabaseExceptionpublic DatabaseImpl createReplicaDb(Locker locker, String databaseName, DatabaseConfig dbConfig, NameLN replicatedLN, ReplicationContext repContext) throws DatabaseException
DatabaseExceptionpublic DatabaseImpl openNonRepInternalDB(DbType dbType)
public void optionalModifyDbRoot(DatabaseImpl db) throws DatabaseException
db - the database represented by this MapLNDatabaseExceptionpublic void modifyDbRoot(DatabaseImpl db) throws DatabaseException
db - the database represented by this MapLNDatabaseExceptionpublic void modifyDbRoot(DatabaseImpl db, long ifBeforeLsn, boolean mustExist) throws DatabaseException
db - the database whose root is held by this MapLNifBeforeLsn - if argument is not NULL_LSN, only do the write if
this MapLN's current LSN is before isBeforeLSN.mustExist - if true, throw DatabaseException if the DB does not
exist; if false, silently do nothing.DatabaseExceptionpublic void updateNameLN(Locker locker, String dbName, DbOpReplicationContext repContext) throws LockConflictException
locker - the locker used to update the NameLNdbName - the name of the database whose corresponding NameLN needs
to be updatedrepContext - information used while replaying a NameLNLogEntry on
the replicas, it's null on masterLockConflictExceptionpublic DatabaseImpl dbRename(Locker locker, String databaseName, String newName) throws DatabaseNotFoundException, DbTree.NeedRepLockerException
public DatabaseImpl renameReplicaDb(Locker locker, String databaseName, String newName, NameLN replicatedLN, DbOpReplicationContext repContext) throws DatabaseNotFoundException
public DatabaseImpl dbRemove(Locker locker, String databaseName, DatabaseId checkId) throws DatabaseNotFoundException, DbTree.NeedRepLockerException
public void removeReplicaDb(Locker locker, String databaseName, DatabaseId checkId, DbOpReplicationContext repContext) throws DatabaseNotFoundException
public DbTree.TruncateDbResult truncate(Locker locker, String databaseName, boolean returnCount) throws DatabaseNotFoundException, DbTree.NeedRepLockerException
public DbTree.TruncateDbResult truncateReplicaDb(Locker locker, String databaseName, boolean returnCount, NameLN replicatedLN, DbOpReplicationContext repContext) throws DatabaseNotFoundException
public void deleteMapLN(DatabaseId id) throws DatabaseException
DatabaseExceptionpublic DatabaseImpl getDb(Locker nameLocker, String databaseName, HandleLocker handleLocker, boolean writeLock) throws DatabaseException
nameLocker - is used to access the NameLN. As always, a NullTxn
is used to access the MapLN.databaseName - target databaseDatabaseExceptionpublic DatabaseId getDbIdFromName(Locker nameLocker, String databaseName, HandleLocker handleLocker, boolean writeLock)
public DatabaseImpl getDb(DatabaseId dbId) throws DatabaseException
DatabaseExceptionpublic DatabaseImpl getDb(DatabaseId dbId, long lockTimeout, Map<DatabaseId,DatabaseImpl> dbCache) throws DatabaseException
DatabaseExceptionpublic DatabaseImpl getDb(DatabaseId dbId, long lockTimeout) throws DatabaseException
DatabaseExceptionpublic void releaseDb(DatabaseImpl db)
public void releaseDbs(Map<DatabaseId,DatabaseImpl> dbCache)
public void rebuildINListMapDb()
throws DatabaseException
DatabaseExceptionpublic Map<DatabaseId,String> getDbNamesAndIds() throws DatabaseException
DatabaseExceptionpublic List<String> getDbNames() throws DatabaseException
DatabaseExceptionpublic static boolean isReservedDbName(String name)
public int getHighestLevel(DatabaseImpl dbImpl) throws DatabaseException
DatabaseExceptionpublic DatabaseImpl getIdDatabaseImpl()
public DatabaseImpl getNameDatabaseImpl()
public boolean isAutoRepairReservedFilesDone()
public void setAutoRepairReservedFilesDone()
public void clearAutoRepairReservedFilesDone()
public int getInitialLogVersion()
public void close()
public int getLogSize()
getLogSize in interface LoggableLoggable.getLogSize()public void writeToLog(ByteBuffer logBuffer)
writeToLog in interface LoggablelogBuffer - is the destination bufferLoggable.writeToLog(java.nio.ByteBuffer)public void readFromLog(ByteBuffer itemBuffer, int entryVersion)
LoggablereadFromLog in interface LoggableitemBuffer - the source bufferentryVersion - the log version of the dataLoggable.readFromLog(java.nio.ByteBuffer, int)public void dumpLog(StringBuilder sb, boolean verbose)
LoggabledumpLog in interface Loggablesb - destination string bufferverbose - if true, dump the full, verbose versionLoggable.dumpLog(java.lang.StringBuilder, boolean)public long getTransactionId()
getTransactionId in interface LoggableLoggable.getTransactionId()public boolean logicalEquals(Loggable other)
logicalEquals in interface LoggableAlways return false, this item should never be compared.public void dump()
Copyright © 2024. All rights reserved.