activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/2] activemq-artemis git commit: ARTEMIS-1094 replica + group-name fix
Date Thu, 06 Apr 2017 17:22:36 GMT
ARTEMIS-1094 replica + group-name fix

When a replica attempts to connect to a live server using a group-name
and there are > 1 servers on the network using that group there is a
chance it will fail because it doesn't keep track of all of the
topology data it receives. This fix ensures that all the topology data
from the cluster tracked until it is used and fails at which point it
is discarded.


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/4a57aecb
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/4a57aecb
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/4a57aecb

Branch: refs/heads/master
Commit: 4a57aecbbfea6453e9d74ba398ea0f89ee28fdbb
Parents: f88311b
Author: Justin Bertram <jbertram@apache.org>
Authored: Wed Apr 5 15:12:23 2017 -0500
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Thu Apr 6 13:22:30 2017 -0400

----------------------------------------------------------------------
 .../impl/NamedLiveNodeLocatorForReplication.java   | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4a57aecb/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForReplication.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForReplication.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForReplication.java
index 101ae3b..a3c50fb 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForReplication.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForReplication.java
@@ -16,6 +16,8 @@
  */
 package org.apache.activemq.artemis.core.server.impl;
 
+import java.util.LinkedList;
+import java.util.Queue;
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
@@ -38,7 +40,7 @@ public class NamedLiveNodeLocatorForReplication extends LiveNodeLocator
{
    private final Lock lock = new ReentrantLock();
    private final Condition condition = lock.newCondition();
    private final String backupGroupName;
-   private Pair<TransportConfiguration, TransportConfiguration> liveConfiguration;
+   private Queue<Pair<TransportConfiguration, TransportConfiguration>> liveConfigurations
= new LinkedList<>();
 
    private String nodeID;
 
@@ -56,12 +58,12 @@ public class NamedLiveNodeLocatorForReplication extends LiveNodeLocator
{
    public void locateNode(long timeout) throws ActiveMQException {
       try {
          lock.lock();
-         if (liveConfiguration == null) {
+         if (liveConfigurations.size() == 0) {
             try {
                if (timeout != -1L) {
                   ConcurrentUtil.await(condition, timeout);
                } else {
-                  while (liveConfiguration == null) {
+                  while (liveConfigurations.size() == 0) {
                      condition.await();
                   }
                }
@@ -79,7 +81,10 @@ public class NamedLiveNodeLocatorForReplication extends LiveNodeLocator
{
       try {
          lock.lock();
          if (backupGroupName.equals(topologyMember.getBackupGroupName()) && topologyMember.getLive()
!= null) {
-            liveConfiguration = new Pair<>(topologyMember.getLive(), topologyMember.getBackup());
+            Pair<TransportConfiguration, TransportConfiguration> liveConfiguration
= new Pair<>(topologyMember.getLive(), topologyMember.getBackup());
+            if (!liveConfigurations.contains(liveConfiguration)) {
+               liveConfigurations.add(liveConfiguration);
+            }
             nodeID = topologyMember.getNodeId();
             condition.signal();
          }
@@ -100,14 +105,14 @@ public class NamedLiveNodeLocatorForReplication extends LiveNodeLocator
{
 
    @Override
    public Pair<TransportConfiguration, TransportConfiguration> getLiveConfiguration()
{
-      return liveConfiguration;
+      return liveConfigurations.peek();
    }
 
    @Override
    public void notifyRegistrationFailed(boolean alreadyReplicating) {
       try {
          lock.lock();
-         liveConfiguration = null;
+         liveConfigurations.poll();
          super.notifyRegistrationFailed(alreadyReplicating);
       } finally {
          lock.unlock();


Mime
View raw message