From d491fe177f1740e7b5882569d51987a15662fc85 Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Thu, 12 Jul 2007 09:30:40 +0000
Subject: [PATCH] fix for 1887 : Define new interfaces used by the synchronization provider so that LocalBackend operations are not exposed
---
opends/src/server/org/opends/server/replication/protocol/OperationContext.java | 24 +++
opends/src/server/org/opends/server/replication/protocol/AddMsg.java | 11 +
opends/src/server/org/opends/server/replication/protocol/UpdateMessage.java | 28 ++--
opends/src/server/org/opends/server/replication/plugin/MultimasterReplication.java | 44 ++++--
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/UpdateComparatorTest.java | 8
opends/src/server/org/opends/server/replication/protocol/ModifyMsg.java | 8
opends/src/server/org/opends/server/replication/protocol/ModifyDNMsg.java | 26 ++--
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ModifyConflictTest.java | 14 +
opends/src/server/org/opends/server/replication/plugin/PendingChanges.java | 4
opends/src/server/org/opends/server/replication/plugin/Historical.java | 11 -
opends/src/server/org/opends/server/replication/server/ReplicationServer.java | 5
opends/src/server/org/opends/server/replication/plugin/PendingChange.java | 10
opends/src/server/org/opends/server/api/SynchronizationProvider.java | 49 +++----
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/SynchronizationMsgTest.java | 51 +-------
opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java | 28 +++-
opends/src/server/org/opends/server/replication/protocol/DeleteMsg.java | 16 +-
16 files changed, 168 insertions(+), 169 deletions(-)
diff --git a/opends/src/server/org/opends/server/api/SynchronizationProvider.java b/opends/src/server/org/opends/server/api/SynchronizationProvider.java
index 96b34f0..b8275e8 100644
--- a/opends/src/server/org/opends/server/api/SynchronizationProvider.java
+++ b/opends/src/server/org/opends/server/api/SynchronizationProvider.java
@@ -32,12 +32,11 @@
import org.opends.server.admin.std.server.SynchronizationProviderCfg;
import org.opends.server.config.ConfigException;
-import org.opends.server.core.ModifyDNOperation;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
import org.opends.server.types.Modification;
import org.opends.server.types.SynchronizationProviderResult;
-import org.opends.server.workflowelement.localbackend.*;
+import org.opends.server.types.operation.*;
@@ -141,9 +140,8 @@
* @throws DirectoryException If a problem occurs during
* synchronization processing.
*/
- public SynchronizationProviderResult
- handleConflictResolution(LocalBackendAddOperation
- addOperation)
+ public SynchronizationProviderResult handleConflictResolution(
+ PreOperationAddOperation addOperation)
throws DirectoryException
{
// No processing is required by default.
@@ -169,9 +167,8 @@
* @throws DirectoryException If a problem occurs during
* synchronization processing.
*/
- public abstract SynchronizationProviderResult
- doPreOperation(LocalBackendAddOperation
- addOperation)
+ public abstract SynchronizationProviderResult doPreOperation(
+ PreOperationAddOperation addOperation)
throws DirectoryException;
@@ -188,8 +185,8 @@
* @throws DirectoryException If a problem occurs during
* synchronization processing.
*/
- public abstract void doPostOperation(LocalBackendAddOperation
- addOperation)
+ public abstract void doPostOperation(
+ PostOperationAddOperation addOperation)
throws DirectoryException;
@@ -213,8 +210,8 @@
* synchronization processing.
*/
public SynchronizationProviderResult
- handleConflictResolution(LocalBackendDeleteOperation
- deleteOperation)
+ handleConflictResolution(
+ PreOperationDeleteOperation deleteOperation)
throws DirectoryException
{
// No processing is required by default.
@@ -241,8 +238,7 @@
* synchronization processing.
*/
public abstract SynchronizationProviderResult
- doPreOperation(LocalBackendDeleteOperation
- deleteOperation)
+ doPreOperation(PreOperationDeleteOperation deleteOperation)
throws DirectoryException;
@@ -260,8 +256,7 @@
* synchronization processing.
*/
public abstract void doPostOperation(
- LocalBackendDeleteOperation
- deleteOperation)
+ PostOperationDeleteOperation deleteOperation)
throws DirectoryException;
@@ -285,8 +280,8 @@
* synchronization processing.
*/
public SynchronizationProviderResult
- handleConflictResolution(LocalBackendModifyOperation
- modifyOperation)
+ handleConflictResolution(
+ PreOperationModifyOperation modifyOperation)
throws DirectoryException
{
// No processing is required by default.
@@ -313,8 +308,7 @@
* synchronization processing.
*/
public abstract SynchronizationProviderResult
- doPreOperation(LocalBackendModifyOperation
- modifyOperation)
+ doPreOperation(PreOperationModifyOperation modifyOperation)
throws DirectoryException;
@@ -332,8 +326,7 @@
* synchronization processing.
*/
public abstract void doPostOperation(
- LocalBackendModifyOperation
- modifyOperation)
+ PostOperationModifyOperation modifyOperation)
throws DirectoryException;
@@ -357,9 +350,8 @@
* @throws DirectoryException If a problem occurs during
* synchronization processing.
*/
- public SynchronizationProviderResult
- handleConflictResolution(ModifyDNOperation
- modifyDNOperation)
+ public SynchronizationProviderResult handleConflictResolution(
+ PreOperationModifyDNOperation modifyDNOperation)
throws DirectoryException
{
// No processing is required by default.
@@ -386,9 +378,8 @@
* @throws DirectoryException If a problem occurs during
* synchronization processing.
*/
- public abstract SynchronizationProviderResult
- doPreOperation(ModifyDNOperation
- modifyDNOperation)
+ public abstract SynchronizationProviderResult doPreOperation(
+ PreOperationModifyDNOperation modifyDNOperation)
throws DirectoryException;
@@ -407,7 +398,7 @@
* synchronization processing.
*/
public abstract void doPostOperation(
- ModifyDNOperation modifyDNOperation)
+ PostOperationModifyDNOperation modifyDNOperation)
throws DirectoryException;
/**
diff --git a/opends/src/server/org/opends/server/replication/plugin/Historical.java b/opends/src/server/org/opends/server/replication/plugin/Historical.java
index 969c1e0..6b84831 100644
--- a/opends/src/server/org/opends/server/replication/plugin/Historical.java
+++ b/opends/src/server/org/opends/server/replication/plugin/Historical.java
@@ -39,9 +39,7 @@
import java.util.TreeMap;
import java.util.HashSet;
-import org.opends.server.core.AddOperation;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.core.ModifyOperation;
import org.opends.server.replication.common.ChangeNumber;
import org.opends.server.replication.protocol.OperationContext;
import org.opends.server.types.Attribute;
@@ -52,7 +50,8 @@
import org.opends.server.types.ErrorLogSeverity;
import org.opends.server.types.Modification;
import org.opends.server.types.ModificationType;
-import org.opends.server.workflowelement.localbackend.*;
+import org.opends.server.types.operation.PreOperationAddOperation;
+import org.opends.server.types.operation.PreOperationModifyOperation;
/**
* This class is used to store historical information that is
@@ -116,7 +115,7 @@
* @param modifiedEntry the entry that is being modified (before modification)
* @return true if the replayed operation was in conflict
*/
- public boolean replayOperation(ModifyOperation modifyOperation,
+ public boolean replayOperation(PreOperationModifyOperation modifyOperation,
Entry modifiedEntry)
{
boolean bConflict = false;
@@ -146,7 +145,7 @@
*
* @param modifyOperation the modification.
*/
- public void generateState(LocalBackendModifyOperation modifyOperation)
+ public void generateState(PreOperationModifyOperation modifyOperation)
{
List<Modification> mods = modifyOperation.getModifications();
Entry modifiedEntry = modifyOperation.getModifiedEntry();
@@ -517,7 +516,7 @@
* @param op The operation
* @return The Entry Unique Id String form.
*/
- public static String getEntryUuid(AddOperation op)
+ public static String getEntryUuid(PreOperationAddOperation op)
{
String uuidString = null;
Map<AttributeType, List<Attribute>> attrs = op.getOperationalAttributes();
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 5c02af2..e21ca23 100644
--- a/opends/src/server/org/opends/server/replication/plugin/MultimasterReplication.java
+++ b/opends/src/server/org/opends/server/replication/plugin/MultimasterReplication.java
@@ -42,7 +42,6 @@
import org.opends.server.api.SynchronizationProvider;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.core.ModifyDNOperation;
import org.opends.server.types.BackupConfig;
import org.opends.server.types.ConfigChangeResult;
import org.opends.server.types.DN;
@@ -55,7 +54,16 @@
import org.opends.server.types.RestoreConfig;
import org.opends.server.types.ResultCode;
import org.opends.server.types.SynchronizationProviderResult;
-import org.opends.server.workflowelement.localbackend.*;
+import org.opends.server.types.operation.PluginOperation;
+import org.opends.server.types.operation.PostOperationAddOperation;
+import org.opends.server.types.operation.PostOperationDeleteOperation;
+import org.opends.server.types.operation.PostOperationModifyDNOperation;
+import org.opends.server.types.operation.PostOperationModifyOperation;
+import org.opends.server.types.operation.PostOperationOperation;
+import org.opends.server.types.operation.PreOperationAddOperation;
+import org.opends.server.types.operation.PreOperationDeleteOperation;
+import org.opends.server.types.operation.PreOperationModifyDNOperation;
+import org.opends.server.types.operation.PreOperationModifyOperation;
import static org.opends.server.messages.ReplicationMessages.*;
@@ -87,13 +95,14 @@
* Can be null is the request has no associated operation.
* @return The domain for this DN.
*/
- public static ReplicationDomain findDomain(DN dn, Operation op)
+ public static ReplicationDomain findDomain(DN dn, PluginOperation op)
{
/*
* Don't run the special replication code on Operation that are
* specifically marked as don't synchronize.
*/
- if ((op != null) && op.dontSynchronize())
+ if ((op != null) && (op instanceof Operation) &&
+ (((Operation) op).dontSynchronize()))
return null;
ReplicationDomain domain = null;
@@ -212,7 +221,7 @@
* {@inheritDoc}
*/
@Override
- public void doPostOperation(LocalBackendAddOperation addOperation)
+ public void doPostOperation(PostOperationAddOperation addOperation)
{
DN dn = addOperation.getEntryDN();
genericPostOperation(addOperation, dn);
@@ -223,7 +232,7 @@
* {@inheritDoc}
*/
@Override
- public void doPostOperation(LocalBackendDeleteOperation deleteOperation)
+ public void doPostOperation(PostOperationDeleteOperation deleteOperation)
{
DN dn = deleteOperation.getEntryDN();
genericPostOperation(deleteOperation, dn);
@@ -233,7 +242,7 @@
* {@inheritDoc}
*/
@Override
- public void doPostOperation(ModifyDNOperation modifyDNOperation)
+ public void doPostOperation(PostOperationModifyDNOperation modifyDNOperation)
{
DN dn = modifyDNOperation.getEntryDN();
genericPostOperation(modifyDNOperation, dn);
@@ -243,7 +252,7 @@
* {@inheritDoc}
*/
@Override
- public void doPostOperation(LocalBackendModifyOperation modifyOperation)
+ public void doPostOperation(PostOperationModifyOperation modifyOperation)
{
DN dn = modifyOperation.getEntryDN();
genericPostOperation(modifyOperation, dn);
@@ -254,7 +263,7 @@
*/
@Override
public SynchronizationProviderResult handleConflictResolution(
- LocalBackendModifyOperation modifyOperation)
+ PreOperationModifyOperation modifyOperation)
{
ReplicationDomain domain =
findDomain(modifyOperation.getEntryDN(), modifyOperation);
@@ -269,7 +278,7 @@
*/
@Override
public SynchronizationProviderResult handleConflictResolution(
- LocalBackendAddOperation addOperation) throws DirectoryException
+ PreOperationAddOperation addOperation) throws DirectoryException
{
ReplicationDomain domain =
findDomain(addOperation.getEntryDN(), addOperation);
@@ -284,7 +293,7 @@
*/
@Override
public SynchronizationProviderResult handleConflictResolution(
- LocalBackendDeleteOperation deleteOperation) throws DirectoryException
+ PreOperationDeleteOperation deleteOperation) throws DirectoryException
{
ReplicationDomain domain =
findDomain(deleteOperation.getEntryDN(), deleteOperation);
@@ -299,7 +308,7 @@
*/
@Override
public SynchronizationProviderResult handleConflictResolution(
- ModifyDNOperation modifyDNOperation) throws DirectoryException
+ PreOperationModifyDNOperation modifyDNOperation) throws DirectoryException
{
ReplicationDomain domain =
findDomain(modifyDNOperation.getEntryDN(), modifyDNOperation);
@@ -314,7 +323,7 @@
*/
@Override
public SynchronizationProviderResult
- doPreOperation(LocalBackendModifyOperation modifyOperation)
+ doPreOperation(PreOperationModifyOperation modifyOperation)
{
DN operationDN = modifyOperation.getEntryDN();
ReplicationDomain domain = findDomain(operationDN, modifyOperation);
@@ -341,7 +350,7 @@
*/
@Override
public SynchronizationProviderResult doPreOperation(
- LocalBackendDeleteOperation deleteOperation) throws DirectoryException
+ PreOperationDeleteOperation deleteOperation) throws DirectoryException
{
return new SynchronizationProviderResult(true);
}
@@ -351,7 +360,8 @@
*/
@Override
public SynchronizationProviderResult doPreOperation(
- ModifyDNOperation modifyDNOperation) throws DirectoryException
+ PreOperationModifyDNOperation modifyDNOperation)
+ throws DirectoryException
{
return new SynchronizationProviderResult(true);
}
@@ -361,7 +371,7 @@
*/
@Override
public SynchronizationProviderResult doPreOperation(
- LocalBackendAddOperation addOperation)
+ PreOperationAddOperation addOperation)
{
ReplicationDomain domain =
findDomain(addOperation.getEntryDN(), addOperation);
@@ -550,7 +560,7 @@
* @param operation The Operation for which the post-operation is called.
* @param dn The Dn for which the post-operation is called.
*/
- private void genericPostOperation(Operation operation, DN dn)
+ private void genericPostOperation(PostOperationOperation operation, DN dn)
{
ReplicationDomain domain = findDomain(dn, operation);
if (domain == null)
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 a73abe0..5f8617a 100644
--- a/opends/src/server/org/opends/server/replication/plugin/PendingChange.java
+++ b/opends/src/server/org/opends/server/replication/plugin/PendingChange.java
@@ -31,7 +31,7 @@
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;
+import org.opends.server.types.operation.PluginOperation;
/**
* This class is use to store an operation currently
@@ -42,7 +42,7 @@
private ChangeNumber changeNumber;
private boolean committed;
private UpdateMessage msg;
- private Operation op;
+ private PluginOperation op;
private ServerState dependencyState = null;
private DN targetDN = null;
@@ -53,7 +53,7 @@
* @param msg the message to use (can be null for local operations)
*/
public PendingChange(ChangeNumber changeNumber,
- Operation op,
+ PluginOperation op,
UpdateMessage msg)
{
this.changeNumber = changeNumber;
@@ -112,7 +112,7 @@
* Get the operation associated to the PendingChange.
* @return the operation
*/
- public Operation getOp()
+ public PluginOperation getOp()
{
return this.op;
}
@@ -121,7 +121,7 @@
* Set the operation asociated to this PendingChange.
* @param op The operation associated to this PendingChange.
*/
- public void setOp(Operation op)
+ public void setOp(PluginOperation op)
{
this.op = op;
}
diff --git a/opends/src/server/org/opends/server/replication/plugin/PendingChanges.java b/opends/src/server/org/opends/server/replication/plugin/PendingChanges.java
index ff5105f..a465fd7 100644
--- a/opends/src/server/org/opends/server/replication/plugin/PendingChanges.java
+++ b/opends/src/server/org/opends/server/replication/plugin/PendingChanges.java
@@ -34,7 +34,7 @@
import org.opends.server.replication.common.ChangeNumberGenerator;
import org.opends.server.replication.common.ServerState;
import org.opends.server.replication.protocol.UpdateMessage;
-import org.opends.server.types.Operation;
+import org.opends.server.types.operation.PluginOperation;
/**
* This class is use to store the list of local operations currently
@@ -155,7 +155,7 @@
* be added in the pending list.
* @return The ChangeNumber now associated to the operation.
*/
- public synchronized ChangeNumber putLocalOperation(Operation operation)
+ public synchronized ChangeNumber putLocalOperation(PluginOperation operation)
{
ChangeNumber changeNumber;
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 29370de..09ae24f 100644
--- a/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
+++ b/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
@@ -117,6 +117,13 @@
import org.opends.server.types.SearchResultEntry;
import org.opends.server.types.SearchScope;
import org.opends.server.types.SynchronizationProviderResult;
+import org.opends.server.types.operation.PluginOperation;
+import org.opends.server.types.operation.PostOperationOperation;
+import org.opends.server.types.operation.PreOperationAddOperation;
+import org.opends.server.types.operation.PreOperationDeleteOperation;
+import org.opends.server.types.operation.PreOperationModifyDNOperation;
+import org.opends.server.types.operation.PreOperationModifyOperation;
+import org.opends.server.types.operation.PreOperationOperation;
import org.opends.server.workflowelement.localbackend.*;
/**
@@ -419,7 +426,7 @@
* can continue.
*/
public SynchronizationProviderResult handleConflictResolution(
- LocalBackendDeleteOperation deleteOperation)
+ PreOperationDeleteOperation deleteOperation)
{
if ((!deleteOperation.isSynchronizationOperation())
&& (!brokerIsConnected(deleteOperation)))
@@ -477,7 +484,7 @@
* can continue.
*/
public SynchronizationProviderResult handleConflictResolution(
- AddOperation addOperation)
+ PreOperationAddOperation addOperation)
{
if ((!addOperation.isSynchronizationOperation())
&& (!brokerIsConnected(addOperation)))
@@ -553,7 +560,7 @@
* When false is returned the resultCode and the reponse message
* is also set in the Operation.
*/
- private boolean brokerIsConnected(Operation op)
+ private boolean brokerIsConnected(PreOperationOperation op)
{
if (isolationpolicy.equals(IsolationPolicy.ACCEPT_ALL_UPDATES))
{
@@ -596,7 +603,7 @@
* can continue.
*/
public SynchronizationProviderResult handleConflictResolution(
- ModifyDNOperation modifyDNOperation)
+ PreOperationModifyDNOperation modifyDNOperation)
{
if ((!modifyDNOperation.isSynchronizationOperation())
&& (!brokerIsConnected(modifyDNOperation)))
@@ -673,7 +680,7 @@
* @return code indicating is operation must proceed
*/
public SynchronizationProviderResult handleConflictResolution(
- LocalBackendModifyOperation modifyOperation)
+ PreOperationModifyOperation modifyOperation)
{
if ((!modifyOperation.isSynchronizationOperation())
&& (!brokerIsConnected(modifyOperation)))
@@ -754,7 +761,7 @@
*
* @param addOperation The Add Operation.
*/
- public void doPreOperation(AddOperation addOperation)
+ public void doPreOperation(PreOperationAddOperation addOperation)
{
AddContext ctx = new AddContext(generateChangeNumber(addOperation),
Historical.getEntryUuid(addOperation),
@@ -897,7 +904,7 @@
* Also update the list of pending changes and the server RUV
* @param op the operation
*/
- public void synchronize(Operation op)
+ public void synchronize(PostOperationOperation op)
{
ResultCode result = op.getResultCode();
if ((result == ResultCode.SUCCESS) && op.isSynchronizationOperation())
@@ -1363,7 +1370,7 @@
* generated.
* @return The new change number.
*/
- private ChangeNumber generateChangeNumber(Operation operation)
+ private ChangeNumber generateChangeNumber(PluginOperation operation)
{
return pendingChanges.putLocalOperation(operation);
}
@@ -1945,7 +1952,7 @@
* @param op the operation to be checked.
* @return true if the operations must be processed as an assured operation.
*/
- private boolean isAssured(Operation op)
+ private boolean isAssured(PostOperationOperation op)
{
// TODO : should have a filtering mechanism for checking
// operation that are assured and operations that are not.
@@ -2854,12 +2861,13 @@
*/
public void synchronizeModifications(List<Modification> modifications)
{
- Operation op =
+ ModifyOperation opBasis =
new ModifyOperationBasis(InternalClientConnection.getRootConnection(),
InternalClientConnection.nextOperationID(),
InternalClientConnection.nextMessageID(),
null, DirectoryServer.getSchemaDN(),
modifications);
+ LocalBackendModifyOperation op = new LocalBackendModifyOperation(opBasis);
ChangeNumber cn = generateChangeNumber(op);
OperationContext ctx = new ModifyContext(cn, "schema");
diff --git a/opends/src/server/org/opends/server/replication/protocol/AddMsg.java b/opends/src/server/org/opends/server/replication/protocol/AddMsg.java
index 84625ad..307e619 100644
--- a/opends/src/server/org/opends/server/replication/protocol/AddMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/AddMsg.java
@@ -26,7 +26,6 @@
*/
package org.opends.server.replication.protocol;
-import org.opends.server.core.AddOperation;
import org.opends.server.core.AddOperationBasis;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.asn1.ASN1Element;
@@ -43,10 +42,12 @@
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.replication.common.ChangeNumber;
+import org.opends.server.types.AbstractOperation;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.LDAPException;
import org.opends.server.types.RawAttribute;
+import org.opends.server.types.operation.PostOperationAddOperation;
import static org.opends.server.replication.protocol.OperationContext.*;
import static org.opends.server.util.StaticUtils.toLowerCase;
@@ -65,7 +66,7 @@
* Creates a new AddMessage.
* @param op the operation to use when creating the message
*/
- public AddMsg(AddOperation op)
+ public AddMsg(PostOperationAddOperation op)
{
super((AddContext) op.getAttachment(SYNCHROCONTEXT),
op.getRawEntryDN().stringValue());
@@ -187,9 +188,9 @@
* {@inheritDoc}
*/
@Override
- public AddOperation createOperation(InternalClientConnection connection,
- String newDn)
- throws LDAPException, ASN1Exception
+ public AbstractOperation createOperation(
+ InternalClientConnection connection, String newDn)
+ throws LDAPException, ASN1Exception
{
ArrayList<RawAttribute> attr = new ArrayList<RawAttribute>();
ArrayList<ASN1Element> elems;
diff --git a/opends/src/server/org/opends/server/replication/protocol/DeleteMsg.java b/opends/src/server/org/opends/server/replication/protocol/DeleteMsg.java
index d8ba12b..bc92182 100644
--- a/opends/src/server/org/opends/server/replication/protocol/DeleteMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/DeleteMsg.java
@@ -31,12 +31,12 @@
import java.io.UnsupportedEncodingException;
import java.util.zip.DataFormatException;
-import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DeleteOperationBasis;
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.replication.common.ChangeNumber;
-import org.opends.server.types.Operation;
+import org.opends.server.types.AbstractOperation;
+import org.opends.server.types.operation.PostOperationDeleteOperation;
/**
* Object used when sending delete information to replication servers.
@@ -48,12 +48,12 @@
/**
* Creates a new delete message.
*
- * @param op the Operation from which the message must be created.
+ * @param operation the Operation from which the message must be created.
*/
- public DeleteMsg(DeleteOperation op)
+ public DeleteMsg(PostOperationDeleteOperation operation)
{
- super((OperationContext) op.getAttachment(SYNCHROCONTEXT),
- op.getRawEntryDN().stringValue());
+ super((OperationContext) operation.getAttachment(SYNCHROCONTEXT),
+ operation.getRawEntryDN().stringValue());
}
/**
@@ -88,8 +88,8 @@
* {@inheritDoc}
*/
@Override
- public Operation createOperation(InternalClientConnection connection,
- String newDn)
+ public AbstractOperation createOperation(
+ InternalClientConnection connection, String newDn)
{
DeleteOperationBasis del = new DeleteOperationBasis(connection,
InternalClientConnection.nextOperationID(),
diff --git a/opends/src/server/org/opends/server/replication/protocol/ModifyDNMsg.java b/opends/src/server/org/opends/server/replication/protocol/ModifyDNMsg.java
index b4f9935..ddce8df 100644
--- a/opends/src/server/org/opends/server/replication/protocol/ModifyDNMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/ModifyDNMsg.java
@@ -35,9 +35,10 @@
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.replication.common.ChangeNumber;
+import org.opends.server.types.AbstractOperation;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
-import org.opends.server.types.Operation;
+import org.opends.server.types.operation.PostOperationModifyDNOperation;
/**
* Message used to send Modify DN information.
@@ -53,22 +54,23 @@
/**
* construct a new Modify DN message.
*
- * @param op The operation to use for building the message
+ * @param operation The operation to use for building the message
*/
- public ModifyDNMsg(ModifyDNOperation op)
+ public ModifyDNMsg(PostOperationModifyDNOperation operation)
{
- super((OperationContext) op.getAttachment(SYNCHROCONTEXT),
- op.getRawEntryDN().stringValue());
+ super((OperationContext) operation.getAttachment(SYNCHROCONTEXT),
+ operation.getRawEntryDN().stringValue());
- ModifyDnContext ctx = (ModifyDnContext) op.getAttachment(SYNCHROCONTEXT);
+ ModifyDnContext ctx =
+ (ModifyDnContext) operation.getAttachment(SYNCHROCONTEXT);
newSuperiorId = ctx.getNewParentId();
- deleteOldRdn = op.deleteOldRDN();
- if (op.getRawNewSuperior() != null)
- newSuperior = op.getRawNewSuperior().stringValue();
+ deleteOldRdn = operation.deleteOldRDN();
+ if (operation.getRawNewSuperior() != null)
+ newSuperior = operation.getRawNewSuperior().stringValue();
else
newSuperior = null;
- newRDN = op.getRawNewRDN().stringValue();
+ newRDN = operation.getRawNewRDN().stringValue();
}
/**
@@ -148,8 +150,8 @@
* {@inheritDoc}
*/
@Override
- public Operation createOperation(InternalClientConnection connection,
- String newDn)
+ public AbstractOperation createOperation(
+ InternalClientConnection connection, String newDn)
{
ModifyDNOperation moddn = new ModifyDNOperation(connection,
InternalClientConnection.nextOperationID(),
diff --git a/opends/src/server/org/opends/server/replication/protocol/ModifyMsg.java b/opends/src/server/org/opends/server/replication/protocol/ModifyMsg.java
index 52fb3e2..d9c185e 100644
--- a/opends/src/server/org/opends/server/replication/protocol/ModifyMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/ModifyMsg.java
@@ -28,7 +28,6 @@
import static org.opends.server.replication.protocol.OperationContext.*;
-import org.opends.server.core.ModifyOperation;
import org.opends.server.core.ModifyOperationBasis;
import org.opends.server.protocols.asn1.ASN1Exception;
import org.opends.server.protocols.asn1.ASN1OctetString;
@@ -38,14 +37,15 @@
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.replication.common.ChangeNumber;
import org.opends.server.replication.plugin.Historical;
+import org.opends.server.types.AbstractOperation;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeUsage;
import org.opends.server.types.DN;
import org.opends.server.types.LDAPException;
import org.opends.server.types.Modification;
-import org.opends.server.types.Operation;
import org.opends.server.types.RawModification;
+import org.opends.server.types.operation.PostOperationModifyOperation;
import java.io.UnsupportedEncodingException;
@@ -67,7 +67,7 @@
*
* @param op The operation to use for building the message
*/
- public ModifyMsg(ModifyOperation op)
+ public ModifyMsg(PostOperationModifyOperation op)
{
super((OperationContext) op.getAttachment(OperationContext.SYNCHROCONTEXT),
op.getRawEntryDN().stringValue());
@@ -127,7 +127,7 @@
* {@inheritDoc}
*/
@Override
- public Operation createOperation(InternalClientConnection connection,
+ public AbstractOperation createOperation(InternalClientConnection connection,
String newDn)
throws LDAPException, ASN1Exception, DataFormatException
{
diff --git a/opends/src/server/org/opends/server/replication/protocol/OperationContext.java b/opends/src/server/org/opends/server/replication/protocol/OperationContext.java
index 78e96e9..e00ac66 100644
--- a/opends/src/server/org/opends/server/replication/protocol/OperationContext.java
+++ b/opends/src/server/org/opends/server/replication/protocol/OperationContext.java
@@ -28,6 +28,7 @@
import org.opends.server.replication.common.ChangeNumber;
import org.opends.server.types.Operation;
+import org.opends.server.types.operation.PluginOperation;
/**
* This class describe the replication context that is attached
@@ -84,9 +85,10 @@
/**
* Get the change number of an operation.
*
- * @param op The operation.
+ * @param op The operation.
+ *
* @return The change number of the provided operation, or null if there is
- * no change number associated with the operation.
+ * no change number associated with the operation.
*/
public static ChangeNumber getChangeNumber(Operation op)
{
@@ -99,6 +101,24 @@
}
/**
+ * Get the change number of an operation.
+ *
+ * @param op The operation.
+ *
+ * @return The change number of the provided operation, or null if there is
+ * no change number associated with the operation.
+ */
+ public static ChangeNumber getChangeNumber(PluginOperation op)
+ {
+ OperationContext ctx = (OperationContext)op.getAttachment(SYNCHROCONTEXT);
+ if (ctx == null)
+ {
+ return null;
+ }
+ return ctx.changeNumber;
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
diff --git a/opends/src/server/org/opends/server/replication/protocol/UpdateMessage.java b/opends/src/server/org/opends/server/replication/protocol/UpdateMessage.java
index 6a1a305..5c54a18 100644
--- a/opends/src/server/org/opends/server/replication/protocol/UpdateMessage.java
+++ b/opends/src/server/org/opends/server/replication/protocol/UpdateMessage.java
@@ -30,15 +30,16 @@
import java.io.UnsupportedEncodingException;
import java.util.zip.DataFormatException;
-import org.opends.server.core.AddOperation;
-import org.opends.server.core.DeleteOperation;
-import org.opends.server.core.ModifyDNOperation;
-import org.opends.server.core.ModifyOperation;
import org.opends.server.protocols.asn1.ASN1Exception;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.replication.common.ChangeNumber;
+import org.opends.server.types.AbstractOperation;
import org.opends.server.types.LDAPException;
-import org.opends.server.types.Operation;
+import org.opends.server.types.operation.PostOperationAddOperation;
+import org.opends.server.types.operation.PostOperationDeleteOperation;
+import org.opends.server.types.operation.PostOperationModifyDNOperation;
+import org.opends.server.types.operation.PostOperationModifyOperation;
+import org.opends.server.types.operation.PostOperationOperation;
/**
* Abstract class that must be extended to define a message
@@ -107,31 +108,32 @@
* @param isAssured flag indicating if the operation is an assured operation.
* @return The generated message.
*/
- public static UpdateMessage generateMsg(Operation op, boolean isAssured)
+ public static UpdateMessage generateMsg(
+ PostOperationOperation op, boolean isAssured)
{
UpdateMessage msg = null;
switch (op.getOperationType())
{
case MODIFY :
- msg = new ModifyMsg((ModifyOperation) op);
+ msg = new ModifyMsg((PostOperationModifyOperation) op);
if (isAssured)
msg.setAssured();
break;
case ADD:
- msg = new AddMsg((AddOperation) op);
+ msg = new AddMsg((PostOperationAddOperation) op);
if (isAssured)
msg.setAssured();
break;
case DELETE :
- msg = new DeleteMsg((DeleteOperation) op);
+ msg = new DeleteMsg((PostOperationDeleteOperation) op);
if (isAssured)
msg.setAssured();
break;
case MODIFY_DN :
- msg = new ModifyDNMsg((ModifyDNOperation) op);
+ msg = new ModifyDNMsg( (PostOperationModifyDNOperation) op);
if (isAssured)
msg.setAssured();
break;
@@ -241,7 +243,7 @@
* @throws ASN1Exception In case of ASN1 decoding exception.
* @throws DataFormatException In case of bad msg format.
*/
- public Operation createOperation(InternalClientConnection conn)
+ public AbstractOperation createOperation(InternalClientConnection conn)
throws LDAPException, ASN1Exception, DataFormatException
{
return createOperation(conn, dn);
@@ -258,8 +260,8 @@
* @throws ASN1Exception In case of ASN1 decoding exception.
* @throws DataFormatException In case of bad msg format.
*/
- public abstract Operation createOperation(InternalClientConnection conn,
- String newDn)
+ public abstract AbstractOperation createOperation(
+ InternalClientConnection conn, String newDn)
throws LDAPException, ASN1Exception, DataFormatException;
/**
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 e8cc35f..8eb31b9 100644
--- a/opends/src/server/org/opends/server/replication/server/ReplicationServer.java
+++ b/opends/src/server/org/opends/server/replication/server/ReplicationServer.java
@@ -49,7 +49,6 @@
import org.opends.server.admin.std.server.MonitorProviderCfg;
import org.opends.server.admin.std.server.ReplicationServerCfg;
import org.opends.server.api.MonitorProvider;
-import org.opends.server.config.ConfigAttribute;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.replication.protocol.SocketSession;
@@ -96,9 +95,6 @@
private String localURL = "null";
private boolean shutdown = false;
private short replicationServerId;
- private DN configDn;
- private List<ConfigAttribute> configAttributes =
- new ArrayList<ConfigAttribute>();
private ReplicationDbEnv dbEnv;
private int rcvWindow;
private int queueSize;
@@ -149,7 +145,6 @@
initialize(replicationServerId, replicationPort);
configuration.addChangeListener(this);
- configDn = configuration.dn();
DirectoryServer.registerMonitorProvider(this);
}
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ModifyConflictTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ModifyConflictTest.java
index 15c2203..7572bf8 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ModifyConflictTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ModifyConflictTest.java
@@ -38,7 +38,6 @@
import static org.opends.server.replication.protocol.OperationContext.*;
-import org.opends.server.core.AddOperation;
import org.opends.server.core.AddOperationBasis;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyOperationBasis;
@@ -61,6 +60,8 @@
import org.opends.server.types.Modification;
import org.opends.server.types.ModificationType;
import org.opends.server.types.ObjectClass;
+import org.opends.server.workflowelement.localbackend.LocalBackendAddOperation;
+import org.opends.server.workflowelement.localbackend.LocalBackendModifyOperation;
/*
* Test the conflict resolution for modify operations As a consequence,
@@ -694,17 +695,20 @@
List<Modification> mods = new ArrayList<Modification>();
mods.add(mod);
- ModifyOperationBasis modOp = new ModifyOperationBasis(connection, 1, 1, null,
- entry.getDN(), mods);
+ ModifyOperationBasis modOpBasis =
+ new ModifyOperationBasis(connection, 1, 1, null, entry.getDN(), mods);
+ LocalBackendModifyOperation modOp = new LocalBackendModifyOperation(modOpBasis);
ModifyContext ctx = new ModifyContext(t, "uniqueId");
modOp.setAttachment(SYNCHROCONTEXT, ctx);
hist.replayOperation(modOp, entry);
if (mod.getModificationType() == ModificationType.ADD)
{
- AddOperationBasis addOp = new AddOperationBasis(connection, 1, 1, null, entry
+ AddOperationBasis addOpBasis =
+ new AddOperationBasis(connection, 1, 1, null, entry
.getDN(), entry.getObjectClasses(), entry.getUserAttributes(),
entry.getOperationalAttributes());
+ LocalBackendAddOperation addOp = new LocalBackendAddOperation(addOpBasis);
testHistorical(hist, addOp);
}
else
@@ -745,7 +749,7 @@
*
*/
private void testHistorical(
- Historical hist, AddOperation addOp)
+ Historical hist, LocalBackendAddOperation addOp)
{
// Get the historical uuid associated to the entry
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/SynchronizationMsgTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/SynchronizationMsgTest.java
index c203fea..f112a94 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/SynchronizationMsgTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/SynchronizationMsgTest.java
@@ -31,7 +31,6 @@
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
-import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
@@ -49,7 +48,6 @@
import org.opends.server.replication.ReplicationTestCase;
import org.opends.server.replication.common.ChangeNumber;
import org.opends.server.replication.common.ServerState;
-import org.opends.server.replication.plugin.PendingChange;
import org.opends.server.replication.protocol.AckMessage;
import org.opends.server.replication.protocol.AddContext;
import org.opends.server.replication.protocol.AddMsg;
@@ -79,6 +77,8 @@
import org.opends.server.types.Operation;
import org.opends.server.types.RDN;
import org.opends.server.util.TimeThread;
+import org.opends.server.workflowelement.localbackend.LocalBackendAddOperation;
+import org.opends.server.workflowelement.localbackend.LocalBackendDeleteOperation;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -189,8 +189,6 @@
* TODO : test that the generated mod equals the original mod.
*/
- // Check pending change
- testPendingChange(changeNumber,op,msg);
}
/**
@@ -260,8 +258,9 @@
{
InternalClientConnection connection =
InternalClientConnection.getRootConnection();
- DeleteOperationBasis op = new DeleteOperationBasis(connection, 1, 1,null,
- DN.decode(rawDN));
+ DeleteOperationBasis opBasis =
+ new DeleteOperationBasis(connection, 1, 1,null, DN.decode(rawDN));
+ LocalBackendDeleteOperation op = new LocalBackendDeleteOperation(opBasis);
ChangeNumber cn = new ChangeNumber(TimeThread.getTime(),
(short) 123, (short) 45);
op.setAttachment(SYNCHROCONTEXT, new DeleteContext(cn, "uniqueid"));
@@ -392,7 +391,7 @@
// Create an new Add Operation from the current addMsg
InternalClientConnection connection =
InternalClientConnection.getRootConnection();
- AddOperation addOp = msg.createOperation(connection, rawDN) ;
+ msg.createOperation(connection, rawDN) ;
// TODO : should test that generated attributes match original attributes.
// List<LDAPAttribute> rawAtt = addOp.getRawAttributes();
@@ -403,8 +402,9 @@
//Create an Add operation and generate and Add msg from it
DN dn = DN.decode(rawDN);
- addOp = new AddOperationBasis(connection,
+ AddOperation addOpBasis = new AddOperationBasis(connection,
(long) 1, 1, null, dn, objectClassList, userAttList, opList);
+ LocalBackendAddOperation addOp = new LocalBackendAddOperation(addOpBasis);
OperationContext opCtx = new AddContext(cn, "thisIsaUniqueID",
"parentUniqueId");
addOp.setAttachment(SYNCHROCONTEXT, opCtx);
@@ -652,39 +652,4 @@
assertEquals(msg.getMsgID(), newMsg.getMsgID());
assertEquals(msg.getDetails(), newMsg.getDetails());
}
-
-
- /**
- * Test PendingChange
- * @throws UnsupportedEncodingException
- */
- private void testPendingChange(
- ChangeNumber cn, Operation op, ReplicationMessage msg)
- throws UnsupportedEncodingException
- {
- if (! (msg instanceof UpdateMessage))
- {
- return ;
- }
- UpdateMessage updateMsg = (UpdateMessage) msg;
- PendingChange pendingChange = new PendingChange(cn,null,null);
-
- pendingChange.setCommitted(false);
- assertFalse(pendingChange.isCommitted()) ;
- pendingChange.setCommitted(true);
- assertTrue(pendingChange.isCommitted()) ;
-
-
- assertTrue(cn.compareTo(pendingChange.getChangeNumber()) == 0);
-
- assertEquals(pendingChange.getMsg(), null) ;
- pendingChange.setMsg(updateMsg);
- assertEquals(updateMsg.getBytes(), pendingChange.getMsg().getBytes());
-
- assertEquals(pendingChange.getOp(), null) ;
- pendingChange.setOp(op);
- assertEquals(op.getClass(), op.getClass());
-
- }
-
}
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/UpdateComparatorTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/UpdateComparatorTest.java
index a287160..670d581 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/UpdateComparatorTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/UpdateComparatorTest.java
@@ -45,6 +45,7 @@
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DN;
import org.opends.server.util.TimeThread;
+import org.opends.server.workflowelement.localbackend.LocalBackendDeleteOperation;
@@ -68,11 +69,12 @@
// Create the update messgae
InternalClientConnection connection =
InternalClientConnection.getRootConnection();
- DeleteOperation op = null;
+ LocalBackendDeleteOperation op = null;
try
{
- op = new DeleteOperationBasis(connection, 1, 1,null,
- DN.decode("dc=com"));
+ DeleteOperation opBasis =
+ new DeleteOperationBasis(connection, 1, 1,null, DN.decode("dc=com"));
+ op = new LocalBackendDeleteOperation(opBasis);
}
catch (DirectoryException e)
{
--
Gitblit v1.10.0