Author: macbean Date: Wed Sep 17 14:10:38 2014 New Revision: 1625601 URL: http://svn.apache.org/r1625601 Log: QPID-6075: [Java Broker] Deleting VHN fails to delete underlying store files if VHN has not been started
Modified: qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyConfigurationStore.java qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java Modified: qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java?rev=1625601&r1=1625600&r2=1625601&view=diff ============================================================================== --- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java (original) +++ qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java Wed Sep 17 14:10:38 2014 @@ -77,7 +77,6 @@ public class BDBConfigurationStore imple private EnvironmentFacade _environmentFacade; - private String _storeLocation; private ConfiguredObject<?> _parent; private final Class<? extends ConfiguredObject> _rootClass; private boolean _overwrite; @@ -106,7 +105,6 @@ public class BDBConfigurationStore imple if (_environmentFacade == null) { _environmentFacade = _environmentFacadeFactory.createEnvironmentFacade(parent); - _storeLocation = _environmentFacade.getStoreLocation(); _overwrite = overwrite; _initialRecords = initialRecords; } @@ -482,24 +480,22 @@ public class BDBConfigurationStore imple @Override public void onDelete(ConfiguredObject<?> parent) { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("Deleting store " + _storeLocation); - } - FileBasedSettings fileBasedSettings = (FileBasedSettings)parent; String storePath = fileBasedSettings.getStorePath(); if (storePath != null) { + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug("Deleting store " + storePath); + } + File configFile = new File(storePath); if (!FileUtils.delete(configFile, true)) { LOGGER.info("Failed to delete the store at location " + storePath); } } - - _storeLocation = null; } private boolean isConfigurationStoreOpen() @@ -570,7 +566,7 @@ public class BDBConfigurationStore imple @Override public String getStoreLocation() { - return BDBConfigurationStore.this._storeLocation; + return ((FileBasedSettings)_parent).getStorePath(); } @Override Modified: qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java?rev=1625601&r1=1625600&r2=1625601&view=diff ============================================================================== --- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java (original) +++ qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java Wed Sep 17 14:10:38 2014 @@ -46,7 +46,6 @@ public class BDBMessageStore extends Abs private EnvironmentFacade _environmentFacade; private ConfiguredObject<?> _parent; - private String _storeLocation; private long _persistentSizeLowThreshold; private long _persistentSizeHighThreshold; @@ -78,7 +77,6 @@ public class BDBMessageStore extends Abs } _environmentFacade = _environmentFacadeFactory.createEnvironmentFacade(parent); - _storeLocation = _environmentFacade.getStoreLocation(); } } @@ -105,24 +103,22 @@ public class BDBMessageStore extends Abs @Override public void onDelete(ConfiguredObject<?> parent) { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("Deleting store " + _storeLocation); - } - FileBasedSettings fileBasedSettings = (FileBasedSettings)parent; String storePath = fileBasedSettings.getStorePath(); if (storePath != null) { + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug("Deleting store " + storePath); + } + File configFile = new File(storePath); if (!FileUtils.delete(configFile, true)) { LOGGER.info("Failed to delete the store at location " + storePath); } } - - _storeLocation = null; } @Override @@ -167,6 +163,6 @@ public class BDBMessageStore extends Abs @Override public String getStoreLocation() { - return _storeLocation; + return ((FileBasedSettings)_parent).getStorePath(); } } Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java?rev=1625601&r1=1625600&r2=1625601&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java (original) +++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java Wed Sep 17 14:10:38 2014 @@ -586,6 +586,11 @@ public class JsonFileConfigStore impleme if (storePath != null) { + if (_logger.isDebugEnabled()) + { + _logger.debug("Deleting store " + storePath); + } + File configFile = new File(storePath); if (!FileUtils.delete(configFile, true)) { Modified: qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyConfigurationStore.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyConfigurationStore.java?rev=1625601&r1=1625600&r2=1625601&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyConfigurationStore.java (original) +++ qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyConfigurationStore.java Wed Sep 17 14:10:38 2014 @@ -47,7 +47,6 @@ public class DerbyConfigurationStore ext private final ProvidedMessageStore _providedMessageStore = new ProvidedMessageStore(); private String _connectionURL; - private String _storeLocation; private ConfiguredObject<?> _parent; private final Class<? extends ConfiguredObject> _rootClass; @@ -68,9 +67,7 @@ public class DerbyConfigurationStore ext _parent = parent; DerbyUtils.loadDerbyDriver(); - final FileBasedSettings settings = (FileBasedSettings)parent; - _storeLocation = settings.getStorePath(); - _connectionURL = DerbyUtils.createConnectionUrl(parent.getName(), _storeLocation); + _connectionURL = DerbyUtils.createConnectionUrl(parent.getName(), ((FileBasedSettings)_parent).getStorePath()); createOrOpenConfigurationStoreDatabase(overwrite); @@ -148,24 +145,25 @@ public class DerbyConfigurationStore ext throw new IllegalStateException("Cannot delete the store as the provided message store is still open"); } - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("Deleting store " + _storeLocation); - } - - FileBasedSettings fileBasedSettings = (FileBasedSettings)parent; + FileBasedSettings fileBasedSettings = (FileBasedSettings) parent; String storePath = fileBasedSettings.getStorePath(); - if (storePath != null) + if (!DerbyUtils.MEMORY_STORE_LOCATION.equals(storePath)) { - File configFile = new File(storePath); - if (!FileUtils.delete(configFile, true)) + if (storePath != null) { - LOGGER.info("Failed to delete the store at location " + storePath); + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug("Deleting store " + storePath); + } + + File configFile = new File(storePath); + if (!FileUtils.delete(configFile, true)) + { + LOGGER.info("Failed to delete the store at location " + storePath); + } } } - - _storeLocation = null; } @Override @@ -219,7 +217,7 @@ public class DerbyConfigurationStore ext @Override public String getStoreLocation() { - return DerbyConfigurationStore.this._storeLocation; + return ((FileBasedSettings)_parent).getStorePath(); } @Override Modified: qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java?rev=1625601&r1=1625600&r2=1625601&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java (original) +++ qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java Wed Sep 17 14:10:38 2014 @@ -41,15 +41,13 @@ public class DerbyMessageStore extends A private static final Logger LOGGER = Logger.getLogger(DerbyMessageStore.class); private String _connectionURL; - private String _storeLocation; + private ConfiguredObject<?> _parent; @Override protected void doOpen(final ConfiguredObject<?> parent) { - final FileBasedSettings settings = (FileBasedSettings)parent; - _storeLocation = settings.getStorePath(); - - _connectionURL = DerbyUtils.createConnectionUrl(parent.getName(), _storeLocation); + _parent = parent; + _connectionURL = DerbyUtils.createConnectionUrl(parent.getName(), ((FileBasedSettings)_parent).getStorePath()); } @Override @@ -80,24 +78,22 @@ public class DerbyMessageStore extends A throw new IllegalStateException("Cannot delete the store as the provided message store is still open"); } - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("Deleting store " + _storeLocation); - } - FileBasedSettings fileBasedSettings = (FileBasedSettings)parent; String storePath = fileBasedSettings.getStorePath(); if (storePath != null) { + if (LOGGER.isDebugEnabled()) + { + LOGGER.debug("Deleting store " + storePath); + } + File configFile = new File(storePath); if (!FileUtils.delete(configFile, true)) { LOGGER.info("Failed to delete the store at location " + storePath); } } - - _storeLocation = null; } @Override @@ -110,7 +106,7 @@ public class DerbyMessageStore extends A @Override public String getStoreLocation() { - return _storeLocation; + return ((FileBasedSettings)_parent).getStorePath(); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org