|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sleepycat.je.dbi.EnvironmentImpl
public class EnvironmentImpl
Underlying Environment implementation. There is a single instance for any database environment opened by the application.
Nested Class Summary | |
---|---|
static interface |
EnvironmentImpl.MBeanRegistrar
Because the Android platform does not have any javax.management classes, we load JEMonitor dynamically to ensure that there are no explicit references to com.sleepycat.je.jmx.*. |
Field Summary | |
---|---|
protected DbConfigManager |
configManager
|
protected DbTree |
dbMapTree
|
protected Logger |
envLogger
|
protected Formatter |
formatter
|
static boolean |
IS_DALVIK
|
protected boolean |
needConvert
|
EnvironmentFailureException |
SAVED_EFE
|
static boolean |
USE_JAVA5_ADLER32
|
Constructor Summary | |
---|---|
|
EnvironmentImpl(File envHome,
EnvironmentConfig envConfig,
EnvironmentImpl sharedCacheEnv)
|
protected |
EnvironmentImpl(File envHome,
EnvironmentConfig envConfig,
EnvironmentImpl sharedCacheEnv,
RepConfigProxy repConfigProxy)
Create a database environment to represent the data in envHome. |
Method Summary | |
---|---|
void |
abnormalClose()
Used by error handling to forcibly close an environment, and by tests to close an environment to simulate a crash. |
void |
addConfigObserver(EnvConfigObserver o)
Adds an observer of mutable config changes. |
boolean |
addDbBackup(DbBackup backup)
For replicated environments only; just return true for a standalone environment. |
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(Collection<BINReference> binRefs,
boolean doWakeup)
Tells the asynchronous IN compressor thread about a collections of BINReferences with deleted entries. |
(package private) void |
alertEvictor()
|
VLSN |
bumpVLSN()
|
void |
checkIfInvalid()
|
void |
checkImmutablePropsForEquality(Properties handleConfigProps)
Throws an exception if an immutable property is changed. |
void |
checkNotClosed()
|
void |
checkRulesForExistingEnv(boolean dbTreeReplicatedBit)
Check whether this environment can be opened on an existing environment directory. |
EnvironmentConfig |
cloneConfig()
Clones the current configuration. |
EnvironmentMutableConfig |
cloneMutableConfig()
Clones the current mutable configuration. |
void |
close()
Decrements the reference count and closes the environment when it reaches zero. |
void |
close(boolean doCheckpoint)
Decrements the reference count and closes the environment when it reaches zero. |
void |
closeAfterInvalid()
|
OperationFailureException |
createDatabasePreemptedException(String msg,
String dbName,
Database db)
For replicated environments only; only the overridden method should ever be called. |
OperationFailureException |
createLockPreemptedException(Locker locker,
Throwable cause)
For replicated environments only; only the overridden method should ever be called. |
OperationFailureException |
createLogOverwriteException(String msg)
For replicated environments only; only the overridden method should ever be called. |
Txn |
createReplayTxn(long txnId)
For replicated environments only; only the overridden method should ever be called. |
ThreadLocker |
createRepThreadLocker()
For replicated environments only; only the overridden method should ever be called. |
Txn |
createRepTxn(TransactionConfig config,
long mandatedId)
For replicated environments only; only the overridden method should ever be called. |
Txn |
createRepUserTxn(TransactionConfig config)
For replicated environments only; only the overridden method should ever be called. |
void |
criticalEviction(boolean backgroundIO)
Performs critical eviction if necessary. |
(package private) boolean |
decReferenceCount()
Returns true if the environment should be closed. |
void |
decrementVLSN()
|
(package private) static void |
decThreadLocalReferenceCount()
|
(package private) void |
doClose(boolean doCheckpoint,
boolean doCheckLeaks)
Closes the environment, optionally performing a checkpoint and checking for resource leaks. |
void |
doCloseAfterInvalid()
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 |
envConfigUpdate(DbConfigManager mgr,
EnvironmentMutableConfig newConfig)
Respond to config updates. |
void |
finishInit(EnvironmentConfig envConfig)
|
long |
forceLogFileFlip()
Flip the log to a new file, forcing an fsync. |
static int |
getAdler32ChunkSize()
|
boolean |
getAllowConvert()
True if ReplicationConfig set allowConvert as true. |
Checkpointer |
getCheckpointer()
|
Cleaner |
getCleaner()
|
long |
getCleanerBarrierStartFile()
Returns the first protected file number. |
DbConfigManager |
getConfigManager()
Returns the config manager for the current base configuration. |
ConsoleHandler |
getConsoleHandler()
|
boolean |
getDbEviction()
Returns whether DB/MapLN eviction is enabled. |
DbTree |
getDbTree()
|
CacheMode |
getDefaultCacheMode()
Returns the default cache mode for this environment. |
CacheModeStrategy |
getDefaultCacheModeStrategy()
Returns the environment cache mode strategy. |
protected String |
getDiagnosticsClassName()
|
File |
getEnvironmentHome()
Get the environment home directory. |
Evictor |
getEvictor()
|
ExceptionListener |
getExceptionListener()
|
static boolean |
getFairLatches()
|
FileHandler |
getFileHandler()
|
FileManager |
getFileManager()
|
INCompressor |
getINCompressor()
Return the incompressor. |
int |
getINCompressorQueueSize()
|
INList |
getInMemoryINs()
|
RecoveryInfo |
getLastRecoveryInfo()
Info about the last recovery. |
long |
getLockTimeout()
|
Logger |
getLogger()
|
LogManager |
getLogManager()
|
MemoryBudget |
getMemoryBudget()
|
MemoryHandler |
getMemoryHandler()
|
protected String |
getMonitorClassName()
|
String |
getName()
Get an environment name, for tagging onto logging and debug message. |
static boolean |
getNoComparators()
|
String |
getNodeName()
|
NodeSequence |
getNodeSequence()
|
protected int |
getReferenceCount()
|
long |
getReplayTxnTimeout()
|
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. |
VLSNRecoveryProxy |
getVLSNProxy()
|
(package private) void |
incReferenceCount()
|
void |
incRelatchesRequired()
|
(package private) static void |
incThreadLocalReferenceCount()
|
protected DbConfigManager |
initConfigManager(EnvironmentConfig envConfig,
RepConfigProxy unused)
Create a config manager that holds the configuration properties that have been passed in. |
protected Formatter |
initFormatter()
|
void |
invalidate(EnvironmentFailureException e)
Invalidate the environment. |
void |
invalidate(Error e)
Invalidate the environment when a Java Error is thrown. |
boolean |
invokeCheckpoint(CheckpointConfig config,
boolean flushAll,
String invokingSource)
Invoke a checkpoint programmatically. |
int |
invokeCleaner()
|
boolean |
invokeCompressor()
Invoke a compress programatically. |
void |
invokeEvictor()
|
boolean |
isCacheFull()
See Evictor.isCacheFull |
boolean |
isClosed()
|
boolean |
isClosing()
|
boolean |
isConverted()
True if this environment is converted from non-replicated to replicated. |
boolean |
isDbLoggingDisabled()
|
boolean |
isInInit()
|
boolean |
isInvalid()
Predicate used to determine whether the EnvironmentImpl is valid. |
boolean |
isMaster()
|
boolean |
isMemOnly()
|
boolean |
isNoLocking()
|
boolean |
isReadOnly()
|
boolean |
isReplicated()
Return true if this environment is part of a replication group. |
boolean |
isTransactional()
|
boolean |
isValid()
|
void |
lazyCompress(IN in,
LocalUtilizationTracker localTracker)
Do lazy compression at opportune moments. |
StatGroup |
loadEnvImplStats(StatsConfig config)
|
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 EnvironmentFailureException occurs or the environment is closed, further writing can cause log corruption. |
boolean |
needConvert()
|
void |
open()
Not much to do, mark state. |
protected void |
postCheckpointClose(boolean checkpointed)
Release any resources from a subclass that need to be released after the closing checkpoint. |
protected void |
postRecoveryConversion()
Convert user defined databases to replicated after doing recovery. |
void |
preCheckpointEndFlush()
Do any work that must be done before the checkpoint end is written, as as part of the checkpoint process. |
void |
preRecoveryCheckpointInit(RecoveryInfo recoveryInfo)
|
void |
pushMemoryHandler()
|
void |
readMapTreeFromLog(long rootLsn)
Set the mapping tree from the log. |
void |
registerExceptionListenerUser(ExceptionListenerUser u)
|
void |
registerMBean(Environment env)
|
void |
registerVLSN(LogItem logItem)
|
void |
removeConfigObserver(EnvConfigObserver o)
Removes an observer of mutable config changes. |
void |
removeDbBackup(DbBackup backup)
For replicated environments only; do nothing for a standalone environment. |
protected DbConfigManager |
resetConfigManager(EnvironmentConfig newConfig)
Make a new config manager that has all the properties needed. |
void |
resetLoggingLevel(String changedLoggerName,
Level level)
Reset the logging level for specified loggers in a JE environment. |
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 |
setCleanerBarrierHook(TestHook<Long> hook)
|
void |
setMutableConfig(EnvironmentMutableConfig config)
Changes the mutable config properties that are present in the given config, and notifies all config observer. |
protected void |
setupClose(PrintWriter errors)
Release any resources from a subclass that need to be released before close is called on regular environment components. |
(package private) void |
shutdownCheckpointer()
|
void |
shutdownCleaner()
public for unit tests. |
protected void |
shutdownDaemons()
Ask all daemon threads to shut down. |
(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. |
long |
specialEviction()
Performs special eviction (eviction other than standard IN eviction) for this environment. |
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 |
boolean |
unregisterExceptionListenerUser(ExceptionListenerUser u)
|
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 |
verify(VerifyConfig config,
PrintStream out)
|
void |
verifyCursors()
|
void |
vlsnHeadTruncate(VLSN lastVLSN,
long deleteFileNum)
Adjust the vlsn index after cleaning. |
boolean |
wasCacheEverFull()
See Evictor.wasCacheEverFull |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected boolean needConvert
protected DbTree dbMapTree
protected DbConfigManager configManager
protected Logger envLogger
public final EnvironmentFailureException SAVED_EFE
public static final boolean USE_JAVA5_ADLER32
protected final Formatter formatter
public static final boolean IS_DALVIK
Constructor Detail |
---|
public EnvironmentImpl(File envHome, EnvironmentConfig envConfig, EnvironmentImpl sharedCacheEnv) throws EnvironmentNotFoundException, EnvironmentLockedException
EnvironmentNotFoundException
EnvironmentLockedException
protected EnvironmentImpl(File envHome, EnvironmentConfig envConfig, EnvironmentImpl sharedCacheEnv, RepConfigProxy repConfigProxy) throws EnvironmentNotFoundException, EnvironmentLockedException
envHome
- absolute path of the database environment home directoryenvConfig
- is the configuration to be used. It's already had
the je.properties file applied, and has been validated.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 failures
IllegalArgumentException
- via Environment ctor.
EnvironmentNotFoundException
EnvironmentLockedException
Method Detail |
---|
protected DbConfigManager initConfigManager(EnvironmentConfig envConfig, RepConfigProxy unused)
envConfig
- is the environment configuration to usereplicationParams
- are the replication configurations to use. In
this case, the Properties bag has been extracted from the configuration
instance, to avoid crossing the compilation firewall.public void finishInit(EnvironmentConfig envConfig) throws DatabaseException
DatabaseException
public void registerMBean(Environment env) throws DatabaseException
DatabaseException
protected String getMonitorClassName()
protected String getDiagnosticsClassName()
public void envConfigUpdate(DbConfigManager mgr, EnvironmentMutableConfig newConfig)
envConfigUpdate
in interface EnvConfigObserver
public void registerExceptionListenerUser(ExceptionListenerUser u)
public boolean unregisterExceptionListenerUser(ExceptionListenerUser u)
public INCompressor getINCompressor()
public UtilizationTracker getUtilizationTracker()
public UtilizationProfile getUtilizationProfile()
public CacheMode getDefaultCacheMode()
public CacheModeStrategy getDefaultCacheModeStrategy()
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 setCleanerBarrierHook(TestHook<Long> hook)
public boolean scanLog(long startPosition, long endPosition, LogScanConfig config, LogScanner scanner) throws DatabaseException
IllegalArgumentException
- via Environment.scanLog.
DatabaseException
public void logMapTreeRoot() throws DatabaseException
DatabaseException
public void logMapTreeRoot(long ifBeforeLsn) throws DatabaseException
DatabaseException
public void rewriteMapTreeRoot(long cleanerTargetLsn) throws DatabaseException
DatabaseException
public long getRootLsn()
public void readMapTreeFromLog(long rootLsn) throws DatabaseException
DatabaseException
public void addToCompressorQueue(BIN bin, Key deletedKey, boolean doWakeup)
public void addToCompressorQueue(BINReference binRef, boolean doWakeup)
public void addToCompressorQueue(Collection<BINReference> binRefs, boolean doWakeup)
public void lazyCompress(IN in, LocalUtilizationTracker localTracker) throws DatabaseException
DatabaseException
public void resetLoggingLevel(String changedLoggerName, Level level)
IllegalArgumentException
- via JEDiagnostics.OP_RESET_LOGGINGpublic void pushMemoryHandler()
protected Formatter initFormatter()
public ConsoleHandler getConsoleHandler()
public MemoryHandler getMemoryHandler()
public FileHandler getFileHandler()
public void open()
public void invalidate(EnvironmentFailureException e)
public void invalidate(Error e)
public boolean isInvalid()
public boolean isValid()
public boolean isInInit()
public boolean isClosing()
public boolean isClosed()
public boolean mayNotWrite()
public void checkIfInvalid() throws EnvironmentFailureException
EnvironmentFailureException
public void checkNotClosed() throws DatabaseException
DatabaseException
public void close() throws DatabaseException
DatabaseException
public void close(boolean doCheckpoint) throws DatabaseException
DatabaseException
public void abnormalClose() throws DatabaseException
DatabaseException
void doClose(boolean doCheckpoint, boolean doCheckLeaks)
IllegalStateException
- if the environment is already closed.
EnvironmentFailureException
- if leaks or other problems are
detected while closing.protected void setupClose(PrintWriter errors) throws DatabaseException
DatabaseException
protected void postCheckpointClose(boolean checkpointed) throws DatabaseException
checkpointed
- if true, a checkpoint as issued before the close
DatabaseException
protected void postRecoveryConversion() throws DatabaseException
DatabaseException
public void closeAfterInvalid() throws DatabaseException
DatabaseException
public void doCloseAfterInvalid()
void incReferenceCount()
boolean decReferenceCount()
protected int getReferenceCount()
public static int getThreadLocalReferenceCount()
static void incThreadLocalReferenceCount()
static void decThreadLocalReferenceCount()
public static boolean getNoComparators()
public boolean invokeCheckpoint(CheckpointConfig config, boolean flushAll, String invokingSource) throws DatabaseException
DatabaseException
public long forceLogFileFlip() throws DatabaseException
DatabaseException
public boolean invokeCompressor() throws DatabaseException
DatabaseException
public void invokeEvictor() throws DatabaseException
DatabaseException
public int invokeCleaner() throws DatabaseException
UnsupportedOperationException
- via Environment.cleanLog.
DatabaseException
public void stopDaemons()
protected void shutdownDaemons()
void shutdownINCompressor()
void shutdownEvictor()
void shutdownCheckpointer()
public void shutdownCleaner()
public boolean isNoLocking()
public boolean isTransactional()
public boolean isReadOnly()
public boolean isMemOnly()
public String getNodeName()
public static boolean getFairLatches()
public static boolean getSharedLatches()
public boolean getDbEviction()
public static int getAdler32ChunkSize()
public boolean getSharedCache()
public Txn txnBegin(Transaction parent, TransactionConfig txnConfig) throws DatabaseException
DatabaseException
public 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(Properties handleConfigProps) throws IllegalArgumentException
IllegalArgumentException
public void setMutableConfig(EnvironmentMutableConfig config) throws DatabaseException
DatabaseException
void doSetMutableConfig(EnvironmentMutableConfig config) throws DatabaseException
DatabaseException
protected DbConfigManager resetConfigManager(EnvironmentConfig newConfig)
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 Logger getLogger()
public boolean isDbLoggingDisabled()
public boolean verify(VerifyConfig config, PrintStream out) throws DatabaseException
DatabaseException
public void verifyCursors() throws DatabaseException
DatabaseException
public EnvironmentStats loadStats(StatsConfig config) throws DatabaseException
DatabaseException
public StatGroup loadEnvImplStats(StatsConfig config)
public void incRelatchesRequired()
public boolean addDbBackup(DbBackup backup)
public void removeDbBackup(DbBackup backup)
public LockStats lockStat(StatsConfig config) throws DatabaseException
DatabaseException
public TransactionStats txnStat(StatsConfig config)
public int getINCompressorQueueSize()
public RecoveryInfo getLastRecoveryInfo()
public File getEnvironmentHome()
public String getName()
public long getTxnTimeout()
public long getLockTimeout()
public long getReplayTxnTimeout()
public SharedLatch getTriggerLatch()
public Evictor getEvictor()
void alertEvictor()
public void criticalEviction(boolean backgroundIO)
public long specialEviction()
public boolean isCacheFull()
public boolean wasCacheEverFull()
public static boolean maybeForceYield()
public boolean isReplicated()
public boolean getAllowConvert()
public boolean isConverted()
public boolean needConvert()
public VLSN bumpVLSN()
public void decrementVLSN()
public VLSNRecoveryProxy getVLSNProxy() throws DatabaseException
DatabaseException
- from subclasses.public boolean isMaster()
public void preRecoveryCheckpointInit(RecoveryInfo recoveryInfo)
public void registerVLSN(LogItem logItem)
public void vlsnHeadTruncate(VLSN lastVLSN, long deleteFileNum)
public void preCheckpointEndFlush() throws DatabaseException
DatabaseException
public Txn createReplayTxn(long txnId)
DatabaseException
- from subclasses.public ThreadLocker createRepThreadLocker()
DatabaseException
- from subclasses.public Txn createRepUserTxn(TransactionConfig config)
DatabaseException
- from subclasses.public Txn createRepTxn(TransactionConfig config, long mandatedId)
DatabaseException
- from subclasses.public OperationFailureException createLockPreemptedException(Locker locker, Throwable cause)
LockPreemptedException
- from subclasses.public OperationFailureException createDatabasePreemptedException(String msg, String dbName, Database db)
DatabasePreemptedException
- from subclasses.public OperationFailureException createLogOverwriteException(String msg)
LogOverwriteException
- from subclasses.public long getCleanerBarrierStartFile()
public void checkRulesForExistingEnv(boolean dbTreeReplicatedBit) throws UnsupportedOperationException
UnsupportedOperationException
- via Environment ctor.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |