From d454b5f9a2b7dc4ef2a70cd983a26436568cbe04 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 08 Oct 2013 13:52:43 +0000
Subject: [PATCH] OPENDJ-1116 Introduce abstraction for the changelog DB

---
 opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationBackend.java |   59 ++++++++++++++++++++++++++++-------------------------------
 1 files changed, 28 insertions(+), 31 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationBackend.java b/opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationBackend.java
index 9c8c0c2..f8a9cac 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationBackend.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationBackend.java
@@ -79,8 +79,7 @@
  * <p>
  * Currently are only implemented the create and restore backup features.
  */
-public class ReplicationBackend
-       extends Backend
+public class ReplicationBackend extends Backend
 {
   private static final String CHANGE_NUMBER = "replicationChangeNumber";
 
@@ -620,43 +619,41 @@
    * Exports or returns all the changes from a ReplicationServerDomain coming
    * after the CSN specified in the searchOperation.
    */
-  private void writeChangesAfterCSN(ReplicationServerDomain rsd,
+  private void writeChangesAfterCSN(ReplicationServerDomain rsDomain,
       final LDIFExportConfig exportConfig, LDIFWriter ldifWriter,
       SearchOperation searchOperation, final CSN previousCSN)
   {
-    for (int serverId : rsd.getServerIds())
+    if (exportConfig != null && exportConfig.isCancelled())
+    { // Abort if cancelled
+      return;
+    }
+
+    ReplicaDBCursor cursor = rsDomain.getCursorFrom(previousCSN);
+    try
     {
-      if (exportConfig != null && exportConfig.isCancelled())
-      { // Abort if cancelled
-        return;
-      }
+      int lookthroughCount = 0;
 
-      ReplicaDBCursor cursor = rsd.getCursorFrom(serverId, previousCSN);
-      try
+      // Walk through the changes
+      cursor.next(); // first try to advance the cursor
+      while (cursor.getChange() != null)
       {
-        int lookthroughCount = 0;
-
-        // Walk through the changes
-        while (cursor.getChange() != null)
-        {
-          if (exportConfig != null && exportConfig.isCancelled())
-          { // abort if cancelled
-            return;
-          }
-          if (!canContinue(searchOperation, lookthroughCount))
-          {
-            break;
-          }
-          lookthroughCount++;
-          writeChange(cursor.getChange(), ldifWriter, searchOperation,
-              rsd.getBaseDN(), exportConfig != null);
-          cursor.next();
+        if (exportConfig != null && exportConfig.isCancelled())
+        { // abort if cancelled
+          return;
         }
+        if (!canContinue(searchOperation, lookthroughCount))
+        {
+          break;
+        }
+        lookthroughCount++;
+        writeChange(cursor.getChange(), ldifWriter, searchOperation,
+            rsDomain.getBaseDN(), exportConfig != null);
+        cursor.next();
       }
-      finally
-      {
-        close(cursor);
-      }
+    }
+    finally
+    {
+      close(cursor);
     }
   }
 

--
Gitblit v1.10.0