From 110726757d33bae25fabde2a8dbd2d9203e85526 Mon Sep 17 00:00:00 2001
From: pgamba <pgamba@localhost>
Date: Wed, 14 Nov 2007 18:20:29 +0000
Subject: [PATCH] Fix 2424 - impact of generation ID on binary copy - add to the SetGenerationID task the possibility to clear the generation id in the topology by providing the attribute ds-task-reset-generation-id-new-value with value -1
---
opends/resource/schema/02-config.ldif | 6 +++
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java | 22 ++++++++++
opends/src/messages/messages/task.properties | 4 +
opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java | 14 ++++++-
opends/src/server/org/opends/server/config/ConfigConstants.java | 7 +++
opends/src/server/org/opends/server/tasks/SetGenerationIdTask.java | 28 ++++++++++++-
6 files changed, 74 insertions(+), 7 deletions(-)
diff --git a/opends/resource/schema/02-config.ldif b/opends/resource/schema/02-config.ldif
index d052a4a..07e1710 100644
--- a/opends/resource/schema/02-config.ldif
+++ b/opends/resource/schema/02-config.ldif
@@ -2167,6 +2167,11 @@
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12
SINGLE-VALUE
X-ORIGIN 'OpenDS Directory Server' )
+attributeTypes: ( 1.3.6.1.4.1.26027.1.1.444
+ NAME 'ds-task-reset-generation-id-new-value'
+ SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
+ SINGLE-VALUE
+ X-ORIGIN 'OpenDS Directory Server' )
objectClasses: ( 1.3.6.1.4.1.26027.1.2.1
NAME 'ds-cfg-access-control-handler'
SUP top
@@ -3330,6 +3335,7 @@
SUP ds-task
STRUCTURAL
MUST ds-task-reset-generation-id-domain-base-dn
+ MAY ds-task-reset-generation-id-new-value
X-ORIGIN 'OpenDS Directory Server' )
objectClasses: ( 1.3.6.1.4.1.26027.1.2.122
NAME 'ds-cfg-entry-uuid-plugin'
diff --git a/opends/src/messages/messages/task.properties b/opends/src/messages/messages/task.properties
index a9c05b4..c0b8d59 100644
--- a/opends/src/messages/messages/task.properties
+++ b/opends/src/messages/messages/task.properties
@@ -186,4 +186,6 @@
INFO_FAILED_DEPENDENCY_ACTION_PROCESS_99=Process
INFO_FAILED_DEPENDENCY_ACTION_CANCEL_100=Cancel
INFO_FAILED_DEPENDENCY_ACTION_DISABLE_101=Disable
-INFO_TASK_STOPPED_BY_ADMIN_102=Task was stopped by an administrator: %s
\ No newline at end of file
+INFO_TASK_STOPPED_BY_ADMIN_102=Task was stopped by an administrator: %s
+SEVERE_ERR_TASK_INITIALIZE_INVALID_GENERATION_ID_103=Invalid generation ID provided with the \
+ task
diff --git a/opends/src/server/org/opends/server/config/ConfigConstants.java b/opends/src/server/org/opends/server/config/ConfigConstants.java
index 246273e..5b61c05 100644
--- a/opends/src/server/org/opends/server/config/ConfigConstants.java
+++ b/opends/src/server/org/opends/server/config/ConfigConstants.java
@@ -4304,6 +4304,13 @@
OC_RESET_GENERATION_ID_TASK + "-domain-base-dn";
/**
+ * The name of the attribute containing the new value of the generation ID
+ * related to the replication domain to which applies the task.
+ */
+ public static final String ATTR_TASK_SET_GENERATION_ID_NEW_VALUE =
+ OC_RESET_GENERATION_ID_TASK + "-new-value";
+
+ /**
* The name of the attribute in an import task definition that specifies
* whether the backend should be cleared before the import.
*/
diff --git a/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java b/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
index 462d4b2..1422ef8 100644
--- a/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
+++ b/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
@@ -2517,11 +2517,21 @@
* Reset the generationId of this domain in the whole topology.
* A message is sent to the Replication Servers for them to reset
* their change dbs.
+ *
+ * @param generationIdNewValue The new value of the generation Id.
*/
- public void resetGenerationId()
+ public void resetGenerationId(Long generationIdNewValue)
{
+ ResetGenerationId genIdMessage = null;
requestedResetSinceLastStart = true;
- ResetGenerationId genIdMessage = new ResetGenerationId(this.generationId);
+ if (generationIdNewValue == null)
+ {
+ genIdMessage = new ResetGenerationId(this.generationId);
+ }
+ else
+ {
+ genIdMessage = new ResetGenerationId(generationIdNewValue);
+ }
broker.publish(genIdMessage);
}
diff --git a/opends/src/server/org/opends/server/tasks/SetGenerationIdTask.java b/opends/src/server/org/opends/server/tasks/SetGenerationIdTask.java
index a439155..0045309 100644
--- a/opends/src/server/org/opends/server/tasks/SetGenerationIdTask.java
+++ b/opends/src/server/org/opends/server/tasks/SetGenerationIdTask.java
@@ -63,6 +63,7 @@
String domainString = null;
ReplicationDomain domain = null;
TaskState initState;
+ Long generationId = null;
private static final void debugInfo(String s)
{
@@ -85,6 +86,8 @@
*/
@Override public void initializeTask() throws DirectoryException
{
+ List<Attribute> attrList;
+
if (TaskState.isDone(getTaskState()))
{
return;
@@ -93,13 +96,32 @@
// FIXME -- Do we need any special authorization here?
Entry taskEntry = getTaskEntry();
- AttributeType typeDomainBase;
+ // Retrieves the eventual generation-ID
+ AttributeType typeNewValue;
+ typeNewValue =
+ getAttributeType(ATTR_TASK_SET_GENERATION_ID_NEW_VALUE, true);
+ attrList = taskEntry.getAttribute(typeNewValue);
+ if ((attrList != null) && !attrList.isEmpty())
+ {
+ try
+ {
+ generationId = new Long(TaskUtils.getSingleValueString(attrList));
+ }
+ catch(Exception e)
+ {
+ MessageBuilder mb = new MessageBuilder();
+ mb.append(TaskMessages.ERR_TASK_INITIALIZE_INVALID_GENERATION_ID.get());
+ mb.append(e.getMessage());
+ throw new DirectoryException(ResultCode.CLIENT_SIDE_PARAM_ERROR,
+ mb.toMessage());
+ }
+ }
// Retrieves the replication domain
+ AttributeType typeDomainBase;
typeDomainBase =
getAttributeType(ATTR_TASK_SET_GENERATION_ID_DOMAIN_DN, true);
- List<Attribute> attrList;
attrList = taskEntry.getAttribute(typeDomainBase);
domainString = TaskUtils.getSingleValueString(attrList);
DN domainDN = DN.nullDN();
@@ -128,7 +150,7 @@
debugInfo("setGenerationIdTask is starting on domain%s" +
domain.getBaseDN());
- domain.resetGenerationId();
+ domain.resetGenerationId(generationId);
debugInfo("setGenerationIdTask is ending SUCCESSFULLY");
return TaskState.COMPLETED_SUCCESSFULLY;
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java
index fe8cffa..bc9b980 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java
@@ -1160,10 +1160,30 @@
debugInfo("Verifying that all replservers genIds have been reset.");
genId = readGenId();
- assertEquals(replServer2.getGenerationId(baseDn), genId);
+ assertEquals(replServer1.getGenerationId(baseDn), genId);
assertEquals(replServer2.getGenerationId(baseDn), genId);
assertEquals(replServer3.getGenerationId(baseDn), genId);
+ debugInfo("Adding reset task to DS.");
+ taskReset = TestCaseUtils.makeEntry(
+ "dn: ds-task-id=resetgenid"+ UUID.randomUUID() +
+ ",cn=Scheduled Tasks,cn=Tasks",
+ "objectclass: top",
+ "objectclass: ds-task",
+ "objectclass: ds-task-reset-generation-id",
+ "ds-task-class-name: org.opends.server.tasks.SetGenerationIdTask",
+ "ds-task-reset-generation-id-domain-base-dn: " + baseDnStr,
+ "ds-task-reset-generation-id-new-value: -1");
+ addTask(taskReset, ResultCode.SUCCESS, null);
+ waitTaskState(taskReset, TaskState.COMPLETED_SUCCESSFULLY, null);
+ Thread.sleep(500);
+
+ debugInfo("Verifying that all replservers genIds have been reset.");
+ genId = readGenId();
+ assertEquals(replServer1.getGenerationId(baseDn), -1);
+ assertEquals(replServer2.getGenerationId(baseDn), -1);
+ assertEquals(replServer3.getGenerationId(baseDn), -1);
+
debugInfo("Disconnect DS from replServer1 (required in order to DEL entries).");
disconnectFromReplServer(changelog1ID);
--
Gitblit v1.10.0