qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kw...@apache.org
Subject svn commit: r1565369 - in /qpid/branches/java-broker-bdb-ha/qpid/java/bdbstore: jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/ src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ systests/src/main/java/org/apache/qpid/ser...
Date Thu, 06 Feb 2014 17:34:38 GMT
Author: kwall
Date: Thu Feb  6 17:34:37 2014
New Revision: 1565369

URL: http://svn.apache.org/r1565369
Log:
QPID-5409: Fix LocalReplicationNode#setAttribute, ignore exception thrown by ReplicatedEnvironmentFacade
in LocalReplicationNode#getAttribute

Modified:
    qpid/branches/java-broker-bdb-ha/qpid/java/bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBean.java
    qpid/branches/java-broker-bdb-ha/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/LocalReplicationNode.java
    qpid/branches/java-broker-bdb-ha/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java
    qpid/branches/java-broker-bdb-ha/qpid/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/HAClusterManagementTest.java

Modified: qpid/branches/java-broker-bdb-ha/qpid/java/bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBean.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-bdb-ha/qpid/java/bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBean.java?rev=1565369&r1=1565368&r2=1565369&view=diff
==============================================================================
--- qpid/branches/java-broker-bdb-ha/qpid/java/bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBean.java
(original)
+++ qpid/branches/java-broker-bdb-ha/qpid/java/bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/BDBHAMessageStoreManagerMBean.java
Thu Feb  6 17:34:37 2014
@@ -159,15 +159,7 @@ public class BDBHAMessageStoreManagerMBe
     @Override
     public boolean getDesignatedPrimary() throws IOException, JMException
     {
-        try
-        {
-            return (Boolean)_localReplicationNode.getAttribute(DESIGNATED_PRIMARY);
-        }
-        catch (RuntimeException e)
-        {
-            LOGGER.debug("Failed query designated primary", e);
-            throw new JMException(e.getMessage());
-        }
+        return (Boolean)_localReplicationNode.getAttribute(DESIGNATED_PRIMARY);
     }
 
     @Override
@@ -224,7 +216,7 @@ public class BDBHAMessageStoreManagerMBe
         catch (Exception e)
         {
             LOGGER.error("Failed to set node " + _localReplicationNode.getName() + " to designated
primary : " + primary, e);
-            throw new JMException(e.getMessage());
+            throw new JMException("Failed to set node " + _localReplicationNode.getName()
+ " to designated primary : " + primary + ":" + e.getMessage());
         }
     }
 

Modified: qpid/branches/java-broker-bdb-ha/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/LocalReplicationNode.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-bdb-ha/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/LocalReplicationNode.java?rev=1565369&r1=1565368&r2=1565369&view=diff
==============================================================================
--- qpid/branches/java-broker-bdb-ha/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/LocalReplicationNode.java
(original)
+++ qpid/branches/java-broker-bdb-ha/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/LocalReplicationNode.java
Thu Feb  6 17:34:37 2014
@@ -40,6 +40,7 @@ import org.apache.qpid.server.model.adap
 import org.apache.qpid.server.util.MapValueConverter;
 import org.apache.qpid.server.util.ParameterizedTypeImpl;
 
+import com.sleepycat.je.DatabaseException;
 import com.sleepycat.je.Durability;
 import com.sleepycat.je.Durability.ReplicaAckPolicy;
 import com.sleepycat.je.Durability.SyncPolicy;
