public class EnvironmentImpl extends java.lang.Object implements EnvConfigObserver
| Modifier and Type | Field and Description |
|---|---|
static boolean |
IS_DALVIK |
protected LogManager |
logManager |
RunRecoveryException |
SAVED_RRE |
static boolean |
USE_JAVA5_ADLER32 |
| Constructor and Description |
|---|
EnvironmentImpl(java.io.File envHome,
EnvironmentConfig envConfig,
EnvironmentImpl sharedCacheEnv,
boolean replicationIntended)
Create a database environment to represent the data in envHome.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abnormalClose()
Used by tests to close an environment to simulate a crash.
|
void |
acquireAPIReadLock(Locker who) |
void |
acquireAPIWriteLock(int time,
java.util.concurrent.TimeUnit units) |
void |
addConfigObserver(EnvConfigObserver o)
Adds an observer of mutable config changes.
|
void |
addToCompressorQueue(BIN bin,
Key deletedKey,
boolean doWakeup)
Tells the asynchronous IN compressor thread about a BIN with a deleted
entry.
|
void |
addToCompressorQueue(BINReference binRef,
boolean doWakeup)
Tells the asynchronous IN compressor thread about a BINReference with a
deleted entry.
|
void |
addToCompressorQueue(java.util.Collection<BINReference> binRefs,
boolean doWakeup)
Tells the asynchronous IN compressor thread about a collections of
BINReferences with deleted entries.
|
(package private) void |
alertEvictor() |
void |
checkIfInvalid() |
void |
checkImmutablePropsForEquality(EnvironmentConfig config)
Throws an exception if an immutable property is changed.
|
void |
checkNotClosed() |
EnvironmentConfig |
cloneConfig()
Clones the current configuration.
|
EnvironmentMutableConfig |
cloneMutableConfig()
Clones the current mutable configuration.
|
void |
close()
Decrements the reference count and closes the enviornment when it
reaches zero.
|
void |
close(boolean doCheckpoint)
Decrements the reference count and closes the environment when it
reaches zero.
|
void |
closeAfterRunRecovery() |
void |
closeLogger()
Close down the logger.
|
(package private) boolean |
decReferenceCount()
Returns true if the environment should be closed.
|
static void |
decThreadLocalReferenceCount() |
(package private) void |
doClose(boolean doCheckpoint,
boolean doCheckLeaks)
Closes the environment, optionally performing a checkpoint and checking
for resource leaks.
|
(package private) void |
doCloseAfterRunRecovery()
This method must be called while synchronized on DbEnvPool.
|
(package private) void |
doReinit(boolean replicationIntended,
EnvironmentImpl sharedCacheEnv)
This method must be called while synchronized on DbEnvPool.
|
(package private) void |
doSetMutableConfig(EnvironmentMutableConfig config)
This method must be called while synchronized on DbEnvPool.
|
void |
enableDebugLoggingToDbLog()
Add the database log as one of the debug logging destinations when the
logging system is sufficiently initialized.
|
void |
envConfigUpdate(DbConfigManager mgr,
EnvironmentMutableConfig newConfig)
Respond to config updates.
|
long |
forceLogFileFlip()
Flip the log to a new file, forcing an fsync.
|
static int |
getAdler32ChunkSize() |
Checkpointer |
getCheckpointer() |
Cleaner |
getCleaner() |
DbConfigManager |
getConfigManager()
Returns the config manager for the current base configuration.
|
boolean |
getDbEviction()
Returns whether DB/MapLN eviction is enabled.
|
DbTree |
getDbTree() |
java.io.File |
getEnvironmentHome()
Get the environment home directory.
|
Evictor |
getEvictor() |
ExceptionListener |
getExceptionListener() |
static boolean |
getFairLatches() |
FileManager |
getFileManager() |
INCompressor |
getINCompressor()
Return the incompressor.
|
int |
getINCompressorQueueSize() |
INList |
getInMemoryINs() |
RecoveryInfo |
getLastRecoveryInfo()
Info about the last recovery
|
long |
getLockTimeout() |
java.util.logging.Logger |
getLogger() |
LogManager |
getLogManager() |
MemoryBudget |
getMemoryBudget() |
static boolean |
getNoComparators() |
NodeSequence |
getNodeSequence() |
ReplicatorInstance |
getReplicator() |
long |
getRootLsn() |
boolean |
getSharedCache() |
static boolean |
getSharedLatches() |
static int |
getThreadLocalReferenceCount() |
SharedLatch |
getTriggerLatch()
Returns the shared trigger latch.
|
TxnManager |
getTxnManager() |
long |
getTxnTimeout() |
UtilizationProfile |
getUtilizationProfile()
Returns the UtilizationProfile.
|
UtilizationTracker |
getUtilizationTracker()
Returns the UtilizationTracker.
|
(package private) void |
incReferenceCount() |
static void |
incThreadLocalReferenceCount() |
void |
invalidate(java.lang.Error e) |
void |
invalidate(RunRecoveryException e)
Invalidate the environment.
|
boolean |
invokeCheckpoint(CheckpointConfig config,
boolean flushAll,
java.lang.String invokingSource)
Invoke a checkpoint programatically.
|
int |
invokeCleaner() |
boolean |
invokeCompressor()
Invoke a compress programatically.
|
void |
invokeEvictor() |
boolean |
isClosed() |
boolean |
isClosing() |
boolean |
isMemOnly() |
boolean |
isNoLocking() |
boolean |
isOpen() |
boolean |
isReadOnly() |
boolean |
isReplicated()
Return true if this environment is part of a replication group.
|
boolean |
isTransactional() |
void |
lazyCompress(IN in,
LocalUtilizationTracker localTracker)
Do lazy compression at opportune moments.
|
EnvironmentStats |
loadStats(StatsConfig config)
Retrieve and return stat information.
|
LockStats |
lockStat(StatsConfig config)
Retrieve lock statistics
|
void |
logMapTreeRoot()
Logs the map tree root and saves the LSN.
|
void |
logMapTreeRoot(long ifBeforeLsn)
Logs the map tree root, but only if its current LSN is before the
ifBeforeLsn parameter or ifBeforeLsn is NULL_LSN.
|
static boolean |
maybeForceYield()
For stress testing.
|
boolean |
mayNotWrite()
When a RunRecoveryException occurs or the environment is closed, further
writing can cause log corruption.
|
void |
open()
Not much to do, mark state.
|
void |
readMapTreeFromLog(long rootLsn,
boolean replicationIntended)
Set the mapping tree from the log.
|
void |
reinit(boolean replicationIntended)
Reinitialize after an Internal Init copies new *.jdb files into envhome.
|
boolean |
releaseAPIReadLock(Locker who) |
void |
releaseAPIWriteLock() |
void |
removeConfigObserver(EnvConfigObserver o)
Removes an observer of mutable config changes.
|
void |
rewriteMapTreeRoot(long cleanerTargetLsn)
Force a rewrite of the map tree root if required.
|
boolean |
scanLog(long startPosition,
long endPosition,
LogScanConfig config,
LogScanner scanner) |
void |
setBackgroundSleepHook(TestHook hook) |
void |
setExceptionListener(ExceptionListener exceptionListener) |
void |
setMutableConfig(EnvironmentMutableConfig config)
Changes the mutable config properties that are present in the given
config, and notifies all config observer.
|
void |
setReplicator(ReplicatorInstance repInstance) |
void |
setupAPILock() |
(package private) void |
shutdownCheckpointer() |
void |
shutdownCleaner()
public for unit tests.
|
(package private) void |
shutdownEvictor() |
(package private) void |
shutdownINCompressor() |
void |
sleepAfterBackgroundIO()
If the sleep backlog is non-zero (set by updateBackgroundReads or
updateBackgroundWrites), sleep for the configured interval and decrement
the backlog.
|
void |
stopDaemons()
For unit testing -- shuts down daemons completely but leaves environment
usable since environment references are not nulled out.
|
Txn |
txnBegin(Transaction parent,
TransactionConfig txnConfig)
Transactional services.
|
TransactionStats |
txnStat(StatsConfig config)
Retrieve txn statistics
|
void |
updateBackgroundReads(int nReads)
If a background read limit has been configured and that limit is
exceeded when the cumulative total is incremented by the given number of
reads, increment the sleep backlog to cause a sleep to occur.
|
void |
updateBackgroundWrites(int writeSize,
int logBufferSize)
If a background write limit has been configured and that limit is
exceeded when the given amount written is added to the cumulative total,
increment the sleep backlog to cause a sleep to occur.
|
boolean |
useDirectNIO() |
boolean |
verify(VerifyConfig config,
java.io.PrintStream out) |
void |
verifyCursors() |
protected LogManager logManager
public final RunRecoveryException SAVED_RRE
public static final boolean USE_JAVA5_ADLER32
public static final boolean IS_DALVIK
public EnvironmentImpl(java.io.File envHome,
EnvironmentConfig envConfig,
EnvironmentImpl sharedCacheEnv,
boolean replicationIntended)
throws DatabaseException
envHome - absolute path of the database environment
home directoryenvConfig - sharedCacheEnv - if non-null, is another environment that is
sharing the cache with this environment; if null, this environment is
not sharing the cache or is the first environment to share the cache.DatabaseException - on all other failurespublic void reinit(boolean replicationIntended)
throws DatabaseException
DatabaseExceptionvoid doReinit(boolean replicationIntended,
EnvironmentImpl sharedCacheEnv)
throws DatabaseException
DatabaseExceptionpublic void envConfigUpdate(DbConfigManager mgr, EnvironmentMutableConfig newConfig) throws DatabaseException
envConfigUpdate in interface EnvConfigObserverDatabaseExceptionpublic INCompressor getINCompressor()
public UtilizationTracker getUtilizationTracker()
public UtilizationProfile getUtilizationProfile()
public void updateBackgroundReads(int nReads)
sleepAfterBackgroundIO()public void updateBackgroundWrites(int writeSize,
int logBufferSize)
The number of writes is estimated by dividing the bytes written by the log buffer size. Since the log write buffer is shared by all writers, this is the best approximation possible.
sleepAfterBackgroundIO()public void sleepAfterBackgroundIO()
If two threads call this method and the first call causes a sleep, the call by the second thread will block until the first thread's sleep interval is over. When the call by the second thread is unblocked, if another sleep is needed then the second thread will sleep again. In other words, when lots of sleeps are needed, background threads may backup. This is intended to give foreground threads a chance to "catch up" when background threads are doing a lot of IO.
public void setBackgroundSleepHook(TestHook hook)
public void setupAPILock()
throws DatabaseException
DatabaseExceptionpublic void acquireAPIWriteLock(int time,
java.util.concurrent.TimeUnit units)
throws DatabaseException
DatabaseExceptionpublic void releaseAPIWriteLock()
throws DatabaseException
DatabaseExceptionpublic void acquireAPIReadLock(Locker who) throws DatabaseException
DatabaseExceptionpublic boolean releaseAPIReadLock(Locker who) throws DatabaseException
DatabaseExceptionpublic boolean scanLog(long startPosition,
long endPosition,
LogScanConfig config,
LogScanner scanner)
throws DatabaseException
DatabaseExceptionpublic void logMapTreeRoot()
throws DatabaseException
DatabaseExceptionpublic void logMapTreeRoot(long ifBeforeLsn)
throws DatabaseException
DatabaseExceptionpublic void rewriteMapTreeRoot(long cleanerTargetLsn)
throws DatabaseException
DatabaseExceptionpublic long getRootLsn()
public void readMapTreeFromLog(long rootLsn,
boolean replicationIntended)
throws DatabaseException
DatabaseExceptionpublic void addToCompressorQueue(BIN bin, Key deletedKey, boolean doWakeup) throws DatabaseException
DatabaseExceptionpublic void addToCompressorQueue(BINReference binRef, boolean doWakeup) throws DatabaseException
DatabaseExceptionpublic void addToCompressorQueue(java.util.Collection<BINReference> binRefs, boolean doWakeup) throws DatabaseException
DatabaseExceptionpublic void lazyCompress(IN in, LocalUtilizationTracker localTracker) throws DatabaseException
DatabaseExceptionpublic void enableDebugLoggingToDbLog()
throws DatabaseException
DatabaseExceptionpublic void closeLogger()
public void open()
public void invalidate(RunRecoveryException e)
public void invalidate(java.lang.Error e)
public boolean isOpen()
public boolean isClosing()
public boolean isClosed()
public boolean mayNotWrite()
public void checkIfInvalid()
throws RunRecoveryException
RunRecoveryExceptionpublic void checkNotClosed()
throws DatabaseException
DatabaseExceptionpublic void close()
throws DatabaseException
DatabaseExceptionpublic void close(boolean doCheckpoint)
throws DatabaseException
DatabaseExceptionpublic void abnormalClose()
throws DatabaseException
DatabaseExceptionvoid doClose(boolean doCheckpoint,
boolean doCheckLeaks)
throws DatabaseException
DatabaseExceptionpublic void closeAfterRunRecovery()
throws DatabaseException
DatabaseExceptionvoid doCloseAfterRunRecovery()
void incReferenceCount()
boolean decReferenceCount()
public static int getThreadLocalReferenceCount()
public static void incThreadLocalReferenceCount()
public static void decThreadLocalReferenceCount()
public static boolean getNoComparators()
public boolean invokeCheckpoint(CheckpointConfig config, boolean flushAll, java.lang.String invokingSource) throws DatabaseException
DatabaseExceptionpublic long forceLogFileFlip()
throws DatabaseException
DatabaseExceptionpublic boolean invokeCompressor()
throws DatabaseException
DatabaseExceptionpublic void invokeEvictor()
throws DatabaseException
DatabaseExceptionpublic int invokeCleaner()
throws DatabaseException
DatabaseExceptionpublic void stopDaemons()
throws java.lang.InterruptedException
java.lang.InterruptedExceptionvoid shutdownINCompressor()
throws java.lang.InterruptedException
java.lang.InterruptedExceptionvoid shutdownEvictor()
throws java.lang.InterruptedException
java.lang.InterruptedExceptionvoid shutdownCheckpointer()
throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic void shutdownCleaner()
throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic boolean isNoLocking()
public boolean isTransactional()
public boolean isReadOnly()
public boolean isMemOnly()
public static boolean getFairLatches()
public static boolean getSharedLatches()
public boolean getDbEviction()
public boolean useDirectNIO()
public static int getAdler32ChunkSize()
public boolean getSharedCache()
public Txn txnBegin(Transaction parent, TransactionConfig txnConfig) throws DatabaseException
DatabaseExceptionpublic LogManager getLogManager()
public FileManager getFileManager()
public DbTree getDbTree()
public DbConfigManager getConfigManager()
The configuration can change, but changes are made by replacing the config manager object with a enw one. To use a consistent set of properties, call this method once and query the returned manager repeatedly for each property, rather than getting the config manager via this method for each property individually.
public NodeSequence getNodeSequence()
public EnvironmentConfig cloneConfig()
public EnvironmentMutableConfig cloneMutableConfig()
public void checkImmutablePropsForEquality(EnvironmentConfig config) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentExceptionpublic void setMutableConfig(EnvironmentMutableConfig config) throws DatabaseException
DatabaseExceptionvoid doSetMutableConfig(EnvironmentMutableConfig config) throws DatabaseException
DatabaseExceptionpublic void setExceptionListener(ExceptionListener exceptionListener)
public ExceptionListener getExceptionListener()
public void addConfigObserver(EnvConfigObserver o)
public void removeConfigObserver(EnvConfigObserver o)
public INList getInMemoryINs()
public TxnManager getTxnManager()
public Checkpointer getCheckpointer()
public Cleaner getCleaner()
public MemoryBudget getMemoryBudget()
public java.util.logging.Logger getLogger()
public boolean verify(VerifyConfig config, java.io.PrintStream out) throws DatabaseException
DatabaseExceptionpublic void verifyCursors()
throws DatabaseException
DatabaseExceptionpublic EnvironmentStats loadStats(StatsConfig config) throws DatabaseException
DatabaseExceptionpublic LockStats lockStat(StatsConfig config) throws DatabaseException
DatabaseExceptionpublic TransactionStats txnStat(StatsConfig config) throws DatabaseException
DatabaseExceptionpublic int getINCompressorQueueSize()
throws DatabaseException
DatabaseExceptionpublic RecoveryInfo getLastRecoveryInfo()
public java.io.File getEnvironmentHome()
public long getTxnTimeout()
public long getLockTimeout()
public SharedLatch getTriggerLatch()
public Evictor getEvictor()
void alertEvictor()
public boolean isReplicated()
public ReplicatorInstance getReplicator()
public void setReplicator(ReplicatorInstance repInstance)
public static boolean maybeForceYield()
Copyright (c) 2004,2008 Oracle. All rights reserved.