summaryrefslogtreecommitdiff
path: root/qpid/java/bdbstore/src
diff options
context:
space:
mode:
authorKeith Wall <kwall@apache.org>2014-03-25 10:07:21 +0000
committerKeith Wall <kwall@apache.org>2014-03-25 10:07:21 +0000
commitfcc3f654b60b7dd2180afe73e8809545725b41af (patch)
treeef5f631412fdbfd5a6ff4232782e90692e3767c1 /qpid/java/bdbstore/src
parentb0e9d446fd5edc23267e2aa924a703749bdb95df (diff)
downloadqpid-python-fcc3f654b60b7dd2180afe73e8809545725b41af.tar.gz
Introduction of separate lifecycle methods on stores for open/close/recover.
Change Upgraders responsibility to create the amqp standard exchanges when upgrading from earlier store versions. git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/java-broker-bdb-ha2@1581288 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/bdbstore/src')
-rw-r--r--qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHost.java32
-rw-r--r--qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java213
-rw-r--r--qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/EnvironmentFacadeFactory.java4
-rw-r--r--qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacadeFactory.java33
-rw-r--r--qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacadeFactory.java4
-rw-r--r--qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreConfigurationTest.java42
-rw-r--r--qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreQuotaEventsTest.java11
7 files changed, 142 insertions, 197 deletions
diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHost.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHost.java
index e41b81f846..7e42d09ba6 100644
--- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHost.java
+++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHost.java
@@ -75,18 +75,12 @@ public class BDBHAVirtualHost extends AbstractVirtualHost
_messageStore.addEventListener(new AfterInitialisationListener(), Event.AFTER_INIT);
_messageStore.addEventListener(new BeforePassivationListener(), Event.BEFORE_PASSIVATE);
- VirtualHostConfigRecoveryHandler recoveryHandler = new VirtualHostConfigRecoveryHandler(this);
- DurableConfigurationRecoverer configRecoverer =
- new DurableConfigurationRecoverer(getName(), getDurableConfigurationRecoverers(),
- new DefaultUpgraderProvider(this, getExchangeRegistry()), getEventLogger());
-
- _messageStore.configureConfigStore(
- virtualHost, configRecoverer
+ _messageStore.openConfigurationStore(
+ virtualHost.getName(), virtualHost.getMessageStoreSettings()
);
- _messageStore.configureMessageStore(
- virtualHost, recoveryHandler,
- recoveryHandler
+ _messageStore.openMessageStore(
+ virtualHost.getName(), virtualHost.getMessageStoreSettings()
);
// Make the virtualhost model object a replication group listener
@@ -105,7 +99,8 @@ public class BDBHAVirtualHost extends AbstractVirtualHost
try
{
_inVhostInitiatedClose = true;
- getMessageStore().close();
+ _messageStore.closeMessageStore();
+ _messageStore.closeConfigurationStore();
}
catch (Exception e)
{
@@ -214,7 +209,7 @@ public class BDBHAVirtualHost extends AbstractVirtualHost
if (LOGGER.isInfoEnabled())
{
LOGGER.info("Received BDB event indicating transition to state " + state
- + " when current message store state is " + _messageStore._stateManager.getState());
+ + " when current message store state is " + _messageStore._messageStoreStateManager.getState());
}
switch (state)
@@ -243,7 +238,14 @@ public class BDBHAVirtualHost extends AbstractVirtualHost
try
{
_messageStore.getEnvironmentFacade().getEnvironment().flushLog(true);
- _messageStore.activate();
+
+ DurableConfigurationRecoverer configRecoverer =
+ new DurableConfigurationRecoverer(getName(), getDurableConfigurationRecoverers(),
+ new DefaultUpgraderProvider(BDBHAVirtualHost.this, getExchangeRegistry()), getEventLogger());
+ _messageStore.recoverConfigurationStore(configRecoverer);
+
+ VirtualHostConfigRecoveryHandler recoveryHandler = new VirtualHostConfigRecoveryHandler(BDBHAVirtualHost.this);
+ _messageStore.recoverMessageStore(recoveryHandler, recoveryHandler);
}
catch (Exception e)
{
@@ -256,9 +258,9 @@ public class BDBHAVirtualHost extends AbstractVirtualHost
try
{
//TODO: move this this into the store method passivate()
- if (_messageStore._stateManager.isNotInState(org.apache.qpid.server.store.State.INITIALISED))
+ if (_messageStore._messageStoreStateManager.isNotInState(org.apache.qpid.server.store.State.INITIALISED))
{
- _messageStore._stateManager.attainState(org.apache.qpid.server.store.State.INITIALISED);
+ _messageStore._messageStoreStateManager.attainState(org.apache.qpid.server.store.State.INITIALISED);
}
}
catch (Exception e)
diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java
index 8be037eb7b..2022f36bd9 100644
--- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java
+++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java
@@ -30,12 +30,10 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.log4j.Logger;
import org.apache.qpid.server.message.EnqueueableMessage;
-import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.store.ConfigurationRecoveryHandler;
import org.apache.qpid.server.store.ConfiguredObjectRecord;
@@ -102,25 +100,20 @@ public class BDBMessageStore implements MessageStore, DurableConfigurationStore
private static String MESSAGE_META_DATA_DB_NAME = "MESSAGE_METADATA";
private static String MESSAGE_CONTENT_DB_NAME = "MESSAGE_CONTENT";
private static String DELIVERY_DB_NAME = "QUEUE_ENTRIES";
+
+ //TODO: Add upgrader to remove BRIDGES and LINKS
private static String BRIDGEDB_NAME = "BRIDGES";
private static String LINKDB_NAME = "LINKS";
private static String XID_DB_NAME = "XIDS";
private static String CONFIG_VERSION_DB_NAME = "CONFIG_VERSION";
- private static final String[] DATABASE_NAMES = new String[] { CONFIGURED_OBJECTS_DB_NAME, MESSAGE_META_DATA_DB_NAME,
- MESSAGE_CONTENT_DB_NAME, DELIVERY_DB_NAME, BRIDGEDB_NAME, LINKDB_NAME, XID_DB_NAME, CONFIG_VERSION_DB_NAME };
-
- private final AtomicBoolean _closed = new AtomicBoolean(false);
+ private static final String[] CONFIGURATION_STORE_DATABASE_NAMES = new String[] { CONFIGURED_OBJECTS_DB_NAME, CONFIG_VERSION_DB_NAME };
+ private static final String[] MESSAGE_STORE_DATABASE_NAMES = new String[] { MESSAGE_META_DATA_DB_NAME, MESSAGE_CONTENT_DB_NAME, DELIVERY_DB_NAME, BRIDGEDB_NAME, LINKDB_NAME, XID_DB_NAME };
private EnvironmentFacade _environmentFacade;
private final AtomicLong _messageId = new AtomicLong(0);
- protected final StateManager _stateManager;
-
- private MessageStoreRecoveryHandler _messageRecoveryHandler;
-
- private TransactionLogRecoveryHandler _tlogRecoveryHandler;
-
- private ConfigurationRecoveryHandler _configRecoveryHandler;
+ protected final StateManager _messageStoreStateManager;
+ private final StateManager _configurationStoreStateManager;
private long _totalStoreSize;
private boolean _limitBusted;
@@ -129,12 +122,14 @@ public class BDBMessageStore implements MessageStore, DurableConfigurationStore
private final EventManager _eventManager = new EventManager();
private final String _type;
- private VirtualHost _virtualHost;
private final EnvironmentFacadeFactory _environmentFacadeFactory;
private volatile Committer _committer;
+ private String _virtualHostName;
+
+
public BDBMessageStore()
{
this(new StandardEnvironmentFacadeFactory());
@@ -144,7 +139,8 @@ public class BDBMessageStore implements MessageStore, DurableConfigurationStore
{
_type = environmentFacadeFactory.getType();
_environmentFacadeFactory = environmentFacadeFactory;
- _stateManager = new StateManager(_eventManager);
+ _messageStoreStateManager = new StateManager(_eventManager);
+ _configurationStoreStateManager = new StateManager(new EventManager());
}
@Override
@@ -154,94 +150,47 @@ public class BDBMessageStore implements MessageStore, DurableConfigurationStore
}
@Override
- public void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler recoveryHandler)
+ public void openConfigurationStore(String virtualHostName, Map<String, Object> storeSettings)
{
- _stateManager.attainState(State.INITIALISING);
+ _configurationStoreStateManager.attainState(State.INITIALISING);
- _configRecoveryHandler = recoveryHandler;
- _virtualHost = virtualHost;
- }
-
- @Override
- public void configureMessageStore(VirtualHost virtualHost, MessageStoreRecoveryHandler messageRecoveryHandler,
- TransactionLogRecoveryHandler tlogRecoveryHandler) throws StoreException
- {
- if(_stateManager.isInState(State.INITIAL))
+ _virtualHostName = virtualHostName;
+ if (_environmentFacade == null)
{
- // Is acting as a message store, but not a durable config store
- _stateManager.attainState(State.INITIALISING);
+ _environmentFacade = _environmentFacadeFactory.createEnvironmentFacade(_virtualHostName, storeSettings);
}
-
- _messageRecoveryHandler = messageRecoveryHandler;
- _tlogRecoveryHandler = tlogRecoveryHandler;
- _virtualHost = virtualHost;
-
-
- completeInitialisation();
+ _configurationStoreStateManager.attainState(State.INITIALISED);
}
- private void completeInitialisation() throws StoreException
+ @Override
+ public void recoverConfigurationStore(ConfigurationRecoveryHandler recoveryHandler)
{
- configure(_virtualHost, _messageRecoveryHandler != null);
+ _configurationStoreStateManager.attainState(State.ACTIVATING);
- _stateManager.attainState(State.INITIALISED);
- }
-
- private void startActivation() throws StoreException
- {
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
try
{
- new Upgrader(_environmentFacade.getEnvironment(), _virtualHost.getName()).upgradeIfNecessary();
- _environmentFacade.openDatabases(dbConfig, DATABASE_NAMES);
- _totalStoreSize = getSizeOnDisk();
+ new Upgrader(_environmentFacade.getEnvironment(), _virtualHostName).upgradeIfNecessary();
+ _environmentFacade.openDatabases(dbConfig, CONFIGURATION_STORE_DATABASE_NAMES);
}
catch(DatabaseException e)
{
throw _environmentFacade.handleDatabaseException("Cannot configure store", e);
}
+ recoverConfig(recoveryHandler);
+ _configurationStoreStateManager.attainState(State.ACTIVE);
}
@Override
- public synchronized void activate() throws StoreException
+ public void openMessageStore(String virtualHostName, Map<String, Object> messageStoreSettings) throws StoreException
{
- // check if acting as a durable config store, but not a message store
- if(_stateManager.isInState(State.INITIALISING))
- {
- completeInitialisation();
- }
-
- _stateManager.attainState(State.ACTIVATING);
- startActivation();
-
- if(_configRecoveryHandler != null)
- {
- recoverConfig(_configRecoveryHandler);
- }
- if(_messageRecoveryHandler != null)
- {
- recoverMessages(_messageRecoveryHandler);
- }
- if(_tlogRecoveryHandler != null)
- {
- recoverQueueEntries(_tlogRecoveryHandler);
- }
+ _messageStoreStateManager.attainState(State.INITIALISING);
- _stateManager.attainState(State.ACTIVE);
- }
+ _virtualHostName = virtualHostName;
- @Override
- public org.apache.qpid.server.store.Transaction newTransaction() throws StoreException
- {
- return new BDBTransaction();
- }
-
- private void configure(VirtualHost virtualHost, boolean isMessageStore) throws StoreException
- {
- Map<String, Object> messageStoreSettings = virtualHost.getMessageStoreSettings();
Object overfullAttr = messageStoreSettings.get(MessageStore.OVERFULL_SIZE);
Object underfullAttr = messageStoreSettings.get(MessageStore.UNDERFULL_SIZE);
@@ -250,16 +199,56 @@ public class BDBMessageStore implements MessageStore, DurableConfigurationStore
_persistentSizeLowThreshold = underfullAttr == null ? _persistentSizeHighThreshold :
underfullAttr instanceof Number ? ((Number) underfullAttr).longValue() : Long.parseLong(underfullAttr.toString());
-
if(_persistentSizeLowThreshold > _persistentSizeHighThreshold || _persistentSizeLowThreshold < 0l)
{
_persistentSizeLowThreshold = _persistentSizeHighThreshold;
}
- _environmentFacade = _environmentFacadeFactory.createEnvironmentFacade(virtualHost, isMessageStore);
+ if (_environmentFacade == null)
+ {
+ _environmentFacade = _environmentFacadeFactory.createEnvironmentFacade(_virtualHostName, messageStoreSettings);
+ }
- _committer = _environmentFacade.createCommitter(virtualHost.getName());
+ _committer = _environmentFacade.createCommitter(_virtualHostName);
_committer.start();
+
+ _messageStoreStateManager.attainState(State.INITIALISED);
+ }
+
+ @Override
+ public synchronized void recoverMessageStore(MessageStoreRecoveryHandler messageRecoveryHandler, TransactionLogRecoveryHandler transactionLogRecoveryHandler) throws StoreException
+ {
+ _messageStoreStateManager.attainState(State.ACTIVATING);
+ DatabaseConfig dbConfig = new DatabaseConfig();
+ dbConfig.setTransactional(true);
+ dbConfig.setAllowCreate(true);
+ try
+ {
+ new Upgrader(_environmentFacade.getEnvironment(), _virtualHostName).upgradeIfNecessary();
+ _environmentFacade.openDatabases(dbConfig, MESSAGE_STORE_DATABASE_NAMES);
+ _totalStoreSize = getSizeOnDisk();
+ }
+ catch(DatabaseException e)
+ {
+ throw _environmentFacade.handleDatabaseException("Cannot activate message store", e);
+ }
+
+ if(messageRecoveryHandler != null)
+ {
+ recoverMessages(messageRecoveryHandler);
+ }
+ if(transactionLogRecoveryHandler != null)
+ {
+ recoverQueueEntries(transactionLogRecoveryHandler);
+ }
+
+ _messageStoreStateManager.attainState(State.ACTIVE);
+ }
+
+ @Override
+ public org.apache.qpid.server.store.Transaction newTransaction() throws StoreException
+ {
+ return new BDBTransaction();
}
@Override
@@ -283,35 +272,59 @@ public class BDBMessageStore implements MessageStore, DurableConfigurationStore
* @throws Exception If the close fails.
*/
@Override
- public void close() throws StoreException
+ public void closeMessageStore() throws StoreException
{
- if (_closed.compareAndSet(false, true))
+ _messageStoreStateManager.attainState(State.CLOSING);
+ try
{
- _stateManager.attainState(State.CLOSING);
- try
+ if (_committer != null)
{
- try
- {
- _committer.stop();
- }
- finally
- {
- closeEnvironment();
- }
+ _committer.stop();
}
- catch(DatabaseException e)
+ }
+ finally
+ {
+ if (_configurationStoreStateManager.isInState(State.CLOSED) || _configurationStoreStateManager.isInState(State.INITIAL))
{
- throw new StoreException("Exception occured on message store close", e);
+ closeEnvironment();
}
- _stateManager.attainState(State.CLOSED);
}
+ _messageStoreStateManager.attainState(State.CLOSED);
+ }
+
+ @Override
+ public void closeConfigurationStore() throws StoreException
+ {
+ _configurationStoreStateManager.attainState(State.CLOSING);
+ try
+ {
+ if (_committer != null)
+ {
+ _committer.stop();
+ }
+ }
+ finally
+ {
+ if (_messageStoreStateManager.isInState(State.CLOSED) || _messageStoreStateManager.isInState(State.INITIAL))
+ {
+ closeEnvironment();
+ }
+ }
+ _configurationStoreStateManager.attainState(State.CLOSED);
}
private void closeEnvironment()
{
if (_environmentFacade != null)
{
- _environmentFacade.close();
+ try
+ {
+ _environmentFacade.close();
+ }
+ catch(DatabaseException e)
+ {
+ throw new StoreException("Exception occured on message store close", e);
+ }
}
}
@@ -704,7 +717,7 @@ public class BDBMessageStore implements MessageStore, DurableConfigurationStore
@Override
public void create(UUID id, String type, Map<String, Object> attributes) throws StoreException
{
- if (_stateManager.isInState(State.ACTIVE))
+ if (_configurationStoreStateManager.isInState(State.ACTIVE))
{
ConfiguredObjectRecord configuredObject = new ConfiguredObjectRecord(id, type, attributes);
storeConfiguredObjectEntry(configuredObject);
@@ -774,7 +787,7 @@ public class BDBMessageStore implements MessageStore, DurableConfigurationStore
{
if (LOGGER.isDebugEnabled())
{
- LOGGER.debug("Updating " +type + ", id: " + id);
+ LOGGER.debug("Updating " + type + ", id: " + id);
}
try
@@ -1286,7 +1299,7 @@ public class BDBMessageStore implements MessageStore, DurableConfigurationStore
*/
private void storeConfiguredObjectEntry(ConfiguredObjectRecord configuredObject) throws StoreException
{
- if (_stateManager.isInState(State.ACTIVE))
+ if (_configurationStoreStateManager.isInState(State.ACTIVE))
{
LOGGER.debug("Storing configured object: " + configuredObject);
DatabaseEntry key = new DatabaseEntry();
diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/EnvironmentFacadeFactory.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/EnvironmentFacadeFactory.java
index d242790efb..fd064d9b0e 100644
--- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/EnvironmentFacadeFactory.java
+++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/EnvironmentFacadeFactory.java
@@ -20,13 +20,13 @@
*/
package org.apache.qpid.server.store.berkeleydb;
-import org.apache.qpid.server.model.VirtualHost;
+import java.util.Map;
public interface EnvironmentFacadeFactory
{
public static final String ENVIRONMENT_CONFIGURATION = "bdbEnvironmentConfig";
- EnvironmentFacade createEnvironmentFacade(VirtualHost<?> virtualHost, boolean isMessageStore);
+ EnvironmentFacade createEnvironmentFacade(String virtualHostName, Map<String, Object> storeSettings);
String getType();
diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacadeFactory.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacadeFactory.java
index 75e14a70c7..cc38b799a6 100644
--- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacadeFactory.java
+++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacadeFactory.java
@@ -25,8 +25,6 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.qpid.server.configuration.BrokerProperties;
-import org.apache.qpid.server.model.VirtualHost;
-import org.apache.qpid.server.store.DurableConfigurationStore;
import org.apache.qpid.server.store.MessageStore;
public class StandardEnvironmentFacadeFactory implements EnvironmentFacadeFactory
@@ -34,38 +32,19 @@ public class StandardEnvironmentFacadeFactory implements EnvironmentFacadeFactor
@SuppressWarnings("unchecked")
@Override
- public EnvironmentFacade createEnvironmentFacade(VirtualHost<?> virtualHost, boolean isMessageStore)
+ public EnvironmentFacade createEnvironmentFacade(String virtualHostName, Map<String, Object> messageStoreSettings)
{
- String name = virtualHost.getName();
- Map<String, Object> messageStoreSettings = virtualHost.getMessageStoreSettings();
Map<String, String> envConfigMap = new HashMap<String, String>();
envConfigMap.putAll(EnvironmentFacade.ENVCONFIG_DEFAULTS);
- final String defaultPath = System.getProperty(BrokerProperties.PROPERTY_QPID_WORK) + File.separator + "bdbstore" + File.separator + name;
+ final String defaultPath = System.getProperty(BrokerProperties.PROPERTY_QPID_WORK) + File.separator + "bdbstore" + File.separator + virtualHostName;
- String storeLocation;
- if(isMessageStore)
+ Object environmentConfigurationAttributes = messageStoreSettings.get(ENVIRONMENT_CONFIGURATION);
+ if (environmentConfigurationAttributes instanceof Map)
{
- Object environmentConfigurationAttributes = messageStoreSettings.get(ENVIRONMENT_CONFIGURATION);
- if (environmentConfigurationAttributes instanceof Map)
- {
- envConfigMap.putAll((Map<String, String>) environmentConfigurationAttributes);
- }
-
- storeLocation = (String) messageStoreSettings.get(MessageStore.STORE_PATH);
- }
- else // we are acting only as the durable config store
- {
- Map<String, Object> configurationStoreSettings = virtualHost.getConfigurationStoreSettings();
-
- Object environmentConfigurationAttributes = configurationStoreSettings.get(ENVIRONMENT_CONFIGURATION);
- if (environmentConfigurationAttributes instanceof Map)
- {
- envConfigMap.putAll((Map<String, String>) environmentConfigurationAttributes);
- }
-
- storeLocation = (String) configurationStoreSettings.get(DurableConfigurationStore.STORE_PATH);
+ envConfigMap.putAll((Map<String, String>) environmentConfigurationAttributes);
}
+ String storeLocation = (String) messageStoreSettings.get(MessageStore.STORE_PATH);
if(storeLocation == null)
{
storeLocation = defaultPath;
diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacadeFactory.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacadeFactory.java
index 4df62b1d0f..c6b3e48cf8 100644
--- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacadeFactory.java
+++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacadeFactory.java
@@ -22,7 +22,6 @@ package org.apache.qpid.server.store.berkeleydb.replication;
import java.util.Map;
-import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.server.store.berkeleydb.EnvironmentFacade;
import org.apache.qpid.server.store.berkeleydb.EnvironmentFacadeFactory;
@@ -48,9 +47,8 @@ public class ReplicatedEnvironmentFacadeFactory implements EnvironmentFacadeFact
private static final boolean DEFAULT_COALESCING_SYNC = true;
@Override
- public EnvironmentFacade createEnvironmentFacade(VirtualHost<?> virtualHost, boolean isMessageStore)
+ public EnvironmentFacade createEnvironmentFacade(String virtualHostName, final Map<String, Object> messageStoreSettings)
{
- final Map<String, Object> messageStoreSettings = virtualHost.getMessageStoreSettings();
ReplicatedEnvironmentConfiguration configuration = new ReplicatedEnvironmentConfiguration()
{
@Override
diff --git a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreConfigurationTest.java b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreConfigurationTest.java
index bfe41773eb..e1678e6f65 100644
--- a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreConfigurationTest.java
+++ b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreConfigurationTest.java
@@ -25,49 +25,9 @@ import org.apache.qpid.server.store.DurableConfigurationStore;
public class BDBMessageStoreConfigurationTest extends AbstractDurableConfigurationStoreTestCase
{
- private BDBMessageStore _bdbMessageStore;
-
- @Override
- protected BDBMessageStore createMessageStore() throws Exception
- {
- createStoreIfNecessary();
- return _bdbMessageStore;
- }
-
- @Override
- protected void closeMessageStore() throws Exception
- {
- closeStoreIfNecessary();
- }
-
@Override
protected DurableConfigurationStore createConfigStore() throws Exception
{
- createStoreIfNecessary();
-
- return _bdbMessageStore;
- }
-
- @Override
- protected void closeConfigStore() throws Exception
- {
- closeStoreIfNecessary();
- }
-
- private void createStoreIfNecessary()
- {
- if(_bdbMessageStore == null)
- {
- _bdbMessageStore = new BDBMessageStore();
- }
- }
-
- private void closeStoreIfNecessary() throws Exception
- {
- if (_bdbMessageStore != null)
- {
- _bdbMessageStore.close();
- _bdbMessageStore = null;
- }
+ return new BDBMessageStore();
}
}
diff --git a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreQuotaEventsTest.java b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreQuotaEventsTest.java
index 65830fd1c2..f2de01445d 100644
--- a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreQuotaEventsTest.java
+++ b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreQuotaEventsTest.java
@@ -20,15 +20,11 @@
*/
package org.apache.qpid.server.store.berkeleydb;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
-import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.server.store.MessageStoreQuotaEventsTestBase;
@@ -62,20 +58,17 @@ public class BDBMessageStoreQuotaEventsTest extends MessageStoreQuotaEventsTestB
@Override
- protected VirtualHost<?> createVirtualHost(String storeLocation)
+ protected Map<String, Object>createStoreSettings(String storeLocation)
{
_logger.debug("Applying store specific config. overfull-size=" + OVERFULL_SIZE + ", underfull-size=" + UNDERFULL_SIZE);
- VirtualHost<?> vhost = mock(VirtualHost.class);
Map<String, Object> messageStoreSettings = new HashMap<String, Object>();
messageStoreSettings.put(MessageStore.STORE_PATH, storeLocation);
messageStoreSettings.put(MessageStore.OVERFULL_SIZE, OVERFULL_SIZE);
messageStoreSettings.put(MessageStore.UNDERFULL_SIZE, UNDERFULL_SIZE);
Map<String,String> envMap = Collections.singletonMap("je.log.fileMax", MAX_BDB_LOG_SIZE);
messageStoreSettings.put(EnvironmentFacadeFactory.ENVIRONMENT_CONFIGURATION, envMap);
- when(vhost.getMessageStoreSettings()).thenReturn(messageStoreSettings);
- when(vhost.getName()).thenReturn("test");
- return vhost;
+ return messageStoreSettings;
}
@Override