From ae41fb531bbbd1bc8f9f6a82eb41c4eeb2da63c4 Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Mon, 30 May 2011 15:20:19 +0000
Subject: [PATCH] Resolve several issues with the External Changelog with regards to Cookies and changes with updates and purging. More specifically these changes are resolving the following issues : OPENDJ-57 - ECL: lastChangeNumber and firstChangeNumber reset to zero when the changelog is purged to empty OPENDJ-172 - External ChangeLog Cookie varies when searching with an empty cookie. Cookie should be reproducible. OPENDJ-173 - External ChangeLog cookies content is altered by Change purging and prevents from continuing search with a previous returned cookie.

---
 opends/src/server/org/opends/server/replication/server/ECLServerHandler.java |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java b/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java
index 624c058..3ba19c3 100644
--- a/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java
+++ b/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java
@@ -182,8 +182,8 @@
               + ")" +
               "] [nextNonEligibleMsg="      + nextNonEligibleMsg +
               "] [startState=" + startState +
-              "] [stopState= " + stopState +
-              "] [currentState= " + currentState + "]]");
+              "] [stopState=" + stopState +
+              "] [currentState=" + currentState + "]]");
     }
 
     /**
@@ -749,7 +749,7 @@
           if (isPersistent ==
             StartECLSessionMsg.PERSISTENT_CHANGES_ONLY)
           {
-            newDomainCtxt.startState = rsd.getEligibleState(eligibleCN, true);
+            newDomainCtxt.startState = rsd.getEligibleState(eligibleCN);
             startStatesFromProvidedCookie.remove(rsd.getBaseDn());
           }
           else
@@ -766,7 +766,12 @@
               // let's start traversing this domain from the beginning of
               // what we have in the replication changelog
               if (newDomainCtxt.startState == null)
-                newDomainCtxt.startState = new ServerState();
+              {
+                ChangeNumber latestTrimCN =
+                    new ChangeNumber(newDomainCtxt.domainLatestTrimDate, 0,0);
+                newDomainCtxt.startState = rsd.getStartState()
+                        .duplicateOnlyOlderThan(latestTrimCN);
+              }
             }
             else
             {
@@ -807,7 +812,7 @@
             }
 
             // Set the stop state for the domain from the eligibleCN
-            newDomainCtxt.stopState = rsd.getEligibleState(eligibleCN, true);
+            newDomainCtxt.stopState = rsd.getEligibleState(eligibleCN);
           }
           newDomainCtxt.currentState = new ServerState();
 
@@ -822,9 +827,8 @@
           rsd.registerHandler(mh);
           newDomainCtxt.mh = mh;
 
-          previousCookie.update(
-              newDomainCtxt.rsd.getBaseDn(),
-              newDomainCtxt.startState);
+          previousCookie.update(newDomainCtxt.rsd.getBaseDn(),
+                                newDomainCtxt.startState);
 
           // store the new context
           tmpSet.add(newDomainCtxt);
@@ -1052,6 +1056,7 @@
           ResultCode.UNWILLING_TO_PERFORM,
           ERR_INVALID_COOKIE_SYNTAX.get());
     }
+
     excludedServiceIDs = startECLSessionMsg.getExcludedServiceIDs();
     replicationServer.disableEligibility(excludedServiceIDs);
     eligibleCN = replicationServer.getEligibleCN();

--
Gitblit v1.10.0