summaryrefslogtreecommitdiff
path: root/qpid/java
diff options
context:
space:
mode:
authorKeith Wall <kwall@apache.org>2014-03-17 17:04:15 +0000
committerKeith Wall <kwall@apache.org>2014-03-17 17:04:15 +0000
commit03d8b35a169a4bb3038ca60ea07d1728a8d50c7b (patch)
treec6d0cf83b4fa00915e3a12be43d30c5b70885d71 /qpid/java
parent8ad99bd6b07efe9f91ed9cde2b2121028005c317 (diff)
downloadqpid-python-03d8b35a169a4bb3038ca60ea07d1728a8d50c7b.tar.gz
QPID-5624: Refactor broker configuration store upgrader for version 1.3
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/java-broker-bdb-ha2@1578464 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/startup/StoreUpgrader.java195
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/startup/StoreUpgrader1_3.java345
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/StoreUpgraderTest.java45
3 files changed, 396 insertions, 189 deletions
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/startup/StoreUpgrader.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/startup/StoreUpgrader.java
index 1dfd834b4a..1cadf270d7 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/startup/StoreUpgrader.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/startup/StoreUpgrader.java
@@ -1,4 +1,4 @@
-package org.apache.qpid.server.configuration.startup;/*
+/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -19,7 +19,8 @@ package org.apache.qpid.server.configuration.startup;/*
*
*/
-import java.util.ArrayList;
+package org.apache.qpid.server.configuration.startup;
+
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -32,6 +33,7 @@ import org.apache.qpid.server.model.Broker;
public abstract class StoreUpgrader
{
+
private static Map<String, StoreUpgrader> _upgraders = new HashMap<String, StoreUpgrader>();
// Note: don't use externally defined constants in upgraders in case they change, the values here MUST stay the same
@@ -136,194 +138,9 @@ public abstract class StoreUpgrader
}
};
- final static StoreUpgrader UPGRADE_1_3 = new StoreUpgrader("1.3")
- {
- private final String[] HA_ATTRIBUTES = {"haNodeName", "haGroupName", "haHelperAddress", "haCoalescingSync", "haNodeAddress","haDurability","haDesignatedPrimary","haReplicationConfig","bdbEnvironmentConfig"};
- private final String[] JDBC_ATTRIBUTES = {"connectionPool", "jdbcBigIntType", "jdbcBytesForBlob", "jdbcVarbinaryType", "jdbcBlobType", "partitionCount", "maxConnectionsPerPartition", "minConnectionsPerPartition"};
- private final String[] STORE_TYPES = {"BDB", "BDB-HA", "JDBC", "Memory", "DERBY"};
- private final String[] CONFIGURATION_STORE_TYPES = {"BDB", "JSON", "JDBC", "Memory", "DERBY"};
-
- @Override
- protected void doUpgrade(ConfigurationEntryStore store)
- {
- ConfigurationEntry root = store.getRootEntry();
- Map<String, Collection<ConfigurationEntry>> children = root.getChildren();
- Collection<ConfigurationEntry> vhosts = children.get("VirtualHost");
- Collection<ConfigurationEntry> changed = new ArrayList<ConfigurationEntry>();
- for(ConfigurationEntry vhost : vhosts)
- {
- Map<String, Object> attributes = vhost.getAttributes();
- Map<String, Object> newAttributes = new HashMap<String, Object>(attributes);
- Map<String, Object> messageStoreSettings = new HashMap<String, Object>();
-
- String storeType = (String) attributes.get("storeType");
- String realStoreType = storeType;
- for (String type : STORE_TYPES)
- {
- if (type.equalsIgnoreCase(storeType))
- {
- realStoreType = type;
- break;
- }
- }
- if(attributes.containsKey("storeType"))
- {
- newAttributes.remove("storeType");
- messageStoreSettings.put("storeType", realStoreType);
- }
- if (attributes.containsKey("storePath"))
- {
- messageStoreSettings.put("storePath", newAttributes.remove("storePath"));
- }
- if (attributes.containsKey("storeUnderfullSize"))
- {
- messageStoreSettings.put("storeUnderfullSize", newAttributes.remove("storeUnderfullSize"));
- }
- if (attributes.containsKey("storeOverfullSize"))
- {
- messageStoreSettings.put("storeOverfullSize", newAttributes.remove("storeOverfullSize"));
- }
-
- if ("BDB_HA".equals(attributes.get("type")))
- {
- for (String haAttribute : HA_ATTRIBUTES)
- {
- if(attributes.containsKey(haAttribute))
- {
- messageStoreSettings.put(haAttribute, newAttributes.remove(haAttribute));
- }
- }
- messageStoreSettings.remove("storeType");
- }
- else
- {
- if ("JDBC".equalsIgnoreCase(realStoreType))
- {
- // storePath attribute might contain the connectionURL
- if (messageStoreSettings.containsKey("storePath"))
- {
- messageStoreSettings.put("connectionURL", messageStoreSettings.remove("storePath"));
- }
-
- if (newAttributes.containsKey("connectionURL"))
- {
- messageStoreSettings.put("connectionURL", newAttributes.remove("connectionURL"));
- }
-
- copyJdbcStoreSettings(attributes, messageStoreSettings);
- }
- else if ("BDB".equals(realStoreType))
- {
- if(attributes.containsKey("bdbEnvironmentConfig"))
- {
- messageStoreSettings.put("bdbEnvironmentConfig", newAttributes.get("bdbEnvironmentConfig"));
- }
- }
- }
-
- //TODO: this might need throwing an exception if message store is not defined
- if (!messageStoreSettings.isEmpty())
- {
- newAttributes.put("messageStoreSettings", messageStoreSettings);
- }
-
- Map<String, Object> configurationStoreSettings = new HashMap<String, Object>();
- String realConfigurationStoreType = copyConfigurationStoreSettings(newAttributes, configurationStoreSettings);
-
- if (!configurationStoreSettings.isEmpty())
- {
- newAttributes.put("configurationStoreSettings", configurationStoreSettings);
- }
-
- if ("JDBC".equalsIgnoreCase(realStoreType) || "JDBC".equalsIgnoreCase(realConfigurationStoreType))
- {
- for (String jdbcAttribute : JDBC_ATTRIBUTES)
- {
- if(newAttributes.containsKey(jdbcAttribute))
- {
- newAttributes.remove(jdbcAttribute);
- }
- }
- }
-
- if ("BDB".equalsIgnoreCase(realStoreType) || "BDB".equalsIgnoreCase(realConfigurationStoreType))
- {
- if(newAttributes.containsKey("bdbEnvironmentConfig"))
- {
- newAttributes.remove("bdbEnvironmentConfig");
- }
- }
-
- changed.add(new ConfigurationEntry(vhost.getId(), vhost.getType(), newAttributes, vhost.getChildrenIds(), store));
- }
- Map<String, Object> attributes = new HashMap<String, Object>(root.getAttributes());
- attributes.put(Broker.MODEL_VERSION, "1.4");
- changed.add(new ConfigurationEntry(root.getId(), root.getType(), attributes, root.getChildrenIds(),store));
-
- store.save(changed.toArray(new ConfigurationEntry[changed.size()]));
-
- }
-
- private String copyConfigurationStoreSettings(Map<String, Object> newAttributes,
- Map<String, Object> configurationStoreSettings)
- {
- String realConfigurationStoreType = null;
- if(newAttributes.containsKey("configStoreType"))
- {
- String configurationStoreType = (String) newAttributes.get("configStoreType");
- realConfigurationStoreType = configurationStoreType;
- for (String type : CONFIGURATION_STORE_TYPES)
- {
- if (type.equalsIgnoreCase(configurationStoreType))
- {
- realConfigurationStoreType = type;
- break;
- }
- }
- newAttributes.remove("configStoreType");
- configurationStoreSettings.put("storeType", realConfigurationStoreType);
- if ("JDBC".equalsIgnoreCase(realConfigurationStoreType))
- {
- // storePath attribute might contain the connectionURL
- if (newAttributes.containsKey("configStorePath"))
- {
- configurationStoreSettings.put("connectionURL", newAttributes.remove("configStorePath"));
- }
- if (newAttributes.containsKey("configConnectionURL"))
- {
- configurationStoreSettings.put("connectionURL", newAttributes.remove("configConnectionURL"));
- }
- copyJdbcStoreSettings(newAttributes, configurationStoreSettings);
- }
- else if ("BDB".equals(realConfigurationStoreType))
- {
- if(newAttributes.containsKey("bdbEnvironmentConfig"))
- {
- configurationStoreSettings.put("bdbEnvironmentConfig", newAttributes.get("bdbEnvironmentConfig"));
- }
- }
- }
-
- if (newAttributes.containsKey("configStorePath"))
- {
- configurationStoreSettings.put("storePath", newAttributes.remove("configStorePath"));
- }
- return realConfigurationStoreType;
- }
-
- private void copyJdbcStoreSettings(Map<String, Object> attributes, Map<String, Object> messageStoreSettings)
- {
- for (String jdbcAttribute : JDBC_ATTRIBUTES)
- {
- if(attributes.containsKey(jdbcAttribute))
- {
- messageStoreSettings.put(jdbcAttribute, attributes.get(jdbcAttribute));
- }
- }
- }
- };
+ final static StoreUpgrader UPGRADE_1_3 = new StoreUpgrader1_3("1.3");
- private StoreUpgrader(String version)
+ protected StoreUpgrader(String version)
{
_upgraders.put(version, this);
}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/startup/StoreUpgrader1_3.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/startup/StoreUpgrader1_3.java
new file mode 100644
index 0000000000..913ed4d773
--- /dev/null
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/startup/StoreUpgrader1_3.java
@@ -0,0 +1,345 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.configuration.startup;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.qpid.server.configuration.ConfigurationEntry;
+import org.apache.qpid.server.configuration.ConfigurationEntryStore;
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.model.Broker;
+
+@SuppressWarnings("serial")
+public final class StoreUpgrader1_3 extends StoreUpgrader
+{
+ public static final String VERSION = "1.3";
+
+ private Map<String, VirtualHostEntryUpgrader> _vhostUpgraderMap = new HashMap<String, VirtualHostEntryUpgrader>()
+ {{
+ put("BDB_HA", new BdbHaVirtualHostUpgrader());
+ put("STANDARD", new StandardVirtualHostUpgrader());
+ }};
+
+ StoreUpgrader1_3(String version)
+ {
+ super(version);
+ }
+
+ @Override
+ protected void doUpgrade(ConfigurationEntryStore store)
+ {
+ ConfigurationEntry root = store.getRootEntry();
+ Map<String, Collection<ConfigurationEntry>> children = root.getChildren();
+ Collection<ConfigurationEntry> vhosts = children.get("VirtualHost");
+ Collection<ConfigurationEntry> changed = new ArrayList<ConfigurationEntry>();
+
+ for (ConfigurationEntry vhost : vhosts)
+ {
+ Map<String, Object> attributes = vhost.getAttributes();
+ if (attributes.containsKey("configPath"))
+ {
+ throw new IllegalConfigurationException("Auto-upgrade of virtual host " + attributes.get("name") + " having XML configuration is not supported. Virtual host configuration file is " + attributes.get("configPath"));
+ }
+
+ String type = (String) attributes.get("type");
+ VirtualHostEntryUpgrader vhostUpgrader = _vhostUpgraderMap.get(type);
+ if (vhostUpgrader == null)
+ {
+ throw new IllegalConfigurationException("Don't know how to perform an upgrade from version " + VERSION
+ + " for virtualhost type " + type);
+ }
+ ConfigurationEntry newVirtualHostConfigurationEntry = vhostUpgrader.upgrade(store, vhost);
+ changed.add(newVirtualHostConfigurationEntry);
+ }
+
+ Map<String, Object> attributes = new HashMap<String, Object>(root.getAttributes());
+ attributes.put(Broker.MODEL_VERSION, "1.4");
+ changed.add(new ConfigurationEntry(root.getId(), root.getType(), attributes, root.getChildrenIds(), store));
+ store.save(changed.toArray(new ConfigurationEntry[changed.size()]));
+ }
+
+ public interface VirtualHostEntryUpgrader
+ {
+ ConfigurationEntry upgrade(ConfigurationEntryStore store, ConfigurationEntry vhost);
+ }
+
+ public class BdbHaVirtualHostUpgrader implements VirtualHostEntryUpgrader
+ {
+ private final String[] HA_ATTRIBUTES =
+ { "storePath", "haNodeName", "haGroupName", "haHelperAddress", "haCoalescingSync", "haNodeAddress", "haDurability",
+ "haDesignatedPrimary", "haReplicationConfig", "bdbEnvironmentConfig" };
+
+ @Override
+ public ConfigurationEntry upgrade(ConfigurationEntryStore store, ConfigurationEntry vhost)
+ {
+ Map<String, Object> attributes = vhost.getAttributes();
+ Map<String, Object> newAttributes = new HashMap<String, Object>(attributes);
+ Map<String, Object> messageStoreSettings = new HashMap<String, Object>();
+
+ for (String haAttribute : HA_ATTRIBUTES)
+ {
+ if (attributes.containsKey(haAttribute))
+ {
+ messageStoreSettings.put(haAttribute, newAttributes.remove(haAttribute));
+ }
+ }
+
+ if (attributes.containsKey("storeUnderfullSize"))
+ {
+ messageStoreSettings.put("storeUnderfullSize", newAttributes.remove("storeUnderfullSize"));
+ }
+ if (attributes.containsKey("storeOverfullSize"))
+ {
+ messageStoreSettings.put("storeOverfullSize", newAttributes.remove("storeOverfullSize"));
+ }
+ newAttributes.remove("storeType");
+ newAttributes.put("messageStoreSettings", messageStoreSettings);
+ return new ConfigurationEntry(vhost.getId(), vhost.getType(), newAttributes, vhost.getChildrenIds(), store);
+ }
+
+ }
+
+ public interface StoreEntryUpgrader
+ {
+ Map<String, Object> upgrade(Map<String, Object> attributes);
+
+ Set<String> getNamesToBeDeleted();
+ }
+
+ public class GenericMessageStoreEntryUpgrader implements StoreEntryUpgrader
+ {
+ private Map<String, String> _oldToNewNamesMap;
+ private String _storeType;
+
+ public GenericMessageStoreEntryUpgrader(String storeType, Map<String, String> oldToNewNamesMap)
+ {
+ _oldToNewNamesMap = oldToNewNamesMap;
+ _storeType = storeType;
+ }
+
+ @Override
+ public Map<String, Object> upgrade(Map<String, Object> attributes)
+ {
+ Map<String, Object> messageStoreSettings = new HashMap<String, Object>();
+ for (Map.Entry<String, String> nameMapEntry : _oldToNewNamesMap.entrySet())
+ {
+ String attributeName = nameMapEntry.getKey();
+ if (attributes.containsKey(attributeName))
+ {
+ messageStoreSettings.put(nameMapEntry.getValue(), attributes.get(attributeName));
+ }
+ }
+ messageStoreSettings.put("storeType", _storeType);
+ return messageStoreSettings;
+ }
+
+ @Override
+ public Set<String> getNamesToBeDeleted()
+ {
+ Set<String> names = new HashSet<String>(_oldToNewNamesMap.keySet());
+ names.add("storeType");
+ return names;
+ }
+
+ }
+
+ public class JDBCMessageStoreEntryUpgrader implements StoreEntryUpgrader
+ {
+ private final String[] JDBC_ATTRIBUTES =
+ { "connectionURL", "connectionPool", "jdbcBigIntType", "jdbcBytesForBlob", "jdbcVarbinaryType", "jdbcBlobType",
+ "partitionCount", "maxConnectionsPerPartition", "minConnectionsPerPartition" };
+
+ @Override
+ public Map<String, Object> upgrade(Map<String, Object> attributes)
+ {
+ Map<String, Object> messageStoreSettings = new HashMap<String, Object>();
+
+ if (attributes.containsKey("storePath"))
+ {
+ messageStoreSettings.put("connectionURL", attributes.get("storePath"));
+ }
+
+ copyJdbcStoreSettings(attributes, messageStoreSettings);
+
+ messageStoreSettings.put("storeType", "JDBC");
+ return messageStoreSettings;
+ }
+
+ @Override
+ public Set<String> getNamesToBeDeleted()
+ {
+ Set<String> names = new HashSet<String>();
+ names.addAll(Arrays.asList(JDBC_ATTRIBUTES));
+ names.add("storePath");
+ names.add("storeType");
+ return names;
+ }
+
+ private void copyJdbcStoreSettings(Map<String, Object> attributes, Map<String, Object> messageStoreSettings)
+ {
+ for (String jdbcAttribute : JDBC_ATTRIBUTES)
+ {
+ if (attributes.containsKey(jdbcAttribute))
+ {
+ messageStoreSettings.put(jdbcAttribute, attributes.get(jdbcAttribute));
+ }
+ }
+ }
+
+ }
+
+ public class JDBCConfigurationStoreEntryUpgrader implements StoreEntryUpgrader
+ {
+
+ private final String[] JDBC_ATTRIBUTES =
+ { "connectionPool", "jdbcBigIntType", "jdbcBytesForBlob", "jdbcVarbinaryType", "jdbcBlobType", "partitionCount",
+ "maxConnectionsPerPartition", "minConnectionsPerPartition" };
+
+ @Override
+ public Map<String, Object> upgrade(Map<String, Object> attributes)
+ {
+ Map<String, Object> messageStoreSettings = new HashMap<String, Object>();
+
+ if (attributes.containsKey("configStorePath"))
+ {
+ messageStoreSettings.put("connectionURL", attributes.get("configStorePath"));
+ }
+
+ if (attributes.containsKey("configConnectionURL"))
+ {
+ messageStoreSettings.put("connectionURL", attributes.get("configConnectionURL"));
+ }
+
+ copyJdbcStoreSettings(attributes, messageStoreSettings);
+
+ messageStoreSettings.put("storeType", "JDBC");
+ return messageStoreSettings;
+ }
+
+ @Override
+ public Set<String> getNamesToBeDeleted()
+ {
+ Set<String> names = new HashSet<String>();
+ names.addAll(Arrays.asList(JDBC_ATTRIBUTES));
+ names.add("configStorePath");
+ names.add("configStoreType");
+ names.add("configConnectionURL");
+ return names;
+ }
+
+ private void copyJdbcStoreSettings(Map<String, Object> attributes, Map<String, Object> messageStoreSettings)
+ {
+ for (String jdbcAttribute : JDBC_ATTRIBUTES)
+ {
+ if (attributes.containsKey(jdbcAttribute))
+ {
+ messageStoreSettings.put(jdbcAttribute, attributes.get(jdbcAttribute));
+ }
+ }
+ }
+ }
+
+ public class StandardVirtualHostUpgrader implements VirtualHostEntryUpgrader
+ {
+ Map<String, StoreEntryUpgrader> _messageStoreEntryUpgrader = new HashMap<String, StoreEntryUpgrader>()
+ {{
+ put("JDBC", new JDBCMessageStoreEntryUpgrader());
+ put("BDB", new GenericMessageStoreEntryUpgrader("BDB", new HashMap<String, String>()
+ {{
+ put("storePath", "storePath");
+ put("bdbEnvironmentConfig", "bdbEnvironmentConfig");
+ put("storeUnderfullSize", "storeUnderfullSize");
+ put("storeOverfullSize", "storeOverfullSize");
+ }}));
+ put("DERBY", new GenericMessageStoreEntryUpgrader("DERBY", new HashMap<String, String>()
+ {{
+ put("storePath", "storePath");
+ put("storeUnderfullSize", "storeUnderfullSize");
+ put("storeOverfullSize", "storeOverfullSize");
+ }}));
+ put("MEMORY", new GenericMessageStoreEntryUpgrader("Memory", Collections.<String, String> emptyMap()));
+ }};
+ Map<String, StoreEntryUpgrader> _configurationStoreEntryUpgrader = new HashMap<String, StoreEntryUpgrader>()
+ {{
+ put("JDBC", new JDBCConfigurationStoreEntryUpgrader());
+ put("DERBY", new GenericMessageStoreEntryUpgrader("DERBY", new HashMap<String, String>()
+ {{
+ put("configStorePath", "storePath");
+ put("configStoreType", "storeType");
+ }}));
+ put("BDB", new GenericMessageStoreEntryUpgrader("BDB", new HashMap<String, String>()
+ {{
+ put("configStoreType", "storeType");
+ put("configStorePath", "storePath");
+ put("bdbEnvironmentConfig", "bdbEnvironmentConfig");
+ }}));
+ put("MEMORY", new GenericMessageStoreEntryUpgrader("Memory",
+ Collections.<String, String> singletonMap("configStoreType", "storeType")));
+ put("JSON", new GenericMessageStoreEntryUpgrader("JSON", new HashMap<String, String>()
+ {{
+ put("configStorePath", "storePath");
+ put("configStoreType", "storeType");
+ }}));
+ }};
+
+ @Override
+ public ConfigurationEntry upgrade(ConfigurationEntryStore store, ConfigurationEntry vhost)
+ {
+ Map<String, Object> attributes = vhost.getAttributes();
+ Map<String, Object> newAttributes = new HashMap<String, Object>(attributes);
+
+ String capitalisedStoreType = String.valueOf(attributes.get("storeType")).toUpperCase();
+ StoreEntryUpgrader messageStoreSettingsUpgrader = _messageStoreEntryUpgrader.get(capitalisedStoreType);
+ Map<String, Object> messageStoreSettings = null;
+ if (messageStoreSettingsUpgrader != null)
+ {
+ messageStoreSettings = messageStoreSettingsUpgrader.upgrade(attributes);
+ }
+
+ if (attributes.containsKey("configStoreType"))
+ {
+ String capitaliseConfigStoreType = ((String) attributes.get("configStoreType")).toUpperCase();
+ StoreEntryUpgrader configurationStoreSettingsUpgrader = _configurationStoreEntryUpgrader
+ .get(capitaliseConfigStoreType);
+ Map<String, Object> configurationStoreSettings = configurationStoreSettingsUpgrader.upgrade(attributes);
+ newAttributes.keySet().removeAll(configurationStoreSettingsUpgrader.getNamesToBeDeleted());
+ newAttributes.put("configurationStoreSettings", configurationStoreSettings);
+ }
+
+ if (messageStoreSettingsUpgrader != null)
+ {
+ newAttributes.keySet().removeAll(messageStoreSettingsUpgrader.getNamesToBeDeleted());
+ newAttributes.put("messageStoreSettings", messageStoreSettings);
+ }
+
+ return new ConfigurationEntry(vhost.getId(), vhost.getType(), newAttributes, vhost.getChildrenIds(), store);
+ }
+
+ }
+
+} \ No newline at end of file
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/StoreUpgraderTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/StoreUpgraderTest.java
index 16acefc78e..cc5137ed66 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/StoreUpgraderTest.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/StoreUpgraderTest.java
@@ -33,6 +33,7 @@ import junit.framework.TestCase;
import org.apache.qpid.server.configuration.ConfigurationEntry;
import org.apache.qpid.server.configuration.ConfigurationEntryStore;
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.model.VirtualHost;
@@ -43,6 +44,23 @@ public class StoreUpgraderTest extends TestCase
private final UUID _virtualHostId = UUID.randomUUID();
private ConfigurationEntryStore _store = mock(ConfigurationEntryStore.class);
+ public void testUpgrade13To14_RejectsConfigPath() throws Exception
+ {
+ HashMap<String, Object> virtualHostAttributes = new HashMap<String, Object>();
+ virtualHostAttributes.put("name", "test");
+ virtualHostAttributes.put("type", "STANDARD");
+ virtualHostAttributes.put("configPath", "/mypath");
+ try
+ {
+ doTest(_store, virtualHostAttributes);
+ fail("Upgrade of virtual host with configuration XML is unsupported at the moment");
+ }
+ catch(IllegalConfigurationException e)
+ {
+ // pass
+ }
+ }
+
public void testUpgrade13To14_Derby() throws Exception
{
HashMap<String, Object> virtualHostAttributes = new HashMap<String, Object>();
@@ -101,6 +119,33 @@ public class StoreUpgraderTest extends TestCase
verify(_store).save(expectedNewVirtualHost, expectNewRoot);
}
+ public void testUpgrade13To14_JsonConfigurationStore() throws Exception
+ {
+ HashMap<String, Object> virtualHostAttributes = new HashMap<String, Object>();
+ virtualHostAttributes.put("name", "test");
+ virtualHostAttributes.put("type", "STANDARD");
+ virtualHostAttributes.put("configStoreType", "JsoN");
+ virtualHostAttributes.put("configStorePath", "/mystorepath");
+
+ doTest(_store, virtualHostAttributes);
+
+ ConfigurationEntry expectNewRoot = new ConfigurationEntry(_brokerId, Broker.class.getSimpleName(), Collections.<String, Object>singletonMap(Broker.MODEL_VERSION, "1.4"), Collections.singleton(_virtualHostId), _store);
+ ConfigurationEntry expectedNewVirtualHost;
+ {
+ Map<String, Object> expectedNewVirtualHostConfigurationStoreSettings = new HashMap<String, Object>();
+ expectedNewVirtualHostConfigurationStoreSettings.put("storeType", "JSON");
+ expectedNewVirtualHostConfigurationStoreSettings.put("storePath", "/mystorepath");
+
+ Map<String, Object> expectedNewVirtualHostAttributes = new HashMap<String, Object>();
+ expectedNewVirtualHostAttributes.put(VirtualHost.NAME, "test");
+ expectedNewVirtualHostAttributes.put(VirtualHost.TYPE, "STANDARD");
+ expectedNewVirtualHostAttributes.put(VirtualHost.CONFIGURATION_STORE_SETTINGS, expectedNewVirtualHostConfigurationStoreSettings);
+
+ expectedNewVirtualHost = new ConfigurationEntry(_virtualHostId, VirtualHost.class.getSimpleName(), expectedNewVirtualHostAttributes, Collections.<UUID>emptySet(), _store);
+ }
+ verify(_store).save(expectedNewVirtualHost, expectNewRoot);
+ }
+
public void testUpgrade13To14_BdbHa() throws Exception
{
HashMap<String, Object> virtualHostAttributes = new HashMap<String, Object>();