From 88e5620001d65afa8d0d8e07d1361fa44705743e Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Fri, 11 May 2007 13:19:28 +0000
Subject: [PATCH] This code allows the replication code to replay operation in the correct order when operation have dependencies (like adding child entry after parent)
---
opends/src/server/org/opends/server/replication/plugin/PendingChange.java | 71 ++++++++++++++++++++++++++++++++++-
1 files changed, 69 insertions(+), 2 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/plugin/PendingChange.java b/opends/src/server/org/opends/server/replication/plugin/PendingChange.java
index bb42a60..a73abe0 100644
--- a/opends/src/server/org/opends/server/replication/plugin/PendingChange.java
+++ b/opends/src/server/org/opends/server/replication/plugin/PendingChange.java
@@ -27,19 +27,24 @@
package org.opends.server.replication.plugin;
import org.opends.server.replication.common.ChangeNumber;
+import org.opends.server.replication.common.ServerState;
import org.opends.server.replication.protocol.UpdateMessage;
+import org.opends.server.types.DN;
+import org.opends.server.types.DirectoryException;
import org.opends.server.types.Operation;
/**
- * This class is use to store the list of operations currently
+ * This class is use to store an operation currently
* in progress and not yet committed in the database.
*/
-public class PendingChange
+public class PendingChange implements Comparable<PendingChange>
{
private ChangeNumber changeNumber;
private boolean committed;
private UpdateMessage msg;
private Operation op;
+ private ServerState dependencyState = null;
+ private DN targetDN = null;
/**
* Construct a new PendingChange.
@@ -121,4 +126,66 @@
this.op = op;
}
+ /**
+ * Add the given ChangeNumber in the list of dependencies of this
+ * PendingChange.
+ *
+ * @param changeNumber The ChangeNumber to add in the list of dependencies
+ * of this PendingChange.
+ */
+ public void addDependency(ChangeNumber changeNumber)
+ {
+ if (dependencyState == null)
+ {
+ dependencyState = new ServerState();
+ }
+ dependencyState.update(changeNumber);
+ }
+
+ /**
+ * Check if the given ServerState covers the dependencies of this
+ * PendingChange.
+ *
+ * @param state The ServerState for which dependencies must be checked,
+ *
+ * @return A boolean indicating if the given ServerState covers the
+ * dependencies of this PendingChange.
+ */
+ public boolean dependenciesIsCovered(ServerState state)
+ {
+ return state.cover(dependencyState);
+ }
+
+ /**
+ * Get the Target DN of this message.
+ *
+ * @return The target DN of this message.
+ */
+ public DN getTargetDN()
+ {
+ synchronized (this)
+ {
+ if (targetDN != null)
+ return targetDN;
+ else
+ {
+ try
+ {
+ targetDN = DN.decode(msg.getDn());
+ }
+ catch (DirectoryException e)
+ {
+ }
+ }
+ return targetDN;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int compareTo(PendingChange o)
+ {
+ return this.getChangeNumber().compareTo(o.getChangeNumber());
+ }
}
--
Gitblit v1.10.0