qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kw...@apache.org
Subject svn commit: r1622162 - in /qpid/trunk/qpid/java/bdbstore/src: main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/ test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/
Date Wed, 03 Sep 2014 05:06:15 GMT
Author: kwall
Date: Wed Sep  3 05:06:14 2014
New Revision: 1622162

URL: http://svn.apache.org/r1622162
Log:
QPID-6063: [Java Broker] Address review comments from Oleksandr Rudyy <orudyy@apache.org>

Modified:
    qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNodeImpl.java
    qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java
    qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeOperationalLoggingTest.java

Modified: qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNodeImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNodeImpl.java?rev=1622162&r1=1622161&r2=1622162&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNodeImpl.java
(original)
+++ qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNodeImpl.java
Wed Sep  3 05:06:14 2014
@@ -62,7 +62,6 @@ public class BDBHARemoteReplicationNodeI
 
     private final AtomicReference<State> _state;
     private final boolean _isMonitor;
-    private boolean _detached;
     private BDBHAVirtualHostNodeLogSubject _virtualHostNodeLogSubject;
     private GroupLogSubject _groupLogSubject;
     private volatile NodeRole _lastKnownRole;
@@ -254,16 +253,6 @@ public class BDBHARemoteReplicationNodeI
         _state.compareAndSet(currentState, isActive ? State.ACTIVE : State.UNAVAILABLE);
     }
 
-    public boolean isDetached()
-    {
-        return _detached;
-    }
-
-    public void setDetached(boolean detached)
-    {
-        _detached = detached;
-    }
-
     @Override
     public void onValidate()
     {

Modified: qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java?rev=1622162&r1=1622161&r2=1622162&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java
(original)
+++ qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java
Wed Sep  3 05:06:14 2014
@@ -118,7 +118,6 @@ public class BDBHAVirtualHostNodeImpl ex
     @ManagedAttributeField(afterSet="postSetPriority")
     private int _priority;
 
-
     @ManagedAttributeField(afterSet="postSetQuorumOverride")
     private int _quorumOverride;
 
@@ -867,15 +866,16 @@ public class BDBHAVirtualHostNodeImpl ex
             BDBHARemoteReplicationNodeImpl remoteNode = getChildByName(BDBHARemoteReplicationNodeImpl.class,
node.getName());
             if (remoteNode != null)
             {
-                NodeRole currentRole = remoteNode.getRole();
+                final NodeRole previousRole = remoteNode.getRole();
+                final NodeRole newRole;
                 if (nodeState == null)
                 {
-                    remoteNode.setRole(NodeRole.UNREACHABLE);
+                    newRole = NodeRole.UNREACHABLE;
+                    remoteNode.setRole(newRole);
                     remoteNode.setLastTransactionId(-1);
-                    if (!remoteNode.isDetached())
+                    if (previousRole != NodeRole.UNREACHABLE)
                     {
                         getEventLogger().message(getGroupLogSubject(), HighAvailabilityMessages.LEFT(remoteNode.getName(),
remoteNode.getAddress()));
-                        remoteNode.setDetached(true);
                     }
                 }
                 else
@@ -883,13 +883,15 @@ public class BDBHAVirtualHostNodeImpl ex
                     remoteNode.setJoinTime(nodeState.getJoinTime());
                     remoteNode.setLastTransactionId(nodeState.getCurrentTxnEndVLSN());
                     ReplicatedEnvironment.State state = nodeState.getNodeState();
-                    remoteNode.setRole(NodeRole.fromJeState(state));
-                    if (remoteNode.isDetached())
+                    newRole = NodeRole.fromJeState(state);
+                    remoteNode.setRole(newRole);
+
+                    if (previousRole == NodeRole.UNREACHABLE)
                     {
                         getEventLogger().message(getGroupLogSubject(), HighAvailabilityMessages.JOINED(remoteNode.getName(),
remoteNode.getAddress()));
-                        remoteNode.setDetached(false);
                     }
-                    if (ReplicatedEnvironment.State.MASTER.name().equals(remoteNode.getRole()))
+
+                    if (NodeRole.MASTER == newRole)
                     {
                         byte[] applicationState = nodeState.getAppState();
                         Set<String> permittedNodes = ReplicatedEnvironmentFacade.convertApplicationStateBytesToPermittedNodeList(applicationState);
@@ -908,10 +910,12 @@ public class BDBHAVirtualHostNodeImpl ex
                     }
                 }
 
-                NodeRole newRole = remoteNode.getRole();
-                if (newRole != currentRole)
+                if (newRole != previousRole)
                 {
-                    getEventLogger().message(getGroupLogSubject(), HighAvailabilityMessages.ROLE_CHANGED(remoteNode.getName(),
remoteNode.getAddress(), currentRole.name(), newRole.name()));
+                    getEventLogger().message(getGroupLogSubject(), HighAvailabilityMessages.ROLE_CHANGED(remoteNode.getName(),
+                                                                                        
                remoteNode.getAddress(),
+                                                                                        
                previousRole.name(),
+                                                                                        
                newRole.name()));
                 }
             }
         }

