From 905c53e2e203e42d5462ecc0acfea80b81c70967 Mon Sep 17 00:00:00 2001
From: pgamba <pgamba@localhost>
Date: Mon, 26 Oct 2009 15:08:24 +0000
Subject: [PATCH] Comments improvment and code cleaning

---
 opends/src/server/org/opends/server/replication/server/ECLServerHandler.java        |   27 ++++++++-----
 opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java |   50 +-----------------------
 2 files changed, 19 insertions(+), 58 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java b/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java
index d9e67d6..c300646 100644
--- a/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java
+++ b/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java
@@ -572,24 +572,27 @@
     draftCompat = true;
 
     DraftCNDbHandler draftCNDb = replicationServer.getDraftCNDbHandler();
+
+    // Any (optimizable) condition on draft changenumber in the request filter ?
     if (startDraftCN <= 1)
     {
-      // Request filter does not contain any firstDraftCN
+      // Request filter DOES NOT contain any firstDraftCN
       // So we'll generate from the beginning of what we have stored here.
 
-      // Get the first DraftCN from DraftCNdb
+      // Get starting state from first DraftCN from DraftCNdb
       if (draftCNDb.count() == 0)
       {
-        // db is empty
+        // DraftCNdb IS EMPTY hence start from what we have in the changelog db.
         isEndOfDraftCNReached = true;
         crossDomainStartState = null;
       }
       else
       {
-        // get the generalizedServerState related to the start of the draftDb
+        // DraftCNdb IS NOT EMPTY hence start from
+        // the generalizedServerState related to the start of the draftDb
         crossDomainStartState = draftCNDb.getValue(draftCNDb.getFirstKey());
 
-        // Get an iterator to traverse the draftCNDb
+        // And get an iterator to traverse the draftCNDb
         try
         {
           draftCNDbIter =
@@ -611,14 +614,14 @@
     }
     else
     {
-      // Request filter does contain a startDraftCN
+      // Request filter DOES contain a startDraftCN
 
       // Read the draftCNDb to see whether it contains startDraftCN
       crossDomainStartState = draftCNDb.getValue(startDraftCN);
 
       if (crossDomainStartState != null)
       {
-        // startDraftCN is present in the draftCnDb
+        // startDraftCN (from the request filter) is present in the draftCnDb
         // Get an iterator to traverse the draftCNDb
         try
         {
@@ -640,17 +643,18 @@
       }
       else
       {
-        // startDraftCN provided in the request is not present in the draftCnDb
-        // Is the provided startDraftCN <= the potential last DraftCNdb
+        // startDraftCN provided in the request IS NOT in the DraftCNDb
+
+        // Is the provided startDraftCN <= the potential last DraftCN
 
         // Get the draftLimits (from the eligibleCN got at the beginning of
-        // the operation.
+        // the operation) in order to have the potential last DraftCN.
         int[] limits = replicationServer.getECLDraftCNLimits(
             eligibleCN, excludedServiceIDs);
 
         if (startDraftCN<=limits[1])
         {
-          // startDraftCN is between first and last and has never been
+          // startDraftCN is between first and potential last and has never been
           // returned yet
           if (draftCNDb.count() == 0)
           {
@@ -684,6 +688,7 @@
         }
         else
         {
+          // startDraftCN is > the potential last DraftCN
           throw new DirectoryException(
               ResultCode.SUCCESS,
               Message.raw(Category.SYNC,
diff --git a/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java b/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
index cabec3a..d41ee2c 100644
--- a/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
+++ b/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
@@ -83,7 +83,6 @@
 import org.opends.server.types.DebugLogLevel;
 import org.opends.server.types.DirectoryException;
 import org.opends.server.types.ResultCode;
-import org.opends.server.util.TimeThread;
 
 import com.sleepycat.je.DatabaseException;
 
@@ -2443,8 +2442,10 @@
   synchronized protected MonitorData computeMonitorData()
     throws DirectoryException
   {
-    // Update the monitorData of all domains if this was necessary.
+    // Update the monitorData of ALL domains if this was necessary.
     replicationServer.computeMonitorData();
+
+    // Returns the monitorData of THIS domain
     return monitorData;
   }
 
@@ -2935,51 +2936,6 @@
   }
 
   /**
-   * TODO: code cleaning - remove this method.
-   * Computes the change number eligible to the ECL.
-   * @return null if the domain does not play in eligibility.
-   */
-  public ChangeNumber computeEligibleCN2()
-  {
-    ChangeNumber eligibleCN = null;
-    ServerState heartbeatState = getChangeTimeHeartbeatState();
-
-    if (heartbeatState==null)
-      return null;
-
-    // compute eligible CN
-    ServerState hbState = heartbeatState.duplicate();
-
-    Iterator<Integer> it = hbState.iterator();
-    while (it.hasNext())
-    {
-      int sid = it.next();
-      ChangeNumber storedCN = hbState.getMaxChangeNumber(sid);
-
-      // If the most recent UpdateMsg or CLHeartbeatMsg received is very old
-      // then the server is considered down and not considered for eligibility
-      if (TimeThread.getTime()-storedCN.getTime()>2000)
-      {
-        if (debugEnabled())
-          TRACER.debugInfo("In " + this.getName() +
-            " Server " + sid
-            + " is not considered for eligibility ... potentially down");
-        continue;
-      }
-
-      if ((eligibleCN == null) || (storedCN.older(eligibleCN)))
-      {
-        eligibleCN = storedCN;
-      }
-    }
-
-    if (debugEnabled())
-      TRACER.debugInfo("In " + this.getName() +
-        " computeEligibleCN() returns " + eligibleCN);
-    return eligibleCN;
-  }
-
-  /**
    * Computes the eligible server state for the domain.
    *
    *     s1               s2          s3

--
Gitblit v1.10.0