You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2016/01/19 15:59:04 UTC

svn commit: r1725540 - in /qpid/java/branches/6.0.x: ./ bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/ bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/ broker-core/src/main/java/org/apache/...

Author: orudyy
Date: Tue Jan 19 14:59:04 2016
New Revision: 1725540

URL: http://svn.apache.org/viewvc?rev=1725540&view=rev
Log:
QPID-6996: Add attribute property 'updateAttributeDespiteUnchangedValue' and set it on role attribute in BDB HA RemoteReplicationNode and BDB HA VirtualHostNode

           merged from trunk
           svn merge -c 1724843,1724844 https://svn.apache.org/repos/asf/qpid/java/trunk

Modified:
    qpid/java/branches/6.0.x/   (props changed)
    qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNode.java
    qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNode.java
    qpid/java/branches/6.0.x/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/MultiNodeTest.java
    qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
    qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredAutomatedAttribute.java
    qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredDerivedAttribute.java
    qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttribute.java
    qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java
    qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/AbstractConfiguredObjectTest.java

Propchange: qpid/java/branches/6.0.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 19 14:59: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:1715445-1715447,1715586,1715940,1716086-1716087,1716127-1716128,1716141,1716153,1716155,1716194,1716204,1716209,1716227,1716277,1716357,1716368,1716370,1716374,1716432,1716444-1716445,1716455,1716461,1716474,1716489,1716497,1716515,1716555,1716602,1716606-1716610,1716619,1716636,1717269,1717299,1717401,1717446,1717449,1717626,1717691,1717735,1717780,1718744,1718889,1718893,1718918,1718922,1719026,1719028,1719033,1719037,1719047,1719051,1720664,1721151,1721198,1722246,1722339,1723064,1723194,1723563,1724216,1724251,1724257,1724397,1724432,1724582,1724603,1724780,1725295
+/qpid/java/trunk:1715445-1715447,1715586,1715940,1716086-1716087,1716127-1716128,1716141,1716153,1716155,1716194,1716204,1716209,1716227,1716277,1716357,1716368,1716370,1716374,1716432,1716444-1716445,1716455,1716461,1716474,1716489,1716497,1716515,1716555,1716602,1716606-1716610,1716619,1716636,1717269,1717299,1717401,1717446,1717449,1717626,1717691,1717735,1717780,1718744,1718889,1718893,1718918,1718922,1719026,1719028,1719033,1719037,1719047,1719051,1720664,1721151,1721198,1722246,1722339,1723064,1723194,1723563,1724216,1724251,1724257,1724397,1724432,1724582,1724603,1724780,1724843-1724844,1725295
 /qpid/trunk/qpid:796646-796653

Modified: qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNode.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNode.java?rev=1725540&r1=1725539&r2=1725540&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNode.java (original)
+++ qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNode.java Tue Jan 19 14:59:04 2016
@@ -41,7 +41,7 @@ public interface BDBHARemoteReplicationN
     @DerivedAttribute
     String getAddress();
 
-    @ManagedAttribute(persist = false)
+    @ManagedAttribute(persist = false, updateAttributeDespiteUnchangedValue = true)
     NodeRole getRole();
 
     @DerivedAttribute

Modified: qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNode.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNode.java?rev=1725540&r1=1725539&r2=1725540&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNode.java (original)
+++ qpid/java/branches/6.0.x/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNode.java Tue Jan 19 14:59:04 2016
@@ -61,7 +61,7 @@ public interface BDBHAVirtualHostNode<X
     @ManagedAttribute(defaultValue = "0")
     int getQuorumOverride();
 
-    @ManagedAttribute(persist = false, defaultValue = "WAITING")
+    @ManagedAttribute(persist = false, defaultValue = "WAITING", updateAttributeDespiteUnchangedValue = true)
     NodeRole getRole();
 
     @DerivedAttribute