@@ -221,43 +222,46 @@ public class LocalReplicationNode extend
         }
         if (_replicatedEnvironmentFacade != null)
         {
-            if(ROLE.equals(attributeName))
+            try
             {
-                return _replicatedEnvironmentFacade.getNodeState();
-            }
-            else if(JOIN_TIME.equals(attributeName))
-            {
-                return _replicatedEnvironmentFacade.getJoinTime();
-            }
-            else if(LAST_KNOWN_REPLICATION_TRANSACTION_ID.equals(attributeName))
-            {
-                return _replicatedEnvironmentFacade.getLastKnownReplicationTransactionId();
-            }
-            else if(QUORUM_OVERRIDE.equals(attributeName))
-            {
-                return _replicatedEnvironmentFacade.getElectableGroupSizeOverride();
+                if(ROLE.equals(attributeName))
+                {
+                    return _replicatedEnvironmentFacade.getNodeState();
+                }
+                else if(JOIN_TIME.equals(attributeName))
+                {
+                    return _replicatedEnvironmentFacade.getJoinTime();
+                }
+                else if(LAST_KNOWN_REPLICATION_TRANSACTION_ID.equals(attributeName))
+                {
+                    return _replicatedEnvironmentFacade.getLastKnownReplicationTransactionId();
+                }
+                else if(QUORUM_OVERRIDE.equals(attributeName))
+                {
+                    return _replicatedEnvironmentFacade.getElectableGroupSizeOverride();
+                }
+                else if(DESIGNATED_PRIMARY.equals(attributeName))
+                {
+                    return _replicatedEnvironmentFacade.isDesignatedPrimary();
+                }
+                else if(PRIORITY.equals(attributeName))
+                {
+                    return _replicatedEnvironmentFacade.getPriority();
+                }
             }
-            else if(DESIGNATED_PRIMARY.equals(attributeName))
+            catch(IllegalStateException e)
             {
-                return _replicatedEnvironmentFacade.isDesignatedPrimary();
+                // ignore, as attribute value will be returned from actual/default attribute
maps if present
             }
-            else if(PRIORITY.equals(attributeName))
+            catch(DatabaseException e)
             {
-                return _replicatedEnvironmentFacade.getPriority();
+                // ignore, as attribute value will be returned from actual/default attribute
maps if present
             }
         }
         return super.getAttribute(attributeName);
     }
 
     @Override
-    public Object setAttribute(String name, Object expected, Object desired)
-            throws IllegalStateException, AccessControlException,
-            IllegalArgumentException
-    {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
     public Statistics getStatistics()
     {
         return NoStatistics.getInstance();
@@ -277,6 +281,13 @@ public class LocalReplicationNode extend
     }
 
     @Override
+    public boolean changeAttribute(final String name, final Object expected, final Object
desired)
+    {
+        updateReplicatedEnvironmentFacade(name, desired);
+        return super.changeAttribute(name, expected, desired);
+    }
+
+    @Override
     public void changeAttributes(Map<String, Object> attributes)
             throws IllegalStateException, AccessControlException,
             IllegalArgumentException
@@ -285,18 +296,16 @@ public class LocalReplicationNode extend
 
         checkWhetherImmutableAttributeChanged(convertedAttributes);
 
-        updateReplicatedEnvironmentFacade(convertedAttributes);
-
         super.changeAttributes(convertedAttributes);
     }
 
