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/common/ServerState.java |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/common/ServerState.java b/opends/src/server/org/opends/server/replication/common/ServerState.java
index e8fea1c..ff19e57 100644
--- a/opends/src/server/org/opends/server/replication/common/ServerState.java
+++ b/opends/src/server/org/opends/server/replication/common/ServerState.java
@@ -518,4 +518,31 @@
   {
     return saved;
   }
+
+  /**
+   * Build a copy of the ServerState with only ChangeNumbers older than
+   * a specific ChangeNumber. This is used when building the initial
+   * Cookie in the External Changelog, to cope with purged changes.
+   * @param cn The ChangeNumber to compare the ServerState with
+   * @return a copy of the ServerState which only contains the ChangeNumbers
+   *         older than cn.
+   */
+  public ServerState duplicateOnlyOlderThan(ChangeNumber cn)
+  {
+    ServerState newState = new ServerState();
+    synchronized (list)
+    {
+      for (Integer key  : list.keySet())
+      {
+        ChangeNumber change = list.get(key);
+        Integer id =  change.getServerId();
+        if (change.older(cn))
+        {
+          newState.list.put(id,change);
+        }
+      }
+    }
+    return newState;
+  }
+
 }

--
Gitblit v1.10.0