qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oru...@apache.org
Subject svn commit: r1775080 - in /qpid/java/branches/6.1.x: ./ broker-core/src/main/java/org/apache/qpid/server/store/ broker-core/src/test/java/org/apache/qpid/server/store/ broker-core/src/test/resources/configuration/
Date Mon, 19 Dec 2016 13:14:04 GMT
Author: orudyy
Date: Mon Dec 19 13:14:04 2016
New Revision: 1775080

URL: http://svn.apache.org/viewvc?rev=1775080&view=rev
Log:
QPID-7548: [Java Broker] Fix upgrade issues from model versions 3.0 and 6.0

merged from trunk using
svn merge -c 1774564,1774885  ^/qpid/java/trunk

Added:
    qpid/java/branches/6.1.x/broker-core/src/test/resources/configuration/
      - copied from r1774564, qpid/java/trunk/broker-core/src/test/resources/configuration/
Removed:
    qpid/java/branches/6.1.x/broker-core/src/test/resources/configuration/broker-config-1.0.json
    qpid/java/branches/6.1.x/broker-core/src/test/resources/configuration/broker-config-latest.json
Modified:
    qpid/java/branches/6.1.x/   (props changed)
    qpid/java/branches/6.1.x/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java
    qpid/java/branches/6.1.x/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java

Propchange: qpid/java/branches/6.1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Dec 19 13:14:04 2016
@@ -9,5 +9,5 @@
 /qpid/branches/java-broker-vhost-refactor/java:1493674-1494547
 /qpid/branches/java-network-refactor/qpid/java:805429-821809
 /qpid/branches/qpid-2935/qpid/java:1061302-1072333
-/qpid/java/trunk:1766544,1766547,1766553,1766666,1766796-1766797,1766806,1767251,1767267-1767268,1767275,1767310,1767326,1767329,1767332,1767514,1767523,1767738,1767825,1767847-1767849,1767882,1767909,1767914,1768016-1768017,1768065,1768643,1768704,1768854,1768875,1768914,1768963,1768967,1768976,1769007,1769009,1769087,1769138-1769139,1769597,1769879,1770236,1770716,1772241,1772574,1773057,1774039,1774446
+/qpid/java/trunk:1766544,1766547,1766553,1766666,1766796-1766797,1766806,1767251,1767267-1767268,1767275,1767310,1767326,1767329,1767332,1767514,1767523,1767738,1767825,1767847-1767849,1767882,1767909,1767914,1768016-1768017,1768065,1768643,1768704,1768854,1768875,1768914,1768963,1768967,1768976,1769007,1769009,1769087,1769138-1769139,1769597,1769879,1770236,1770716,1772241,1772574,1773057,1774039,1774446,1774564,1774885
 /qpid/trunk/qpid:796646-796653

Modified: qpid/java/branches/6.1.x/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.1.x/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java?rev=1775080&r1=1775079&r2=1775080&view=diff
==============================================================================
--- qpid/java/branches/6.1.x/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java
(original)
+++ qpid/java/branches/6.1.x/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java
Mon Dec 19 13:14:04 2016
@@ -353,7 +353,6 @@ public class BrokerStoreUpgraderAndRecov
 
                 addLogger(record, "memory", "Memory");
                 addLogger(record, "logfile", "File");
-                getNextUpgrader().configuredObject(record);
             }
             else if (record.getType().equals("VirtualHostNode"))
             {
@@ -366,8 +365,6 @@ public class BrokerStoreUpgraderAndRecov
                     String nodeName = (String) record.getAttributes().get("name");
                     _knownNonBdbHaVirtualHostNode.put(nodeName, record);
                 }
-                getNextUpgrader().configuredObject(record);
-
             }
             else if (record.getType().equals("Port") && "AMQP".equals(record.getAttributes().get("type")))
             {
@@ -378,9 +375,9 @@ public class BrokerStoreUpgraderAndRecov
                     updatedAttributes.remove("sendBufferSize");
                     record = new ConfiguredObjectRecordImpl(record.getId(), record.getType(),
updatedAttributes, record.getParents());
                     getUpdateMap().put(record.getId(), record);
-                    getNextUpgrader().configuredObject(record);
                 }
             }
+            getNextUpgrader().configuredObject(record);
         }
 
         private void addLogger(final ConfiguredObjectRecord record, String name, String type)
@@ -565,8 +562,8 @@ public class BrokerStoreUpgraderAndRecov
                 }
                 record = new ConfiguredObjectRecordImpl(record.getId(), record.getType(),
updatedAttributes, record.getParents());
                 getUpdateMap().put(record.getId(), record);
-                getNextUpgrader().configuredObject(record);
             }
+            getNextUpgrader().configuredObject(record);
         }
 
         @Override