Modified: qpid/java/branches/6.0.x/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/MultiNodeTest.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/MultiNodeTest.java?rev=1725540&r1=1725539&r2=1725540&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/MultiNodeTest.java (original)
+++ qpid/java/branches/6.0.x/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/MultiNodeTest.java Tue Jan 19 14:59:04 2016
@@ -215,14 +215,26 @@ public class MultiNodeTest extends QpidB
     {
         final Connection connection = getConnection(_positiveFailoverUrl);
 
-        ((AMQConnection)connection).setConnectionListener(_failoverListener);
-
         final int activeBrokerPort = _groupCreator.getBrokerPortNumberFromConnection(connection);
         LOGGER.info("Active connection port " + activeBrokerPort);
 
         final int inactiveBrokerPort = _groupCreator.getPortNumberOfAnInactiveBroker(connection);
         LOGGER.info("Update role attribute on inactive broker on port " + inactiveBrokerPort);
 
+        // transfer mastership 3 times in order to verify
+        // that repeated mastership transfer to the same node works, See QPID-6996
+        transferMasterFromLocalNode(connection, inactiveBrokerPort, activeBrokerPort);
+        transferMasterFromLocalNode(connection, activeBrokerPort, inactiveBrokerPort);
+        transferMasterFromLocalNode(connection, inactiveBrokerPort, activeBrokerPort);
+    }
+
+    private void transferMasterFromLocalNode(final Connection connection,
+                                             final int inactiveBrokerPort,
+                                             final int activeBrokerPort) throws Exception
+    {
+        _failoverListener = new FailoverAwaitingListener();
+        ((AMQConnection)connection).setConnectionListener(_failoverListener);
+
         Map<String, Object> attributes = _groupCreator.getNodeAttributes(inactiveBrokerPort);
         assertEquals("Inactive broker has unexpected role", "REPLICA", attributes.get(BDBHAVirtualHostNode.ROLE));
         _groupCreator.setNodeAttributes(inactiveBrokerPort,
@@ -251,6 +263,20 @@ public class MultiNodeTest extends QpidB
         final int inactiveBrokerPort = _groupCreator.getPortNumberOfAnInactiveBroker(connection);
         LOGGER.info("Update role attribute on inactive broker on port " + inactiveBrokerPort);
 
+        // transfer mastership 3 times in order to verify
+        // that repeated mastership transfer to the same node works, See QPID-6996
+        transferMasterFromRemoteNode(connection, activeBrokerPort, inactiveBrokerPort);
+        transferMasterFromRemoteNode(connection, inactiveBrokerPort, activeBrokerPort);
+        transferMasterFromRemoteNode(connection, activeBrokerPort, inactiveBrokerPort);
+    }
+
+    private void transferMasterFromRemoteNode(final Connection connection,
+                                              final int activeBrokerPort,
+                                              final int inactiveBrokerPort) throws Exception
+    {
+        _failoverListener = new FailoverAwaitingListener();
+        ((AMQConnection)connection).setConnectionListener(_failoverListener);
+
         _groupCreator.awaitNodeToAttainRole(activeBrokerPort, inactiveBrokerPort, "REPLICA");
         Map<String, Object> attributes = _groupCreator.getNodeAttributes(activeBrokerPort, inactiveBrokerPort);
         assertEquals("Inactive broker has unexpected role", "REPLICA", attributes.get(BDBHAVirtualHostNode.ROLE));

Modified: qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java?rev=1725540&r1=1725539&r2=1725540&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java (original)
+++ qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java Tue Jan 19 14:59:04 2016
@@ -1684,18 +1684,21 @@ public abstract class AbstractConfigured
         });
     }
 
