From 67405dde9ba213331dab1fc46cb18c485070fd5b Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Fri, 05 Jun 2009 09:04:50 +0000
Subject: [PATCH] svn merge -r5333:5417 https://opends.dev.java.net/svn/opends/branches/b2.0

---
 opends/src/server/org/opends/server/replication/service/ReplicationBroker.java |   39 +++++++++++++++++++++++++++++++++------
 1 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java b/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java
index 29b0b11..c349289 100644
--- a/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java
+++ b/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java
@@ -59,6 +59,7 @@
 import org.opends.server.replication.common.ServerState;
 import org.opends.server.replication.common.ServerStatus;
 import org.opends.server.replication.protocol.*;
+import org.opends.server.replication.server.ReplicationServer;
 
 /**
  * The broker for Multi-master Replication.
@@ -995,12 +996,14 @@
     {
 
       /*
-       * Some up to date servers, among them, choose the one that has the
-       * maximum number of changes to send us. This is the most up to date one
-       * regarding the whole topology. This server is the one which has the less
-       * difference with the topology server state. For comparison, we need to
-       * compute the difference for each server id with the topology server
-       * state.
+       * Some up to date servers, among them, choose either :
+       * - The local one
+       * - The one that has the maximum number of changes to send us.
+       *   This is the most up to date one regarding the whole topology.
+       *   This server is the one which has the less
+       *   difference with the topology server state.
+       *   For comparison, we need to compute the difference for each
+       *   server id with the topology server state.
        */
 
       Message message = NOTE_FOUND_CHANGELOGS_WITH_MY_CHANGES.get(
@@ -1008,6 +1011,30 @@
       logError(message);
 
       /*
+       * If there are local Replication Servers, remove all the other one
+       * from the list so that we are sure that we choose a local one.
+       */
+      boolean localRS = false;
+      for (String upServer : upToDateServers.keySet())
+      {
+        if (ReplicationServer.isLocalReplicationServer(upServer))
+        {
+          localRS = true;
+        }
+      }
+      if (localRS)
+      {
+        Iterator<String> it = upToDateServers.keySet().iterator();
+        while (it.hasNext())
+        {
+          if (!ReplicationServer.isLocalReplicationServer(it.next()))
+          {
+            it.remove();
+          }
+        }
+      }
+
+      /*
        * First of all, compute the virtual server state for the whole topology,
        * which is composed of the most up to date change numbers for
        * each server id in the topology.

--
Gitblit v1.10.0