From 319071cd34b2e868beffb8f003e4549b26801b4e Mon Sep 17 00:00:00 2001
From: pgamba <pgamba@localhost>
Date: Fri, 11 Dec 2009 15:26:13 +0000
Subject: [PATCH] Improve error msg adding a usable cookie when a domain has been removed or ECL disabled
---
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java | 9 +++++----
opendj-sdk/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java | 18 +++++++++++++-----
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java b/opendj-sdk/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java
index d6635ea..1b8efbb 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java
@@ -466,7 +466,6 @@
if (this.replicationServerDomain != null)
lockDomain(true);
-// this.localGenerationId = replicationServerDomain.getGenerationId();
this.localGenerationId = -1;
// send start to remote
@@ -808,21 +807,30 @@
// the request is rejected and a full resync is required.
throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
ERR_RESYNC_REQUIRED_MISSING_DOMAIN_IN_PROVIDED_COOKIE.get(
- missingDomains + " .Possible cookie:" +
- (providedCookie + missingDomains)));
+ missingDomains +
+ ". Possible cookie: <" + (providedCookie + missingDomains)+ ">"));
}
+ domainCtxts = tmpSet.toArray(new DomainContext[0]);
+
if (!startStatesFromProvidedCookie.isEmpty())
{
// After reading all the knows domains from the provided cookie, there
// is one (or several) domain that are not currently configured.
// This domain has probably been removed or replication disabled on it.
// The request is rejected and full resync is required.
+ String unknownDomains = startStatesFromProvidedCookie.toString();
+ String possibleCookie = "";
+ for (int j=0; j<domainCtxts.length; j++)
+ {
+ possibleCookie += (domainCtxts[j].rsd.getBaseDn() + ":"
+ + domainCtxts[j].startState + ";");
+ }
throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
ERR_RESYNC_REQUIRED_UNKNOWN_DOMAIN_IN_PROVIDED_COOKIE.get(
- startStatesFromProvidedCookie.toString()));
+ unknownDomains +
+ ". Possible cookie: <" + possibleCookie+ ">"));
}
- domainCtxts = tmpSet.toArray(new DomainContext[0]);
// the next record from the DraftCNdb should be the one
startCookie = providedCookie;
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java
index 748101b..7332768 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java
@@ -1152,9 +1152,10 @@
waitOpResult(searchOp, ResultCode.UNWILLING_TO_PERFORM);
assertEquals(searchOp.getSearchEntries().size(), 0);
assertTrue(searchOp.getErrorMessage().toString().startsWith(
- "Full resync required. Reason: The provided cookie contains unknown replicated domain {o=test6=}"),
+ "Full resync required. Reason: The provided cookie contains unknown replicated domain {o=test6=}. Possible cookie: <"),
searchOp.getErrorMessage().toString());
-
+ // The cookie value is not tested because it is build from a hashmap in
+ // the server and the order of domains is not predictable.
// Test missing domain in provided cookie
newCookie = lastCookie.substring(lastCookie.indexOf(';')+1);
control =
@@ -1178,8 +1179,8 @@
waitOpResult(searchOp, ResultCode.UNWILLING_TO_PERFORM);
assertEquals(searchOp.getSearchEntries().size(), 0);
assertTrue(searchOp.getErrorMessage().toString().equalsIgnoreCase(
- "Full resync required. Reason: The provided cookie is missing the replicated domain(s) o=test:; .Possible cookie:"
- + newCookie + "o=test:;"), "Server output:" +
+ "Full resync required. Reason: The provided cookie is missing the replicated domain(s) o=test:;. Possible cookie: <"
+ + newCookie + "o=test:;>"), "Server output:" +
searchOp.getErrorMessage().toString());
s1test.stop();
--
Gitblit v1.10.0