Modified: qpid/java/branches/6.1.x/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.1.x/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java?rev=1775080&r1=1775079&r2=1775080&view=diff
==============================================================================
--- qpid/java/branches/6.1.x/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java
(original)
+++ qpid/java/branches/6.1.x/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java
Mon Dec 19 13:14:04 2016
@@ -33,6 +33,7 @@ import java.util.UUID;
 import org.apache.qpid.server.BrokerOptions;
 import org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor;
 import org.apache.qpid.server.logging.EventLogger;
+import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.BrokerModel;
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.JsonSystemConfigImpl;
@@ -137,16 +138,9 @@ public class BrokerStoreUpgraderAndRecov
     private List<ConfiguredObjectRecord> upgrade(final DurableConfigurationStore dcs,
                                                  final BrokerStoreUpgraderAndRecoverer recoverer)
     {
-        final List<ConfiguredObjectRecord> records = new ArrayList<>();
-        dcs.openConfigurationStore(new ConfiguredObjectRecordHandler()
-        {
-            @Override
-            public void handle(final ConfiguredObjectRecord record)
-            {
-                records.add(record);
-            }
-        });
-        return recoverer.upgrade(dcs, records);
+        RecordRetrievingConfiguredObjectRecordHandler handler = new RecordRetrievingConfiguredObjectRecordHandler();
+        dcs.openConfigurationStore(handler);
+        return recoverer.upgrade(dcs, handler.getRecords());
     }
 
     public void testUpgradeVirtualHostWithJDBCStoreAndDefaultPool()
@@ -668,6 +662,119 @@ public class BrokerStoreUpgraderAndRecov
                     authenticationProviders.get(0).getAttributes().containsKey("preferencesproviders"));
     }
 
