From 1c8b422d63f419d8c85a28b1f2276ac0f3e3632c Mon Sep 17 00:00:00 2001
From: pgamba <pgamba@localhost>
Date: Thu, 12 Jul 2007 15:41:32 +0000
Subject: [PATCH] Fix for 1895 Summary: Total update does not work with 3 servers that are also replication servers

---
 opends/src/server/org/opends/server/replication/server/ServerHandler.java |   82 ++++++++++++++++++++++++++++++++++------
 1 files changed, 69 insertions(+), 13 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/server/ServerHandler.java b/opends/src/server/org/opends/server/replication/server/ServerHandler.java
index 7a0f72c..9dc3848 100644
--- a/opends/src/server/org/opends/server/replication/server/ServerHandler.java
+++ b/opends/src/server/org/opends/server/replication/server/ServerHandler.java
@@ -35,6 +35,7 @@
 import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString;
 
 import java.io.IOException;
+import java.util.List;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
@@ -61,6 +62,7 @@
 import org.opends.server.replication.protocol.UpdateMessage;
 import org.opends.server.replication.protocol.WindowMessage;
 import org.opends.server.replication.protocol.WindowProbe;
+import org.opends.server.replication.protocol.ReplServerInfoMessage;
 import org.opends.server.types.Attribute;
 import org.opends.server.types.AttributeType;
 import org.opends.server.types.AttributeValue;
@@ -129,6 +131,14 @@
 
   private short protocolVersion;
 
+
+  /**
+   * When this Handler is connected to a changelog server this collection
+   * will contain the list of LDAP servers connected to the remote changelog
+   * server.
+   */
+  private List<String> remoteLDAPservers = new ArrayList<String>();
+
   /**
    * The time in milliseconds between heartbeats from the replication
    * server.  Zero means heartbeats are off.
@@ -1342,18 +1352,70 @@
   public void process(RoutableMessage msg)
   {
     if (debugEnabled())
-      TRACER.debugInfo("SH(" + replicationServerId + ") forwards " +
-                 msg + " to " + serverId);
-
-    logError(ErrorLogCategory.SYNCHRONIZATION,
-        ErrorLogSeverity.SEVERE_ERROR,
-        "SH(" + replicationServerId + ") receives " + msg +
-            " from " + serverId, 1);
+      TRACER.debugInfo("SH(" + replicationServerId + ") receives " +
+                 msg + " from " + serverId);
 
     replicationCache.process(msg, this);
   }
 
   /**
+   * Sends the provided ReplServerInfoMessage.
+   *
+   * @param info The ReplServerInfoMessage message to be sent.
+   * @throws IOException When it occurs while sending the message,
+   *
+   */
+   public void sendInfo(ReplServerInfoMessage info)
+   throws IOException
+   {
+     session.publish(info);
+   }
+
+   /**
+    *
+    * Sets the replication server from the message provided.
+    *
+    * @param infoMsg The information message.
+    */
+   public void setReplServerInfo(ReplServerInfoMessage infoMsg)
+   {
+     remoteLDAPservers = infoMsg.getConnectedServers();
+   }
+
+   /**
+    * When this handler is connected to a replication server, specifies if
+    * a wanted server is connected to this replication server.
+    *
+    * @param wantedServer The server we want to know if it is connected
+    * to the replication server represented by this handler.
+    * @return boolean True is the wanted server is connected to the server
+    * represented by this handler.
+    */
+   public boolean isRemoteLDAPServer(short wantedServer)
+   {
+     for (String server : remoteLDAPservers)
+     {
+       if (wantedServer == Short.valueOf(server))
+       {
+         return true;
+       }
+     }
+     return false;
+   }
+
+   /**
+    * When the handler is connected to a replication server, specifies the
+    * replication server has remote LDAP servers connected to it.
+    *
+    * @return boolean True is the replication server has remote LDAP servers
+    * connected to it.
+    */
+   public List<String> getRemoteLDAPServers()
+   {
+     return remoteLDAPservers;
+   }
+
+  /**
    * Send an InitializeRequestMessage to the server connected through this
    * handler.
    *
@@ -1365,12 +1427,6 @@
     if (debugEnabled())
       TRACER.debugInfo("SH(" + replicationServerId + ") forwards " +
                  msg + " to " + serverId);
-
-    logError(ErrorLogCategory.SYNCHRONIZATION,
-        ErrorLogSeverity.SEVERE_ERROR,
-        "SH(" + replicationServerId + ") forwards " +
-             msg + " to " + serverId, 1);
-
     session.publish(msg);
   }
 

--
Gitblit v1.10.0