From 3298001b86b35e1a05ff9d6a2f0ac402d674400a Mon Sep 17 00:00:00 2001
From: pgamba <pgamba@localhost>
Date: Thu, 20 Sep 2007 16:46:22 +0000
Subject: [PATCH] Fix ReplicationTestServer failure by removing all entries before starting
---
opends/src/server/org/opends/server/replication/server/ReplicationCache.java | 80 ++++++++++++++++++++++------------------
opends/src/server/org/opends/server/replication/server/ReplicationServer.java | 18 ++++++++
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java | 6 ++
3 files changed, 66 insertions(+), 38 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 6fd8925..279871a 100644
--- a/opends/src/server/org/opends/server/replication/server/ReplicationCache.java
+++ b/opends/src/server/org/opends/server/replication/server/ReplicationCache.java
@@ -1037,42 +1037,7 @@
if (this.generationId != newGenId)
{
- // Reset the localchange and state db for the current domain
- synchronized (sourceDbHandlers)
- {
- for (DbHandler dbHandler : sourceDbHandlers.values())
- {
- try
- {
- dbHandler.clear();
- }
- catch (Exception e)
- {
- // TODO: i18n
- logError(Message.raw(
- "Exception caught while clearing dbHandler:" +
- e.getLocalizedMessage()));
- }
- }
- sourceDbHandlers.clear();
-
- if (debugEnabled())
- TRACER.debugInfo(
- "In " + this.replicationServer.getMonitorInstanceName() +
- " baseDN=" + baseDn +
- " The source db handler has been cleared");
- }
- try
- {
- replicationServer.clearGenerationId(baseDn);
- }
- catch (Exception e)
- {
- // TODO: i18n
- logError(Message.raw(
- "Exception caught while clearing generationId:" +
- e.getLocalizedMessage()));
- }
+ clearDbs();
// Reset the in memory domain generationId
generationId = newGenId;
@@ -1080,6 +1045,49 @@
}
/**
+ * Clears the Db associated with that cache.
+ */
+ public void clearDbs()
+ {
+ // Reset the localchange and state db for the current domain
+ synchronized (sourceDbHandlers)
+ {
+ for (DbHandler dbHandler : sourceDbHandlers.values())
+ {
+ try
+ {
+ dbHandler.clear();
+ }
+ catch (Exception e)
+ {
+ // TODO: i18n
+ logError(Message.raw(
+ "Exception caught while clearing dbHandler:" +
+ e.getLocalizedMessage()));
+ }
+ }
+ sourceDbHandlers.clear();
+
+ if (debugEnabled())
+ TRACER.debugInfo(
+ "In " + this.replicationServer.getMonitorInstanceName() +
+ " baseDN=" + baseDn +
+ " The source db handler has been cleared");
+ }
+ try
+ {
+ replicationServer.clearGenerationId(baseDn);
+ }
+ catch (Exception e)
+ {
+ // TODO: i18n
+ logError(Message.raw(
+ "Exception caught while clearing generationId:" +
+ e.getLocalizedMessage()));
+ }
+ }
+
+ /**
* Returns whether the provided server is in degraded
* state due to the fact that the peer server has an invalid
* generationId for this domain.
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 57f9a7e..118c352 100644
--- a/opends/src/server/org/opends/server/replication/server/ReplicationServer.java
+++ b/opends/src/server/org/opends/server/replication/server/ReplicationServer.java
@@ -989,4 +989,20 @@
else
return null;
}
-}
+
+ /**
+ * Clears the Db associated with that server.
+ */
+ public void clearDb()
+ {
+ Iterator<ReplicationCache> rcachei = getCacheIterator();
+ if (rcachei != null)
+ {
+ while (rcachei.hasNext())
+ {
+ ReplicationCache rc = rcachei.next();
+ rc.clearDbs();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
index dc38816..40ff3e7 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
@@ -41,6 +41,7 @@
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
@@ -74,6 +75,7 @@
import org.opends.server.replication.protocol.ReplServerStartMessage;
import org.opends.server.replication.protocol.ReplSessionSecurity;
import org.opends.server.replication.protocol.ReplicationMessage;
+import org.opends.server.replication.protocol.ResetGenerationId;
import org.opends.server.replication.protocol.ServerStartMessage;
import org.opends.server.replication.protocol.UpdateMessage;
import org.opends.server.replication.protocol.WindowMessage;
@@ -1237,7 +1239,9 @@
public void searchBackend() throws Exception
{
debugInfo("Starting searchBackend");
-
+
+ replicationServer.clearDb();
+
LDIFWriter ldifWriter = null;
ByteArrayOutputStream stream = new ByteArrayOutputStream();
LDIFExportConfig exportConfig = new LDIFExportConfig(stream);
--
Gitblit v1.10.0