Search in sources :

Example 1 with BdbEnvironmentStats

use of voldemort.store.bdb.stats.BdbEnvironmentStats in project voldemort by voldemort.

the class BdbStorageConfiguration method removeStorageEngine.

/**
     * Clean up the environment object for the given storage engine
     */
@Override
public void removeStorageEngine(StorageEngine<ByteArray, byte[], byte[]> engine) {
    String storeName = engine.getName();
    BdbStorageEngine bdbEngine = (BdbStorageEngine) engine;
    synchronized (lock) {
        // cleanup a shared 'Environment' object
        if (useOneEnvPerStore) {
            Environment environment = this.environments.get(storeName);
            if (environment == null) {
                // Nothing to clean up.
                return;
            }
            // Remove from the set of unreserved stores if needed.
            if (this.unreservedStores.remove(environment)) {
                logger.info("Removed environment for store name: " + storeName + " from unreserved stores");
            } else {
                logger.info("No environment found in unreserved stores for store name: " + storeName);
            }
            // Try to delete the BDB directory associated
            File bdbDir = environment.getHome();
            if (bdbDir.exists() && bdbDir.isDirectory()) {
                String bdbDirPath = bdbDir.getPath();
                try {
                    FileUtils.deleteDirectory(bdbDir);
                    logger.info("Successfully deleted BDB directory : " + bdbDirPath + " for store name: " + storeName);
                } catch (IOException e) {
                    logger.error("Unable to delete BDB directory: " + bdbDirPath + " for store name: " + storeName);
                }
            }
            // Remove the reference to BdbEnvironmentStats, which holds a
            // reference to the Environment
            BdbEnvironmentStats bdbEnvStats = bdbEngine.getBdbEnvironmentStats();
            this.aggBdbStats.unTrackEnvironment(bdbEnvStats);
            // Unregister the JMX bean for Environment
            if (voldemortConfig.isJmxEnabled()) {
                ObjectName name = JmxUtils.createObjectName(JmxUtils.getPackageName(bdbEnvStats.getClass()), storeName);
                // Un-register the environment stats mbean
                JmxUtils.unregisterMbean(name);
            }
            // Cleanup the environment
            environment.close();
            this.environments.remove(storeName);
            logger.info("Successfully closed the environment for store name : " + storeName);
        }
    }
}
Also used : Environment(com.sleepycat.je.Environment) BdbEnvironmentStats(voldemort.store.bdb.stats.BdbEnvironmentStats) AggregatedBdbEnvironmentStats(voldemort.store.bdb.stats.AggregatedBdbEnvironmentStats) IOException(java.io.IOException) File(java.io.File) ObjectName(javax.management.ObjectName)

Aggregations

Environment (com.sleepycat.je.Environment)1 File (java.io.File)1 IOException (java.io.IOException)1 ObjectName (javax.management.ObjectName)1 AggregatedBdbEnvironmentStats (voldemort.store.bdb.stats.AggregatedBdbEnvironmentStats)1 BdbEnvironmentStats (voldemort.store.bdb.stats.BdbEnvironmentStats)1