diff options
| author | Robert Godfrey <rgodfrey@apache.org> | 2012-04-13 08:48:34 +0000 |
|---|---|---|
| committer | Robert Godfrey <rgodfrey@apache.org> | 2012-04-13 08:48:34 +0000 |
| commit | 5d9f4b9130209b2cd992fcdda880fc370bd64acf (patch) | |
| tree | 5314536196732c9d2d05e7453092d8ae786d7575 /qpid | |
| parent | 06603e5c3df2ae0e1a47c9a17e6378f8f8e030d7 (diff) | |
| download | qpid-python-5d9f4b9130209b2cd992fcdda880fc370bd64acf.tar.gz | |
QPID-3917 : Fix failing BDB test, remove unusued readOnly flag
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1325661 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid')
3 files changed, 31 insertions, 59 deletions
diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java index 3f394b79a7..439ec8ac4f 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java @@ -156,8 +156,6 @@ public abstract class AbstractBDBMessageStore implements MessageStore protected TransactionConfig _transactionConfig = new TransactionConfig(); - private boolean _readOnly = false; - private MessageStoreRecoveryHandler _messageRecoveryHandler; private TransactionLogRecoveryHandler _tlogRecoveryHandler; @@ -239,53 +237,36 @@ public abstract class AbstractBDBMessageStore implements MessageStore _storeLocation = storeLocation; - configure(environmentPath, false); - } - - /** - * @param environmentPath location for the store to be created in/recovered from - * @param readonly if true then don't allow modifications to an existing store, and don't create a new store if none exists - * @return whether or not a new store environment was created - * @throws AMQStoreException - * @throws DatabaseException - */ - protected void configure(File environmentPath, boolean readonly) throws AMQStoreException, DatabaseException - { - if (_stateManager.isInState(State.INITIAL)) - { - // TODO - currently required for BDBUpgrade and BDBMessageStoreTest - _stateManager.stateTransition(State.INITIAL, State.CONFIGURING); - } - - _readOnly = readonly; - LOGGER.info("Configuring BDB message store"); - setupStore(environmentPath, readonly); + setupStore(environmentPath); } /** - * Move the store state from CONFIGURING to ACTIVE. + * Move the store state from INITIAL to ACTIVE without actually recovering. * * This is required if you do not want to perform recovery of the store data * * @throws AMQStoreException if the store is not in the correct state */ - public void start() throws AMQStoreException + void startWithNoRecover() throws AMQStoreException { - _stateManager.stateTransition(State.CONFIGURING, State.ACTIVE); + _stateManager.attainState(State.CONFIGURING); + _stateManager.attainState(State.CONFIGURED); + _stateManager.attainState(State.RECOVERING); + _stateManager.attainState(State.ACTIVE); } - protected void setupStore(File storePath, boolean readonly) throws DatabaseException, AMQStoreException + protected void setupStore(File storePath) throws DatabaseException, AMQStoreException { - _environment = createEnvironment(storePath, readonly); + _environment = createEnvironment(storePath); new Upgrader(_environment).upgradeIfNecessary(); - openDatabases(readonly); + openDatabases(); } - protected Environment createEnvironment(File environmentPath, boolean readonly) throws DatabaseException + protected Environment createEnvironment(File environmentPath) throws DatabaseException { LOGGER.info("BDB message store using environment path " + environmentPath.getAbsolutePath()); EnvironmentConfig envConfig = new EnvironmentConfig(); @@ -306,7 +287,7 @@ public abstract class AbstractBDBMessageStore implements MessageStore _transactionConfig.setReadCommitted(true); //This prevents background threads running which will potentially update the store. - envConfig.setReadOnly(readonly); + envConfig.setReadOnly(false); try { return new Environment(environmentPath, envConfig); @@ -336,14 +317,14 @@ public abstract class AbstractBDBMessageStore implements MessageStore return _environment; } - private void openDatabases(boolean readonly) throws DatabaseException + private void openDatabases() throws DatabaseException { DatabaseConfig dbConfig = new DatabaseConfig(); dbConfig.setTransactional(true); dbConfig.setAllowCreate(true); //This is required if we are wanting read only access. - dbConfig.setReadOnly(readonly); + dbConfig.setReadOnly(false); _messageMetaDataDb = openDatabase(MESSAGEMETADATADB_NAME, dbConfig); _queueDb = openDatabase(QUEUEDB_NAME, dbConfig); @@ -446,13 +427,10 @@ public abstract class AbstractBDBMessageStore implements MessageStore { if (_environment != null) { - if(!_readOnly) - { - // Clean the log before closing. This makes sure it doesn't contain - // redundant data. Closing without doing this means the cleaner may not - // get a chance to finish. - _environment.cleanLog(); - } + // Clean the log before closing. This makes sure it doesn't contain + // redundant data. Closing without doing this means the cleaner may not + // get a chance to finish. + _environment.cleanLog(); _environment.close(); } } 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 4484c140e0..e5aeed57cd 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 @@ -50,18 +50,14 @@ public class BDBMessageStore extends AbstractBDBMessageStore private final CommitThread _commitThread = new CommitThread("Commit-Thread"); @Override - protected void setupStore(File storePath, boolean readonly) throws DatabaseException, AMQStoreException + protected void setupStore(File storePath) throws DatabaseException, AMQStoreException { - super.setupStore(storePath, readonly); + super.setupStore(storePath); - if (!readonly) - { - startCommitThread(); - } + startCommitThread(); } - @Override - protected Environment createEnvironment(File environmentPath, boolean readonly) throws DatabaseException + protected Environment createEnvironment(File environmentPath) throws DatabaseException { LOGGER.info("BDB message store using environment path " + environmentPath.getAbsolutePath()); EnvironmentConfig envConfig = new EnvironmentConfig(); @@ -82,7 +78,7 @@ public class BDBMessageStore extends AbstractBDBMessageStore _transactionConfig.setReadCommitted(true); //This prevents background threads running which will potentially update the store. - envConfig.setReadOnly(readonly); + envConfig.setReadOnly(false); try { return new Environment(environmentPath, envConfig); diff --git a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreTest.java b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreTest.java index 5b69c2ead6..18e20f2ee8 100644 --- a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreTest.java +++ b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreTest.java @@ -20,6 +20,9 @@ */ package org.apache.qpid.server.store.berkeleydb; +import java.nio.ByteBuffer; +import java.util.Arrays; +import java.util.List; import org.apache.qpid.AMQStoreException; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.BasicContentHeaderProperties; @@ -48,11 +51,6 @@ import org.apache.qpid.transport.MessageDeliveryPriority; import org.apache.qpid.transport.MessageProperties; import org.apache.qpid.transport.MessageTransfer; -import java.io.File; -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.List; - /** * Subclass of MessageStoreTest which runs the standard tests from the superclass against * the BDB Store as well as additional tests specific to the DBB store-implementation. @@ -123,7 +121,7 @@ public class BDBMessageStoreTest extends org.apache.qpid.server.store.MessageSto /* * reload the store only (read-only) */ - bdbStore = reloadStoreReadOnly(bdbStore); + bdbStore = reloadStore(bdbStore); /* * Read back and validate the 0-8 message metadata and content @@ -220,14 +218,14 @@ public class BDBMessageStoreTest extends org.apache.qpid.server.store.MessageSto * Use this method instead of reloading the virtual host like other tests in order * to avoid the recovery handler deleting the message for not being on a queue. */ - private BDBMessageStore reloadStoreReadOnly(BDBMessageStore messageStore) throws Exception + private BDBMessageStore reloadStore(BDBMessageStore messageStore) throws Exception { messageStore.close(); - File storePath = new File(String.valueOf(_config.getProperty("store.environment-path"))); BDBMessageStore newStore = new BDBMessageStore(); - newStore.configure(storePath, false); - newStore.start(); + newStore.configure("", _config.subset("store")); + + newStore.startWithNoRecover(); return newStore; } |
