Author: orudyy
Date: Thu Mar 21 13:43:40 2013
New Revision: 1459307
URL: http://svn.apache.org/r1459307
Log:
QPID-4390: Add ability to save java broker store version with existing broker
configuration stores. Add broker attributes for the store version, store type,
store location and version of management interfaces.
Modified:
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStore.java
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/MemoryConfigurationEntryStore.java
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Model.java
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
qpid/trunk/qpid/java/broker/src/main/resources/initial-store.json
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/ConfigurationEntryStoreTestCase.java
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/MemoryConfigurationEntryStoreTest.java
Modified:
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStore.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStore.java?rev=1459307&r1=1459306&r2=1459307&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStore.java
(original)
+++
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStore.java
Thu Mar 21 13:43:40 2013
@@ -62,12 +62,26 @@ public interface ConfigurationEntryStore
* @param target location to copy store into
* @throws IllegalConfigurationException if store cannot be copied into
given location
*/
- public void copyTo(String copyLocation);
+ void copyTo(String copyLocation);
/**
* Return the store location for the opened store or null if store has not
been opened.
*
* @return store location for the opened store or null if store has not
been opened
*/
- public String getStoreLocation();
+ String getStoreLocation();
+
+ /**
+ * Returns the version of the store
+ *
+ * @return store version
+ */
+ int getVersion();
+
+ /**
+ * Returns the type of the store
+ *
+ * @return store type
+ */
+ String getType();
}
Modified:
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java?rev=1459307&r1=1459306&r2=1459307&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java
(original)
+++
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java
Thu Mar 21 13:43:40 2013
@@ -50,7 +50,7 @@ public class BrokerRecoverer implements
{
StoreConfigurationChangeListener storeChangeListener = new
StoreConfigurationChangeListener(entry.getStore());
BrokerAdapter broker = new BrokerAdapter(entry.getId(),
entry.getAttributes(), _statisticsGatherer, _virtualHostRegistry,
- _logRecorder, _rootMessageLogger,
_authenticationProviderFactory, _portFactory, _taskExecutor);
+ _logRecorder, _rootMessageLogger,
_authenticationProviderFactory, _portFactory, _taskExecutor, entry.getStore());
broker.addChangeListener(storeChangeListener);
Map<String, Collection<ConfigurationEntry>> childEntries =
entry.getChildren();
Modified:
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java?rev=1459307&r1=1459306&r2=1459307&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java
(original)
+++
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java
Thu Mar 21 13:43:40 2013
@@ -57,6 +57,12 @@ public class JsonConfigurationEntryStore
}
@Override
+ public String getType()
+ {
+ return STORE_TYPE;
+ }
+
+ @Override
public String toString()
{
return "JsonConfigurationEntryStore [_storeFile=" + _storeFile + ",
_rootId=" + getRootEntry().getId() + "]";
@@ -81,7 +87,7 @@ public class JsonConfigurationEntryStore
ConfigurationEntry rootEntry = initialStore.getRootEntry();
Map<UUID, ConfigurationEntry> entries = new HashMap<UUID,
ConfigurationEntry>();
copyEntry(rootEntry.getId(), initialStore, entries);
- saveAsTree(rootEntry.getId(), entries, getObjectMapper(),
storeFile);
+ saveAsTree(rootEntry.getId(), entries, getObjectMapper(),
storeFile, getVersion());
}
}
}
Modified:
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java?rev=1459307&r1=1459306&r2=1459307&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java
(original)
+++
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java
Thu Mar 21 13:43:40 2013
@@ -149,6 +149,18 @@ public class ManagementModeStoreHandler
return _store.getStoreLocation();
}
+ @Override
+ public int getVersion()
+ {
+ return _store.getVersion();
+ }
+
+ @Override
+ public String getType()
+ {
+ return _store.getType();
+ }
+
private Map<UUID, ConfigurationEntry>
createPortsFromCommadLineOptions(BrokerOptions options)
{
int managementModeRmiPort = options.getManagementModeRmiPort();
@@ -312,4 +324,5 @@ public class ManagementModeStoreHandler
}
return new ConfigurationEntry(entry.getId(), entry.getType(),
attributes, children, entry.getStore());
}
+
}
Modified:
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/MemoryConfigurationEntryStore.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/MemoryConfigurationEntryStore.java?rev=1459307&r1=1459306&r2=1459307&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/MemoryConfigurationEntryStore.java
(original)
+++
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/MemoryConfigurationEntryStore.java
Thu Mar 21 13:43:40 2013
@@ -66,6 +66,8 @@ public class MemoryConfigurationEntrySto
private static final String ID = "id";
private static final String TYPE = "@type";
+ private static final int STORE_VERSION = 1;
+
private final ObjectMapper _objectMapper;
private final Map<UUID, ConfigurationEntry> _entries;
private final Map<String, Class<? extends ConfiguredObject>>
_relationshipClasses;
@@ -189,6 +191,18 @@ public class MemoryConfigurationEntrySto
}
@Override
+ public int getVersion()
+ {
+ return STORE_VERSION;
+ }
+
+ @Override
+ public String getType()
+ {
+ return STORE_TYPE;
+ }
+
+ @Override
public String toString()
{
return "MemoryConfigurationEntryStore [_rootId=" + _rootId + "]";
@@ -215,12 +229,13 @@ public class MemoryConfigurationEntrySto
protected void saveAsTree(File file)
{
- saveAsTree(_rootId, _entries, _objectMapper, file);
+ saveAsTree(_rootId, _entries, _objectMapper, file, STORE_VERSION);
}
- protected void saveAsTree(UUID rootId, Map<UUID, ConfigurationEntry>
entries, ObjectMapper mapper, File file)
+ protected void saveAsTree(UUID rootId, Map<UUID, ConfigurationEntry>
entries, ObjectMapper mapper, File file, int version)
{
Map<String, Object> tree = toTree(rootId, entries);
+ tree.put(Broker.STORE_VERSION, version);
try
{
mapper.writeValue(file, tree);
@@ -317,8 +332,11 @@ public class MemoryConfigurationEntrySto
throw new IllegalConfigurationException("Duplicate id is
found: " + entryId
+ "! The following configuration entries have the same
id: " + entries.get(entryId) + ", " + entry);
}
- entries.put(entryId, entry);
+
Set<UUID> children = entry.getChildrenIds();
+ Set<UUID> childrenCopy = children == null? null : new
HashSet<UUID>(children);
+ ConfigurationEntry copy = new ConfigurationEntry(entryId,
entry.getType(), new HashMap<String, Object>(entry.getAttributes()),
childrenCopy, this);
+ entries.put(entryId, copy);
if (children != null)
{
for (UUID uuid : children)
Modified:
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java?rev=1459307&r1=1459306&r2=1459307&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java
(original)
+++
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java
Thu Mar 21 13:43:40 2013
@@ -71,6 +71,10 @@ public interface Broker extends Configur
String HEART_BEAT_DELAY = "heartBeatDelay";
String STATISTICS_REPORTING_PERIOD = "statisticsReportingPeriod";
String STATISTICS_REPORTING_RESET_ENABLED =
"statisticsReportingResetEnabled";
+ String STORE_TYPE = "storeType";
+ String STORE_VERSION = "storeVersion";
+ String STORE_PATH = "storePath";
+ String MANAGEMENT_VERSION = "managementVersion";
/*
* A temporary attribute to pass the path to ACL file.
@@ -131,6 +135,10 @@ public interface Broker extends Configur
HEART_BEAT_DELAY,
STATISTICS_REPORTING_PERIOD,
STATISTICS_REPORTING_RESET_ENABLED,
+ STORE_TYPE,
+ STORE_VERSION,
+ STORE_PATH,
+ MANAGEMENT_VERSION,
ACL_FILE,
KEY_STORE_PATH,
Modified:
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Model.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Model.java?rev=1459307&r1=1459306&r2=1459307&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Model.java
(original)
+++
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Model.java
Thu Mar 21 13:43:40 2013
@@ -29,6 +29,12 @@ import java.util.Map;
public class Model
{
+ /*
+ * API version for the broker management interfaces
+ */
+ public static final int MANAGEMENT_API_MAJOR_VERSION = 1;
+ public static final int MANAGEMENT_API_MINOR_VERSION = 0;
+
private static final Model MODEL_INSTANCE = new Model();
private final Map<Class<? extends ConfiguredObject>, Collection<Class<?
extends ConfiguredObject>>>
Modified:
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java?rev=1459307&r1=1459306&r2=1459307&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
(original)
+++
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
Thu Mar 21 13:43:40 2013
@@ -37,6 +37,7 @@ import java.security.cert.Certificate;
import org.apache.log4j.Logger;
import org.apache.qpid.common.QpidProperties;
+import org.apache.qpid.server.configuration.ConfigurationEntryStore;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.logging.LogRecorder;
import org.apache.qpid.server.logging.RootMessageLogger;
@@ -49,6 +50,7 @@ import org.apache.qpid.server.model.Conf
import org.apache.qpid.server.model.GroupProvider;
import org.apache.qpid.server.model.KeyStore;
import org.apache.qpid.server.model.LifetimePolicy;
+import org.apache.qpid.server.model.Model;
import org.apache.qpid.server.model.Plugin;
import org.apache.qpid.server.model.Port;
import org.apache.qpid.server.model.State;
@@ -178,11 +180,12 @@ public class BrokerAdapter extends Abstr
private final UUID _defaultKeyStoreId;
private final UUID _defaultTrustStoreId;
- private Collection<String> _supportedStoreTypes;
+ private final Collection<String> _supportedStoreTypes;
+ private final ConfigurationEntryStore _brokerStore;
public BrokerAdapter(UUID id, Map<String, Object> attributes,
StatisticsGatherer statisticsGatherer, VirtualHostRegistry virtualHostRegistry,
LogRecorder logRecorder, RootMessageLogger rootMessageLogger,
AuthenticationProviderFactory authenticationProviderFactory,
- PortFactory portFactory, TaskExecutor taskExecutor)
+ PortFactory portFactory, TaskExecutor taskExecutor,
ConfigurationEntryStore brokerStore)
{
super(id, DEFAULTS, MapValueConverter.convert(attributes,
ATTRIBUTE_TYPES), taskExecutor);
_statisticsGatherer = statisticsGatherer;
@@ -198,6 +201,7 @@ public class BrokerAdapter extends Abstr
_defaultTrustStoreId =
UUIDGenerator.generateBrokerChildUUID(TrustStore.class.getSimpleName(),
DEFAULT_TRUST_STORE_NAME);
createBrokerChildrenFromAttributes();
_supportedStoreTypes = new MessageStoreCreator().getStoreTypes();
+ _brokerStore = brokerStore;
}
/*
@@ -705,6 +709,22 @@ public class BrokerAdapter extends Abstr
}
return null;
}
+ else if (MANAGEMENT_VERSION.equals(name))
+ {
+ return Model.MANAGEMENT_API_MAJOR_VERSION + "." +
Model.MANAGEMENT_API_MINOR_VERSION;
+ }
+ else if (STORE_VERSION.equals(name))
+ {
+ return _brokerStore.getVersion();
+ }
+ else if (STORE_TYPE.equals(name))
+ {
+ return _brokerStore.getType();
+ }
+ else if (STORE_PATH.equals(name))
+ {
+ return _brokerStore.getStoreLocation();
+ }
return super.getAttribute(name);
}
Modified: qpid/trunk/qpid/java/broker/src/main/resources/initial-store.json
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/resources/initial-store.json?rev=1459307&r1=1459306&r2=1459307&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/resources/initial-store.json (original)
+++ qpid/trunk/qpid/java/broker/src/main/resources/initial-store.json Thu Mar
21 13:43:40 2013
@@ -20,6 +20,7 @@
*/
{
"name": "QpidBroker",
+ "storeVersion": 1,
"defaultAuthenticationProvider" : "passwordFile",
"defaultVirtualHost" : "default",
"authenticationproviders" : [ {
Modified:
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/ConfigurationEntryStoreTestCase.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/ConfigurationEntryStoreTestCase.java?rev=1459307&r1=1459306&r2=1459307&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/ConfigurationEntryStoreTestCase.java
(original)
+++
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/ConfigurationEntryStoreTestCase.java
Thu Mar 21 13:43:40 2013
@@ -110,7 +110,10 @@ public abstract class ConfigurationEntry
assertEquals("Unexpected type ", Broker.class.getSimpleName(),
brokerConfigEntry.getType());
Map<String, Object> attributes = brokerConfigEntry.getAttributes();
assertNotNull("Attributes cannot be null", attributes);
- assertEquals("Unexpected attributes", _brokerAttributes, attributes);
+ for (Map.Entry<String, Object> attribute :
_brokerAttributes.entrySet())
+ {
+ assertEquals("Unexpected attribute " + attribute.getKey(),
attribute.getValue(), attributes.get(attribute.getKey()));
+ }
}
public void testGetEntry()
Modified:
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java?rev=1459307&r1=1459306&r2=1459307&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java
(original)
+++
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java
Thu Mar 21 13:43:40 2013
@@ -52,6 +52,7 @@ public class JsonConfigurationEntryStore
Map<String, Object> brokerObjectMap = new HashMap<String, Object>();
brokerObjectMap.put(Broker.ID, brokerId);
brokerObjectMap.put("@type", Broker.class.getSimpleName());
+ brokerObjectMap.put("storeVersion", 1);
brokerObjectMap.putAll(brokerAttributes);
StringWriter sw = new StringWriter();
@@ -114,8 +115,9 @@ public class JsonConfigurationEntryStore
assertEquals("Unexpected root entry", brokerId, root.getId());
Map<String, Object> attributes = root.getAttributes();
assertNotNull("Attributes not found", attributes);
- assertEquals("Unexpected number of attriburtes", 1, attributes.size());
+ assertEquals("Unexpected number of attriburtes", 2, attributes.size());
assertEquals("Unexpected name attribute", getTestName(),
attributes.get(Broker.NAME));
+ assertEquals("Unexpected version attribute", 1,
attributes.get(Broker.STORE_VERSION));
}
public void testCreateFromInitialStore() throws Exception
@@ -135,8 +137,18 @@ public class JsonConfigurationEntryStore
assertEquals("Unexpected root entry", brokerId, root.getId());
Map<String, Object> attributes = root.getAttributes();
assertNotNull("Attributes not found", attributes);
- assertEquals("Unexpected number of attriburtes", 1, attributes.size());
+ assertEquals("Unexpected number of attriburtes", 2, attributes.size());
assertEquals("Unexpected name attribute", getTestName(),
attributes.get(Broker.NAME));
+ assertEquals("Unexpected version attribute", 1,
attributes.get(Broker.STORE_VERSION));
}
+ public void testGetVersion()
+ {
+ assertEquals("Unexpected version", 1, getStore().getVersion());
+ }
+
+ public void testGetType()
+ {
+ assertEquals("Unexpected type", "json", getStore().getType());
+ }
}
Modified:
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/MemoryConfigurationEntryStoreTest.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/MemoryConfigurationEntryStoreTest.java?rev=1459307&r1=1459306&r2=1459307&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/MemoryConfigurationEntryStoreTest.java
(original)
+++
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/MemoryConfigurationEntryStoreTest.java
Thu Mar 21 13:43:40 2013
@@ -94,4 +94,14 @@ public class MemoryConfigurationEntrySto
assertEquals("Unexpected broker attributes",
initialStoreRoot.getAttributes(), root.getAttributes());
assertEquals("Unexpected broker children",
initialStoreRoot.getChildrenIds(), root.getChildrenIds());
}
+
+ public void testGetVersion()
+ {
+ assertEquals("Unexpected version", 1, getStore().getVersion());
+ }
+
+ public void testGetType()
+ {
+ assertEquals("Unexpected type", "memory", getStore().getType());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]