From 2c977273201717e109f7373cd60979cdc435f6e9 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 19 Sep 2014 16:04:02 +0000
Subject: [PATCH] Removed useless getChangeNumber() and setChangeNumber methods from *Operation interfaces. These methods are useless because setChangeNumber() is never set inside production code, so changeNumber is always equal to -1 for all the update operations. In addition it is very unlikely the ChangeNumberIndexer could have computed the changeNumber before a results are sent to a persistent search.

---
 opendj3-server-dev/src/server/org/opends/server/replication/server/ECLServerWriter.java |   53 ++++++++++++++++++++++++++++++-----------------------
 1 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/replication/server/ECLServerWriter.java b/opendj3-server-dev/src/server/org/opends/server/replication/server/ECLServerWriter.java
index 0005e50..45640f1 100644
--- a/opendj3-server-dev/src/server/org/opends/server/replication/server/ECLServerWriter.java
+++ b/opendj3-server-dev/src/server/org/opends/server/replication/server/ECLServerWriter.java
@@ -143,13 +143,17 @@
         }
 
         if (shutdown)
+        {
           return;
+        }
 
         // Not suspended
         doIt();
 
         if (shutdown)
+        {
           return;
+        }
 
         suspendWriter();
       }
@@ -171,12 +175,14 @@
     }
     finally
     {
-      if (session!=null)
+      if (session != null)
       {
         session.close();
       }
       if (replicationServerDomain != null)
+      {
         replicationServerDomain.stopServer(handler, false);
+      }
     }
   }
 
@@ -188,24 +194,10 @@
    */
   private void doIt() throws IOException, InterruptedException
   {
-    while (true)
+    while (!shutdown && !suspended)
     {
-      if (shutdown || suspended)
-      {
-        return;
-      }
-
-      ECLUpdateMsg update = null;
-      try
-      {
-        update = handler.takeECLUpdate();
-      }
-      catch(DirectoryException de)
-      {
-        logger.traceException(de);
-      }
-
-      if (update == null)
+      final ECLUpdateMsg updateMsg = takeECLUpdate(handler);
+      if (updateMsg == null)
       {
         if (session != null && handler.isInitPhaseDone())
         {
@@ -225,14 +217,25 @@
       }
       else
       {
-        // Publish the update to the remote server using a protocol version it
-        // supports
-        publish(update);
-        update = null;
+        // Publish the update to the remote server using a protocol version it supports
+        publish(updateMsg);
       }
     }
   }
 
+  private ECLUpdateMsg takeECLUpdate(ECLServerHandler handler)
+  {
+    try
+    {
+      return handler.takeECLUpdate();
+    }
+    catch(DirectoryException de)
+    {
+      logger.traceException(de);
+      return null;
+    }
+  }
+
   /**
    * Shutdown the writer.
    */
@@ -248,7 +251,9 @@
   private void publish(ECLUpdateMsg msg) throws IOException
   {
     if (logger.isTraceEnabled())
+    {
       logger.trace(getName() + " publishes msg=[" + msg + "]");
+    }
 
     if (session != null)
     {
@@ -258,8 +263,10 @@
     {
       try
       {
+        // Using processAdd() because all ECLUpdateMsgs are adds to the external changelog
+        // (even though the underlying changes can be adds, deletes, modifies or modDNs)
         Entry eclEntry = ECLSearchOperation.createEntryFromMsg(msg);
-        mypsearch.processAdd(eclEntry, -1);
+        mypsearch.processAdd(eclEntry);
       }
       catch (Exception e)
       {

--
Gitblit v1.10.0