From 92a7350758362b7b90576a01fdf96417298e0a5c Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Mon, 09 Oct 2006 14:15:55 +0000
Subject: [PATCH] - Change the synchronization code so that the changelog server can now be used directly through the ChangelogBroker class as a client API.

---
 opends/src/server/org/opends/server/synchronization/SynchronizationDomain.java |   61 ++++++++++++++----------------
 1 files changed, 28 insertions(+), 33 deletions(-)

diff --git a/opends/src/server/org/opends/server/synchronization/SynchronizationDomain.java b/opends/src/server/org/opends/server/synchronization/SynchronizationDomain.java
index 7e71f2e..d593969 100644
--- a/opends/src/server/org/opends/server/synchronization/SynchronizationDomain.java
+++ b/opends/src/server/org/opends/server/synchronization/SynchronizationDomain.java
@@ -34,6 +34,7 @@
 import static org.opends.server.synchronization.OperationContext.SYNCHROCONTEXT;
 import static org.opends.server.synchronization.Historical.*;
 
+import java.net.SocketTimeoutException;
 import java.util.ArrayList;
 import java.util.LinkedHashSet;
 import java.util.LinkedList;
@@ -290,10 +291,11 @@
      */
     try
     {
-      broker = new ChangelogBroker(this);
+      broker = new ChangelogBroker(state, baseDN, serverId, maxReceiveQueue,
+          maxReceiveDelay, maxSendQueue, maxSendDelay);
       synchronized (broker)
       {
-        broker.start(serverId, changelogServers);
+        broker.start(changelogServers);
         if (!receiveStatus)
           broker.suspendReceive();
       }
@@ -379,7 +381,7 @@
       {
         broker.stop();
         changelogServers = newChangelogServers;
-        broker.start(serverId, changelogServers);
+        broker.start(changelogServers);
       }
 
       /*
@@ -676,14 +678,22 @@
       UpdateMessage update = null;
       while (update == null)
       {
-        SynchronizationMessage msg = broker.receive();
-        if (msg == null)
+        SynchronizationMessage msg;
+        try
         {
-          // The server is in the shutdown process
-          return null;
+          msg = broker.receive();
+          if (msg == null)
+          {
+            // The server is in the shutdown process
+            return null;
+          }
+
+          update = msg.processReceive(this);
+        } catch (SocketTimeoutException e)
+        {
+          // just retry
         }
 
-        update = msg.processReceive(this);
       }
       return update;
     }
@@ -1001,28 +1011,6 @@
   }
 
   /**
-   * Get the largest ChangeNumber that has been processed locally.
-   *
-   * @return The largest ChangeNumber that has been processed locally.
-   */
-  public ChangeNumber getMaxChangeNumber()
-  {
-    return state.getMaxChangeNumber(serverId);
-  }
-
-  /**
-   * Create a new serverStartMessage suitable for this SynchronizationDomain.
-   *
-   * @return A new serverStartMessage suitable for this SynchronizationDomain.
-   */
-  public ServerStartMessage newServerStartMessage()
-  {
-    return new ServerStartMessage(serverId, baseDN, maxReceiveDelay,
-                                  maxReceiveQueue, maxSendDelay, maxSendQueue,
-                                  state);
-  }
-
-  /**
    * Create and replay a synchronized Operation from an UpdateMessage.
    *
    * @param msg The UpdateMessage to be replayed.
@@ -1074,6 +1062,13 @@
           {
             done = true;  // unknown type of operation ?!
           }
+          if (done)
+          {
+            // the update became a dummy update and the result
+            // of the conflict resolution phase is to do nothing.
+            // however we still need to push this change to the serverState
+            updateError(changeNumber);
+          }
         }
         else
         {
@@ -1377,8 +1372,8 @@
       }
       else
       {
-        RDN entryRdn = op.getEntryDN().getRDN();
-        msg.setDn(parentDn + "," + entryRdn);
+        RDN entryRdn = DN.decode(msg.getDn()).getRDN();
+        msg.setDn(entryRdn + "," + parentDn);
         return false;
       }
     }
@@ -1534,7 +1529,7 @@
    */
   private String generateConflictDn(String entryUid, String dn)
   {
-    return dn + "entryuuid=" + entryUid;
+    return "entryuuid=" + entryUid + "+" + dn;
   }
 
   /**

--
Gitblit v1.10.0