From 8d51279ac9c7d0163337175b23f2146e27a72cb8 Mon Sep 17 00:00:00 2001
From: pgamba <pgamba@localhost>
Date: Thu, 20 Mar 2008 11:24:57 +0000
Subject: [PATCH]  Fix 2911 dsreplication pre/post-external initialisation fails to clear all the changelogs

---
 opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java |   39 ++++++++++++++++++++++-----------------
 1 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java b/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
index 7c43a7c..3f21859 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
@@ -203,6 +203,8 @@
   private long generationId = -1;
   private boolean generationIdSavedStatus = false;
 
+  ChangeNumberGenerator generator;
+
   /**
    * This object is used to store the list of update currently being
    * done on the local database.
@@ -482,7 +484,7 @@
      * The generator time is adjusted to the time of the last CN received from
      * remote other servers.
      */
-    ChangeNumberGenerator generator =
+    generator =
       new ChangeNumberGenerator(serverId, state);
 
     pendingChanges =
@@ -2255,6 +2257,21 @@
   }
 
   /**
+   * Do what necessary when the data have changed : load state, load
+   * generation Id.
+   * @exception DirectoryException Thrown when an error occurs.
+  */
+  protected void loadDataState()
+  throws DirectoryException
+  {
+    state.clearInMemory();
+    state.loadState();
+    generator.adjust(state.getMaxChangeNumber(serverId));
+    // Retrieves the generation ID associated with the data imported
+    generationId = loadGenerationId();
+  }
+
+  /**
    * Enable back the domain after a previous disable.
    * The domain will connect back to a replication Server and
    * will recreate threads to listen for messages from the Sycnhronization
@@ -2264,13 +2281,9 @@
    */
   public void enable()
   {
-    state.clearInMemory();
-    state.loadState();
-    disabled = false;
-
     try
     {
-      generationId = loadGenerationId();
+      loadDataState();
     }
     catch (Exception e)
     {
@@ -2293,6 +2306,8 @@
     // Create the listener thread
     listenerThread = new ListenerThread(this, updateToReplayQueue);
     listenerThread.start();
+
+    disabled = false;
   }
 
   /**
@@ -3247,17 +3262,7 @@
     }
     else
     {
-      // Retrieves the generation ID associated with the data imported
-      try
-      {
-        generationId = loadGenerationId();
-      }
-      catch (DirectoryException e)
-      {
-        logError(ERR_LOADING_GENERATION_ID.get(
-            baseDN.toNormalizedString(),
-            e.getLocalizedMessage()));
-      }
+      loadDataState();
 
       if (debugEnabled())
         TRACER.debugInfo(

--
Gitblit v1.10.0