From c7ab736ed396b178babaa0120661cca653e6f85f Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 18 Nov 2013 13:51:55 +0000
Subject: [PATCH] FirstChangeNumberVirtualAttributeProvider.java, LastChangeNumberVirtualAttributeProvider.java: Updated copy/pasted javadocs.

---
 opends/src/server/org/opends/server/replication/server/ReplicationServer.java                         |   22 +++++++----
 opends/src/server/org/opends/server/replication/common/FirstChangeNumberVirtualAttributeProvider.java |    6 --
 opends/src/server/org/opends/server/replication/common/LastChangeNumberVirtualAttributeProvider.java  |    6 --
 opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDB.java                |   36 +++++++++---------
 4 files changed, 34 insertions(+), 36 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/common/FirstChangeNumberVirtualAttributeProvider.java b/opends/src/server/org/opends/server/replication/common/FirstChangeNumberVirtualAttributeProvider.java
index 7a985d7..25bf29c 100644
--- a/opends/src/server/org/opends/server/replication/common/FirstChangeNumberVirtualAttributeProvider.java
+++ b/opends/src/server/org/opends/server/replication/common/FirstChangeNumberVirtualAttributeProvider.java
@@ -49,11 +49,7 @@
 import static org.opends.server.loggers.debug.DebugLogger.*;
 
 /**
- * This class implements a virtual attribute provider that allows administrators
- * to define their own values that will be inserted into any entry that matches
- * the criteria defined in the virtual attribute rule.  This can be used to
- * provide functionality like Class of Service (CoS) in the Sun Java System
- * Directory Server.
+ * Virtual attribute returning the oldest change number from the changelogDB.
  */
 public class FirstChangeNumberVirtualAttributeProvider
        extends VirtualAttributeProvider<UserDefinedVirtualAttributeCfg>
diff --git a/opends/src/server/org/opends/server/replication/common/LastChangeNumberVirtualAttributeProvider.java b/opends/src/server/org/opends/server/replication/common/LastChangeNumberVirtualAttributeProvider.java
index 626fea5..0ffc03d 100644
--- a/opends/src/server/org/opends/server/replication/common/LastChangeNumberVirtualAttributeProvider.java
+++ b/opends/src/server/org/opends/server/replication/common/LastChangeNumberVirtualAttributeProvider.java
@@ -49,11 +49,7 @@
 import static org.opends.server.loggers.debug.DebugLogger.*;
 
 /**
- * This class implements a virtual attribute provider that allows administrators
- * to define their own values that will be inserted into any entry that matches
- * the criteria defined in the virtual attribute rule.  This can be used to
- * provide functionality like Class of Service (CoS) in the Sun Java System
- * Directory Server.
+ * Virtual attribute returning the newest change number from the changelogDB.
  */
 public class LastChangeNumberVirtualAttributeProvider
        extends VirtualAttributeProvider<UserDefinedVirtualAttributeCfg>
diff --git a/opends/src/server/org/opends/server/replication/server/ReplicationServer.java b/opends/src/server/org/opends/server/replication/server/ReplicationServer.java
index 37b6d7b..ae96f6d 100644
--- a/opends/src/server/org/opends/server/replication/server/ReplicationServer.java
+++ b/opends/src/server/org/opends/server/replication/server/ReplicationServer.java
@@ -1360,18 +1360,24 @@
   }
 
   /**
-   * Get oldest and newest change numbers.
+   * Get the oldest and newest change numbers.
+   * <p>
+   * Implementation detail (but it could be more than a detail): The newest
+   * change number seem to be a "potential" newest number. It adds up the
+   * newesst change number to the number of changes coming from a domain's
+   * ReplicaDBs.
    *
-   * @param maxOldestChangeNumber
-   *          The provided crossDomainEligibleCSN used as the upper limit for
-   *          the oldest change number
+   * @param endCSN
+   *          The CSN used as the upper limit when computing the newest change
+   *          number
    * @param excludedBaseDNs
    *          The baseDNs that are excluded from the ECL.
-   * @return The oldest and newest change numbers.
+   * @return an array of size 2 holding the oldest and newest change numbers at
+   *         indexes 0 and 1.
    * @throws DirectoryException
    *           When it happens.
    */
-  public long[] getECLChangeNumberLimits(CSN maxOldestChangeNumber,
+  public long[] getECLChangeNumberLimits(CSN endCSN,
       Set<String> excludedBaseDNs) throws DirectoryException
   {
     /* The content of the CNIndexDB depends on the SEARCH operations done before
@@ -1444,7 +1450,7 @@
           // Count changes of this domain from the beginning of the changelog
           final ServerState startState = rsDomain.getOldestState()
               .duplicateOnlyOlderThan(rsDomain.getLatestDomainTrimDate());
-          ec = rsDomain.getEligibleCount(startState, maxOldestChangeNumber);
+          ec = rsDomain.getEligibleCount(startState, endCSN);
         }
         else
         {
@@ -1458,7 +1464,7 @@
           // And count changes of this domain from the date of the
           // newest seqnum record (that does not refer to this domain)
           CSN csnx = new CSN(newestTime, csnForNewestCN.getSeqnum(), 0);
-          ec = rsDomain.getEligibleCount(csnx, maxOldestChangeNumber);
+          ec = rsDomain.getEligibleCount(csnx, endCSN);
 
           if (baseDNForNewestCN.equals(rsDomain.getBaseDN()))
             ec--;
diff --git a/opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDB.java b/opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDB.java
index 2a569ad..2b14cc0 100644
--- a/opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDB.java
+++ b/opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDB.java
@@ -973,6 +973,8 @@
       else
       {
         key = new DatabaseEntry();
+        // JNR: I suspect this is equivalent to writing cursor.getFirst().
+        // If it is, then please change the code to make it clearer.
         status = cursor.getNext(key, data, LockMode.DEFAULT);
       }
 
@@ -987,19 +989,15 @@
           break;
         }
 
-        // reached a regular change record
-        // test whether we reached the 'stop' target
-        if (!csn.isNewerThan(stop))
-        {
-          // let's loop
-          distanceToCounterRecords[START]++;
-          status = cursor.getNext(key, data, LockMode.DEFAULT);
-        }
-        else
-        {
-          // reached the end
+        // it is a regular change record
+        if (csn.isNewerThan(stop))
+        { // we are outside the range: we reached the 'stop' target
           break;
         }
+
+        distanceToCounterRecords[START]++;
+        status = cursor.getNext(key, data, LockMode.DEFAULT);
+        // loop to update the distance and possibly find a counter record
       }
     }
     finally
@@ -1040,13 +1038,14 @@
         }
 
         // it is a regular change record
-        if (!csn.isOlderThan(start))
-        {
-          distanceToCounterRecords[STOP]++;
-          status = cursor.getPrev(key, data, LockMode.DEFAULT);
-        }
-        else
+        if (csn.isOlderThan(start))
+        { // we are outside the range: we reached the 'start' target
           break;
+        }
+
+        distanceToCounterRecords[STOP]++;
+        status = cursor.getPrev(key, data, LockMode.DEFAULT);
+        // loop to update the distance and possibly find a counter record
       }
       return true;
     }
@@ -1133,7 +1132,8 @@
    *
    * @param csn
    *          The CSN to test
-   * @return true if the provided CSN is a counter, false otherwise
+   * @return true if the provided CSN is a counter record, false if the change
+   *         is a regular/normal change that was performed on the replica.
    */
   private static boolean isACounterRecord(CSN csn)
   {

--
Gitblit v1.10.0