-
     protected boolean changeAttribute(final String name, final Object expected, final Object desired)
     {
         synchronized (_attributes)
         {
             Object currentValue = getAttribute(name);
-            if((currentValue == null && expected == null)
-               || (currentValue != null && currentValue.equals(expected)))
+            Object actualValue = _attributes.get(name);
+
+            ConfiguredObjectAttribute<?,?> attr = _attributeTypes.get(name);
+
+            if(attr.updateAttributeDespiteUnchangedValue() ||
+               (((currentValue == null && expected == null) || (currentValue != null && currentValue.equals(expected))) &&
+                ((actualValue != null && !actualValue.equals(desired)) || (actualValue == null && desired != null))))
             {
                 //TODO: don't put nulls
                 _attributes.put(name, desired);
-                ConfiguredObjectAttribute<?,?> attr = _attributeTypes.get(name);
                 if(attr != null && attr.isAutomated())
                 {
                     automatedSetValue(name, desired);
@@ -2503,10 +2506,7 @@ public abstract class AbstractConfigured
                 {
                     Object desired = entry.getValue();
                     Object expected = getAttribute(attributeName);
-                    Object currentValue = _attributes.get(attributeName);
-                    if (((currentValue != null && !currentValue.equals(desired))
-                         || (currentValue == null && desired != null))
-                        && changeAttribute(attributeName, expected, desired))
+                    if (changeAttribute(attributeName, expected, desired))
                     {
                         attributeSet(attributeName, expected, desired);
                     }

Modified: qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredAutomatedAttribute.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredAutomatedAttribute.java?rev=1725540&r1=1725539&r2=1725540&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredAutomatedAttribute.java (original)
+++ qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredAutomatedAttribute.java Tue Jan 19 14:59:04 2016
@@ -148,6 +148,12 @@ public class ConfiguredAutomatedAttribut
     }
 
     @Override
+    public boolean updateAttributeDespiteUnchangedValue()
+    {
+        return _annotation.updateAttributeDespiteUnchangedValue();
+    }
+
+    @Override
     public String getOversizedAltText()
     {
         return _annotation.oversizedAltText();

Modified: qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredDerivedAttribute.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredDerivedAttribute.java?rev=1725540&r1=1725539&r2=1725540&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredDerivedAttribute.java (original)
+++ qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredDerivedAttribute.java Tue Jan 19 14:59:04 2016
@@ -73,6 +73,12 @@ public class ConfiguredDerivedAttribute<
     }
 
     @Override
+    public boolean updateAttributeDespiteUnchangedValue()
+    {
+        return false;
+    }
+
+    @Override
     public String getOversizedAltText()
     {
         return "";

Modified: qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttribute.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttribute.java?rev=1725540&r1=1725539&r2=1725540&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttribute.java (original)
+++ qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttribute.java Tue Jan 19 14:59:04 2016
@@ -46,6 +46,8 @@ public abstract class ConfiguredObjectAt
 
     public abstract boolean isOversized();
 
+    public abstract boolean updateAttributeDespiteUnchangedValue();
+
     public abstract String getOversizedAltText();
 
     public abstract String getDescription();

Modified: qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java?rev=1725540&r1=1725539&r2=1725540&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java (original)
+++ qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java Tue Jan 19 14:59:04 2016
@@ -41,4 +41,5 @@ public @interface ManagedAttribute
     /** If true, the model attribute value cannot be mutated after construction. */
     boolean immutable() default false;
 
+    boolean updateAttributeDespiteUnchangedValue() default false;
 }

Modified: qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/AbstractConfiguredObjectTest.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/AbstractConfiguredObjectTest.java?rev=1725540&r1=1725539&r2=1725540&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/AbstractConfiguredObjectTest.java (original)
+++ qpid/java/branches/6.0.x/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/AbstractConfiguredObjectTest.java Tue Jan 19 14:59:04 2016
@@ -597,7 +597,7 @@ public class AbstractConfiguredObjectTes
         assertEquals(originalType, object.getType());
     }
 
-    public void testAttributeSetListenerFiring()
+    public void testSetAttributesFiresListener()
     {
         final String objectName = "listenerFiring";
 
@@ -651,6 +651,55 @@ public class AbstractConfiguredObjectTes
         assertEquals("null=>third", delta);
     }
 
+    public void testSetAttributesInterpolateValues()
+    {
+        setTestSystemProperty("foo1", "myValue1");
+        setTestSystemProperty("foo2", "myValue2");
+        setTestSystemProperty("foo3", null);
+
+        Map<String, Object> attributes = new HashMap<>();
+        attributes.put(ConfiguredObject.NAME, getTestName());
+        attributes.put(TestSingleton.STRING_VALUE, "${foo1}");
+
+        final TestSingleton object = _model.getObjectFactory().create(TestSingleton.class, attributes);
+
+        final AtomicInteger listenerCount = new AtomicInteger();
+        object.addChangeListener(new NoopConfigurationChangeListener()
+        {
+            @Override
+            public void attributeSet(final ConfiguredObject<?> object,
+                                     final String attributeName,
+                                     final Object oldAttributeValue,
+                                     final Object newAttributeValue)
+            {
+                listenerCount.incrementAndGet();
+            }
+        });
+
+        assertEquals("myValue1", object.getStringValue());
+        assertEquals("${foo1}", object.getActualAttributes().get(TestSingleton.STRING_VALUE));
+
+        // Update the actual value ${foo1} => ${foo2}
+        object.setAttributes(Collections.singletonMap(TestSingleton.STRING_VALUE, "${foo2}"));
+        assertEquals(1, listenerCount.get());
+
+        assertEquals("myValue2", object.getStringValue());
+        assertEquals("${foo2}", object.getActualAttributes().get(TestSingleton.STRING_VALUE));
+
+        // No change
+        object.setAttributes(Collections.singletonMap(TestSingleton.STRING_VALUE, "${foo2}"));
+        assertEquals(1, listenerCount.get());
+
+        // Update the actual value ${foo2} => ${foo3} (which doesn't have a value)
+        object.setAttributes(Collections.singletonMap(TestSingleton.STRING_VALUE, "${foo3}"));
+        // TODO KW - I would expect this to be equivilent to the above, but it is not because setAttribute wants the
+        // effective value as the expected.
+        //object.setAttribute(TestSingleton.STRING_VALUE, "${foo2}", "${foo3}");
+        assertEquals(2, listenerCount.get());
+        assertEquals("${foo3}", object.getStringValue());
+        assertEquals("${foo3}", object.getActualAttributes().get(TestSingleton.STRING_VALUE));
+    }
+
     private static class NoopConfigurationChangeListener implements ConfigurationChangeListener
     {
         @Override



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