From 030cd9b2dbc0d7016114f75e8b93190e34d1e213 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Fri, 28 Nov 2014 14:11:01 +0000
Subject: [PATCH] OPENDJ-1611 CR-5492 Filter replicaIds when filling late queue in MessageHandler

---
 opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java b/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
index 675853c..34727a4 100644
--- a/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
+++ b/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
@@ -31,9 +31,11 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Set;
 import java.util.Timer;
 import java.util.TimerTask;
 import java.util.concurrent.ConcurrentHashMap;
@@ -1291,15 +1293,14 @@
    */
   public UpdateMsg take(ServerHandler sHandler)
   {
-    /*
-     * Get the balanced tree that we use to sort the changes to be
-     * sent to the replica from the cookie
-     *
-     * The next change to send is always the first one in the tree
-     * So this methods simply need to check that dependencies are OK
-     * and update this replicaId RUV
-     */
-    return sHandler.take();
+    // Next message can only be taken from connected DSs
+    final Set<Integer> connectedReplicaIds = new HashSet<Integer>(getConnectedDSs().keySet());
+    if (sHandler.isDataServer())
+    {
+      // Prevents sending to a DS its own messages
+      connectedReplicaIds.remove(sHandler.getServerId());
+    }
+    return sHandler.take(connectedReplicaIds);
   }
 
   /**

--
Gitblit v1.10.0