[hornetq-commits] JBoss hornetq SVN: r9497 - branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/cluster/impl.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Aug 3 09:45:13 EDT 2010


Author: jmesnil
Date: 2010-08-03 09:45:12 -0400 (Tue, 03 Aug 2010)
New Revision: 9497

Modified:
   branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/cluster/impl/DiscoveryGroupImpl.java
Log:
HA refactoring

* make sure we expire the connectors even when the packet is coming from the own node
  (otherwise the last node would never expire the 2nd to last node and callListeners would not be triggered)

Modified: branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/cluster/impl/DiscoveryGroupImpl.java
===================================================================
--- branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/cluster/impl/DiscoveryGroupImpl.java	2010-08-03 13:36:54 UTC (rev 9496)
+++ branches/2_2_0_HA_Improvements/src/main/org/hornetq/core/cluster/impl/DiscoveryGroupImpl.java	2010-08-03 13:45:12 UTC (rev 9497)
@@ -314,6 +314,11 @@
 
             if (nodeID.equals(originatingNodeID))
             {
+               if (checkExpiration())
+               {
+                  callListeners();
+               }
+               
                // Ignore traffic from own node
                continue;
             }
@@ -340,23 +345,7 @@
                   }
                }
 
-               long now = System.currentTimeMillis();
-
-               Iterator<Map.Entry<String, DiscoveryEntry>> iter = connectors.entrySet().iterator();
-
-               // Weed out any expired connectors
-
-               while (iter.hasNext())
-               {
-                  Map.Entry<String, DiscoveryEntry> entry = iter.next();
-
-                  if (entry.getValue().getLastUpdate() + timeout <= now)
-                  {
-                     iter.remove();
-
-                     changed = true;
-                  }
-               }
+               changed = changed || checkExpiration();
             }
 
             if (changed)
@@ -409,4 +398,28 @@
       }
    }
 
+   private boolean checkExpiration()
+   {
+      boolean changed = false;
+      long now = System.currentTimeMillis();
+
+      Iterator<Map.Entry<String, DiscoveryEntry>> iter = connectors.entrySet().iterator();
+
+      // Weed out any expired connectors
+
+      while (iter.hasNext())
+      {
+         Map.Entry<String, DiscoveryEntry> entry = iter.next();
+
+         if (entry.getValue().getLastUpdate() + timeout <= now)
+         {
+            System.out.println("remove " + entry);
+            iter.remove();
+
+            changed = true;
+         }
+      }
+      
+      return changed;
+   }
 }



More information about the hornetq-commits mailing list