summaryrefslogtreecommitdiff
path: root/qpid/java/broker-plugins
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/broker-plugins
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/broker-plugins')
-rw-r--r--qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java20
-rw-r--r--qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java40
-rw-r--r--qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java13
-rw-r--r--qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java10
-rw-r--r--qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java27
-rw-r--r--qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java13
6 files changed, 29 insertions, 94 deletions
diff --git a/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java b/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java
index f7b65075f7..2c2938cb01 100644
--- a/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java
+++ b/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java
@@ -35,7 +35,6 @@ import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
-import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.store.AbstractJDBCMessageStore;
import org.apache.qpid.server.store.DurableConfigurationStore;
import org.apache.qpid.server.store.Event;
@@ -125,28 +124,13 @@ public class DerbyMessageStore extends AbstractJDBCMessageStore implements Messa
}
@Override
- protected void implementationSpecificConfiguration(String name,
- VirtualHost virtualHost)
+ protected void implementationSpecificConfiguration(String name, Map<String, Object> messageStoreSettings)
throws ClassNotFoundException
{
//Update to pick up QPID_WORK and use that as the default location not just derbyDB
-
- Map<String, Object> messageStoreSettings = virtualHost.getMessageStoreSettings();
- Map<String, Object> configurationStoreSettings = virtualHost.getConfigurationStoreSettings();
_driverClass = (Class<Driver>) Class.forName(SQL_DRIVER_NAME);
- String databasePath = null;
- if (isConfigStoreOnly())
- {
- databasePath = (String) configurationStoreSettings.get(DurableConfigurationStore.STORE_PATH);
- }
- else
- {
- if (messageStoreSettings != null)
- {
- databasePath = (String) messageStoreSettings.get(MessageStore.STORE_PATH);
- }
- }
+ String databasePath = (String) messageStoreSettings.get(MessageStore.STORE_PATH);;
if(databasePath == null)
{
diff --git a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java b/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java
index 4a1a3251e3..aaf65e9ee0 100644
--- a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java
+++ b/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java
@@ -25,48 +25,10 @@ import org.apache.qpid.server.store.AbstractDurableConfigurationStoreTestCase;
public class DerbyMessageStoreConfigurationTest extends AbstractDurableConfigurationStoreTestCase
{
- private DerbyMessageStore _derbyMessageStore;
-
- @Override
- protected DerbyMessageStore createMessageStore() throws Exception
- {
- createStoreIfNecessary();
- return _derbyMessageStore;
- }
-
- @Override
- protected void closeMessageStore() throws Exception
- {
- closeStoreIfNecessary();
- }
-
- private void createStoreIfNecessary()
- {
- if(_derbyMessageStore == null)
- {
- _derbyMessageStore = new DerbyMessageStore();
- }
- }
-
@Override
protected DerbyMessageStore createConfigStore() throws Exception
{
- createStoreIfNecessary();
- return _derbyMessageStore;
+ return new DerbyMessageStore();
}
- @Override
- protected void closeConfigStore() throws Exception
- {
- closeStoreIfNecessary();
- }
-
- private void closeStoreIfNecessary() throws Exception
- {
- if (_derbyMessageStore != null)
- {
- _derbyMessageStore.close();
- _derbyMessageStore = null;
- }
- }
}
diff --git a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java b/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java
index f23b5a3e23..ba7ae26292 100644
--- a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java
+++ b/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java
@@ -20,14 +20,10 @@
*/
package org.apache.qpid.server.store.derby;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
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;
@@ -58,20 +54,15 @@ public class DerbyMessageStoreQuotaEventsTest extends MessageStoreQuotaEventsTes
}
@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);
-
- when(vhost.getMessageStoreSettings()).thenReturn(messageStoreSettings );
- when(vhost.getName()).thenReturn("test");
-
- return vhost;
+ return messageStoreSettings;
}
}
diff --git a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java b/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java
index e3f91cc8fb..20de4ea339 100644
--- a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java
+++ b/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java
@@ -20,13 +20,11 @@
*/
package org.apache.qpid.server.store.derby;
-import static org.mockito.Mockito.when;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
-import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.server.store.MessageStoreTestCase;
import org.apache.qpid.util.FileUtils;
@@ -53,7 +51,7 @@ public class DerbyMessageStoreTest extends MessageStoreTestCase
File location = new File(_storeLocation);
assertTrue("Store does not exist at " + _storeLocation, location.exists());
- getStore().close();
+ getStore().closeMessageStore();
assertTrue("Store does not exist at " + _storeLocation, location.exists());
getStore().onDelete();
@@ -61,13 +59,13 @@ public class DerbyMessageStoreTest extends MessageStoreTestCase
}
@Override
- protected void setUpStoreConfiguration(VirtualHost virtualHost) throws Exception
+ protected Map<String, Object> getStoreSettings() throws Exception
{
_storeLocation = TMP_FOLDER + File.separator + getTestName();
+ deleteStoreIfExists();
Map<String, Object> messageStoreSettings = new HashMap<String, Object>();
messageStoreSettings.put(MessageStore.STORE_PATH, _storeLocation);
- when(virtualHost.getMessageStoreSettings()).thenReturn(messageStoreSettings);
- deleteStoreIfExists();
+ return messageStoreSettings;
}
private void deleteStoreIfExists()
diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java
index 2c2b701c61..55c8d3ef79 100644
--- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java
+++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java
@@ -31,7 +31,6 @@ import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import org.apache.log4j.Logger;
-import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.plugin.JDBCConnectionProviderFactory;
import org.apache.qpid.server.store.AbstractJDBCMessageStore;
import org.apache.qpid.server.store.MessageStore;
@@ -259,18 +258,24 @@ public class JDBCMessageStore extends AbstractJDBCMessageStore implements Messag
@Override
protected void doClose()
{
- while(!_transactions.isEmpty())
- {
- RecordedJDBCTransaction txn = _transactions.get(0);
- txn.abortTran();
- }
try
{
- _connectionProvider.close();
+ while(!_transactions.isEmpty())
+ {
+ RecordedJDBCTransaction txn = _transactions.get(0);
+ txn.abortTran();
+ }
}
- catch (SQLException e)
+ finally
{
- throw new StoreException("Unable to close connection provider ", e);
+ try
+ {
+ _connectionProvider.close();
+ }
+ catch (SQLException e)
+ {
+ throw new StoreException("Unable to close connection provider ", e);
+ }
}
}
@@ -281,11 +286,9 @@ public class JDBCMessageStore extends AbstractJDBCMessageStore implements Messag
}
- protected void implementationSpecificConfiguration(String name,
- VirtualHost virtualHost)
+ protected void implementationSpecificConfiguration(String name, Map<String, Object> storeSettings)
throws ClassNotFoundException, SQLException
{
- Map<String, Object> storeSettings = isConfigStoreOnly() ? virtualHost.getConfigurationStoreSettings() : virtualHost.getMessageStoreSettings();
String connectionURL = String.valueOf(storeSettings.get(CONNECTION_URL));
Object poolAttribute = storeSettings.get(CONNECTION_POOL);
diff --git a/qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java b/qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java
index dc6bb0158d..2322fa7102 100644
--- a/qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java
+++ b/qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java
@@ -20,8 +20,6 @@
*/
package org.apache.qpid.server.store.jdbc;
-import static org.mockito.Mockito.when;
-
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
@@ -32,7 +30,6 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.server.store.MessageStoreTestCase;
@@ -55,21 +52,21 @@ public class JDBCMessageStoreTest extends MessageStoreTestCase
public void testOnDelete() throws Exception
{
- String[] expectedTables = JDBCMessageStore.ALL_TABLES;
+ Set<String> expectedTables = JDBCMessageStore.MESSAGE_STORE_TABLE_NAMES;
assertTablesExist(expectedTables, true);
- getStore().close();
+ getStore().closeMessageStore();
assertTablesExist(expectedTables, true);
getStore().onDelete();
assertTablesExist(expectedTables, false);
}
@Override
- protected void setUpStoreConfiguration(VirtualHost virtualHost) throws Exception
+ protected Map<String, Object> getStoreSettings()
{
_connectionURL = "jdbc:derby:memory:/" + getTestName() + ";create=true";
Map<String, Object> messageStoreSettings = new HashMap<String, Object>();
messageStoreSettings.put(JDBCMessageStore.CONNECTION_URL, _connectionURL);
- when(virtualHost.getMessageStoreSettings()).thenReturn(messageStoreSettings);
+ return messageStoreSettings;
}
@@ -79,7 +76,7 @@ public class JDBCMessageStoreTest extends MessageStoreTestCase
return new JDBCMessageStore();
}
- private void assertTablesExist(String[] expectedTables, boolean exists) throws SQLException
+ private void assertTablesExist(Set<String> expectedTables, boolean exists) throws SQLException
{
Set<String> existingTables = getTableNames();
for (String tableName : expectedTables)