From 9268da54b39dff6f0afbda53c9bd61deff1a8f66 Mon Sep 17 00:00:00 2001
From: pgamba <pgamba@localhost>
Date: Wed, 25 Nov 2009 10:52:59 +0000
Subject: [PATCH] Fix P3/#4340 ECL (draft mode): on second RS, first and last ChangeNumber are 0 and lastExternalChangelogCookie missing until first search

---
 opends/src/server/org/opends/server/replication/server/ReplicationServer.java                         |    6 +++++-
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java    |    9 +++++++++
 opends/src/server/org/opends/server/replication/common/FirstChangeNumberVirtualAttributeProvider.java |   10 +++++++++-
 opends/src/server/org/opends/server/replication/common/LastChangeNumberVirtualAttributeProvider.java  |    8 +++++++-
 4 files changed, 30 insertions(+), 3 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 a069dd6..9c84ad1 100644
--- a/opends/src/server/org/opends/server/replication/common/FirstChangeNumberVirtualAttributeProvider.java
+++ b/opends/src/server/org/opends/server/replication/common/FirstChangeNumberVirtualAttributeProvider.java
@@ -26,6 +26,8 @@
  */
 package org.opends.server.replication.common;
 
+import static org.opends.server.loggers.debug.DebugLogger.getTracer;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
@@ -39,6 +41,7 @@
 import org.opends.server.config.ConfigException;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.core.SearchOperation;
+import org.opends.server.loggers.debug.DebugTracer;
 import org.opends.server.replication.plugin.MultimasterReplication;
 import org.opends.server.replication.server.ReplicationServer;
 import org.opends.server.types.AttributeValue;
@@ -46,6 +49,7 @@
 import org.opends.server.types.ByteString;
 import org.opends.server.types.ConfigChangeResult;
 import org.opends.server.types.DN;
+import org.opends.server.types.DebugLogLevel;
 import org.opends.server.types.Entry;
 import org.opends.server.types.InitializationException;
 import org.opends.server.types.ResultCode;
@@ -66,6 +70,9 @@
        extends VirtualAttributeProvider<UserDefinedVirtualAttributeCfg>
        implements ConfigurationChangeListener<UserDefinedVirtualAttributeCfg>
 {
+  // The tracer object for the debug logger.
+  private static final DebugTracer TRACER = getTracer();
+
   /**
    * Creates a new instance of this member virtual attribute provider.
    */
@@ -140,6 +147,7 @@
           excludedDomains.add(ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT);
 
         ReplicationServer rs = eclwe.getReplicationServer();
+        rs.disableEligibility(excludedDomains);
         int[] limits = rs.getECLDraftCNLimits(
             rs.getEligibleCN(), excludedDomains);
 
@@ -149,7 +157,7 @@
     }
     catch(Exception e)
     {
-
+      TRACER.debugCaught(DebugLogLevel.ERROR, e);
     }
     AttributeValue value =
       AttributeValues.create(
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 05b4b73..510d5dd 100644
--- a/opends/src/server/org/opends/server/replication/common/LastChangeNumberVirtualAttributeProvider.java
+++ b/opends/src/server/org/opends/server/replication/common/LastChangeNumberVirtualAttributeProvider.java
@@ -26,6 +26,8 @@
  */
 package org.opends.server.replication.common;
 
+import static org.opends.server.loggers.debug.DebugLogger.getTracer;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
@@ -39,6 +41,7 @@
 import org.opends.server.config.ConfigException;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.core.SearchOperation;
+import org.opends.server.loggers.debug.DebugTracer;
 import org.opends.server.replication.plugin.MultimasterReplication;
 import org.opends.server.replication.server.ReplicationServer;
 import org.opends.server.types.AttributeValue;
@@ -46,6 +49,7 @@
 import org.opends.server.types.ByteString;
 import org.opends.server.types.ConfigChangeResult;
 import org.opends.server.types.DN;
+import org.opends.server.types.DebugLogLevel;
 import org.opends.server.types.Entry;
 import org.opends.server.types.InitializationException;
 import org.opends.server.types.ResultCode;
@@ -66,6 +70,7 @@
        extends VirtualAttributeProvider<UserDefinedVirtualAttributeCfg>
        implements ConfigurationChangeListener<UserDefinedVirtualAttributeCfg>
 {
+  private static final DebugTracer TRACER = getTracer();
   /**
    * Creates a new instance of this member virtual attribute provider.
    */
@@ -140,6 +145,7 @@
           excludedDomains.add(ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT);
 
         ReplicationServer rs = eclwe.getReplicationServer();
+        rs.disableEligibility(excludedDomains);
         int[] limits = rs.getECLDraftCNLimits(
             rs.getEligibleCN(), excludedDomains);
 
@@ -148,7 +154,7 @@
     }
     catch(Exception e)
     {
-
+      TRACER.debugCaught(DebugLogLevel.ERROR, e);
     }
     AttributeValue value =
       AttributeValues.create(
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 a33973e..e554086 100644
--- a/opends/src/server/org/opends/server/replication/server/ReplicationServer.java
+++ b/opends/src/server/org/opends/server/replication/server/ReplicationServer.java
@@ -198,6 +198,9 @@
   // used to synchronize the domain creation with the connect thread.
   final private Object domainMonitor = new Object();
 
+  // ServiceIDs excluded for ECL
+  private  ArrayList<String> excludedServiceIDs = new ArrayList<String>();
+
   /**
    * The weight affected to the replication server.
    * Each replication server of the topology has a weight. When combined
@@ -1779,7 +1782,6 @@
     }
   }
 
-  private  ArrayList<String> excludedServiceIDs;
   /**
    * Excluded a list of domain from eligibility computation.
    * @param excludedServiceIDs the provided list of serviceIDs excluded from
@@ -2026,6 +2028,8 @@
   public MultiDomainServerState getLastECLCookie(
     ArrayList<String> excludedServiceIDs)
   {
+    disableEligibility(excludedServiceIDs);
+
     MultiDomainServerState result = new MultiDomainServerState();
     // Initialize start state for  all running domains with empty state
     Iterator<ReplicationServerDomain> rsdk = this.getDomainIterator();
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java
index 6d4cae8..baea982 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java
@@ -3067,6 +3067,15 @@
       waitOpResult(searchOp, ResultCode.SUCCESS);
       assertEquals(searchOp.getSearchEntries().size(), 
           lastDraftChangeNumber-firstDraftChangeNumber+1);
+      if (searchOp.getSearchEntries() != null)
+      {
+        int i=0;
+        for (SearchResultEntry resultEntry : searchOp.getSearchEntries())
+        {
+          i++;
+          debugInfo(tn, "Result entry returned:" + resultEntry.toLDIFString());
+        }
+      }
     }
     catch(Exception e)
     {

--
Gitblit v1.10.0