fix for 1887 : Define new interfaces used by the synchronization provider so that LocalBackend operations are not exposed
These changes modify the SynchronizationProvider API so that the LocalBackendXXXOperation
are not exposed by this api anymore.
The solution is to use the PreOperationxxxOperation and PostOperationXXXOperation :
the PreOperation methods now use the PreOperationXXXOperation interface
the PostOperation methods now use the PostOperationXXXOperation interface
the handlConflict methods now use the PreOperationXXXOperation interface
| | |
| | | |
| | | 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.*; |
| | | |
| | | |
| | | |
| | |
| | | * @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. |
| | |
| | | * @throws DirectoryException If a problem occurs during |
| | | * synchronization processing. |
| | | */ |
| | | public abstract SynchronizationProviderResult |
| | | doPreOperation(LocalBackendAddOperation |
| | | addOperation) |
| | | public abstract SynchronizationProviderResult doPreOperation( |
| | | PreOperationAddOperation addOperation) |
| | | throws DirectoryException; |
| | | |
| | | |
| | |
| | | * @throws DirectoryException If a problem occurs during |
| | | * synchronization processing. |
| | | */ |
| | | public abstract void doPostOperation(LocalBackendAddOperation |
| | | addOperation) |
| | | public abstract void doPostOperation( |
| | | PostOperationAddOperation addOperation) |
| | | throws DirectoryException; |
| | | |
| | | |
| | |
| | | * synchronization processing. |
| | | */ |
| | | public SynchronizationProviderResult |
| | | handleConflictResolution(LocalBackendDeleteOperation |
| | | deleteOperation) |
| | | handleConflictResolution( |
| | | PreOperationDeleteOperation deleteOperation) |
| | | throws DirectoryException |
| | | { |
| | | // No processing is required by default. |
| | |
| | | * synchronization processing. |
| | | */ |
| | | public abstract SynchronizationProviderResult |
| | | doPreOperation(LocalBackendDeleteOperation |
| | | deleteOperation) |
| | | doPreOperation(PreOperationDeleteOperation deleteOperation) |
| | | throws DirectoryException; |
| | | |
| | | |
| | |
| | | * synchronization processing. |
| | | */ |
| | | public abstract void doPostOperation( |
| | | LocalBackendDeleteOperation |
| | | deleteOperation) |
| | | PostOperationDeleteOperation deleteOperation) |
| | | throws DirectoryException; |
| | | |
| | | |
| | |
| | | * synchronization processing. |
| | | */ |
| | | public SynchronizationProviderResult |
| | | handleConflictResolution(LocalBackendModifyOperation |
| | | modifyOperation) |
| | | handleConflictResolution( |
| | | PreOperationModifyOperation modifyOperation) |
| | | throws DirectoryException |
| | | { |
| | | // No processing is required by default. |
| | |
| | | * synchronization processing. |
| | | */ |
| | | public abstract SynchronizationProviderResult |
| | | doPreOperation(LocalBackendModifyOperation |
| | | modifyOperation) |
| | | doPreOperation(PreOperationModifyOperation modifyOperation) |
| | | throws DirectoryException; |
| | | |
| | | |
| | |
| | | * synchronization processing. |
| | | */ |
| | | public abstract void doPostOperation( |
| | | LocalBackendModifyOperation |
| | | modifyOperation) |
| | | PostOperationModifyOperation modifyOperation) |
| | | throws DirectoryException; |
| | | |
| | | |
| | |
| | | * @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. |
| | |
| | | * @throws DirectoryException If a problem occurs during |
| | | * synchronization processing. |
| | | */ |
| | | public abstract SynchronizationProviderResult |
| | | doPreOperation(ModifyDNOperation |
| | | modifyDNOperation) |
| | | public abstract SynchronizationProviderResult doPreOperation( |
| | | PreOperationModifyDNOperation modifyDNOperation) |
| | | throws DirectoryException; |
| | | |
| | | |
| | |
| | | * synchronization processing. |
| | | */ |
| | | public abstract void doPostOperation( |
| | | ModifyDNOperation modifyDNOperation) |
| | | PostOperationModifyDNOperation modifyDNOperation) |
| | | throws DirectoryException; |
| | | |
| | | /** |
| | |
| | | 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; |
| | |
| | | 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 |
| | |
| | | * @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; |
| | |
| | | * |
| | | * @param modifyOperation the modification. |
| | | */ |
| | | public void generateState(LocalBackendModifyOperation modifyOperation) |
| | | public void generateState(PreOperationModifyOperation modifyOperation) |
| | | { |
| | | List<Modification> mods = modifyOperation.getModifications(); |
| | | Entry modifiedEntry = modifyOperation.getModifiedEntry(); |
| | |
| | | * @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(); |
| | |
| | | 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; |
| | |
| | | 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.*; |
| | | |
| | |
| | | * 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; |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void doPostOperation(LocalBackendAddOperation addOperation) |
| | | public void doPostOperation(PostOperationAddOperation addOperation) |
| | | { |
| | | DN dn = addOperation.getEntryDN(); |
| | | genericPostOperation(addOperation, dn); |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void doPostOperation(LocalBackendDeleteOperation deleteOperation) |
| | | public void doPostOperation(PostOperationDeleteOperation deleteOperation) |
| | | { |
| | | DN dn = deleteOperation.getEntryDN(); |
| | | genericPostOperation(deleteOperation, dn); |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void doPostOperation(ModifyDNOperation modifyDNOperation) |
| | | public void doPostOperation(PostOperationModifyDNOperation modifyDNOperation) |
| | | { |
| | | DN dn = modifyDNOperation.getEntryDN(); |
| | | genericPostOperation(modifyDNOperation, dn); |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void doPostOperation(LocalBackendModifyOperation modifyOperation) |
| | | public void doPostOperation(PostOperationModifyOperation modifyOperation) |
| | | { |
| | | DN dn = modifyOperation.getEntryDN(); |
| | | genericPostOperation(modifyOperation, dn); |
| | |
| | | */ |
| | | @Override |
| | | public SynchronizationProviderResult handleConflictResolution( |
| | | LocalBackendModifyOperation modifyOperation) |
| | | PreOperationModifyOperation modifyOperation) |
| | | { |
| | | ReplicationDomain domain = |
| | | findDomain(modifyOperation.getEntryDN(), modifyOperation); |
| | |
| | | */ |
| | | @Override |
| | | public SynchronizationProviderResult handleConflictResolution( |
| | | LocalBackendAddOperation addOperation) throws DirectoryException |
| | | PreOperationAddOperation addOperation) throws DirectoryException |
| | | { |
| | | ReplicationDomain domain = |
| | | findDomain(addOperation.getEntryDN(), addOperation); |
| | |
| | | */ |
| | | @Override |
| | | public SynchronizationProviderResult handleConflictResolution( |
| | | LocalBackendDeleteOperation deleteOperation) throws DirectoryException |
| | | PreOperationDeleteOperation deleteOperation) throws DirectoryException |
| | | { |
| | | ReplicationDomain domain = |
| | | findDomain(deleteOperation.getEntryDN(), deleteOperation); |
| | |
| | | */ |
| | | @Override |
| | | public SynchronizationProviderResult handleConflictResolution( |
| | | ModifyDNOperation modifyDNOperation) throws DirectoryException |
| | | PreOperationModifyDNOperation modifyDNOperation) throws DirectoryException |
| | | { |
| | | ReplicationDomain domain = |
| | | findDomain(modifyDNOperation.getEntryDN(), modifyDNOperation); |
| | |
| | | */ |
| | | @Override |
| | | public SynchronizationProviderResult |
| | | doPreOperation(LocalBackendModifyOperation modifyOperation) |
| | | doPreOperation(PreOperationModifyOperation modifyOperation) |
| | | { |
| | | DN operationDN = modifyOperation.getEntryDN(); |
| | | ReplicationDomain domain = findDomain(operationDN, modifyOperation); |
| | |
| | | */ |
| | | @Override |
| | | public SynchronizationProviderResult doPreOperation( |
| | | LocalBackendDeleteOperation deleteOperation) throws DirectoryException |
| | | PreOperationDeleteOperation deleteOperation) throws DirectoryException |
| | | { |
| | | return new SynchronizationProviderResult(true); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public SynchronizationProviderResult doPreOperation( |
| | | ModifyDNOperation modifyDNOperation) throws DirectoryException |
| | | PreOperationModifyDNOperation modifyDNOperation) |
| | | throws DirectoryException |
| | | { |
| | | return new SynchronizationProviderResult(true); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public SynchronizationProviderResult doPreOperation( |
| | | LocalBackendAddOperation addOperation) |
| | | PreOperationAddOperation addOperation) |
| | | { |
| | | ReplicationDomain domain = |
| | | findDomain(addOperation.getEntryDN(), addOperation); |
| | |
| | | * @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) |
| | |
| | | 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 |
| | |
| | | private ChangeNumber changeNumber; |
| | | private boolean committed; |
| | | private UpdateMessage msg; |
| | | private Operation op; |
| | | private PluginOperation op; |
| | | private ServerState dependencyState = null; |
| | | private DN targetDN = null; |
| | | |
| | |
| | | * @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; |
| | |
| | | * Get the operation associated to the PendingChange. |
| | | * @return the operation |
| | | */ |
| | | public Operation getOp() |
| | | public PluginOperation getOp() |
| | | { |
| | | return this.op; |
| | | } |
| | |
| | | * 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; |
| | | } |
| | |
| | | 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 |
| | |
| | | * 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; |
| | | |
| | |
| | | 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.*; |
| | | |
| | | /** |
| | |
| | | * can continue. |
| | | */ |
| | | public SynchronizationProviderResult handleConflictResolution( |
| | | LocalBackendDeleteOperation deleteOperation) |
| | | PreOperationDeleteOperation deleteOperation) |
| | | { |
| | | if ((!deleteOperation.isSynchronizationOperation()) |
| | | && (!brokerIsConnected(deleteOperation))) |
| | |
| | | * can continue. |
| | | */ |
| | | public SynchronizationProviderResult handleConflictResolution( |
| | | AddOperation addOperation) |
| | | PreOperationAddOperation addOperation) |
| | | { |
| | | if ((!addOperation.isSynchronizationOperation()) |
| | | && (!brokerIsConnected(addOperation))) |
| | |
| | | * 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)) |
| | | { |
| | |
| | | * can continue. |
| | | */ |
| | | public SynchronizationProviderResult handleConflictResolution( |
| | | ModifyDNOperation modifyDNOperation) |
| | | PreOperationModifyDNOperation modifyDNOperation) |
| | | { |
| | | if ((!modifyDNOperation.isSynchronizationOperation()) |
| | | && (!brokerIsConnected(modifyDNOperation))) |
| | |
| | | * @return code indicating is operation must proceed |
| | | */ |
| | | public SynchronizationProviderResult handleConflictResolution( |
| | | LocalBackendModifyOperation modifyOperation) |
| | | PreOperationModifyOperation modifyOperation) |
| | | { |
| | | if ((!modifyOperation.isSynchronizationOperation()) |
| | | && (!brokerIsConnected(modifyOperation))) |
| | |
| | | * |
| | | * @param addOperation The Add Operation. |
| | | */ |
| | | public void doPreOperation(AddOperation addOperation) |
| | | public void doPreOperation(PreOperationAddOperation addOperation) |
| | | { |
| | | AddContext ctx = new AddContext(generateChangeNumber(addOperation), |
| | | Historical.getEntryUuid(addOperation), |
| | |
| | | * 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()) |
| | |
| | | * generated. |
| | | * @return The new change number. |
| | | */ |
| | | private ChangeNumber generateChangeNumber(Operation operation) |
| | | private ChangeNumber generateChangeNumber(PluginOperation operation) |
| | | { |
| | | return pendingChanges.putLocalOperation(operation); |
| | | } |
| | |
| | | * @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. |
| | |
| | | */ |
| | | 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"); |
| | |
| | | */ |
| | | 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; |
| | |
| | | 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; |
| | |
| | | * 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()); |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public AddOperation createOperation(InternalClientConnection connection, |
| | | String newDn) |
| | | public AbstractOperation createOperation( |
| | | InternalClientConnection connection, String newDn) |
| | | throws LDAPException, ASN1Exception |
| | | { |
| | | ArrayList<RawAttribute> attr = new ArrayList<RawAttribute>(); |
| | |
| | | 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. |
| | |
| | | /** |
| | | * 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()); |
| | | } |
| | | |
| | | /** |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Operation createOperation(InternalClientConnection connection, |
| | | String newDn) |
| | | public AbstractOperation createOperation( |
| | | InternalClientConnection connection, String newDn) |
| | | { |
| | | DeleteOperationBasis del = new DeleteOperationBasis(connection, |
| | | InternalClientConnection.nextOperationID(), |
| | |
| | | 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. |
| | |
| | | /** |
| | | * 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(); |
| | | } |
| | | |
| | | /** |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Operation createOperation(InternalClientConnection connection, |
| | | String newDn) |
| | | public AbstractOperation createOperation( |
| | | InternalClientConnection connection, String newDn) |
| | | { |
| | | ModifyDNOperation moddn = new ModifyDNOperation(connection, |
| | | InternalClientConnection.nextOperationID(), |
| | |
| | | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | * |
| | | * @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()); |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Operation createOperation(InternalClientConnection connection, |
| | | public AbstractOperation createOperation(InternalClientConnection connection, |
| | | String newDn) |
| | | throws LDAPException, ASN1Exception, DataFormatException |
| | | { |
| | |
| | | |
| | | 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 |
| | |
| | | * 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. |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 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 |
| | |
| | | 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 |
| | |
| | | * @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; |
| | |
| | | * @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); |
| | |
| | | * @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; |
| | | |
| | | /** |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | |
| | | initialize(replicationServerId, replicationPort); |
| | | configuration.addChangeListener(this); |
| | | configDn = configuration.dn(); |
| | | DirectoryServer.registerMonitorProvider(this); |
| | | } |
| | | |
| | |
| | | |
| | | 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; |
| | |
| | | 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, |
| | |
| | | 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 |
| | |
| | | * |
| | | */ |
| | | private void testHistorical( |
| | | Historical hist, AddOperation addOp) |
| | | Historical hist, LocalBackendAddOperation addOp) |
| | | { |
| | | |
| | | // Get the historical uuid associated to the entry |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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; |
| | | |
| | |
| | | * TODO : test that the generated mod equals the original mod. |
| | | */ |
| | | |
| | | // Check pending change |
| | | testPendingChange(changeNumber,op,msg); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | 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")); |
| | |
| | | // 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(); |
| | | |
| | |
| | | //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); |
| | |
| | | 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()); |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | 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; |
| | | |
| | | |
| | | |
| | |
| | | // 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) |
| | | { |