Modified: qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeOperationalLoggingTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeOperationalLoggingTest.java?rev=1622162&r1=1622161&r2=1622162&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeOperationalLoggingTest.java
(original)
+++ qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeOperationalLoggingTest.java
Wed Sep  3 05:06:14 2014
@@ -24,6 +24,7 @@ import static org.mockito.Matchers.argTh
 import static org.mockito.Mockito.*;
 
 import java.util.Collections;
+import java.util.EnumSet;
 import java.util.Map;
 
 import org.apache.qpid.server.logging.EventLogger;
@@ -264,7 +265,7 @@ public class BDBHAVirtualHostNodeOperati
         // close remote node
         node2.close();
 
-        waitForNodeDetachedField(remoteNode, true);
+        waitForRemoteNodeToAttainRole(remoteNode, EnumSet.of(NodeRole.DETACHED));
 
         // verify that remaining node issues the DETACHED operational logging for remote
node
         String expectedMessage = HighAvailabilityMessages.LEFT(node2.getName(), node2.getAddress()).toString();
@@ -296,23 +297,25 @@ public class BDBHAVirtualHostNodeOperati
 
         node2.close();
 
-        waitForNodeDetachedField(remoteNode, true);
+        waitForRemoteNodeToAttainRole(remoteNode, EnumSet.of(NodeRole.DETACHED));
 
         reset(_eventLogger);
 
-        node2Attributes.put(BDBHAVirtualHostNode.PERMITTED_NODES, node1Attributes.get(BDBHAVirtualHostNode.PERMITTED_NODES));
+        node2Attributes.put(BDBHAVirtualHostNode.PERMITTED_NODES,
+                            node1Attributes.get(BDBHAVirtualHostNode.PERMITTED_NODES));
         node2 = (BDBHAVirtualHostNodeImpl)_helper.recoverHaVHN(node2.getId(), node2Attributes);
         _helper.assertNodeRole(node2, NodeRole.REPLICA, NodeRole.MASTER);
-        waitForNodeDetachedField(remoteNode, false);
+        waitForRemoteNodeToAttainRole(remoteNode, EnumSet.of(NodeRole.REPLICA, NodeRole.MASTER));
 
         final String expectedMessage = HighAvailabilityMessages.JOINED(node2.getName(), node2.getAddress()).toString();
         verify(_eventLogger).message(argThat(new LogSubjectMatcher(node1.getGroupLogSubject())),
                 argThat(new LogMessageMatcher(expectedMessage, HighAvailabilityMessages.JOINED_LOG_HIERARCHY)));
     }
 
-    private void waitForNodeDetachedField(BDBHARemoteReplicationNodeImpl remoteNode, boolean
expectedDetached) throws InterruptedException {
+    private void waitForRemoteNodeToAttainRole(BDBHARemoteReplicationNode remoteNode, EnumSet<NodeRole>
desiredRoles) throws Exception
+    {
         int counter = 0;
-        while (expectedDetached != remoteNode.isDetached() && counter<50)
+        while (!desiredRoles.contains(remoteNode.getRole())  && counter<50)
         {
             Thread.sleep(100);
             counter++;



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


Mime
View raw message