From c08575b5d155b34529c402d7e5398e77abc49117 Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Mon, 20 Aug 2007 08:04:16 +0000
Subject: [PATCH] These changes rovides the ability to repair the consistency in the replication topology in the (hopefully) rare case when hardware failure or software bugs could break it (issue 788 and 791)
---
opends/src/server/org/opends/server/replication/plugin/MultimasterReplication.java | 53 +++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 45 insertions(+), 8 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/plugin/MultimasterReplication.java b/opends/src/server/org/opends/server/replication/plugin/MultimasterReplication.java
index 016582b..82b8b6f 100644
--- a/opends/src/server/org/opends/server/replication/plugin/MultimasterReplication.java
+++ b/opends/src/server/org/opends/server/replication/plugin/MultimasterReplication.java
@@ -45,6 +45,7 @@
import org.opends.server.types.BackupConfig;
import org.opends.server.types.ConfigChangeResult;
+import org.opends.server.types.Control;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
@@ -67,6 +68,8 @@
import org.opends.server.types.operation.PreOperationModifyOperation;
import org.opends.messages.Message;
+import static org.opends.server.replication.plugin.
+ ReplicationRepairRequestControl.*;
/**
* This class is used to load the Replication code inside the JVM
@@ -91,20 +94,51 @@
/**
* Finds the domain for a given DN.
*
- * @param dn The DN for which the domain must be returned.
- * @param op An optional operation for which the check is done.
- * Can be null is the request has no associated operation.
- * @return The domain for this DN.
+ * @param dn The DN for which the domain must be returned.
+ * @param pluginOp An optional operation for which the check is done.
+ * Can be null is the request has no associated operation.
+ * @return The domain for this DN.
*/
- public static ReplicationDomain findDomain(DN dn, PluginOperation op)
+ public static ReplicationDomain findDomain(DN dn, PluginOperation pluginOp)
{
/*
* Don't run the special replication code on Operation that are
* specifically marked as don't synchronize.
*/
- if ((op != null) && (op instanceof Operation) &&
- (((Operation) op).dontSynchronize()))
- return null;
+ if ((pluginOp != null) && (pluginOp instanceof Operation))
+ {
+ Operation op = ((Operation) pluginOp);
+
+ if (op.dontSynchronize())
+ return null;
+
+ /*
+ * Check if the provided operation is a repair operation and set
+ * the synchronization flags if necessary.
+ * The repair operations are tagged as synchronization operations
+ * so that the core server let the operation modify the entryuuid
+ * and ds-sync-hist attributes.
+ * They are also tagged as dontSynchronize so that the replication
+ * code running later do not generate ChnageNumber, solve conflicts
+ * and forward the operation to the replication server.
+ */
+ for (Control c : op.getRequestControls())
+ {
+ if (c.getOID().equals(OID_REPLICATION_REPAIR_CONTROL))
+ {
+ op.setSynchronizationOperation(true);
+ op.setDontSynchronize(true);
+ // remove this control from the list of controls since
+ // it has now been processed and the local backend will
+ // fail if it finds a control that it does not know about and
+ // that is marked as critical.
+ List<Control> controls = op.getRequestControls();
+ controls.remove(c);
+ return null;
+ }
+ }
+ }
+
ReplicationDomain domain = null;
DN temp = dn;
@@ -188,6 +222,9 @@
DirectoryServer.registerRestoreTaskListener(this);
DirectoryServer.registerExportTaskListener(this);
DirectoryServer.registerImportTaskListener(this);
+
+ DirectoryServer.registerSupportedControl(
+ ReplicationRepairRequestControl.OID_REPLICATION_REPAIR_CONTROL);
}
/**
--
Gitblit v1.10.0