From cc98695069d613fb483650235920b70f1022f4d5 Mon Sep 17 00:00:00 2001
From: pgamba <pgamba@localhost>
Date: Thu, 29 Nov 2007 08:43:16 +0000
Subject: [PATCH] Fix #2630 dsrepl pre-external-initialization does not work with bin copy

---
 opends/src/server/org/opends/server/replication/server/ReplicationCache.java |   47 +++++++++++++++++++++++------------------------
 1 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/server/ReplicationCache.java b/opends/src/server/org/opends/server/replication/server/ReplicationCache.java
index d27d11f..41df388 100644
--- a/opends/src/server/org/opends/server/replication/server/ReplicationCache.java
+++ b/opends/src/server/org/opends/server/replication/server/ReplicationCache.java
@@ -1004,7 +1004,7 @@
       {
         for (ServerHandler handler : connectedServers.values())
         {
-          handler.resetGenerationId();
+          handler.warnBadGenerationId();
         }
       }
 
@@ -1027,45 +1027,44 @@
 
       if (debugEnabled())
         TRACER.debugInfo(
-          "In " + this.replicationServer.getMonitorInstanceName() +
-          " baseDN=" + baseDn +
-          " RCache.resetGenerationId received new ref genId="  + newGenId);
+            "In " + this.replicationServer.getMonitorInstanceName() +
+            " baseDN=" + baseDn +
+            " RCache.resetGenerationId received new ref genId="  + newGenId);
 
-      // Notifies the others LDAP servers that from now on
-      // they have the bad generationId
+      // Notifies the remote LDAP servers that from now on
+      // they have a generationId different from the reference one
       for (ServerHandler handler : connectedServers.values())
       {
         if (newGenId != handler.getGenerationId())
         {
-          handler.resetGenerationId();
+          handler.warnBadGenerationId();
         }
       }
 
-      // Propagates the reset message to the others replication servers
-      // dealing with the same domain.
-      if (senderHandler.isLDAPserver())
+      // If we are the first replication server warned,
+      // then forwards the reset message to the remote replication servers
+      for (ServerHandler rsHandler : replicationServers.values())
       {
-        for (ServerHandler handler : replicationServers.values())
+        try
         {
-          try
+          rsHandler.setGenerationId(newGenId);
+          if (senderHandler.isLDAPserver())
           {
-            handler.sendGenerationId(genIdMsg);
+            rsHandler.forwardGenerationIdToRS(genIdMsg);
           }
-          catch (IOException e)
-          {
-            logError(ERR_CHANGELOG_ERROR_SENDING_INFO.
-                get(handler.getMonitorInstanceName()));
-           }
+        }
+        catch (IOException e)
+        {
+          logError(ERR_CHANGELOG_ERROR_SENDING_INFO.
+              get(rsHandler.getMonitorInstanceName()));
         }
       }
 
-      if (this.generationId != newGenId)
-      {
-        clearDbs();
+      clearDbs();
 
-        // Reset the in memory domain generationId
-        generationId = newGenId;
-      }
+      // Reset the in memory domain generationId
+      generationId = newGenId;
+
     }
 
     /**

--
Gitblit v1.10.0