From b48ce50fdf4d73e8be3799e3a7c6c2bf9d1b2965 Mon Sep 17 00:00:00 2001
From: pgamba <pgamba@localhost>
Date: Sun, 02 Sep 2007 17:58:07 +0000
Subject: [PATCH] fix for #1733 & #845 - Initialization of replication

---
 opends/src/server/org/opends/server/replication/plugin/ReplLDIFOutputStream.java |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/plugin/ReplLDIFOutputStream.java b/opends/src/server/org/opends/server/replication/plugin/ReplLDIFOutputStream.java
index 45d63cc..dbc4c63 100644
--- a/opends/src/server/org/opends/server/replication/plugin/ReplLDIFOutputStream.java
+++ b/opends/src/server/org/opends/server/replication/plugin/ReplLDIFOutputStream.java
@@ -29,7 +29,6 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-
 /**
  * This class creates an output stream that can be used to export entries
  * to a synchonization domain.
@@ -37,7 +36,15 @@
 public class ReplLDIFOutputStream
        extends OutputStream
 {
+  // The synchronization domain on which the export is done
   ReplicationDomain domain;
+
+  // The number of entries to be exported
+  long numEntries;
+
+  // The current number of entries exported
+  long numExportedEntries;
+
   String entryBuffer = "";
 
   /**
@@ -45,10 +52,12 @@
    * domain.
    *
    * @param domain The replication domain
+   * @param numEntries The max number of entry to process.
    */
-  public ReplLDIFOutputStream(ReplicationDomain domain)
+  public ReplLDIFOutputStream(ReplicationDomain domain, long numEntries)
   {
     this.domain = domain;
+    this.numEntries = numEntries;
   }
 
   /**
@@ -75,11 +84,19 @@
       endOfEntryIndex = ebytes.indexOf("\n\n");
       if ( endOfEntryIndex >= 0 )
       {
+
         endOfEntryIndex += 2;
         entryBuffer = entryBuffer + ebytes.substring(0, endOfEntryIndex);
 
         // Send the entry
-        domain.sendEntryLines(entryBuffer);
+        if ((numEntries>0) && (numExportedEntries > numEntries))
+        {
+          // This outputstream has reached the total number
+          // of entries to export.
+          return;
+        }
+        domain.exportLDIFEntry(entryBuffer);
+        numExportedEntries++;
 
         startOfEntryIndex = startOfEntryIndex + endOfEntryIndex;
         entryBuffer = "";

--
Gitblit v1.10.0