com.sleepycat.je.dbi
Class DbEnvPool

java.lang.Object
  extended by com.sleepycat.je.dbi.DbEnvPool

public class DbEnvPool
extends Object

Singleton collection of environments. Responsible for environment open and close, supporting this from multiple threads by synchronizing on the pool. To avoid multiple environment openings from being blocked by recovery in getEnvironment(), the EnvironmentImpl constructor is broken into two parts, with the second part (EnvironmentImpl.finishInit) doing the recovery. When synchronizing on two or more of the following objects the synchronization order must be as follows. Synchronization is not performed in constructors, of course, because no other thread can access the object. Synchronization order: Environment, DbEnvPool, EnvironmentImpl, Evictor


Method Summary
 void clear()
          For unit testing only.
(package private)  void closeEnvironment(EnvironmentImpl envImpl, boolean doCheckpoint, boolean isAbnormalClose)
          Called by EnvironmentImpl.close to perform the close operation while synchronized on the DbEnvPool.
(package private)  void closeEnvironmentAfterInvalid(EnvironmentImpl envImpl)
          Called by EnvironmentImpl.closeAfterInvalid to perform the close operation while synchronized on the DbEnvPool.
 Collection<EnvironmentImpl> getEnvImpls()
           
 EnvironmentImpl getEnvironment(File envHome, EnvironmentConfig config, boolean checkImmutableParams, boolean openIfNeeded, RepConfigProxy repConfigProxy)
          Find a single environment, used by Environment handles and by command line utilities.
(package private)  String getEnvironmentMapKey(File file)
           
static DbEnvPool getInstance()
          Access the singleton instance.
 int getNSharedCacheEnvironments()
           
 void setBeforeFinishInitHook(TestHook<CountDownLatch> hook)
           
(package private)  void setMutableConfig(EnvironmentImpl envImpl, EnvironmentMutableConfig mutableConfig)
          Called by EnvironmentImpl.setMutableConfig to perform the setMutableConfig operation while synchronized on the DbEnvPool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static DbEnvPool getInstance()
Access the singleton instance.


setBeforeFinishInitHook

public void setBeforeFinishInitHook(TestHook<CountDownLatch> hook)

getNSharedCacheEnvironments

public int getNSharedCacheEnvironments()

getEnvironment

public EnvironmentImpl getEnvironment(File envHome,
                                      EnvironmentConfig config,
                                      boolean checkImmutableParams,
                                      boolean openIfNeeded,
                                      RepConfigProxy repConfigProxy)
                               throws EnvironmentNotFoundException,
                                      EnvironmentLockedException
Find a single environment, used by Environment handles and by command line utilities.

Throws:
EnvironmentNotFoundException
EnvironmentLockedException

setMutableConfig

void setMutableConfig(EnvironmentImpl envImpl,
                      EnvironmentMutableConfig mutableConfig)
                throws DatabaseException
Called by EnvironmentImpl.setMutableConfig to perform the setMutableConfig operation while synchronized on the DbEnvPool. In theory we shouldn't need to synchronize here when envImpl.getSharedCache() is false; however, we synchronize unconditionally to standardize the synchronization order and avoid accidental deadlocks.

Throws:
DatabaseException

closeEnvironment

void closeEnvironment(EnvironmentImpl envImpl,
                      boolean doCheckpoint,
                      boolean isAbnormalClose)
Called by EnvironmentImpl.close to perform the close operation while synchronized on the DbEnvPool. Synchronization on this DbEnvPool during the close is used to protect its data structures. Unfortunately, this means that a long checkpoint during a close will block other closes and opens. We may want to improve this in the future. However, at least there is a user workaround: perform a full checkpoint before closing the environment.


closeEnvironmentAfterInvalid

void closeEnvironmentAfterInvalid(EnvironmentImpl envImpl)
                            throws DatabaseException
Called by EnvironmentImpl.closeAfterInvalid to perform the close operation while synchronized on the DbEnvPool.

Throws:
DatabaseException

clear

public void clear()
For unit testing only.


getEnvImpls

public Collection<EnvironmentImpl> getEnvImpls()

getEnvironmentMapKey

String getEnvironmentMapKey(File file)
                      throws DatabaseException
Throws:
DatabaseException


Copyright (c) 2004-2012 Oracle. All rights reserved.