+    public void testUpgradeTrustStoreRecordsFrom_6_0() throws Exception
+    {
+        _brokerRecord.getAttributes().put("modelVersion", "6.0");
+        Map<String, UUID> parents = Collections.singletonMap("Broker", _brokerRecord.getId());
+
+        Map<String, Object> trustStoreAttributes1 = new HashMap<>();
+        trustStoreAttributes1.put("name", "truststore1");
+        trustStoreAttributes1.put("type", "FileTrustStore");
+        trustStoreAttributes1.put("path", "${json:test.ssl.resources}/java_broker_truststore1.jks");
+        trustStoreAttributes1.put("password", "password");
+        ConfiguredObjectRecord trustStore1 = new ConfiguredObjectRecordImpl(UUID.randomUUID(),
"TrustStore",
+                                                                        trustStoreAttributes1,
+                                                                        parents);
+
+        Map<String, Object> trustStoreAttributes2 = new HashMap<>();
+        trustStoreAttributes2.put("name", "truststore2");
+        trustStoreAttributes2.put("type", "FileTrustStore");
+        trustStoreAttributes2.put("path", "${json:test.ssl.resources}/java_broker_truststore2.jks");
+        trustStoreAttributes2.put("password", "password");
+        trustStoreAttributes2.put("includedVirtualHostMessageSources", "true");
+        ConfiguredObjectRecord trustStore2 = new ConfiguredObjectRecordImpl(UUID.randomUUID(),
"TrustStore",
+                                                                            trustStoreAttributes2,
+                                                                            parents);
+
+        Map<String, Object> trustStoreAttributes3 = new HashMap<>();
+        trustStoreAttributes3.put("name", "truststore3");
+        trustStoreAttributes3.put("type", "FileTrustStore");
+        trustStoreAttributes3.put("path", "${json:test.ssl.resources}/java_broker_truststore3.jks");
+        trustStoreAttributes3.put("password", "password");
+        trustStoreAttributes3.put("excludedVirtualHostMessageSources", "true");
+        ConfiguredObjectRecord trustStore3 = new ConfiguredObjectRecordImpl(UUID.randomUUID(),
"TrustStore",
+                                                                            trustStoreAttributes3,
+                                                                            parents);
+
+        DurableConfigurationStore dcs = new DurableConfigurationStoreStub(_brokerRecord,
trustStore1, trustStore2, trustStore3);
+        BrokerStoreUpgraderAndRecoverer recoverer = new BrokerStoreUpgraderAndRecoverer(_systemConfig);
+        List<ConfiguredObjectRecord> records = upgrade(dcs, recoverer);
+
+        ConfiguredObjectRecord trustStore1Upgraded = findRecordById(trustStore1.getId(),
records);
+        ConfiguredObjectRecord trustStore2Upgraded = findRecordById(trustStore2.getId(),
records);
+        ConfiguredObjectRecord trustStore3Upgraded = findRecordById(trustStore3.getId(),
records);
+
+        assertNotNull("Trust store 1 is not found after upgrade", trustStore1Upgraded);
+        assertNotNull("Trust store 2 is not found after upgrade", trustStore2Upgraded);
+        assertNotNull("Trust store 3 is not found after upgrade", trustStore3Upgraded);
+
+        assertEquals("Unexpected attributes after upgrade for Trust store 1",
+                     trustStoreAttributes1,
+                     new HashMap<>(trustStore1Upgraded.getAttributes()));
+
+        assertEquals("includedVirtualHostNodeMessageSources is not found",
+                     "true",
+                     trustStore2Upgraded.getAttributes().get("includedVirtualHostNodeMessageSources"));
+        assertNull("includedVirtualHostMessageSources is  found",
+                     trustStore2Upgraded.getAttributes().get("includedVirtualHostMessageSources"));
+
+        assertEquals("includedVirtualHostNodeMessageSources is not found",
+                     "true",
+                     trustStore3Upgraded.getAttributes().get("excludedVirtualHostNodeMessageSources"));
+        assertNull("includedVirtualHostMessageSources is  found",
+                   trustStore3Upgraded.getAttributes().get("excludedVirtualHostMessageSources"));
+        assertModelVersionUpgraded(records);
+    }
+
+    public void testUpgradeJmxRecordsFrom_3_0() throws Exception
+    {
+        _brokerRecord.getAttributes().put("modelVersion", "3.0");
+        Map<String, UUID> parents = Collections.singletonMap("Broker", _brokerRecord.getId());
+
+        Map<String, Object> jmxPortAttributes = new HashMap<>();
+        jmxPortAttributes.put("name", "jmx1");
+        jmxPortAttributes.put("type", "JMX");
+        ConfiguredObjectRecord jmxPort = new ConfiguredObjectRecordImpl(UUID.randomUUID(),
"Port",
+                                                                        jmxPortAttributes,
+                                                                        parents);
+        Map<String, Object> rmiPortAttributes = new HashMap<>();
+        rmiPortAttributes.put("name", "rmi1");
+        rmiPortAttributes.put("type", "RMI");
+        ConfiguredObjectRecord rmiPort = new ConfiguredObjectRecordImpl(UUID.randomUUID(),
"Port",
+                                                                        rmiPortAttributes,
+                                                                        parents);
+
+        Map<String, Object> jmxPluginAttributes = new HashMap<>();
+        jmxPluginAttributes.put("name", getTestName());
+        jmxPluginAttributes.put("type", "MANAGEMENT-JMX");
+
+        _brokerRecord.getAttributes().put("modelVersion", "6.0");
+
+        ConfiguredObjectRecord jmxManagement = new ConfiguredObjectRecordImpl(UUID.randomUUID(),
+                                                                           "Plugin",
+                                                                           jmxPluginAttributes,
+                                                                           parents);
+
+        DurableConfigurationStore dcs = new DurableConfigurationStoreStub(_brokerRecord,
jmxPort, rmiPort, jmxManagement);
+
+        BrokerStoreUpgraderAndRecoverer recoverer = new BrokerStoreUpgraderAndRecoverer(_systemConfig);
+        List<ConfiguredObjectRecord> records = upgrade(dcs, recoverer);
+
+        assertNull("Jmx port is not removed", findRecordById(jmxPort.getId(), records));
+        assertNull("Rmi port is not removed", findRecordById(rmiPort.getId(), records));
+        assertNull("Jmx plugin is not removed", findRecordById(jmxManagement.getId(), records));
+
+        assertModelVersionUpgraded(records);
+    }
+
+    private void assertModelVersionUpgraded(final List<ConfiguredObjectRecord> records)
+    {
+        ConfiguredObjectRecord upgradedBrokerRecord = findRecordById(_brokerRecord.getId(),
records);
+        assertEquals("Unexpected model version",
+                     BrokerModel.MODEL_VERSION,
+                     upgradedBrokerRecord.getAttributes().get(Broker.MODEL_VERSION));
+    }
+
     private void upgradeBrokerRecordAndAssertUpgradeResults()
     {
         DurableConfigurationStore dcs = new DurableConfigurationStoreStub(_brokerRecord);
@@ -795,4 +902,20 @@ public class BrokerStoreUpgraderAndRecov
             }
         }
     }
+
+    private class RecordRetrievingConfiguredObjectRecordHandler implements ConfiguredObjectRecordHandler
+    {
+        private List<ConfiguredObjectRecord> _records = new ArrayList<>();
+
+        @Override
+        public void handle(final ConfiguredObjectRecord record)
+        {
+            _records.add(record);
+        }
+
+        public List<ConfiguredObjectRecord> getRecords()
+        {
+            return _records;
+        }
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message