summaryrefslogtreecommitdiff
path: root/qpid/java/broker
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2013-03-10 22:33:43 +0000
committerRobert Gemmell <robbie@apache.org>2013-03-10 22:33:43 +0000
commit54bfebd60800c46458072769555d86402fd830db (patch)
tree10d1a78ff2fe712888d6b2eb8c786cbfe686a9a5 /qpid/java/broker
parent66992683e1310209c24435c8ff1d0ced0e94cd5a (diff)
downloadqpid-python-54bfebd60800c46458072769555d86402fd830db.tar.gz
QPID-4596: remove manipulation of store files, and vhost store type etc.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1454943 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker')
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java159
1 files changed, 1 insertions, 158 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
index eaf187c95c..40af67f211 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
@@ -1054,163 +1054,6 @@ public final class VirtualHostAdapter extends AbstractAdapter implements Virtual
@Override
protected void changeAttributes(Map<String, Object> attributes)
{
- if (State.ACTIVE.equals(getActualState()))
- {
- throw new IllegalStateException("Cannot change host attributes on active virtual host. This operation is only supported in management mode.");
- }
- Map<String, Object> newAttributes = MapValueConverter.convert(attributes, ATTRIBUTE_TYPES);
- validateConfigurationAndCopyStoreIntoNewLocationIfRequired(newAttributes);
- super.changeAttributes(newAttributes);
- }
-
- private void validateConfigurationAndCopyStoreIntoNewLocationIfRequired(Map<String, Object> newAttributes)
- {
- String name = (String)getAttribute(NAME);
- String configPath = (String)getAttribute(CONFIG_PATH);
- String storePath = (String)getAttribute(STORE_PATH);
- String storeType = (String)getAttribute(STORE_TYPE);
-
- String newConfigPath = (String)newAttributes.get(CONFIG_PATH);
- String newStorePath = (String)newAttributes.get(STORE_PATH);
- String newStoreType = (String)newAttributes.get(STORE_TYPE);
-
- String newName = (String)newAttributes.get(NAME);
- if (newName != null && !newName.equals(name))
- {
- if (name.equals(_broker.getAttribute(Broker.DEFAULT_VIRTUAL_HOST)))
- {
- throw new IntegrityViolationException("Cannot rename virtual host '" + name + "' as it is set as a default." +
- " Change the broker default virtual host before renaming");
- }
- }
- if (newConfigPath != null)
- {
- // try to open new configuration xml and extract information about message store
- try
- {
- Map<String, String> storeDetails = getStoreDetailsFromVirtualHostConfigXml(name, configPath);
- newStorePath = storeDetails.get(STORE_PATH);
- newStoreType = storeDetails.get(STORE_TYPE);
- }
- catch (Exception e)
- {
- throw new IllegalConfigurationException("Cannot open new virtual host configuration at " + newConfigPath, e);
- }
- newAttributes.put(STORE_PATH, null);
- newAttributes.put(STORE_TYPE, null);
- }
- else
- {
- newAttributes.put(CONFIG_PATH, null);
- }
-
- if (configPath != null )
- {
- // try to identify store type and location in order to copy old store into a new location
- try
- {
- Map<String, String> storeDetails = getStoreDetailsFromVirtualHostConfigXml(name, configPath);
- storePath = storeDetails.get(STORE_PATH);
- storeType = storeDetails.get(STORE_TYPE);
- }
- catch (Exception e)
- {
- // old configuration might be broken
- LOGGER.warn("Cannot open virtual host cofiguration at " + configPath + ". Ignoring old broken configuration.", e);
- }
- }
-
- if (storeType != null && storePath != null && newStoreType != null)
- {
- File oldStoreLocation = new File(storePath);
- if (oldStoreLocation.exists())
- {
- if (newStoreType.equals(newStoreType))
- {
- File newStoreLocation = new File(newStorePath);
- if (!oldStoreLocation.equals(newStoreLocation))
- {
- if (LOGGER.isInfoEnabled())
- {
- LOGGER.info("Copying store for virtual host '" + name + "' from '"
- + oldStoreLocation.getAbsolutePath() + "' into '" + newStoreLocation.getAbsolutePath() + "'");
- }
- copyStoreFiles(oldStoreLocation, newStoreLocation);
- }
- }
- else
- {
- LOGGER.warn("Requested a message store of different type ("
- + newStoreType + ") than existing store (" + storeType
- + "). At the moment, copying of data is not supported for stores of different types."
- + " As result an empty new store will be created and old data will be lost.");
- }
- }
- else
- {
- if (LOGGER.isInfoEnabled())
- {
- LOGGER.info("Virtual host '" + name + "' store does not exists at " + oldStoreLocation.getAbsolutePath() + ". Skipping srore copying...");
- }
- }
- }
- }
-
- private void copyStoreFiles(File oldStoreLocation, File newStoreLocation)
- {
- if (!newStoreLocation.exists() && !newStoreLocation.getParentFile().exists())
- {
- newStoreLocation.getParentFile().mkdirs();
- }
- try
- {
- if (oldStoreLocation.isFile())
- {
- if (!newStoreLocation.exists())
- {
- newStoreLocation.createNewFile();
- }
- FileUtils.copy(oldStoreLocation, newStoreLocation);
- }
- else
- {
- if (!newStoreLocation.exists())
- {
- newStoreLocation.mkdir();
- }
- FileUtils.copyRecursive(oldStoreLocation, newStoreLocation);
- }
- }
- catch (Exception e)
- {
- throw new IllegalConfigurationException("Cannot copy store data into a new location at " + newStoreLocation, e);
- }
- }
-
- private Map<String, String> getStoreDetailsFromVirtualHostConfigXml(String name, String configPath) throws Exception
- {
- Map<String, String> storeDetails = new HashMap<String, String>();
- VirtualHostConfiguration configuration = new VirtualHostConfiguration(name, new File(configPath) , _broker);
- String storePath = configuration.getStoreConfiguration().getString("environment-path");
- String storeType = configuration.getStoreConfiguration().getString("type");
- if (storeType == null)
- {
- String storeClass = configuration.getStoreConfiguration().getString("class");
- if (storeClass != null)
- {
- final Class<?> clazz = Class.forName(storeClass);
- final Object o = clazz.newInstance();
-
- if (o instanceof MessageStore)
- {
- MessageStore ms = (MessageStore)o;
- storeType = ms.getStoreType();
- }
- }
- }
-
- storeDetails.put(STORE_PATH, storePath);
- storeDetails.put(STORE_TYPE, storeType);
- return storeDetails;
+ throw new UnsupportedOperationException("Changing attributes on virtualhosts is not supported.");
}
}