-    private void updateReplicatedEnvironmentFacade(Map<String, Object> convertedAttributes)
+    private void updateReplicatedEnvironmentFacade(String attributeName, Object attributeValue)
     {
         if (_replicatedEnvironmentFacade != null)
         {
-            if (convertedAttributes.get(PRIORITY) != null)
+            if (PRIORITY.equals(attributeName))
             {
-                int priority = (Integer)convertedAttributes.get(PRIORITY);
+                int priority = (Integer)attributeValue;
                 try
                 {
                     _replicatedEnvironmentFacade.setPriority(priority);
@@ -307,9 +316,9 @@ public class LocalReplicationNode extend
                 }
             }
 
-            if (convertedAttributes.get(DESIGNATED_PRIMARY) != null)
+            if (DESIGNATED_PRIMARY.equals(attributeName))
             {
-                boolean designatedPrimary = (Boolean)convertedAttributes.get(DESIGNATED_PRIMARY);
+                boolean designatedPrimary = (Boolean)attributeValue;
                 try
                 {
                     _replicatedEnvironmentFacade.setDesignatedPrimary(designatedPrimary);
@@ -320,9 +329,9 @@ public class LocalReplicationNode extend
                 }
             }
 
-            if (convertedAttributes.get(QUORUM_OVERRIDE) != null)
+            if (QUORUM_OVERRIDE.equals(attributeName))
             {
-                int quorumOverride = (Integer)convertedAttributes.get(QUORUM_OVERRIDE);
+                int quorumOverride = (Integer)attributeValue;
                 try
                 {
                     _replicatedEnvironmentFacade.setElectableGroupSizeOverride(quorumOverride);
@@ -334,7 +343,7 @@ public class LocalReplicationNode extend
             }
         }
 
-        if (convertedAttributes.containsKey(ROLE))
+        if (ROLE.equals(attributeName))
         {
             String currentRole = (String)getAttribute(ROLE);
             if (!ReplicatedEnvironment.State.REPLICA.name().equals(currentRole))
@@ -343,7 +352,7 @@ public class LocalReplicationNode extend
             }
 
             // we do not want to write role into the store
-            String role  = (String)convertedAttributes.remove(ROLE);
+            String role  = (String)attributeValue;
 
             if (ReplicatedEnvironment.State.MASTER.name().equals(role) )
             {

Modified: qpid/branches/java-broker-bdb-ha/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-bdb-ha/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java?rev=1565369&r1=1565368&r2=1565369&view=diff
==============================================================================
--- qpid/branches/java-broker-bdb-ha/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java
(original)
+++ qpid/branches/java-broker-bdb-ha/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java
Thu Feb  6 17:34:37 2014
@@ -432,16 +432,8 @@ public class ReplicatedEnvironmentFacade
 
     public String getNodeState()
     {
-        try
-        {
-            ReplicatedEnvironment.State state = _environment.getState();
-            return state.toString();
-        }
-        catch (IllegalStateException ise)
-        {
-            // Environment must be being recreated
-            return ReplicatedEnvironment.State.UNKNOWN.name();
-        }
+        ReplicatedEnvironment.State state = _environment.getState();
+        return state.toString();
     }
 
     public boolean isDesignatedPrimary()
@@ -502,19 +494,6 @@ public class ReplicatedEnvironmentFacade
         }
     }
 
-    private void checkIsOpenAndEnvironmentIsValid()
-    {
-        if (_state.get() != State.OPEN)
-        {
-            throw new IllegalStateException("Environment facade is not in open state");
-        }
-
-        if (!_environment.isValid())
-        {
-            throw new IllegalStateException("Environment is not valid");
-        }
-    }
-
     int getElectableGroupSizeOverride()
     {
         ReplicationMutableConfig repConfig = _environment.getRepMutableConfig();
@@ -553,7 +532,6 @@ public class ReplicatedEnvironmentFacade
         {
             VLSNRange range = RepInternal.getRepImpl(_environment).getVLSNIndex().getRange();
             VLSN lastTxnEnd = range.getLastTxnEnd();
-            LOGGER.debug("VLSN Range is " + range );
             return lastTxnEnd.getSequence();
         }
         else

Modified: qpid/branches/java-broker-bdb-ha/qpid/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/HAClusterManagementTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-bdb-ha/qpid/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/HAClusterManagementTest.java?rev=1565369&r1=1565368&r2=1565369&view=diff
==============================================================================
--- qpid/branches/java-broker-bdb-ha/qpid/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/HAClusterManagementTest.java
(original)
+++ qpid/branches/java-broker-bdb-ha/qpid/java/bdbstore/systests/src/main/java/org/apache/qpid/server/store/berkeleydb/HAClusterManagementTest.java
Thu Feb  6 17:34:37 2014
@@ -198,6 +198,15 @@ public class HAClusterManagementTest ext
         }
     }
 
+    public void testSetDesignatedPrimary() throws Exception
+    {
+        int brokerPort = _clusterCreator.getBrokerPortNumbersForNodes().iterator().next();
+        final ManagedBDBHAMessageStore storeBean = getStoreBeanForNodeAtBrokerPort(brokerPort);
+        assertFalse("Unexpected designated primary before change", storeBean.getDesignatedPrimary());
+        storeBean.setDesignatedPrimary(true);
+        assertTrue("Unexpected designated primary after change", storeBean.getDesignatedPrimary());
+    }
+
     private ManagedBDBHAMessageStore getStoreBeanForNodeAtBrokerPort(final int brokerPortNumber)
throws Exception
     {
         _jmxUtils.open(brokerPortNumber);



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


Mime
View raw message