OPENDJ-1116 Introduce abstraction for the changelog DB
String baseDn => DN baseDN
The change mostly affects package org.opends.server.replication.protocol and dependent classes.
ModifyCommonMsg.java:
In getMods(), called decodeMods()
ReplicationTestCase.java:
Converted removeDomain(Entry) to removeDomain(Entry...).
| | |
| | | @Override |
| | | public AddMsg generateMessage() |
| | | { |
| | | return new AddMsg(getCSN(), entry.getDN().toString(), |
| | | return new AddMsg(getCSN(), entry.getDN(), |
| | | EntryHistorical.getEntryUUID(entry), |
| | | LDAPReplicationDomain.findEntryUUID( |
| | | entry.getDN().getParentDNInSuffix()), |
| | |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.replication.protocol.DeleteMsg; |
| | | import org.opends.server.replication.protocol.ReplicationMsg; |
| | | import org.opends.server.types.DN; |
| | | |
| | | /** |
| | | * This class if used to build pseudo DEL Operation from the historical |
| | |
| | | */ |
| | | public class FakeDelOperation extends FakeOperation |
| | | { |
| | | private final String dn; |
| | | private final DN dn; |
| | | private final String entryUUID; |
| | | |
| | | /** |
| | |
| | | * @param csn The CSN of the operation. |
| | | * @param entryUUID The Unique ID of the deleted entry. |
| | | */ |
| | | public FakeDelOperation(String dn, CSN csn, String entryUUID) |
| | | public FakeDelOperation(DN dn, CSN csn, String entryUUID) |
| | | { |
| | | super(csn); |
| | | this.dn = dn; |
| | |
| | | public ReplicationMsg generateMessage() |
| | | { |
| | | DN dn = entry.getDN(); |
| | | return new ModifyDNMsg(dn.toString(), getCSN(), |
| | | return new ModifyDNMsg(dn, getCSN(), |
| | | EntryHistorical.getEntryUUID(entry), |
| | | LDAPReplicationDomain.findEntryUUID(dn.getParent()), |
| | | false, dn.getParent().toString(), dn.getRDN().toString()); |
| | |
| | | { |
| | | replayOperations.remove(replayOperations.firstKey()); |
| | | } |
| | | replayOperations.put( |
| | | csn, |
| | | new FakeDelOperation( |
| | | deleteOperation.getEntryDN().toString(), |
| | | csn, modifiedEntryUUID)); |
| | | FakeOperation op = new FakeDelOperation( |
| | | deleteOperation.getEntryDN(), csn, modifiedEntryUUID); |
| | | replayOperations.put(csn, op); |
| | | } |
| | | |
| | | } |
| | |
| | | { |
| | | // There is an entry with the same unique id as this modify operation |
| | | // replay the modify using the current dn of this entry. |
| | | msg.setDn(newDN.toString()); |
| | | msg.setDN(newDN); |
| | | numResolvedNamingConflicts.incrementAndGet(); |
| | | return false; |
| | | } |
| | |
| | | /* |
| | | * Find if the entry is still in the database. |
| | | */ |
| | | DN currentDn = findEntryDN(entryUUID); |
| | | if (currentDn == null) |
| | | DN currentDN = findEntryDN(entryUUID); |
| | | if (currentDN == null) |
| | | { |
| | | /* |
| | | * The entry has already been deleted, either because this delete |
| | |
| | | } |
| | | else |
| | | { |
| | | /* |
| | | * This entry has been renamed, replay the delete using its new DN. |
| | | */ |
| | | msg.setDn(currentDn.toString()); |
| | | // This entry has been renamed, replay the delete using its new DN. |
| | | msg.setDN(currentDN); |
| | | numResolvedNamingConflicts.incrementAndGet(); |
| | | return false; |
| | | } |
| | |
| | | * The action taken here must be consistent with the actions |
| | | * done in the solveNamingConflict(AddOperation) method |
| | | * when we are adding an entry whose parent entry has already been deleted. |
| | | * |
| | | */ |
| | | if (findAndRenameChild(op.getEntryDN(), op)) |
| | | { |
| | |
| | | * reconstruct the operation with the DN we just built |
| | | */ |
| | | ModifyDNMsg modifyDnMsg = (ModifyDNMsg) msg; |
| | | msg.setDn(currentDN.toString()); |
| | | modifyDnMsg.setDN(currentDN); |
| | | modifyDnMsg.setNewSuperior(newSuperior.toString()); |
| | | numResolvedNamingConflicts.incrementAndGet(); |
| | | return false; |
| | |
| | | */ |
| | | addConflict(msg); |
| | | |
| | | msg.setDn(generateConflictRDN(entryUUID, |
| | | op.getEntryDN().getRDN().toString()) + "," + getBaseDNString()); |
| | | String conflictRDN = |
| | | generateConflictRDN(entryUUID, op.getEntryDN().getRDN().toString()); |
| | | msg.setDN(DN.decode(conflictRDN + "," + getBaseDNString())); |
| | | // reset the parent entryUUID so that the check done is the |
| | | // handleConflict phase does not fail. |
| | | msg.setParentEntryUUID(null); |
| | |
| | | } |
| | | else |
| | | { |
| | | RDN entryRdn = DN.decode(msg.getDn()).getRDN(); |
| | | msg.setDn(entryRdn + "," + parentDn); |
| | | msg.setDN(DN.decode(msg.getDN().getRDN() + "," + parentDn)); |
| | | numResolvedNamingConflicts.incrementAndGet(); |
| | | } |
| | | return false; |
| | |
| | | else |
| | | { |
| | | addConflict(msg); |
| | | msg.setDn(generateConflictRDN(entryUUID, msg.getDn())); |
| | | String conflictRDN = |
| | | generateConflictRDN(entryUUID, msg.getDN().toNormalizedString()); |
| | | msg.setDN(DN.decode(conflictRDN)); |
| | | numUnresolvedNamingConflicts.incrementAndGet(); |
| | | return false; |
| | | } |
| | |
| | | |
| | | /** |
| | | * Find all the entries below the provided DN and rename them |
| | | * so that they stay below the baseDn of this replicationDomain and |
| | | * so that they stay below the baseDN of this replicationDomain and |
| | | * use the conflicting name and attribute. |
| | | * |
| | | * @param entryDN The DN of the entry whose child must be renamed. |
| | |
| | | |
| | | /** |
| | | * Rename an entry that was conflicting so that it stays below the |
| | | * baseDn of the replicationDomain. |
| | | * baseDN of the replicationDomain. |
| | | * |
| | | * @param conflictOp The Operation that caused the conflict. |
| | | * @param dn The DN of the entry to be renamed. |
| | |
| | | */ |
| | | private void addConflict(AddMsg msg) throws ASN1Exception |
| | | { |
| | | String normalizedDN; |
| | | try |
| | | { |
| | | normalizedDN = DN.decode(msg.getDn()).toNormalizedString(); |
| | | } catch (DirectoryException e) |
| | | { |
| | | normalizedDN = msg.getDn(); |
| | | } |
| | | String normalizedDN = msg.getDN().toNormalizedString(); |
| | | |
| | | // Generate an alert to let the administrator know that some |
| | | // conflict could not be solved. |
| | |
| | | os = output; |
| | | } |
| | | |
| | | // baseDn branch is the only one included in the export |
| | | // baseDN branch is the only one included in the export |
| | | List<DN> includeBranches = new ArrayList<DN>(1); |
| | | includeBranches.add(getBaseDN()); |
| | | LDIFExportConfig exportConfig = new LDIFExportConfig(os); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Retrieves a replication domain based on the baseDn. |
| | | * Retrieves a replication domain based on the baseDN. |
| | | * |
| | | * @param baseDn The baseDn of the domain to retrieve |
| | | * @param baseDN The baseDN of the domain to retrieve |
| | | * @return The domain retrieved |
| | | * @throws DirectoryException When an error occurred or no domain |
| | | * match the provided baseDn. |
| | | * match the provided baseDN. |
| | | */ |
| | | public static LDAPReplicationDomain retrievesReplicationDomain(DN baseDn) |
| | | throws DirectoryException |
| | | public static LDAPReplicationDomain retrievesReplicationDomain(DN baseDN) |
| | | throws DirectoryException |
| | | { |
| | | LDAPReplicationDomain replicationDomain = null; |
| | | |
| | |
| | | |
| | | // From the domainDN retrieves the replication domain |
| | | LDAPReplicationDomain domain = |
| | | MultimasterReplication.findDomain(baseDn, null); |
| | | MultimasterReplication.findDomain(baseDN, null); |
| | | if (domain == null) |
| | | { |
| | | break; |
| | |
| | | if (replicationDomain == null) |
| | | { |
| | | throw new DirectoryException(ResultCode.OTHER, |
| | | ERR_NO_MATCHING_DOMAIN.get(String.valueOf(baseDn))); |
| | | ERR_NO_MATCHING_DOMAIN.get(String.valueOf(baseDN))); |
| | | } |
| | | return replicationDomain; |
| | | } |
| | |
| | | * attribute. The only changes that will be send will be the one generated on |
| | | * the serverId provided in fromCSN. |
| | | * |
| | | * @param baseDn |
| | | * @param baseDN |
| | | * the base DN |
| | | * @param fromCSN |
| | | * The CSN from which we want the changes |
| | |
| | | * @throws Exception |
| | | * when raised. |
| | | */ |
| | | private static InternalSearchOperation searchForChangedEntries(DN baseDn, |
| | | private static InternalSearchOperation searchForChangedEntries(DN baseDN, |
| | | CSN fromCSN, CSN lastCSN, InternalSearchListener resultListener) |
| | | throws Exception |
| | | { |
| | |
| | | "(" + HISTORICAL_ATTRIBUTE_NAME + "<=dummy:" + maxValueForId + "))"); |
| | | |
| | | return conn.processSearch( |
| | | ByteString.valueOf(baseDn.toString()), |
| | | ByteString.valueOf(baseDN.toString()), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | 0, 0, false, filter, |
| | |
| | | * attribute. The only changes that will be send will be the one generated on |
| | | * the serverId provided in fromCSN. |
| | | * |
| | | * @param baseDn |
| | | * @param baseDN |
| | | * the base DN |
| | | * @param fromCSN |
| | | * The CSN from which we want the changes |
| | |
| | | * @throws Exception |
| | | * when raised. |
| | | */ |
| | | public static InternalSearchOperation searchForChangedEntries(DN baseDn, |
| | | public static InternalSearchOperation searchForChangedEntries(DN baseDN, |
| | | CSN fromCSN, InternalSearchListener resultListener) throws Exception |
| | | { |
| | | return searchForChangedEntries(baseDn, fromCSN, null, resultListener); |
| | | return searchForChangedEntries(baseDN, fromCSN, null, resultListener); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * Base DN the fractional configuration is for. |
| | | */ |
| | | private DN baseDn; |
| | | private DN baseDN; |
| | | |
| | | /** |
| | | * Constructs a new fractional configuration object. |
| | | * @param baseDn The base dn the object is for. |
| | | * @param baseDN The base DN the object is for. |
| | | */ |
| | | FractionalConfig(DN baseDn) |
| | | FractionalConfig(DN baseDN) |
| | | { |
| | | this.baseDn = baseDn; |
| | | this.baseDN = baseDN; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * Getter for the base baseDn. |
| | | * @return The baseDn attribute. |
| | | * Getter for the base baseDN. |
| | | * @return The baseDN attribute. |
| | | */ |
| | | DN getBaseDn() |
| | | { |
| | | return baseDn; |
| | | return baseDN; |
| | | } |
| | | |
| | | /** |
| | |
| | | import org.opends.server.replication.common.ServerState; |
| | | import org.opends.server.replication.protocol.LDAPUpdateMsg; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.operation.PluginOperation; |
| | | |
| | | /** |
| | |
| | | { |
| | | synchronized (this) |
| | | { |
| | | if (targetDN != null) |
| | | if (targetDN == null) |
| | | { |
| | | return targetDN; |
| | | } |
| | | try |
| | | { |
| | | targetDN = DN.decode(msg.getDn()); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | targetDN = msg.getDN(); |
| | | } |
| | | return targetDN; |
| | | } |
| | |
| | | package org.opends.server.replication.protocol; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.zip.DataFormatException; |
| | | |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.AddOperationBasis; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.asn1.ASN1; |
| | |
| | | */ |
| | | public AddMsg(PostOperationAddOperation op) |
| | | { |
| | | super((AddContext) op.getAttachment(SYNCHROCONTEXT), |
| | | op.getRawEntryDN().toString()); |
| | | super((AddContext) op.getAttachment(SYNCHROCONTEXT), op.getEntryDN()); |
| | | |
| | | AddContext ctx = (AddContext) op.getAttachment(SYNCHROCONTEXT); |
| | | |
| | |
| | | * @param operationalAttributes operational attributes of the added entry. |
| | | */ |
| | | public AddMsg(CSN csn, |
| | | String dn, |
| | | DN dn, |
| | | String entryUUID, |
| | | String parentEntryUUID, |
| | | Map<ObjectClass, String> objectClasses, |
| | |
| | | * @param operationalAttributes operational attributes of the added entry. |
| | | */ |
| | | public AddMsg(CSN csn, |
| | | String dn, |
| | | DN dn, |
| | | String uniqueId, |
| | | String parentId, |
| | | Attribute objectClass, |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public AddOperationBasis createOperation( |
| | | InternalClientConnection connection, String newDn) |
| | | public AddOperation createOperation( |
| | | InternalClientConnection connection, DN newDN) |
| | | throws LDAPException, ASN1Exception |
| | | { |
| | | ArrayList<RawAttribute> attr = decodeRawAttributes(encodedAttributes); |
| | | List<RawAttribute> attr = decodeRawAttributes(encodedAttributes); |
| | | |
| | | AddOperationBasis add = new AddOperationBasis(connection, |
| | | AddOperation add = new AddOperationBasis(connection, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), null, |
| | | ByteString.valueOf(newDn), attr); |
| | | ByteString.valueOf(newDN.toString()), attr); |
| | | AddContext ctx = new AddContext(getCSN(), getEntryUUID(), |
| | | parentEntryUUID); |
| | | add.setAttachment(SYNCHROCONTEXT, ctx); |
| | |
| | | @Override |
| | | public int size() |
| | | { |
| | | return encodedAttributes.length + + encodedEclIncludes.length |
| | | + headerSize(); |
| | | return encodedAttributes.length + encodedEclIncludes.length + headerSize(); |
| | | } |
| | | |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | |
| | | import static org.opends.server.replication.protocol.OperationContext.*; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.zip.DataFormatException; |
| | | |
| | | import org.opends.server.controls.SubtreeDeleteControl; |
| | | import org.opends.server.core.DeleteOperation; |
| | | import org.opends.server.core.DeleteOperationBasis; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.types.ByteString; |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.operation.PostOperationDeleteOperation; |
| | | |
| | | import static org.opends.server.replication.protocol.OperationContext.*; |
| | | |
| | | /** |
| | | * Object used when sending delete information to replication servers. |
| | | */ |
| | |
| | | public DeleteMsg(PostOperationDeleteOperation operation) |
| | | { |
| | | super((OperationContext) operation.getAttachment(SYNCHROCONTEXT), |
| | | operation.getRawEntryDN().toString()); |
| | | operation.getEntryDN()); |
| | | try |
| | | { |
| | | if (operation.getRequestControl(SubtreeDeleteControl.DECODER) != null) |
| | |
| | | * @param csn The CSN with which the message must be created. |
| | | * @param entryUUID The unique id with which the message must be created. |
| | | */ |
| | | public DeleteMsg(String dn, CSN csn, String entryUUID) |
| | | public DeleteMsg(DN dn, CSN csn, String entryUUID) |
| | | { |
| | | super(new DeleteContext(csn, entryUUID), dn); |
| | | } |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Operation createOperation(InternalClientConnection connection, |
| | | String newDn) |
| | | public DeleteOperation createOperation(InternalClientConnection connection, |
| | | DN newDN) |
| | | { |
| | | DeleteOperationBasis del = new DeleteOperationBasis(connection, |
| | | DeleteOperation del = new DeleteOperationBasis(connection, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), null, |
| | | ByteString.valueOf(newDn)); |
| | | InternalClientConnection.nextMessageID(), null, newDN); |
| | | |
| | | if (isSubtreeDelete) |
| | | del.addRequestControl(new SubtreeDeleteControl(false)); |
| | |
| | | import java.util.zip.DataFormatException; |
| | | |
| | | import org.opends.server.replication.common.MultiDomainServerState; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | /** |
| | |
| | | private final LDAPUpdateMsg updateMsg; |
| | | |
| | | /** The baseDN of the domain to which applies the change. */ |
| | | private final String baseDN; |
| | | private final DN baseDN; |
| | | |
| | | /** The value of the cookie updated with the current change. */ |
| | | private MultiDomainServerState cookie; |
| | |
| | | * @param changeNumber The provided change number. |
| | | */ |
| | | public ECLUpdateMsg(LDAPUpdateMsg updateMsg, MultiDomainServerState cookie, |
| | | String baseDN, long changeNumber) |
| | | DN baseDN, long changeNumber) |
| | | { |
| | | this.cookie = cookie; |
| | | this.baseDN = baseDN; |
| | |
| | | |
| | | // Decode the baseDN |
| | | length = getNextLength(in, pos); |
| | | this.baseDN = new String(in, pos, length, "UTF-8"); |
| | | this.baseDN = DN.decode(new String(in, pos, length, "UTF-8")); |
| | | pos += length + 1; |
| | | |
| | | // Decode the changeNumber |
| | |
| | | * |
| | | * @return The baseDN. |
| | | */ |
| | | public String getBaseDN() |
| | | public DN getBaseDN() |
| | | { |
| | | return baseDN; |
| | | } |
| | |
| | | */ |
| | | public class InitializeRequestMsg extends RoutableMsg |
| | | { |
| | | private String baseDn = null; |
| | | private DN baseDN; |
| | | private int initWindow = 0; |
| | | |
| | | /** |
| | | * Creates a InitializeRequestMsg message. |
| | | * |
| | | * @param baseDn the base DN of the replication domain. |
| | | * @param baseDN the base DN of the replication domain. |
| | | * @param destination destination of this message |
| | | * @param serverID serverID of the server that will send this message |
| | | * @param initWindow initialization window for flow control |
| | | */ |
| | | public InitializeRequestMsg(String baseDn, int serverID, int destination, |
| | | public InitializeRequestMsg(DN baseDN, int serverID, int destination, |
| | | int initWindow) |
| | | { |
| | | super(serverID, destination); |
| | | this.baseDn = baseDn; |
| | | this.baseDN = baseDN; |
| | | this.initWindow = initWindow; // V4 |
| | | } |
| | | |
| | |
| | | "input is not a valid InitializeRequestMessage"); |
| | | int pos = 1; |
| | | |
| | | // baseDn |
| | | // baseDN |
| | | int length = getNextLength(in, pos); |
| | | baseDn = new String(in, pos, length, "UTF-8"); |
| | | baseDN = DN.decode(new String(in, pos, length, "UTF-8")); |
| | | pos += length +1; |
| | | |
| | | // sender |
| | |
| | | initWindow = Integer.valueOf(initWindowString); |
| | | pos += length +1; |
| | | } |
| | | } catch (UnsupportedEncodingException e) |
| | | } |
| | | catch (UnsupportedEncodingException e) |
| | | { |
| | | throw new DataFormatException("UTF-8 is not supported by this jvm."); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | throw new DataFormatException(e.getLocalizedMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return the base DN from this InitializeRequestMsg. |
| | | */ |
| | | public DN getBaseDn() |
| | | public DN getBaseDN() |
| | | { |
| | | if (baseDn == null) |
| | | return null; |
| | | try |
| | | { |
| | | return DN.decode(baseDn); |
| | | } catch (DirectoryException e) |
| | | { |
| | | return null; |
| | | } |
| | | return baseDN; |
| | | } |
| | | |
| | | // ============ |
| | |
| | | public byte[] getBytes(short version) |
| | | { |
| | | try { |
| | | byte[] baseDNBytes = baseDn.getBytes("UTF-8"); |
| | | byte[] baseDNBytes = baseDN.toString().getBytes("UTF-8"); |
| | | byte[] senderBytes = String.valueOf(senderID).getBytes("UTF-8"); |
| | | byte[] destinationBytes = String.valueOf(destination).getBytes("UTF-8"); |
| | | byte[] initWindowBytes = null; |
| | |
| | | * Get a string representation of this object. |
| | | * @return A string representation of this object. |
| | | */ |
| | | @Override |
| | | public String toString() |
| | | { |
| | | return "InitializeRequestMessage: baseDn="+baseDn+" senderId="+senderID + |
| | | " destination=" + destination + " initWindow=" + initWindow; |
| | | return "InitializeRequestMessage: baseDN=" + baseDN + " senderId=" |
| | | + senderID + " destination=" + destination + " initWindow=" + initWindow; |
| | | } |
| | | |
| | | /** |
| | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.zip.DataFormatException; |
| | | |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | /** |
| | | * This message is part of the replication protocol. |
| | | * This message is sent by a server to one or several servers as the |
| | |
| | | */ |
| | | public class InitializeTargetMsg extends RoutableMsg |
| | | { |
| | | private String baseDN = null; |
| | | private DN baseDN; |
| | | |
| | | // Specifies the number of entries expected to be exported. |
| | | /** Specifies the number of entries expected to be exported. */ |
| | | private long entryCount; |
| | | |
| | | // Specifies the serverID of the server that requested this export |
| | | // to happen. It allows a server that previously sent an |
| | | // InitializeRequestMessage to know that the current message |
| | | // is related to its own request. |
| | | /** |
| | | * Specifies the serverID of the server that requested this export to happen. |
| | | * It allows a server that previously sent an InitializeRequestMessage to know |
| | | * that the current message is related to its own request. |
| | | */ |
| | | private int requestorID; |
| | | |
| | | private int initWindow; |
| | |
| | | * |
| | | * @param baseDN The base DN for which the InitializeMessage is created. |
| | | * @param serverID The serverID of the server that sends this message. |
| | | * @param target The destination of this message. |
| | | * @param target2 The server that initiates this export. |
| | | * @param destination The destination of this message. |
| | | * @param requestorID The server that initiates this export. |
| | | * @param entryCount The count of entries that will be sent. |
| | | * @param initWindow the initialization window. |
| | | */ |
| | | public InitializeTargetMsg(String baseDN, int serverID, |
| | | int target, int target2, long entryCount, int initWindow) |
| | | public InitializeTargetMsg(DN baseDN, int serverID, |
| | | int destination, int requestorID, long entryCount, int initWindow) |
| | | { |
| | | super(serverID, target); |
| | | this.requestorID = target2; |
| | | super(serverID, destination); |
| | | this.requestorID = requestorID; |
| | | this.baseDN = baseDN; |
| | | this.entryCount = entryCount; |
| | | this.initWindow = initWindow; // V4 |
| | |
| | | this.destination = Integer.valueOf(destinationString); |
| | | pos += length +1; |
| | | |
| | | // baseDn |
| | | // baseDN |
| | | length = getNextLength(in, pos); |
| | | baseDN = new String(in, pos, length, "UTF-8"); |
| | | baseDN = DN.decode(new String(in, pos, length, "UTF-8")); |
| | | pos += length +1; |
| | | |
| | | // sender |
| | |
| | | { |
| | | throw new DataFormatException("UTF-8 is not supported by this jvm."); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | throw new DataFormatException(e.getLocalizedMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return the base DN |
| | | */ |
| | | public String getBaseDN() |
| | | public DN getBaseDN() |
| | | { |
| | | return this.baseDN; |
| | | } |
| | |
| | | try |
| | | { |
| | | byte[] byteDestination = String.valueOf(destination).getBytes("UTF-8"); |
| | | byte[] byteDn = baseDN.getBytes("UTF-8"); |
| | | byte[] byteDn = baseDN.toString().getBytes("UTF-8"); |
| | | byte[] byteSender = String.valueOf(senderID).getBytes("UTF-8"); |
| | | byte[] byteRequestor = String.valueOf(requestorID).getBytes("UTF-8"); |
| | | byte[] byteEntryCount = String.valueOf(entryCount).getBytes("UTF-8"); |
| | |
| | | /** |
| | | * The DN on which the update was originally done. |
| | | */ |
| | | protected String dn; |
| | | protected DN dn; |
| | | |
| | | /** |
| | | * The entryUUID of the entry that was updated. |
| | |
| | | * @param dn The DN of the entry on which the change |
| | | * that caused the creation of this object happened |
| | | */ |
| | | public LDAPUpdateMsg(OperationContext ctx, String dn) |
| | | public LDAPUpdateMsg(OperationContext ctx, DN dn) |
| | | { |
| | | this.protocolVersion = ProtocolVersion.getCurrentVersion(); |
| | | this.csn = ctx.getCSN(); |
| | |
| | | * @param dn The DN of the entry on which the change |
| | | * that caused the creation of this object happened |
| | | */ |
| | | public LDAPUpdateMsg(CSN csn, String entryUUID, String dn) |
| | | public LDAPUpdateMsg(CSN csn, String entryUUID, DN dn) |
| | | { |
| | | this.protocolVersion = ProtocolVersion.getCurrentVersion(); |
| | | this.csn = csn; |
| | |
| | | * |
| | | * @return The DN on which the operations happened. |
| | | */ |
| | | public String getDn() |
| | | public DN getDN() |
| | | { |
| | | return dn; |
| | | } |
| | |
| | | * Set the DN. |
| | | * @param dn The dn that must now be used for this message. |
| | | */ |
| | | public void setDn(String dn) |
| | | public void setDN(DN dn) |
| | | { |
| | | this.dn = dn; |
| | | } |
| | |
| | | * Create and Operation from the message using the provided DN. |
| | | * |
| | | * @param conn connection to use when creating the message. |
| | | * @param newDn the DN to use when creating the operation. |
| | | * @param newDN the DN to use when creating the operation. |
| | | * @return the created Operation. |
| | | * @throws LDAPException In case of LDAP decoding exception. |
| | | * @throws ASN1Exception In case of ASN1 decoding exception. |
| | | * @throws DataFormatException In case of bad msg format. |
| | | */ |
| | | public abstract Operation createOperation(InternalClientConnection conn, |
| | | String newDn) throws LDAPException, ASN1Exception, DataFormatException; |
| | | DN newDN) throws LDAPException, ASN1Exception, DataFormatException; |
| | | |
| | | |
| | | // ============ |
| | |
| | | public byte[] encodeHeader(byte type, int additionalLength, short version) |
| | | throws UnsupportedEncodingException |
| | | { |
| | | byte[] byteDn = dn.getBytes("UTF-8"); |
| | | byte[] byteDn = dn.toString().getBytes("UTF-8"); |
| | | byte[] csnByte = getCSN().toString().getBytes("UTF-8"); |
| | | byte[] byteEntryuuid = getEntryUUID().getBytes("UTF-8"); |
| | | |
| | |
| | | public byte[] encodeHeader_V1(byte type, int additionalLength) |
| | | throws UnsupportedEncodingException |
| | | { |
| | | byte[] byteDn = dn.getBytes("UTF-8"); |
| | | byte[] byteDn = dn.toString().getBytes("UTF-8"); |
| | | byte[] csnByte = getCSN().toString().getBytes("UTF-8"); |
| | | byte[] byteEntryuuid = getEntryUUID().getBytes("UTF-8"); |
| | | |
| | |
| | | |
| | | // Read the dn |
| | | length = getNextLength(encodedMsg, pos); |
| | | dn = new String(encodedMsg, pos, length, "UTF-8"); |
| | | dn = DN.decode(new String(encodedMsg, pos, length, "UTF-8")); |
| | | pos += length + 1; |
| | | |
| | | // Read the entryuuid |
| | |
| | | safeDataLevel = encodedMsg[pos++]; |
| | | |
| | | return pos; |
| | | } catch (UnsupportedEncodingException e) |
| | | } |
| | | catch (UnsupportedEncodingException e) |
| | | { |
| | | throw new DataFormatException("UTF-8 is not supported by this jvm."); |
| | | } catch (IllegalArgumentException e) |
| | | } |
| | | catch (IllegalArgumentException e) |
| | | { |
| | | throw new DataFormatException(e.getMessage()); |
| | | throw new DataFormatException(e.getLocalizedMessage()); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | throw new DataFormatException(e.getLocalizedMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | // read the dn |
| | | length = getNextLength(encodedMsg, pos); |
| | | dn = new String(encodedMsg, pos, length, "UTF-8"); |
| | | dn = DN.decode(new String(encodedMsg, pos, length, "UTF-8")); |
| | | pos += length + 1; |
| | | |
| | | // read the entryuuid |
| | |
| | | pos += length + 1; |
| | | |
| | | return pos; |
| | | } catch (UnsupportedEncodingException e) |
| | | } |
| | | catch (UnsupportedEncodingException e) |
| | | { |
| | | throw new DataFormatException("UTF-8 is not supported by this jvm."); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | throw new DataFormatException(e.getLocalizedMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param dn The DN of the entry on which the change |
| | | * that caused the creation of this object happened |
| | | */ |
| | | public ModifyCommonMsg(OperationContext ctx, String dn) |
| | | public ModifyCommonMsg(OperationContext ctx, DN dn) |
| | | { |
| | | super(ctx, dn); |
| | | } |
| | |
| | | * @param dn The DN of the entry on which the change |
| | | * that caused the creation of this object happened |
| | | */ |
| | | public ModifyCommonMsg(CSN csn, String entryUUID, String dn) |
| | | public ModifyCommonMsg(CSN csn, String entryUUID, DN dn) |
| | | { |
| | | super(csn, entryUUID, dn); |
| | | } |
| | |
| | | */ |
| | | public List<Modification> getMods() throws ASN1Exception, LDAPException |
| | | { |
| | | List<Modification> mods = new ArrayList<Modification>(); |
| | | |
| | | ASN1Reader reader = ASN1.getReader(encodedMods); |
| | | |
| | | while (reader.hasNextElement()) |
| | | mods.add((LDAPModification.decode(reader)).toModification()); |
| | | |
| | | return mods; |
| | | return decodeMods(encodedMods); |
| | | } |
| | | |
| | | // ============ |
| | |
| | | * @throws LDAPException when occurs. |
| | | * @return The decoded mods. |
| | | */ |
| | | protected List<Modification> decodeMods(byte[] in) |
| | | throws ASN1Exception, LDAPException |
| | | protected List<Modification> decodeMods(byte[] in) throws ASN1Exception, |
| | | LDAPException |
| | | { |
| | | List<Modification> mods = new ArrayList<Modification>(); |
| | | ASN1Reader reader = ASN1.getReader(in); |
| | |
| | | * @throws ASN1Exception when occurs. |
| | | * @throws LDAPException when occurs. |
| | | */ |
| | | protected ArrayList<RawModification> decodeRawMods(byte[] in) |
| | | throws LDAPException, ASN1Exception |
| | | protected List<RawModification> decodeRawMods(byte[] in) |
| | | throws LDAPException, ASN1Exception |
| | | { |
| | | ArrayList<RawModification> ldapmods = new ArrayList<RawModification>(); |
| | | List<RawModification> ldapmods = new ArrayList<RawModification>(); |
| | | ASN1Reader asn1Reader = ASN1.getReader(in); |
| | | while(asn1Reader.hasNextElement()) |
| | | { |
| | |
| | | import java.util.List; |
| | | import java.util.zip.DataFormatException; |
| | | |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.core.ModifyDNOperationBasis; |
| | | import org.opends.server.protocols.asn1.ASN1Exception; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | |
| | | public ModifyDNMsg(PostOperationModifyDNOperation operation) |
| | | { |
| | | super((OperationContext) operation.getAttachment(SYNCHROCONTEXT), |
| | | operation.getRawEntryDN().toString()); |
| | | operation.getEntryDN()); |
| | | |
| | | encodedMods = encodeMods(operation.getModifications()); |
| | | |
| | |
| | | * @param newSuperior The new Superior entry to use for building the message. |
| | | * @param newRDN The new Rdn to use for building the message. |
| | | */ |
| | | public ModifyDNMsg(String dn, CSN csn, String entryUUID, |
| | | public ModifyDNMsg(DN dn, CSN csn, String entryUUID, |
| | | String newSuperiorEntryUUID, boolean deleteOldRdn, |
| | | String newSuperior, String newRDN) |
| | | { |
| | |
| | | * @param newRDN The new Rdn to use for building the message. |
| | | * @param mods The mod of the operation. |
| | | */ |
| | | public ModifyDNMsg(String dn, CSN csn, String entryUUID, |
| | | public ModifyDNMsg(DN dn, CSN csn, String entryUUID, |
| | | String newSuperiorEntryUUID, boolean deleteOldRdn, String newSuperior, |
| | | String newRDN, List<Modification> mods) |
| | | { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Operation createOperation(InternalClientConnection connection, |
| | | String newDn) throws LDAPException, ASN1Exception |
| | | public ModifyDNOperation createOperation(InternalClientConnection connection, |
| | | DN newDN) throws LDAPException, ASN1Exception |
| | | { |
| | | ModifyDNOperationBasis moddn = new ModifyDNOperationBasis(connection, |
| | | ModifyDNOperation moddn = new ModifyDNOperationBasis(connection, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), null, |
| | | ByteString.valueOf(newDn), ByteString.valueOf(newRDN), |
| | | ByteString.valueOf(newDN.toString()), |
| | | ByteString.valueOf(newRDN), |
| | | deleteOldRdn, |
| | | (newSuperior == null ? null : ByteString.valueOf(newSuperior))); |
| | | |
| | |
| | | { |
| | | if (newSuperior == null) |
| | | { |
| | | DN parentDn = DN.decode(this.getDn()).getParent(); |
| | | DN parentDn = getDN().getParent(); |
| | | return parentDn.concat(RDN.decode(newRDN)); |
| | | } |
| | | else |
| | |
| | | package org.opends.server.replication.protocol; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.zip.DataFormatException; |
| | | |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.ModifyOperationBasis; |
| | | import org.opends.server.protocols.asn1.ASN1Exception; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | |
| | | public ModifyMsg(PostOperationModifyOperation op) |
| | | { |
| | | super((OperationContext) op.getAttachment(OperationContext.SYNCHROCONTEXT), |
| | | op.getRawEntryDN().toString()); |
| | | op.getEntryDN()); |
| | | encodedMods = encodeMods(op.getModifications()); |
| | | } |
| | | |
| | |
| | | */ |
| | | public ModifyMsg(CSN csn, DN dn, List<Modification> mods, String entryUUID) |
| | | { |
| | | super(new ModifyContext(csn, entryUUID), |
| | | dn.toNormalizedString()); |
| | | super(new ModifyContext(csn, entryUUID), dn); |
| | | this.encodedMods = encodeMods(mods); |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Operation createOperation(InternalClientConnection connection, |
| | | String newDn) throws LDAPException, ASN1Exception, DataFormatException |
| | | public ModifyOperation createOperation(InternalClientConnection connection, |
| | | DN newDN) throws LDAPException, ASN1Exception, DataFormatException |
| | | { |
| | | if (newDn == null) |
| | | newDn = getDn(); |
| | | if (newDN == null) |
| | | newDN = getDN(); |
| | | |
| | | ArrayList<RawModification> ldapmods = decodeRawMods(encodedMods); |
| | | List<RawModification> ldapmods = decodeRawMods(encodedMods); |
| | | |
| | | ModifyOperationBasis mod = new ModifyOperationBasis(connection, |
| | | ModifyOperation mod = new ModifyOperationBasis(connection, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), null, |
| | | ByteString.valueOf(newDn), ldapmods); |
| | | ByteString.valueOf(newDN.toString()), ldapmods); |
| | | ModifyContext ctx = new ModifyContext(getCSN(), getEntryUUID()); |
| | | mod.setAttachment(SYNCHROCONTEXT, ctx); |
| | | return mod; |
| | |
| | | import java.util.zip.DataFormatException; |
| | | |
| | | import org.opends.server.replication.common.ServerState; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | /** |
| | | * Message sent by a replication server to a directory server in reply to the |
| | |
| | | { |
| | | private int serverId; |
| | | private String serverURL; |
| | | private String baseDn = null; |
| | | private DN baseDN; |
| | | private int windowSize; |
| | | private ServerState serverState; |
| | | |
| | |
| | | * |
| | | * @param serverId replication server id |
| | | * @param serverURL replication server URL |
| | | * @param baseDn base DN for which the ReplServerStartDSMsg is created. |
| | | * @param baseDN base DN for which the ReplServerStartDSMsg is created. |
| | | * @param windowSize The window size. |
| | | * @param serverState our ServerState for this baseDn. |
| | | * @param serverState our ServerState for this baseDN. |
| | | * @param generationId The generationId for this server. |
| | | * @param sslEncryption Whether to continue using SSL to encrypt messages |
| | | * after the start messages have been exchanged. |
| | |
| | | * @param connectedDSNumber Number of currently connected DS to the |
| | | * replication server. |
| | | */ |
| | | public ReplServerStartDSMsg(int serverId, String serverURL, String baseDn, |
| | | public ReplServerStartDSMsg(int serverId, String serverURL, DN baseDN, |
| | | int windowSize, |
| | | ServerState serverState, |
| | | long generationId, |
| | |
| | | super((short) -1 /* version set when sending */, generationId); |
| | | this.serverId = serverId; |
| | | this.serverURL = serverURL; |
| | | if (baseDn != null) |
| | | this.baseDn = baseDn; |
| | | else |
| | | this.baseDn = null; |
| | | this.baseDN = baseDN; |
| | | this.windowSize = windowSize; |
| | | this.serverState = serverState; |
| | | this.sslEncryption = sslEncryption; |
| | |
| | | try |
| | | { |
| | | /* The ReplServerStartDSMsg payload is stored in the form : |
| | | * <baseDn><serverId><serverURL><windowSize><sslEncryption> |
| | | * <baseDN><serverId><serverURL><windowSize><sslEncryption> |
| | | * <degradedStatusThreshold><weight><connectedDSNumber> |
| | | * <serverState> |
| | | */ |
| | |
| | | * first calculate the length then construct the string |
| | | */ |
| | | int length = getNextLength(in, pos); |
| | | baseDn = new String(in, pos, length, "UTF-8"); |
| | | baseDN = DN.decode(new String(in, pos, length, "UTF-8")); |
| | | pos += length +1; |
| | | |
| | | /* |
| | |
| | | // the ServerState to be the last. This should be changed and we want to |
| | | // have more than one ServerState field. |
| | | serverState = new ServerState(in, pos, in.length - 1); |
| | | } catch (UnsupportedEncodingException e) |
| | | } |
| | | catch (UnsupportedEncodingException e) |
| | | { |
| | | throw new DataFormatException("UTF-8 is not supported by this jvm."); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | throw new DataFormatException(e.getLocalizedMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return the base DN from this ReplServerStartDSMsg. |
| | | */ |
| | | public String getBaseDn() |
| | | public DN getBaseDN() |
| | | { |
| | | return baseDn; |
| | | return baseDN; |
| | | } |
| | | |
| | | /** |
| | |
| | | throws UnsupportedEncodingException |
| | | { |
| | | /* The ReplServerStartDSMsg is stored in the form : |
| | | * <operation type><baseDn><serverId><serverURL><windowSize><sslEncryption> |
| | | * <operation type><baseDN><serverId><serverURL><windowSize><sslEncryption> |
| | | * <degradedStatusThreshold><weight><connectedDSNumber> |
| | | * <serverState> |
| | | */ |
| | | byte[] byteDn = baseDn.getBytes("UTF-8"); |
| | | byte[] byteDn = baseDN.toString().getBytes("UTF-8"); |
| | | byte[] byteServerId = String.valueOf(serverId).getBytes("UTF-8"); |
| | | byte[] byteServerUrl = serverURL.getBytes("UTF-8"); |
| | | byte[] byteServerState = serverState.getBytes(); |
| | |
| | | return "ReplServerStartDSMsg content: " + |
| | | "\nprotocolVersion: " + protocolVersion + |
| | | "\ngenerationId: " + generationId + |
| | | "\nbaseDn: " + baseDn + |
| | | "\nbaseDN: " + baseDN + |
| | | "\ngroupId: " + groupId + |
| | | "\nserverId: " + serverId + |
| | | "\nserverState: " + serverState + |
| | |
| | | import java.util.zip.DataFormatException; |
| | | |
| | | import org.opends.server.replication.common.ServerState; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | /** |
| | | * Message sent by a replication server to another replication server |
| | |
| | | { |
| | | private Integer serverId; |
| | | private String serverURL; |
| | | private String baseDn = null; |
| | | private DN baseDN; |
| | | private int windowSize; |
| | | private ServerState serverState; |
| | | |
| | |
| | | * |
| | | * @param serverId replication server id |
| | | * @param serverURL replication server URL |
| | | * @param baseDn base DN for which the ReplServerStartMsg is created. |
| | | * @param baseDN base DN for which the ReplServerStartMsg is created. |
| | | * @param windowSize The window size. |
| | | * @param serverState our ServerState for this baseDn. |
| | | * @param serverState our ServerState for this baseDN. |
| | | * @param generationId The generationId for this server. |
| | | * @param sslEncryption Whether to continue using SSL to encrypt messages |
| | | * after the start messages have been exchanged. |
| | | * @param groupId The group id of the RS |
| | | * @param degradedStatusThreshold The degraded status threshold |
| | | */ |
| | | public ReplServerStartMsg(int serverId, String serverURL, String baseDn, |
| | | public ReplServerStartMsg(int serverId, String serverURL, DN baseDN, |
| | | int windowSize, |
| | | ServerState serverState, |
| | | long generationId, |
| | |
| | | super((short) -1 /* version set when sending */, generationId); |
| | | this.serverId = serverId; |
| | | this.serverURL = serverURL; |
| | | if (baseDn != null) |
| | | this.baseDn = baseDn; |
| | | else |
| | | this.baseDn = null; |
| | | this.baseDN = baseDN; |
| | | this.windowSize = windowSize; |
| | | this.serverState = serverState; |
| | | this.sslEncryption = sslEncryption; |
| | |
| | | try |
| | | { |
| | | /* The ReplServerStartMsg payload is stored in the form : |
| | | * <baseDn><serverId><serverURL><windowSize><sslEncryption> |
| | | * <baseDN><serverId><serverURL><windowSize><sslEncryption> |
| | | * <degradedStatusThreshold><serverState> |
| | | */ |
| | | |
| | |
| | | * first calculate the length then construct the string |
| | | */ |
| | | int length = getNextLength(in, pos); |
| | | baseDn = new String(in, pos, length, "UTF-8"); |
| | | baseDN = DN.decode(new String(in, pos, length, "UTF-8")); |
| | | pos += length +1; |
| | | |
| | | /* |
| | |
| | | // the ServerState to be the last. This should be changed and we want to |
| | | // have more than one ServerState field. |
| | | serverState = new ServerState(in, pos, in.length - 1); |
| | | } catch (UnsupportedEncodingException e) |
| | | } |
| | | catch (UnsupportedEncodingException e) |
| | | { |
| | | throw new DataFormatException("UTF-8 is not supported by this jvm."); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | throw new DataFormatException(e.getLocalizedMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | try |
| | | { |
| | | /* The ReplServerStartMsg payload is stored in the form : |
| | | * <baseDn><serverId><serverURL><windowSize><sslEncryption> |
| | | * <baseDN><serverId><serverURL><windowSize><sslEncryption> |
| | | * <serverState> |
| | | */ |
| | | |
| | |
| | | * first calculate the length then construct the string |
| | | */ |
| | | int length = getNextLength(in, pos); |
| | | baseDn = new String(in, pos, length, "UTF-8"); |
| | | baseDN = DN.decode(new String(in, pos, length, "UTF-8")); |
| | | pos += length +1; |
| | | |
| | | /* |
| | |
| | | // the ServerState to be the last. This should be changed and we want to |
| | | // have more than one ServerState field. |
| | | serverState = new ServerState(in, pos, in.length - 1); |
| | | } catch (UnsupportedEncodingException e) |
| | | } |
| | | catch (UnsupportedEncodingException e) |
| | | { |
| | | throw new DataFormatException("UTF-8 is not supported by this jvm."); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | throw new DataFormatException(e.getLocalizedMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return the base DN from this ReplServerStartMsg. |
| | | */ |
| | | public String getBaseDn() |
| | | public DN getBaseDN() |
| | | { |
| | | return baseDn; |
| | | return baseDN; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /* The ReplServerStartMsg is stored in the form : |
| | | * <operation type><baseDn><serverId><serverURL><windowSize><sslEncryption> |
| | | * <operation type><baseDN><serverId><serverURL><windowSize><sslEncryption> |
| | | * <degradedStatusThreshold><serverState> |
| | | */ |
| | | |
| | | byte[] byteDn = baseDn.getBytes("UTF-8"); |
| | | byte[] byteDn = baseDN.toString().getBytes("UTF-8"); |
| | | byte[] byteServerId = String.valueOf(serverId).getBytes("UTF-8"); |
| | | byte[] byteServerUrl = serverURL.getBytes("UTF-8"); |
| | | byte[] byteServerState = serverState.getBytes(); |
| | |
| | | return "ReplServerStartMsg content: " + |
| | | "\nprotocolVersion: " + protocolVersion + |
| | | "\ngenerationId: " + generationId + |
| | | "\nbaseDn: " + baseDn + |
| | | "\nbaseDN: " + baseDN + |
| | | "\ngroupId: " + groupId + |
| | | "\nserverId: " + serverId + |
| | | "\nserverState: " + serverState + |
| | |
| | | * <operation type><basedn><serverid><serverURL><windowsize><serverState> |
| | | */ |
| | | try { |
| | | byte[] byteDn = baseDn.getBytes("UTF-8"); |
| | | byte[] byteDn = baseDN.toString().getBytes("UTF-8"); |
| | | byte[] byteServerId = String.valueOf(serverId).getBytes("UTF-8"); |
| | | byte[] byteServerUrl = serverURL.getBytes("UTF-8"); |
| | | byte[] byteServerState = serverState.getBytes(); |
| | |
| | | import java.util.zip.DataFormatException; |
| | | |
| | | import org.opends.server.replication.common.ServerState; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | /** |
| | | * This message is used by LDAP server when they first connect. |
| | |
| | | { |
| | | private int serverId; // Id of the LDAP server that sent this message |
| | | private String serverURL; |
| | | private String baseDn; |
| | | private DN baseDN; |
| | | private int maxReceiveQueue; |
| | | private int maxSendQueue; |
| | | private int maxReceiveDelay; |
| | |
| | | * @param serverId2 The serverId of the server for which the ServerStartMsg |
| | | * is created. |
| | | * @param serverURL directory server URL |
| | | * @param baseDn The base DN. |
| | | * @param baseDN The base DN. |
| | | * @param windowSize The window size used by this server. |
| | | * @param heartbeatInterval The requested heartbeat interval. |
| | | * @param serverState The state of this server. |
| | |
| | | * after the start messages have been exchanged. |
| | | * @param groupId The group id of the DS for this DN |
| | | */ |
| | | public ServerStartMsg(int serverId2, String serverURL, String baseDn, |
| | | public ServerStartMsg(int serverId2, String serverURL, DN baseDN, |
| | | int windowSize, long heartbeatInterval, ServerState serverState, |
| | | long generationId, boolean sslEncryption, |
| | | byte groupId) |
| | |
| | | |
| | | this.serverId = serverId2; |
| | | this.serverURL = serverURL; |
| | | this.baseDn = baseDn; |
| | | this.baseDN = baseDN; |
| | | this.maxReceiveDelay = 0; |
| | | this.maxReceiveQueue = 0; |
| | | this.maxSendDelay = 0; |
| | |
| | | * first calculate the length then construct the string |
| | | */ |
| | | int length = getNextLength(in, pos); |
| | | baseDn = new String(in, pos, length, "UTF-8"); |
| | | baseDN = DN.decode(new String(in, pos, length, "UTF-8")); |
| | | pos += length +1; |
| | | |
| | | /* |
| | |
| | | // have more than one ServerState field. |
| | | serverState = new ServerState(in, pos, in.length - 1); |
| | | |
| | | } catch (UnsupportedEncodingException e) |
| | | } |
| | | catch (UnsupportedEncodingException e) |
| | | { |
| | | throw new DataFormatException("UTF-8 is not supported by this jvm."); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | throw new DataFormatException(e.getLocalizedMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * Get the baseDn. |
| | | * @return Returns the baseDn. |
| | | * Get the baseDN. |
| | | * |
| | | * @return Returns the baseDN. |
| | | */ |
| | | public String getBaseDn() |
| | | public DN getBaseDN() |
| | | { |
| | | return baseDn; |
| | | return baseDN; |
| | | } |
| | | |
| | | /** |
| | |
| | | public byte[] getBytes(short sessionProtocolVersion) |
| | | { |
| | | try { |
| | | byte[] byteDn = baseDn.getBytes("UTF-8"); |
| | | byte[] byteDn = baseDN.toString().getBytes("UTF-8"); |
| | | byte[] byteServerId = String.valueOf(serverId).getBytes("UTF-8"); |
| | | byte[] byteServerUrl = serverURL.getBytes("UTF-8"); |
| | | byte[] byteMaxRecvDelay = |
| | |
| | | "\nprotocolVersion: " + protocolVersion + |
| | | "\ngenerationId: " + generationId + |
| | | "\ngroupId: " + groupId + |
| | | "\nbaseDn: " + baseDn + |
| | | "\nbaseDN: " + baseDN + |
| | | "\nheartbeatInterval: " + heartbeatInterval + |
| | | "\nmaxReceiveDelay: " + maxReceiveDelay + |
| | | "\nmaxReceiveQueue: " + maxReceiveQueue + |
| | |
| | | "\nsslEncryption: " + sslEncryption + |
| | | "\nwindowSize: " + windowSize; |
| | | } |
| | | } |
| | | } |
| | |
| | | // gen status) |
| | | Message message = NOTE_BAD_GEN_ID_IN_FULL_UPDATE.get( |
| | | Integer.toString(replicationServer.getServerId()), |
| | | getBaseDN(), |
| | | getBaseDNString(), |
| | | Integer.toString(serverId), |
| | | Long.toString(generationId), |
| | | Long.toString(newGenId)); |
| | |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugInfo("In RS " + replicationServer.getServerId() |
| | | + ", DS " + getServerId() + " for baseDN=" + getBaseDN() |
| | | + ", DS " + getServerId() + " for baseDN=" + getBaseDNString() |
| | | + " has already generation id " + newGenId |
| | | + " so no ChangeStatusMsg sent to him."); |
| | | } |
| | |
| | | { |
| | | TRACER.debugInfo("In RS " + replicationServer.getServerId() |
| | | + ", closing connection to DS " + getServerId() + " for baseDN=" |
| | | + getBaseDN() + " to force reconnection as new local" |
| | | + getBaseDNString() + " to force reconnection as new local" |
| | | + " generationId and remote one match and DS is in bad gen id: " |
| | | + newGenId); |
| | | } |
| | |
| | | ServerStatus newStatus = StatusMachine.computeNewStatus(status, event); |
| | | if (newStatus == ServerStatus.INVALID_STATUS) |
| | | { |
| | | Message msg = ERR_RS_CANNOT_CHANGE_STATUS.get(getBaseDN(), |
| | | Message msg = ERR_RS_CANNOT_CHANGE_STATUS.get(getBaseDNString(), |
| | | Integer.toString(serverId), status.toString(), event.toString()); |
| | | logError(msg); |
| | | // Only change allowed is from NORMAL_STATUS to DEGRADED_STATUS and vice |
| | |
| | | { |
| | | TRACER.debugInfo("In RS " + replicationServer.getServerId() |
| | | + " Sending change status " + origin + " to " + getServerId() |
| | | + " for baseDN=" + getBaseDN() + ":\n" + csMsg); |
| | | + " for baseDN=" + getBaseDNString() + ":\n" + csMsg); |
| | | } |
| | | |
| | | session.publish(csMsg); |
| | |
| | | if (event == StatusMachineEvent.INVALID_EVENT) |
| | | { |
| | | Message msg = ERR_RS_INVALID_NEW_STATUS.get(reqStatus.toString(), |
| | | getBaseDN(), Integer.toString(serverId)); |
| | | getBaseDNString(), Integer.toString(serverId)); |
| | | logError(msg); |
| | | return ServerStatus.INVALID_STATUS; |
| | | } |
| | |
| | | ServerStatus newStatus = StatusMachine.computeNewStatus(status, event); |
| | | if (newStatus == ServerStatus.INVALID_STATUS) |
| | | { |
| | | Message msg = ERR_RS_CANNOT_CHANGE_STATUS.get(getBaseDN(), |
| | | Message msg = ERR_RS_CANNOT_CHANGE_STATUS.get(getBaseDNString(), |
| | | Integer.toString(serverId), status.toString(), event.toString()); |
| | | logError(msg); |
| | | return ServerStatus.INVALID_STATUS; |
| | |
| | | heartbeatInterval = serverStartMsg.getHeartbeatInterval(); |
| | | |
| | | // generic stuff |
| | | DN baseDN = DN.decode(serverStartMsg.getBaseDn()); |
| | | setBaseDNAndDomain(baseDN, true); |
| | | setBaseDNAndDomain(serverStartMsg.getBaseDN(), true); |
| | | setInitialServerState(serverStartMsg.getServerState()); |
| | | setSendWindowSize(serverStartMsg.getWindowSize()); |
| | | |
| | |
| | | { |
| | | Message message = ERR_RS_INVALID_INIT_STATUS.get( |
| | | this.status.toString(), |
| | | getBaseDN(), |
| | | getBaseDNString(), |
| | | Integer.toString(serverId)); |
| | | throw new DirectoryException(ResultCode.OTHER, message); |
| | | } |
| | |
| | | { |
| | | Message message = WARN_BAD_GENERATION_ID_FROM_DS.get( |
| | | serverId, session.getReadableRemoteAddress(), |
| | | generationId, getBaseDN(), |
| | | generationId, getBaseDNString(), |
| | | getReplicationServerId(), localGenerationId); |
| | | logError(message); |
| | | } |
| | |
| | | // it is not expected to connect to an empty RS |
| | | Message message = WARN_BAD_GENERATION_ID_FROM_DS.get( |
| | | serverId, session.getReadableRemoteAddress(), |
| | | generationId, getBaseDN(), |
| | | generationId, getBaseDNString(), |
| | | getReplicationServerId(), localGenerationId); |
| | | logError(message); |
| | | } |
| | |
| | | private void getNextEligibleMessageForDomain(String opid) |
| | | { |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo(" In ECLServerHandler, for " + mh.getBaseDN() + |
| | | TRACER.debugInfo(" In ECLServerHandler, for " + mh.getBaseDNString() + |
| | | " getNextEligibleMessageForDomain(" + opid+ ") " |
| | | + "ctxt=" + toString()); |
| | | |
| | |
| | | <= eligibleCSN.getTime()); |
| | | |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo(" In ECLServerHandler, for " + mh.getBaseDN() + |
| | | " getNextEligibleMessageForDomain(" + opid+ ") " |
| | | TRACER.debugInfo(" In ECLServerHandler, for " |
| | | + mh.getBaseDNString() |
| | | + " getNextEligibleMessageForDomain(" + opid + ") " |
| | | + " stored nonEligibleMsg " + nextNonEligibleMsg |
| | | + " has now become eligible regarding " |
| | | + " the eligibleCSN ("+ eligibleCSN |
| | |
| | | (newMsg.getCSN().getTime() < domainLatestTrimDate)); |
| | | |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo(" In ECLServerHandler, for " + mh.getBaseDN() + |
| | | " getNextEligibleMessageForDomain(" + opid+ ") " |
| | | TRACER.debugInfo(" In ECLServerHandler, for " |
| | | + mh.getBaseDNString() |
| | | + " getNextEligibleMessageForDomain(" + opid + ") " |
| | | + " got new message : " |
| | | + " baseDN=[" + mh.getBaseDN() |
| | | + " baseDN=[" + mh.getBaseDNString() |
| | | + "] [newMsg=" + newMsg + "]" + dumpState()); |
| | | |
| | | // in non blocking mode, return null when no more msg |
| | |
| | | <= eligibleCSN.getTime()); |
| | | |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo(" In ECLServerHandler, for " + mh.getBaseDN() |
| | | TRACER.debugInfo(" In ECLServerHandler, for " |
| | | + mh.getBaseDNString() |
| | | + " getNextEligibleMessageForDomain(" + opid+ ") " |
| | | + "newMsg isEligible=" + isEligible + " since " |
| | | + "newMsg=[" + newMsg.getCSN() |
| | |
| | | final String eclServer = "External changelog Server "; |
| | | if (this.serverId != 0) |
| | | { |
| | | return eclServer + serverId + " " + serverURL + " " + getBaseDN() + " " |
| | | + operationId; |
| | | return eclServer + serverId + " " + serverURL + " " |
| | | + getBaseDNString() + " " + operationId; |
| | | } |
| | | return eclServer + getClass().getCanonicalName() + " " + operationId; |
| | | } |
| | |
| | | final ECLUpdateMsg change = new ECLUpdateMsg( |
| | | (LDAPUpdateMsg) oldestContext.nextMsg, |
| | | null, // cookie will be set later |
| | | oldestContext.rsd.getBaseDN().toNormalizedString(), |
| | | oldestContext.rsd.getBaseDN(), |
| | | 0); // changeNumber may be set later |
| | | oldestContext.nextMsg = null; |
| | | |
| | |
| | | final ECLUpdateMsg change = new ECLUpdateMsg( |
| | | (LDAPUpdateMsg) oldestContext.nextMsg, |
| | | null, // set later |
| | | oldestContext.rsd.getBaseDN().toNormalizedString(), |
| | | oldestContext.rsd.getBaseDN(), |
| | | 0); |
| | | oldestContext.nextMsg = null; // clean |
| | | |
| | |
| | | TRACER.debugInfo("getNextECLUpdate updates previousCookie:" + csn); |
| | | |
| | | // Update the current state |
| | | previousCookie.update(DN.decode(oldestChange.getBaseDN()), csn); |
| | | previousCookie.update(oldestChange.getBaseDN(), csn); |
| | | |
| | | // Set the current value of global state in the returned message |
| | | oldestChange.setCookie(previousCookie); |
| | |
| | | |
| | | // replogCSN : the oldest change from the changelog db |
| | | CSN csnFromChangelogDb = oldestChange.getUpdateMsg().getCSN(); |
| | | DN dnFromChangelogDb = DN.decode(oldestChange.getBaseDN()); |
| | | DN dnFromChangelogDb = oldestChange.getBaseDN(); |
| | | |
| | | while (true) |
| | | { |
| | |
| | | replicationServer.getChangeNumberIndexDB().addRecord(new CNIndexRecord( |
| | | change.getChangeNumber(), |
| | | previousCookie.toString(), |
| | | DN.decode(change.getBaseDN()), |
| | | change.getBaseDN(), |
| | | change.getUpdateMsg().getCSN())); |
| | | } |
| | | |
| | |
| | | handler.getReplicationServerId(), |
| | | handler.getServerId(), |
| | | session.getReadableRemoteAddress(), |
| | | handler.getBaseDN()); |
| | | handler.getBaseDNString()); |
| | | } |
| | | else |
| | | { |
| | |
| | | handler.getReplicationServerId(), |
| | | handler.getServerId(), |
| | | session.getReadableRemoteAddress(), |
| | | handler.getBaseDN()); |
| | | handler.getBaseDNString()); |
| | | } |
| | | logError(errMessage); |
| | | } |
| | |
| | | /** |
| | | * Get the baseDN for this handler. |
| | | * |
| | | * @return The baseDN. |
| | | */ |
| | | protected DN getBaseDN() |
| | | { |
| | | return baseDN; |
| | | } |
| | | |
| | | /** |
| | | * Get the baseDN for this handler as a String. |
| | | * |
| | | * @return The name of the baseDN. |
| | | */ |
| | | protected String getBaseDN() |
| | | protected String getBaseDNString() |
| | | { |
| | | return baseDN.toNormalizedString(); |
| | | } |
| | |
| | | |
| | | dn = DN.decode("puid=" + addMsg.getParentEntryUUID() + "+" + |
| | | CHANGE_NUMBER + "=" + msg.getCSN() + "+" + |
| | | msg.getDn() + "," + BASE_DN); |
| | | msg.getDN() + "," + BASE_DN); |
| | | |
| | | Map<AttributeType,List<Attribute>> attrs = |
| | | new HashMap<AttributeType,List<Attribute>>(); |
| | |
| | | private DN computeDN(LDAPUpdateMsg msg) throws DirectoryException |
| | | { |
| | | return DN.decode("uuid=" + msg.getEntryUUID() + "," + CHANGE_NUMBER + "=" |
| | | + msg.getCSN() + "," + msg.getDn() + "," + BASE_DN); |
| | | + msg.getCSN() + "," + msg.getDN() + "," + BASE_DN); |
| | | } |
| | | |
| | | private Entry writeChangeRecord(LDIFWriter ldifWriter, |
| | |
| | | serverId = inReplServerStartMsg.getServerId(); |
| | | serverURL = inReplServerStartMsg.getServerURL(); |
| | | serverAddressURL = toServerAddressURL(serverURL); |
| | | DN baseDN = DN.decode(inReplServerStartMsg.getBaseDn()); |
| | | setBaseDNAndDomain(baseDN, false); |
| | | setBaseDNAndDomain(inReplServerStartMsg.getBaseDN(), false); |
| | | setInitialServerState(inReplServerStartMsg.getServerState()); |
| | | setSendWindowSize(inReplServerStartMsg.getWindowSize()); |
| | | if (protocolVersion > ProtocolVersion.REPLICATION_PROTOCOL_V1) |
| | |
| | | */ |
| | | Message message = WARN_BAD_GENERATION_ID_FROM_RS.get( |
| | | serverId, session.getReadableRemoteAddress(), generationId, |
| | | getBaseDN(), getReplicationServerId(), localGenerationId); |
| | | getBaseDNString(), getReplicationServerId(), localGenerationId); |
| | | logError(message); |
| | | } |
| | | } |
| | |
| | | List<Attribute> attributes = super.getMonitorData(); |
| | | |
| | | attributes.add(Attributes.create("server-id", String.valueOf(serverId))); |
| | | attributes.add(Attributes.create("domain-name", getBaseDN())); |
| | | attributes.add(Attributes.create("domain-name", getBaseDNString())); |
| | | |
| | | // Deprecated |
| | | attributes.add(Attributes.create("max-waiting-changes", String |
| | |
| | | if (!lockAcquired) |
| | | { |
| | | Message message = WARN_TIMEOUT_WHEN_CROSS_CONNECTION.get( |
| | | getBaseDN(), |
| | | getBaseDNString(), |
| | | serverId, |
| | | session.getReadableRemoteAddress(), |
| | | getReplicationServerId()); |
| | |
| | | logError(WARN_IGNORING_UPDATE_FROM_DS_BADGENID.get( |
| | | handler.getReplicationServerId(), |
| | | updateMsg.getCSN().toString(), |
| | | handler.getBaseDN(), handler.getServerId(), |
| | | handler.getBaseDNString(), handler.getServerId(), |
| | | session.getReadableRemoteAddress(), |
| | | handler.getGenerationId(), |
| | | referenceGenerationId)); |
| | |
| | | logError(WARN_IGNORING_UPDATE_FROM_DS_FULLUP.get( |
| | | handler.getReplicationServerId(), |
| | | updateMsg.getCSN().toString(), |
| | | handler.getBaseDN(), handler.getServerId(), |
| | | handler.getBaseDNString(), handler.getServerId(), |
| | | session.getReadableRemoteAddress())); |
| | | filtered = true; |
| | | } |
| | |
| | | WARN_IGNORING_UPDATE_FROM_RS.get( |
| | | handler.getReplicationServerId(), |
| | | updateMsg.getCSN().toString(), |
| | | handler.getBaseDN(), |
| | | handler.getBaseDNString(), |
| | | handler.getServerId(), |
| | | session.getReadableRemoteAddress(), |
| | | handler.getGenerationId(), |
| | |
| | | { |
| | | errMessage = |
| | | ERR_RECEIVED_CHANGE_STATUS_NOT_FROM_DS.get( |
| | | handler.getBaseDN(), |
| | | handler.getBaseDNString(), |
| | | Integer.toString(handler.getServerId()), |
| | | csMsg.toString()); |
| | | logError(errMessage); |
| | |
| | | { |
| | | errMessage = ERR_DS_BADLY_DISCONNECTED.get( |
| | | handler.getReplicationServerId(), handler.getServerId(), |
| | | remoteAddress, handler.getBaseDN()); |
| | | remoteAddress, handler.getBaseDNString()); |
| | | } |
| | | else |
| | | { |
| | | errMessage = ERR_RS_BADLY_DISCONNECTED.get( |
| | | handler.getReplicationServerId(), handler.getServerId(), |
| | | remoteAddress, handler.getBaseDN()); |
| | | remoteAddress, handler.getBaseDNString()); |
| | | } |
| | | logError(errMessage); |
| | | } |
| | |
| | | logError(WARN_IGNORING_UPDATE_TO_DS_BADGENID.get( |
| | | handler.getReplicationServerId(), |
| | | update.getCSN().toString(), |
| | | handler.getBaseDN(), handler.getServerId(), |
| | | handler.getBaseDNString(), handler.getServerId(), |
| | | session.getReadableRemoteAddress(), |
| | | handler.getGenerationId(), |
| | | referenceGenerationId)); |
| | |
| | | logError(WARN_IGNORING_UPDATE_TO_DS_FULLUP.get( |
| | | handler.getReplicationServerId(), |
| | | update.getCSN().toString(), |
| | | handler.getBaseDN(), handler.getServerId(), |
| | | handler.getBaseDNString(), handler.getServerId(), |
| | | session.getReadableRemoteAddress())); |
| | | continue; |
| | | } |
| | |
| | | WARN_IGNORING_UPDATE_TO_RS.get( |
| | | handler.getReplicationServerId(), |
| | | update.getCSN().toString(), |
| | | handler.getBaseDN(), |
| | | handler.getBaseDNString(), |
| | | handler.getServerId(), |
| | | session.getReadableRemoteAddress(), |
| | | handler.getGenerationId(), |
| | |
| | | { |
| | | errMessage = ERR_DS_BADLY_DISCONNECTED.get( |
| | | handler.getReplicationServerId(), handler.getServerId(), |
| | | session.getReadableRemoteAddress(), handler.getBaseDN()); |
| | | session.getReadableRemoteAddress(), handler.getBaseDNString()); |
| | | } |
| | | else |
| | | { |
| | | errMessage = ERR_RS_BADLY_DISCONNECTED.get( |
| | | handler.getReplicationServerId(), handler.getServerId(), |
| | | session.getReadableRemoteAddress(), handler.getBaseDN()); |
| | | session.getReadableRemoteAddress(), handler.getBaseDNString()); |
| | | } |
| | | |
| | | logError(errMessage); |
| | |
| | | { |
| | | errMessage = ERR_DS_BADLY_DISCONNECTED.get( |
| | | handler.getReplicationServerId(), handler.getServerId(), |
| | | session.getReadableRemoteAddress(), handler.getBaseDN()); |
| | | session.getReadableRemoteAddress(), handler.getBaseDNString()); |
| | | } |
| | | else |
| | | { |
| | | errMessage = ERR_RS_BADLY_DISCONNECTED.get( |
| | | handler.getReplicationServerId(), handler.getServerId(), |
| | | session.getReadableRemoteAddress(), handler.getBaseDN()); |
| | | session.getReadableRemoteAddress(), handler.getBaseDNString()); |
| | | } |
| | | logError(errMessage); |
| | | } |
| | |
| | | private int serverId; |
| | | /** Received server URL. */ |
| | | private String serverURL; |
| | | private String baseDn = null; |
| | | private DN baseDN; |
| | | private int windowSize; |
| | | private ServerState serverState = null; |
| | | private ServerState serverState; |
| | | private boolean sslEncryption; |
| | | private int degradedStatusThreshold = -1; |
| | | /** Keeps the 1 value if created with a ReplServerStartMsg. */ |
| | | private int weight = 1; |
| | | /** Keeps the 0 value if created with a ReplServerStartMsg. */ |
| | | private int connectedDSNumber = 0; |
| | | private List<Integer> connectedDSs = null; |
| | | private List<Integer> connectedDSs; |
| | | /** |
| | | * Is this RS locally configured? (the RS is recognized as a usable server). |
| | | */ |
| | |
| | | this.groupId = replServerStartMsg.getGroupId(); |
| | | this.serverId = replServerStartMsg.getServerId(); |
| | | this.serverURL = replServerStartMsg.getServerURL(); |
| | | this.baseDn = replServerStartMsg.getBaseDn(); |
| | | this.baseDN = replServerStartMsg.getBaseDN(); |
| | | this.windowSize = replServerStartMsg.getWindowSize(); |
| | | this.serverState = replServerStartMsg.getServerState(); |
| | | this.sslEncryption = replServerStartMsg.getSSLEncryption(); |
| | |
| | | this.groupId = replServerStartDSMsg.getGroupId(); |
| | | this.serverId = replServerStartDSMsg.getServerId(); |
| | | this.serverURL = replServerStartDSMsg.getServerURL(); |
| | | this.baseDn = replServerStartDSMsg.getBaseDn(); |
| | | this.baseDN = replServerStartDSMsg.getBaseDN(); |
| | | this.windowSize = replServerStartDSMsg.getWindowSize(); |
| | | this.serverState = replServerStartDSMsg.getServerState(); |
| | | this.sslEncryption = replServerStartDSMsg.getSSLEncryption(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Get the base dn. |
| | | * @return the baseDn |
| | | * Get the base DN. |
| | | * |
| | | * @return the base DN |
| | | */ |
| | | public String getBaseDn() |
| | | public DN getBaseDN() |
| | | { |
| | | return baseDn; |
| | | return baseDN; |
| | | } |
| | | |
| | | /** |
| | |
| | | private ReplicationServerInfo performPhaseOneHandshake( |
| | | String server, boolean keepConnection, boolean isECL) |
| | | { |
| | | final String baseDn = this.baseDN.toNormalizedString(); |
| | | |
| | | Session localSession = null; |
| | | Socket socket = null; |
| | | boolean hasConnected = false; |
| | |
| | | if (!isECL) |
| | | { |
| | | serverStartMsg = new ServerStartMsg(serverId, url, |
| | | baseDN.toNormalizedString(), maxRcvWindow, heartbeatInterval, state, |
| | | baseDN, maxRcvWindow, heartbeatInterval, state, |
| | | getGenerationID(), isSslEncryption, groupId); |
| | | } |
| | | else |
| | |
| | | .newInstance(msg, server); |
| | | |
| | | // Sanity check |
| | | String repDn = replServerInfo.getBaseDn(); |
| | | if (!baseDn.equals(repDn)) |
| | | DN repDN = replServerInfo.getBaseDN(); |
| | | if (!baseDN.equals(repDN)) |
| | | { |
| | | errorMessage = ERR_DS_DN_DOES_NOT_MATCH.get(repDn, baseDn); |
| | | errorMessage = ERR_DS_DN_DOES_NOT_MATCH.get( |
| | | repDN.toNormalizedString(), baseDN.toNormalizedString()); |
| | | return null; |
| | | } |
| | | |
| | |
| | | catch (ConnectException e) |
| | | { |
| | | errorMessage = WARN_NO_CHANGELOG_SERVER_LISTENING.get(serverId, |
| | | server, baseDn); |
| | | server, baseDN.toNormalizedString()); |
| | | return null; |
| | | } |
| | | catch (SocketTimeoutException e) |
| | | { |
| | | errorMessage = WARN_TIMEOUT_CONNECTING_TO_RS.get(serverId, |
| | | server, baseDn); |
| | | server, baseDN.toNormalizedString()); |
| | | return null; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | errorMessage = WARN_EXCEPTION_STARTING_SESSION_PHASE.get(serverId, |
| | | server, baseDn, stackTraceToSingleLineString(e)); |
| | | server, baseDN.toNormalizedString(), stackTraceToSingleLineString(e)); |
| | | return null; |
| | | } |
| | | finally |
| | |
| | | |
| | | // Send start message to the peer |
| | | InitializeTargetMsg initTargetMsg = new InitializeTargetMsg( |
| | | getBaseDNString(), serverID, serverToInitialize, |
| | | getBaseDN(), serverID, serverToInitialize, |
| | | serverRunningTheTask, ieContext.entryCount, initWindow); |
| | | |
| | | broker.publish(initTargetMsg); |
| | |
| | | ieContext.initializeTask = initTask; |
| | | ieContext.attemptCnt = 0; |
| | | ieContext.initReqMsgSent = new InitializeRequestMsg( |
| | | getBaseDNString(), serverID, source, this.initWindow); |
| | | getBaseDN(), serverID, source, this.initWindow); |
| | | |
| | | // Publish Init request msg |
| | | broker.publish(ieContext.initReqMsgSent); |
| | |
| | | |
| | | /** |
| | | * Build an ECL entry from a provided ECL msg and return it. |
| | | * @param eclmsg The provided ECL msg. |
| | | * @param eclMsg The provided ECL msg. |
| | | * @return <CODE>true</CODE> if the caller should continue processing the |
| | | * search request and sending additional entries and references, or |
| | | * <CODE>false</CODE> if not for some reason (e.g., the size limit |
| | | * has been reached or the search has been abandoned). |
| | | * @throws DirectoryException When an errors occurs. |
| | | */ |
| | | private boolean buildAndReturnEntry(ECLUpdateMsg eclmsg) |
| | | private boolean buildAndReturnEntry(ECLUpdateMsg eclMsg) |
| | | throws DirectoryException |
| | | { |
| | | final Entry entry = createEntryFromMsg(eclmsg); |
| | | final Entry entry = createEntryFromMsg(eclMsg); |
| | | if (matchScopeAndFilter(entry)) |
| | | { |
| | | List<Control> controls = null; |
| | |
| | | |
| | | EntryChangelogNotificationControl clrc = |
| | | new EntryChangelogNotificationControl( |
| | | true, eclmsg.getCookie().toString()); |
| | | true, eclMsg.getCookie().toString()); |
| | | controls.add(clrc); |
| | | } |
| | | return returnEntry(entry, controls); |
| | |
| | | /** |
| | | * Create an ECL entry from a provided ECL msg. |
| | | * |
| | | * @param eclmsg |
| | | * @param eclMsg |
| | | * the provided ECL msg. |
| | | * @return the created ECL entry. |
| | | * @throws DirectoryException |
| | | * When an error occurs. |
| | | */ |
| | | public static Entry createEntryFromMsg(ECLUpdateMsg eclmsg) |
| | | public static Entry createEntryFromMsg(ECLUpdateMsg eclMsg) |
| | | throws DirectoryException |
| | | { |
| | | Entry clEntry = null; |
| | | |
| | | // Get the meat from the ecl msg |
| | | UpdateMsg msg = eclmsg.getUpdateMsg(); |
| | | UpdateMsg msg = eclMsg.getUpdateMsg(); |
| | | |
| | | if (msg instanceof AddMsg) |
| | | { |
| | |
| | | Severity.MILD_ERROR, |
| | | "An exception was encountered while try to encode a " |
| | | + "replication add message for entry \"" |
| | | + addMsg.getDn() |
| | | + addMsg.getDN() |
| | | + "\" into an External Change Log entry: " |
| | | + e.getMessage())); |
| | | } |
| | | |
| | | List<RawAttribute> eclAttributes = addMsg.getEclIncludes(); |
| | | |
| | | clEntry = createChangelogEntry(eclmsg.getBaseDN(), eclmsg |
| | | .getCookie().toString(), DN.decode(addMsg.getDn()), |
| | | addMsg.getCSN(), ldifChanges, // entry as created (in LDIF |
| | | // format) |
| | | clEntry = createChangelogEntry(eclMsg.getBaseDN(), |
| | | eclMsg.getCookie().toString(), addMsg.getDN(), |
| | | addMsg.getCSN(), ldifChanges, // entry as created (in LDIF format) |
| | | addMsg.getEntryUUID(), |
| | | eclAttributes, // entry attributes |
| | | eclmsg.getChangeNumber(), "add", changeInitiatorsName); |
| | | eclMsg.getChangeNumber(), "add", changeInitiatorsName); |
| | | } |
| | | else if (msg instanceof ModifyCommonMsg) |
| | | { |
| | |
| | | Severity.MILD_ERROR, |
| | | "An exception was encountered while try to encode a " |
| | | + "replication modify message for entry \"" |
| | | + modifyMsg.getDn() |
| | | + modifyMsg.getDN() |
| | | + "\" into an External Change Log entry: " |
| | | + e.getMessage())); |
| | | } |
| | |
| | | String changeType = (modifyMsg instanceof ModifyDNMsg) ? "modrdn" |
| | | : "modify"; |
| | | |
| | | clEntry = createChangelogEntry(eclmsg.getBaseDN(), eclmsg |
| | | .getCookie().toString(), DN.decode(modifyMsg.getDn()), |
| | | clEntry = createChangelogEntry(eclMsg.getBaseDN(), |
| | | eclMsg.getCookie().toString(), modifyMsg.getDN(), |
| | | modifyMsg.getCSN(), ldifChanges, |
| | | modifyMsg.getEntryUUID(), |
| | | modifyMsg.getEclIncludes(), // entry attributes |
| | | eclmsg.getChangeNumber(), changeType, |
| | | eclMsg.getChangeNumber(), changeType, |
| | | changeInitiatorsName); |
| | | |
| | | if (modifyMsg instanceof ModifyDNMsg) |
| | |
| | | { |
| | | DeleteMsg delMsg = (DeleteMsg) msg; |
| | | |
| | | clEntry = createChangelogEntry(eclmsg.getBaseDN(), eclmsg |
| | | .getCookie().toString(), DN.decode(delMsg.getDn()), |
| | | clEntry = createChangelogEntry(eclMsg.getBaseDN(), |
| | | eclMsg.getCookie().toString(), delMsg.getDN(), |
| | | delMsg.getCSN(), |
| | | null, // no changes |
| | | delMsg.getEntryUUID(), |
| | | delMsg.getEclIncludes(), // entry attributes |
| | | eclmsg.getChangeNumber(), "delete", |
| | | eclMsg.getChangeNumber(), "delete", |
| | | delMsg.getInitiatorsName()); |
| | | } |
| | | |
| | |
| | | * When any error occurs. |
| | | */ |
| | | private static Entry createChangelogEntry( |
| | | String baseDN, |
| | | DN baseDN, |
| | | String cookie, |
| | | DN targetDN, |
| | | CSN csn, |
| | |
| | | if (changenumber == 0) |
| | | { |
| | | // Draft uncompat mode |
| | | dnString = "replicationCSN=" + csn + "," + baseDN + "," |
| | | + ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT; |
| | | dnString = "replicationCSN=" + csn + "," + baseDN.toNormalizedString() |
| | | + "," + ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT; |
| | | } |
| | | else |
| | | { |
| | |
| | | import org.opends.server.replication.server.ReplicationServer; |
| | | import org.opends.server.replication.service.ReplicationBroker; |
| | | import org.opends.server.types.*; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | |
| | | @SuppressWarnings("javadoc") |
| | | public class DependencyTest extends ReplicationTestCase |
| | | { |
| | | |
| | | private final long CLEAN_DB_GENERATION_ID = 7883L; |
| | | private DN TEST_ROOT_DN; |
| | | |
| | | |
| | | @BeforeClass |
| | | public void setup() throws Exception |
| | | { |
| | | TEST_ROOT_DN = DN.decode(TEST_ROOT_DN_STRING); |
| | | } |
| | | |
| | | /** |
| | | * Check that a sequence of dependents adds and mods is correctly ordered: |
| | | * Using a deep dit : |
| | |
| | | { |
| | | ReplicationServer replServer = null; |
| | | LDAPReplicationDomain domain = null; |
| | | DN baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | DN baseDN = TEST_ROOT_DN; |
| | | int brokerId = 2; |
| | | int serverId = 1; |
| | | int replServerId = 81; |
| | |
| | | replServer = new ReplicationServer(conf); |
| | | |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, brokerId, 1000, replServerPort, 1000, |
| | | openReplicationSession(baseDN, brokerId, 1000, replServerPort, 1000, |
| | | false, CLEAN_DB_GENERATION_ID); |
| | | |
| | | Thread.sleep(2000); |
| | | // send a sequence of add operation |
| | | |
| | | String addDn = TEST_ROOT_DN_STRING; |
| | | DN addDN = TEST_ROOT_DN; |
| | | CSNGenerator gen = new CSNGenerator(brokerId, 0L); |
| | | |
| | | int sequence; |
| | |
| | | entry.removeAttribute(uidType); |
| | | entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1)), |
| | | new LinkedList<AttributeValue>()); |
| | | addDn = "dc=dependency" + sequence + "," + addDn; |
| | | addDN = DN.decode("dc=dependency" + sequence + "," + addDN); |
| | | AddMsg addMsg = |
| | | new AddMsg(gen.newCSN(), addDn, stringUID(sequence+1), |
| | | new AddMsg(gen.newCSN(), addDN, stringUID(sequence+1), |
| | | stringUID(sequence), |
| | | entry.getObjectClassAttribute(), |
| | | entry.getAttributes(), null ); |
| | | broker.publish(addMsg); |
| | | |
| | | ModifyMsg modifyMsg = |
| | | new ModifyMsg(gen.newCSN(), DN.decode(addDn), |
| | | new ModifyMsg(gen.newCSN(), addDN, |
| | | generatemods("description", "test"), |
| | | stringUID(sequence+1)); |
| | | broker.publish(modifyMsg); |
| | |
| | | // configure and start replication of TEST_ROOT_DN_STRING on the server |
| | | SortedSet<String> replServers = new TreeSet<String>(); |
| | | replServers.add("localhost:"+replServerPort); |
| | | DomainFakeCfg domainConf = |
| | | new DomainFakeCfg(baseDn, serverId, replServers); |
| | | DomainFakeCfg domainConf = new DomainFakeCfg(baseDN, serverId, replServers); |
| | | domainConf.setHeartbeatInterval(100000); |
| | | |
| | | domain = MultimasterReplication.createNewDomain(domainConf); |
| | | domain.start(); |
| | | |
| | | // check that last entry in sequence got added. |
| | | Entry lastEntry = getEntry(DN.decode(addDn), 30000, true); |
| | | Entry lastEntry = getEntry(addDN, 30000, true); |
| | | assertNotNull(lastEntry, |
| | | "The last entry of the ADD sequence was not added."); |
| | | |
| | | // Check that all the modify have been replayed |
| | | // (all the entries should have a description). |
| | | addDn = TEST_ROOT_DN_STRING; |
| | | addDN = TEST_ROOT_DN; |
| | | for (sequence = 1; sequence<=AddSequenceLength; sequence ++) |
| | | { |
| | | addDn = "dc=dependency" + sequence + "," + addDn; |
| | | addDN = DN.decode("dc=dependency" + sequence + "," + addDN); |
| | | |
| | | boolean found = |
| | | checkEntryHasAttribute(DN.decode(addDn), "description", "test", |
| | | 10000, true); |
| | | if (!found) |
| | | { |
| | | fail("The modification was not replayed on entry " + addDn); |
| | | } |
| | | boolean found = checkEntryHasAttribute(addDN, "description", "test", 10000, true); |
| | | assertTrue(found, "The modification was not replayed on entry " + addDN); |
| | | } |
| | | |
| | | /* |
| | |
| | | Thread.sleep(2000); // necesary because disable does not wait |
| | | // for full termination of all threads. (issue 1571) |
| | | |
| | | DN deleteDN = DN.decode(addDn); |
| | | DN deleteDN = addDN; |
| | | while (sequence-->1) |
| | | { |
| | | DeleteMsg delMsg = new DeleteMsg(deleteDN.toString(), |
| | | gen.newCSN(), |
| | | stringUID(sequence + 1)); |
| | | DeleteMsg delMsg = new DeleteMsg(deleteDN, gen.newCSN(), stringUID(sequence + 1)); |
| | | broker.publish(delMsg); |
| | | deleteDN = deleteDN.getParent(); |
| | | } |
| | |
| | | { |
| | | remove(replServer); |
| | | if (domain != null) |
| | | MultimasterReplication.deleteDomain(baseDn); |
| | | MultimasterReplication.deleteDomain(baseDN); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | ReplicationServer replServer = null; |
| | | LDAPReplicationDomain domain = null; |
| | | DN baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | DN baseDN = TEST_ROOT_DN; |
| | | int brokerId = 2; |
| | | int serverId = 1; |
| | | int replServerId = 82; |
| | |
| | | // configure and start replication of TEST_ROOT_DN_STRING on the server |
| | | SortedSet<String> replServers = new TreeSet<String>(); |
| | | replServers.add("localhost:"+replServerPort); |
| | | DomainFakeCfg domainConf = |
| | | new DomainFakeCfg(baseDn, serverId, replServers); |
| | | DomainFakeCfg domainConf = new DomainFakeCfg(baseDN, serverId, replServers); |
| | | domainConf.setHeartbeatInterval(100000); |
| | | |
| | | Thread.sleep(2000); |
| | |
| | | domain.start(); |
| | | |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, brokerId, 1000, replServerPort, 1000, |
| | | openReplicationSession(baseDN, brokerId, 1000, replServerPort, 1000, |
| | | false, CLEAN_DB_GENERATION_ID); |
| | | |
| | | // add an entry to play with. |
| | |
| | | entry.addAttribute(Attributes.create("entryuuid", |
| | | stringUID(renamedEntryUuid)), |
| | | new LinkedList<AttributeValue>()); |
| | | String addDn = "dc=moddndel" + "," + TEST_ROOT_DN_STRING; |
| | | DN addDN = DN.decode("dc=moddndel" + "," + TEST_ROOT_DN_STRING); |
| | | AddMsg addMsg = |
| | | new AddMsg(gen.newCSN(), addDn, stringUID(renamedEntryUuid), |
| | | new AddMsg(gen.newCSN(), addDN, stringUID(renamedEntryUuid), |
| | | stringUID(1), |
| | | entry.getObjectClassAttribute(), |
| | | entry.getAttributes(), null ); |
| | |
| | | broker.publish(addMsg); |
| | | |
| | | // check that the entry was correctly added |
| | | boolean found = |
| | | checkEntryHasAttribute(DN.decode(addDn), "entryuuid", |
| | | stringUID(renamedEntryUuid), |
| | | 30000, true); |
| | | |
| | | boolean found = checkEntryHasAttribute(addDN, "entryuuid", stringUID(renamedEntryUuid), 30000, true); |
| | | assertTrue(found, "The initial entry add failed"); |
| | | |
| | | |
| | |
| | | |
| | | // rename and delete the entry. |
| | | ModifyDNMsg moddnMsg = |
| | | new ModifyDNMsg(addDn, gen.newCSN(), |
| | | new ModifyDNMsg(addDN, gen.newCSN(), |
| | | stringUID(renamedEntryUuid), |
| | | stringUID(1), true, null, "dc=new_name"); |
| | | broker.publish(moddnMsg); |
| | | DeleteMsg delMsg = |
| | | new DeleteMsg("dc=new_name" + "," + TEST_ROOT_DN_STRING, |
| | | new DeleteMsg(DN.decode("dc=new_name" + "," + TEST_ROOT_DN_STRING), |
| | | gen.newCSN(), stringUID(renamedEntryUuid)); |
| | | broker.publish(delMsg); |
| | | |
| | |
| | | { |
| | | remove(replServer); |
| | | if (domain != null) |
| | | MultimasterReplication.deleteDomain(baseDn); |
| | | MultimasterReplication.deleteDomain(baseDN); |
| | | } |
| | | } |
| | | |
| | | |
| | | private final long CLEAN_DB_GENERATION_ID = 7883L; |
| | | /** |
| | | * Clean the database and replace with a single entry. |
| | | * |
| | |
| | | { |
| | | ReplicationServer replServer = null; |
| | | LDAPReplicationDomain domain = null; |
| | | DN baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | DN baseDN = TEST_ROOT_DN; |
| | | int brokerId = 2; |
| | | int serverId = 1; |
| | | int replServerId = 83; |
| | |
| | | replServer = new ReplicationServer(conf); |
| | | |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, brokerId, 100, replServerPort, 1000, |
| | | openReplicationSession(baseDN, brokerId, 100, replServerPort, 1000, |
| | | false, CLEAN_DB_GENERATION_ID); |
| | | |
| | | // send a sequence of add/del/add operations |
| | |
| | | entry.removeAttribute(uidType); |
| | | entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1)), |
| | | new LinkedList<AttributeValue>()); |
| | | String addDn = "dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING; |
| | | DN addDN = DN.decode("dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING); |
| | | AddMsg addMsg = |
| | | new AddMsg(gen.newCSN(), addDn, stringUID(sequence+1), |
| | | new AddMsg(gen.newCSN(), addDN, stringUID(sequence+1), |
| | | stringUID(1), |
| | | entry.getObjectClassAttribute(), |
| | | entry.getAttributes(), null ); |
| | | broker.publish(addMsg); |
| | | |
| | | // delete the entry |
| | | DeleteMsg delMsg = new DeleteMsg(addDn, gen.newCSN(), |
| | | DeleteMsg delMsg = new DeleteMsg(addDN, gen.newCSN(), |
| | | stringUID(sequence+1)); |
| | | broker.publish(delMsg); |
| | | |
| | |
| | | entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1025)), |
| | | new LinkedList<AttributeValue>()); |
| | | addMsg = |
| | | new AddMsg(gen.newCSN(), addDn, stringUID(sequence+1025), |
| | | new AddMsg(gen.newCSN(), addDN, stringUID(sequence+1025), |
| | | stringUID(1), |
| | | entry.getObjectClassAttribute(), |
| | | entry.getAttributes(), null ); |
| | |
| | | // configure and start replication of TEST_ROOT_DN_STRING on the server |
| | | SortedSet<String> replServers = new TreeSet<String>(); |
| | | replServers.add("localhost:"+replServerPort); |
| | | DomainFakeCfg domainConf = |
| | | new DomainFakeCfg(baseDn, serverId, replServers); |
| | | |
| | | DomainFakeCfg domainConf = new DomainFakeCfg(baseDN, serverId, replServers); |
| | | domain = MultimasterReplication.createNewDomain(domainConf); |
| | | domain.start(); |
| | | |
| | |
| | | |
| | | for (sequence = 1; sequence<=AddSequenceLength; sequence ++) |
| | | { |
| | | String deleteDN = "dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING; |
| | | DN deleteDN = DN.decode("dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING); |
| | | DeleteMsg delMsg = new DeleteMsg(deleteDN, |
| | | gen.newCSN(), |
| | | stringUID(sequence + 1025)); |
| | |
| | | { |
| | | remove(replServer); |
| | | if (domain != null) |
| | | MultimasterReplication.deleteDomain(baseDn); |
| | | MultimasterReplication.deleteDomain(baseDN); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | ReplicationServer replServer = null; |
| | | LDAPReplicationDomain domain = null; |
| | | DN baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | DN baseDN = TEST_ROOT_DN; |
| | | int brokerId = 2; |
| | | int serverId = 1; |
| | | int replServerId = 84; |
| | |
| | | replServer = new ReplicationServer(conf); |
| | | |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, brokerId, 100, replServerPort, 1000, |
| | | openReplicationSession(baseDN, brokerId, 100, replServerPort, 1000, |
| | | false, CLEAN_DB_GENERATION_ID); |
| | | |
| | | |
| | | String addDn = TEST_ROOT_DN_STRING; |
| | | DN addDN = TEST_ROOT_DN; |
| | | CSNGenerator gen = new CSNGenerator(brokerId, 0L); |
| | | |
| | | // send a sequence of add/modrdn operations |
| | |
| | | entry.removeAttribute(uidType); |
| | | entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1)), |
| | | new LinkedList<AttributeValue>()); |
| | | addDn = "dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING; |
| | | addDN = DN.decode("dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING); |
| | | AddMsg addMsg = |
| | | new AddMsg(gen.newCSN(), addDn, stringUID(sequence+1), |
| | | new AddMsg(gen.newCSN(), addDN, stringUID(sequence+1), |
| | | stringUID(1), |
| | | entry.getObjectClassAttribute(), |
| | | entry.getAttributes(), null ); |
| | |
| | | |
| | | // rename the entry |
| | | ModifyDNMsg moddnMsg = |
| | | new ModifyDNMsg(addDn, gen.newCSN(), stringUID(sequence+1), |
| | | new ModifyDNMsg(addDN, gen.newCSN(), stringUID(sequence+1), |
| | | stringUID(1), true, null, "dc=new_dep" + sequence); |
| | | broker.publish(moddnMsg); |
| | | } |
| | |
| | | // configure and start replication of TEST_ROOT_DN_STRING on the server |
| | | SortedSet<String> replServers = new TreeSet<String>(); |
| | | replServers.add("localhost:"+replServerPort); |
| | | DomainFakeCfg domainConf = |
| | | new DomainFakeCfg(baseDn, serverId, replServers); |
| | | |
| | | DomainFakeCfg domainConf = new DomainFakeCfg(baseDN, serverId, replServers); |
| | | domain = MultimasterReplication.createNewDomain(domainConf); |
| | | domain.start(); |
| | | |
| | | // check that all entries have been renamed |
| | | for (sequence = 1; sequence<=AddSequenceLength; sequence ++) |
| | | { |
| | | addDn = "dc=new_dep" + sequence + "," + TEST_ROOT_DN_STRING; |
| | | |
| | | Entry baseEntry = getEntry(DN.decode(addDn), 30000, true); |
| | | addDN = DN.decode("dc=new_dep" + sequence + "," + TEST_ROOT_DN_STRING); |
| | | Entry baseEntry = getEntry(addDN, 30000, true); |
| | | assertNotNull(baseEntry, |
| | | "The rename was not applied correctly on :" + addDn); |
| | | "The rename was not applied correctly on :" + addDN); |
| | | } |
| | | |
| | | // delete the entries to clean the database. |
| | | for (sequence = 1; sequence<=AddSequenceLength; sequence ++) |
| | | { |
| | | addDn = "dc=new_dep" + sequence + "," + TEST_ROOT_DN_STRING; |
| | | DeleteMsg delMsg = new DeleteMsg(addDn.toString(), |
| | | gen.newCSN(), |
| | | stringUID(sequence + 1)); |
| | | addDN = DN.decode("dc=new_dep" + sequence + "," + TEST_ROOT_DN_STRING); |
| | | DeleteMsg delMsg = new DeleteMsg(addDN, gen.newCSN(), stringUID(sequence + 1)); |
| | | broker.publish(delMsg); |
| | | } |
| | | } |
| | |
| | | { |
| | | remove(replServer); |
| | | if (domain != null) |
| | | MultimasterReplication.deleteDomain(baseDn); |
| | | MultimasterReplication.deleteDomain(baseDN); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | // Create and publish an update message to add an entry. |
| | | return new AddMsg(gen.newCSN(), |
| | | personWithUUIDEntry.getDN().toString(), |
| | | personWithUUIDEntry.getDN(), |
| | | user1entryUUID, |
| | | baseUUID, |
| | | personWithUUIDEntry.getObjectClassAttribute(), |
| | |
| | | int senderID, int destinationServerID, int requestorID) |
| | | { |
| | | RoutableMsg initTargetMessage = |
| | | new InitializeTargetMsg(EXAMPLE_DN, server2ID, destinationServerID, |
| | | new InitializeTargetMsg(baseDN, server2ID, destinationServerID, |
| | | requestorID, updatedEntries.length, initWindow); |
| | | broker.publish(initTargetMessage); |
| | | |
| | |
| | | // checks for session establishment ? |
| | | // Thread.sleep(3000); |
| | | |
| | | InitializeRequestMsg initMsg = new InitializeRequestMsg(EXAMPLE_DN, |
| | | server2ID, server1ID, 100); |
| | | InitializeRequestMsg initMsg = new InitializeRequestMsg(baseDN, server2ID, server1ID, 100); |
| | | server2.publish(initMsg); |
| | | |
| | | // Signal RS we just entered the full update status |
| | |
| | | |
| | | // S3 sends init request |
| | | log(testCase + " server 3 Will send reqinit to " + server1ID); |
| | | InitializeRequestMsg initMsg = |
| | | new InitializeRequestMsg(EXAMPLE_DN, server3ID, server1ID, 100); |
| | | InitializeRequestMsg initMsg = new InitializeRequestMsg(baseDN, server3ID, server1ID, 100); |
| | | server3.publish(initMsg); |
| | | |
| | | // S3 should receive target, entries & done |
| | |
| | | */ |
| | | package org.opends.server.replication; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.net.SocketTimeoutException; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Test the constructors, encoders and decoders of the Replication AckMsg, |
| | | * ModifyMsg, ModifyDnMsg, AddMsg and Delete MSG |
| | |
| | | |
| | | |
| | | /** the base DN used for this test */ |
| | | private DN baseDn; |
| | | private DN baseDN; |
| | | private ReplicationServer replicationServer; |
| | | |
| | | /** |
| | |
| | | "Unable to add the synchronized server"); |
| | | configEntryList.add(repDomainEntry.getDN()); |
| | | |
| | | ReplicationBroker broker = openReplicationSession(baseDn, 12, |
| | | ReplicationBroker broker = openReplicationSession(baseDN, 12, |
| | | WINDOW_SIZE, replServerPort, 1000, true); |
| | | |
| | | try { |
| | |
| | | assertTrue(OperationType.ADD.compareTo(receivedOp.getOperationType()) == 0, |
| | | "The received Replication message is not an ADD msg"); |
| | | |
| | | assertEquals(DN.decode(addMsg.getDn()),personEntry.getDN(), |
| | | assertEquals(addMsg.getDN(), personEntry.getDN(), |
| | | "The received ADD Replication message is not for the excepted DN"); |
| | | |
| | | // send (2 * window + replicationServer queue) modify operations |
| | |
| | | // This test suite depends on having the schema available. |
| | | super.setUp(); |
| | | |
| | | baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | baseDN = DN.decode(TEST_ROOT_DN_STRING); |
| | | |
| | | replServerPort = TestCaseUtils.findFreePort(); |
| | | |
| | |
| | | /** |
| | | * Utility method : removes a domain deleting the passed config entry |
| | | */ |
| | | protected void removeDomain(Entry domainCfgEntry) |
| | | protected void removeDomain(Entry... domainCfgEntries) |
| | | { |
| | | DN dn = domainCfgEntry.getDN(); |
| | | deleteEntry(dn); |
| | | for (Entry entry : domainCfgEntries) |
| | | { |
| | | if (entry != null) |
| | | { |
| | | deleteEntry(entry.getDN()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | cleanUpReplicationServersDB(); |
| | | |
| | | final DN baseDn = DN.decode("cn=schema"); |
| | | final DN baseDN = DN.decode("cn=schema"); |
| | | |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, 2, 100, replServerPort, 5000, true); |
| | | openReplicationSession(baseDN, 2, 100, replServerPort, 5000, true); |
| | | |
| | | try |
| | | { |
| | |
| | | mods.add(mod); |
| | | ModifyOperationBasis modOp = new ModifyOperationBasis(connection, |
| | | InternalClientConnection.nextOperationID(), InternalClientConnection |
| | | .nextMessageID(), null, baseDn, mods); |
| | | .nextMessageID(), null, baseDN, mods); |
| | | modOp.setInternalOperation(true); |
| | | modOp.run(); |
| | | |
| | |
| | | ModifyMsg modMsg = (ModifyMsg) msg; |
| | | |
| | | Operation receivedOp = modMsg.createOperation(connection); |
| | | assertTrue(DN.decode(modMsg.getDn()).compareTo(baseDn) == 0, |
| | | assertEquals(modMsg.getDN(), baseDN, |
| | | "The received message is not for cn=schema"); |
| | | |
| | | assertTrue(receivedOp instanceof ModifyOperation, |
| | |
| | | mods.add(mod); |
| | | modOp = new ModifyOperationBasis(connection, |
| | | InternalClientConnection.nextOperationID(), InternalClientConnection |
| | | .nextMessageID(), null, baseDn, mods); |
| | | .nextMessageID(), null, baseDN, mods); |
| | | modOp.setInternalOperation(true); |
| | | modOp.run(); |
| | | |
| | |
| | | |
| | | cleanUpReplicationServersDB(); |
| | | |
| | | final DN baseDn = DN.decode("cn=schema"); |
| | | final DN baseDN = DN.decode("cn=schema"); |
| | | |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, 2, 100, replServerPort, 5000, true); |
| | | openReplicationSession(baseDN, 2, 100, replServerPort, 5000, true); |
| | | |
| | | try |
| | | { |
| | | CSNGenerator gen = new CSNGenerator( 2, 0); |
| | | |
| | | ModifyMsg modMsg = new ModifyMsg(gen.newCSN(), baseDn, rcvdMods, |
| | | EntryHistorical.getEntryUUID(DirectoryServer.getEntry(baseDn))); |
| | | ModifyMsg modMsg = new ModifyMsg(gen.newCSN(), baseDN, rcvdMods, |
| | | EntryHistorical.getEntryUUID(DirectoryServer.getEntry(baseDN))); |
| | | broker.publish(modMsg); |
| | | |
| | | boolean found = checkEntryHasAttribute(baseDn, "attributetypes", |
| | | boolean found = checkEntryHasAttribute(baseDN, "attributetypes", |
| | | "( 2.5.44.77.33 NAME 'dummy' )", |
| | | 10000, true); |
| | | |
| | |
| | | |
| | | cleanUpReplicationServersDB(); |
| | | |
| | | final DN baseDn = DN.decode("cn=schema"); |
| | | final DN baseDN = DN.decode("cn=schema"); |
| | | |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, 3, 100, replServerPort, 5000, true); |
| | | openReplicationSession(baseDN, 3, 100, replServerPort, 5000, true); |
| | | |
| | | try |
| | | { |
| | |
| | | ModifyMsg modMsg = (ModifyMsg) msg; |
| | | |
| | | Operation receivedOp = modMsg.createOperation(connection); |
| | | assertTrue(DN.decode(modMsg.getDn()).compareTo(baseDn) == 0, |
| | | assertEquals(modMsg.getDN(), baseDN, |
| | | "The received message is not for cn=schema"); |
| | | |
| | | assertTrue(receivedOp instanceof ModifyOperation, |
| | |
| | | */ |
| | | package org.opends.server.replication; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Stress test for the synchronization code using the ReplicationBroker API. |
| | | */ |
| | |
| | | logError(Message.raw(Category.SYNC, Severity.NOTICE, |
| | | "Starting replication StressTest : fromServertoBroker")); |
| | | |
| | | final DN baseDn = DN.decode("ou=People," + TEST_ROOT_DN_STRING); |
| | | final DN baseDN = DN.decode("ou=People," + TEST_ROOT_DN_STRING); |
| | | final int TOTAL_MESSAGES = 1000; |
| | | |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, 18, 100, replServerPort, 5000, true); |
| | | openReplicationSession(baseDN, 18, 100, replServerPort, 5000, true); |
| | | Monitor monitor = new Monitor(); |
| | | DirectoryServer.registerMonitorProvider(monitor); |
| | | |
| | |
| | | assertTrue(OperationType.ADD.compareTo(receivedOp.getOperationType()) == 0, |
| | | "The received replication message is not an ADD msg"); |
| | | |
| | | assertEquals(DN.decode(addMsg.getDn()),personEntry.getDN(), |
| | | assertEquals(addMsg.getDN(), personEntry.getDN(), |
| | | "The received ADD replication message is not for the excepted DN"); |
| | | } |
| | | |
| | |
| | | private Entry personWithSecondUniqueID; |
| | | |
| | | private Entry user3Entry; |
| | | private String user3dn; |
| | | private DN user3dn; |
| | | private String user3UUID; |
| | | |
| | | private String baseUUID; |
| | | |
| | | private String user1dn; |
| | | private DN user1dn; |
| | | private String user1entrysecondUUID; |
| | | private String user1entryUUID; |
| | | |
| | |
| | | private String domain1uid; |
| | | private String domain2uid; |
| | | private String domain3uid; |
| | | private String domain1dn; |
| | | private String domain2dn; |
| | | private String domain3dn; |
| | | private DN domain1dn; |
| | | private DN domain2dn; |
| | | private DN domain3dn; |
| | | private Entry domain1; |
| | | private Entry domain2; |
| | | private Entry domain3; |
| | |
| | | */ |
| | | user1entryUUID = "33333333-3333-3333-3333-333333333333"; |
| | | user1entrysecondUUID = "22222222-2222-2222-2222-222222222222"; |
| | | user1dn = "uid=user1,ou=People," + TEST_ROOT_DN_STRING; |
| | | user1dn = DN.decode("uid=user1,ou=People," + TEST_ROOT_DN_STRING); |
| | | String entryWithUUIDldif = "dn: "+ user1dn + "\n" |
| | | + "objectClass: top\n" + "objectClass: person\n" |
| | | + "objectClass: organizationalPerson\n" |
| | |
| | | TestCaseUtils.entryFromLdifString(entryWithSecondUUID); |
| | | |
| | | user3UUID = "44444444-4444-4444-4444-444444444444"; |
| | | user3dn = "uid=user3,ou=People," + TEST_ROOT_DN_STRING; |
| | | user3dn = DN.decode("uid=user3,ou=People," + TEST_ROOT_DN_STRING); |
| | | String user3LDIFEntry = "dn: "+ user3dn + "\n" |
| | | + "objectClass: top\n" + "objectClass: person\n" |
| | | + "objectClass: organizationalPerson\n" |
| | |
| | | + "entryUUID: " + user3UUID + "\n"; |
| | | user3Entry = TestCaseUtils.entryFromLdifString(user3LDIFEntry); |
| | | |
| | | domain1dn = "dc=domain1,ou=People," + TEST_ROOT_DN_STRING; |
| | | domain2dn = "dc=domain2,dc=domain1,ou=People," + TEST_ROOT_DN_STRING; |
| | | domain3dn = "dc=domain3,dc=domain1,ou=People," + TEST_ROOT_DN_STRING; |
| | | domain1dn = DN.decode("dc=domain1,ou=People," + TEST_ROOT_DN_STRING); |
| | | domain2dn = DN.decode("dc=domain2,dc=domain1,ou=People," + TEST_ROOT_DN_STRING); |
| | | domain3dn = DN.decode("dc=domain3,dc=domain1,ou=People," + TEST_ROOT_DN_STRING); |
| | | domain1 = TestCaseUtils.entryFromLdifString( |
| | | "dn:" + domain1dn + "\n" |
| | | + "objectClass:domain\n" |
| | |
| | | // Clean replication server database from previous run |
| | | cleanUpReplicationServersDB(); |
| | | |
| | | final DN baseDn = DN.decode("ou=People," + TEST_ROOT_DN_STRING); |
| | | final DN baseDN = DN.decode("ou=People," + TEST_ROOT_DN_STRING); |
| | | |
| | | /* |
| | | * Open a session to the replicationServer using the broker API. |
| | | * This must use a different serverId to that of the directory server. |
| | | */ |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, 2, 100, replServerPort, 1000, true); |
| | | |
| | | openReplicationSession(baseDN, 2, 100, replServerPort, 1000, true); |
| | | |
| | | try |
| | | { |
| | |
| | | |
| | | |
| | | // Disable the directory server receive status. |
| | | setReceiveStatus(synchroServerEntry.getDN().toString(), false); |
| | | setReceiveStatus(synchroServerEntry.getDN(), false); |
| | | |
| | | |
| | | // Create and publish an update message to add an entry. |
| | | AddMsg addMsg = new AddMsg(gen.newCSN(), |
| | | personWithUUIDEntry.getDN().toString(), |
| | | personWithUUIDEntry.getDN(), |
| | | user1entryUUID, |
| | | baseUUID, |
| | | personWithUUIDEntry.getObjectClassAttribute(), |
| | |
| | | + "receive status was disabled"); |
| | | |
| | | // Enable the directory server receive status. |
| | | setReceiveStatus(synchroServerEntry.getDN().toString(), true); |
| | | setReceiveStatus(synchroServerEntry.getDN(), true); |
| | | |
| | | // Create and publish another update message to add an entry. |
| | | addMsg = new AddMsg(gen.newCSN(), |
| | | personWithUUIDEntry.getDN().toString(), |
| | | personWithUUIDEntry.getDN(), |
| | | user1entryUUID, |
| | | baseUUID, |
| | | personWithUUIDEntry.getObjectClassAttribute(), |
| | |
| | | |
| | | // Delete the entries to clean the database. |
| | | DeleteMsg delMsg = |
| | | new DeleteMsg(personWithUUIDEntry.getDN().toString(), |
| | | new DeleteMsg(personWithUUIDEntry.getDN(), |
| | | gen.newCSN(), user1entryUUID); |
| | | broker.publish(delMsg); |
| | | resultEntry = getEntry(personWithUUIDEntry.getDN(), 10000, false); |
| | |
| | | // Clean replication server database from previous run |
| | | cleanUpReplicationServersDB(); |
| | | |
| | | final DN baseDn = DN.decode("ou=People," + TEST_ROOT_DN_STRING); |
| | | final DN baseDN = DN.decode("ou=People," + TEST_ROOT_DN_STRING); |
| | | |
| | | /* |
| | | * Open a session to the replicationServer using the broker API. |
| | | * This must use a different serverId to that of the directory server. |
| | | */ |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, 2, 100, replServerPort, 1000, true); |
| | | openReplicationSession(baseDN, 2, 100, replServerPort, 1000, true); |
| | | |
| | | try |
| | | { |
| | |
| | | |
| | | // Create and publish an update message to add an entry. |
| | | AddMsg addMsg = new AddMsg(gen.newCSN(), |
| | | personWithUUIDEntry.getDN().toString(), |
| | | personWithUUIDEntry.getDN(), |
| | | user1entryUUID, |
| | | baseUUID, |
| | | personWithUUIDEntry.getObjectClassAttribute(), |
| | |
| | | } |
| | | |
| | | // Delete the entries to clean the database. |
| | | DeleteMsg delMsg = |
| | | new DeleteMsg(personWithUUIDEntry.getDN().toString(), |
| | | gen.newCSN(), user1entryUUID); |
| | | DeleteMsg delMsg = new DeleteMsg(personWithUUIDEntry.getDN(), gen.newCSN(), user1entryUUID); |
| | | broker.publish(delMsg); |
| | | resultEntry = getEntry(personWithUUIDEntry.getDN(), 10000, false); |
| | | |
| | |
| | | public void modifyConflicts() |
| | | throws Exception |
| | | { |
| | | final DN baseDn = DN.decode("ou=People," + TEST_ROOT_DN_STRING); |
| | | final DN dn1 = DN.decode("cn=test1," + baseDn.toString()); |
| | | final DN baseDN = DN.decode("ou=People," + TEST_ROOT_DN_STRING); |
| | | final DN dn1 = DN.decode("cn=test1," + baseDN.toString()); |
| | | final AttributeType attrType = |
| | | DirectoryServer.getAttributeType("displayname"); |
| | | final AttributeType entryuuidType = |
| | |
| | | * This must use a different serverId to that of the directory server. |
| | | */ |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, 2, 100, replServerPort, 1000, true); |
| | | openReplicationSession(baseDN, 2, 100, replServerPort, 1000, true); |
| | | |
| | | try |
| | | { |
| | | // Add the first test entry. |
| | | TestCaseUtils.addEntry( |
| | | "dn: cn=test1," + baseDn.toString(), |
| | | "dn: cn=test1," + baseDN.toString(), |
| | | "displayname: Test1", |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | |
| | | CSN t2 = new CSN(changeTime, 0, 4); |
| | | |
| | | // Simulate the ordering t2:replace:B followed by t1:add:A that |
| | | updateMonitorCount(baseDn, monitorAttr); |
| | | updateMonitorCount(baseDN, monitorAttr); |
| | | |
| | | // Replay a replace of a value B at time t2 on a second server. |
| | | Attribute attr = Attributes.create(attrType, "B"); |
| | |
| | | t2 = new CSN(changeTime, 0, 4); |
| | | |
| | | // Simulate the ordering t2:delete:displayname followed by t1:replace:A |
| | | updateMonitorCount(baseDn, monitorAttr); |
| | | updateMonitorCount(baseDN, monitorAttr); |
| | | |
| | | // Replay an delete of attribute displayname at time t2 on a second server. |
| | | attr = Attributes.empty(attrType); |
| | |
| | | logError(Message.raw(Category.SYNC, Severity.INFORMATION, |
| | | "Starting replication test : namingConflicts")); |
| | | |
| | | final DN baseDn = DN.decode("ou=People," + TEST_ROOT_DN_STRING); |
| | | final DN baseDN = DN.decode("ou=People," + TEST_ROOT_DN_STRING); |
| | | String resolvedMonitorAttr = "resolved-naming-conflicts"; |
| | | String unresolvedMonitorAttr = "unresolved-naming-conflicts"; |
| | | |
| | |
| | | * This must use a serverId different from the LDAP server ID |
| | | */ |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, 2, 100, replServerPort, 1000, true); |
| | | openReplicationSession(baseDN, 2, 100, replServerPort, 1000, true); |
| | | |
| | | try |
| | | { |
| | |
| | | */ |
| | | // create the entry with a given DN |
| | | AddMsg addMsg = new AddMsg(gen.newCSN(), |
| | | personWithUUIDEntry.getDN().toString(), |
| | | personWithUUIDEntry.getDN(), |
| | | user1entryUUID, |
| | | baseUUID, |
| | | personWithUUIDEntry.getObjectClassAttribute(), |
| | |
| | | ModifyMsg modMsg = new ModifyMsg(gen.newCSN(), |
| | | DN.decode("cn=something,ou=People," + TEST_ROOT_DN_STRING), mods, |
| | | user1entryUUID); |
| | | updateMonitorCount(baseDn, resolvedMonitorAttr); |
| | | updateMonitorCount(baseDN, resolvedMonitorAttr); |
| | | int AlertCount = DummyAlertHandler.getAlertCount(); |
| | | broker.publish(modMsg); |
| | | |
| | |
| | | personWithUUIDEntry.getDN(), mods, |
| | | user1entryUUID); |
| | | |
| | | updateMonitorCount(baseDn, resolvedMonitorAttr); |
| | | updateMonitorCount(baseDN, resolvedMonitorAttr); |
| | | AlertCount = DummyAlertHandler.getAlertCount(); |
| | | broker.publish(modMsg); |
| | | |
| | |
| | | |
| | | // create the entry with a given DN and unique ID |
| | | addMsg = new AddMsg(gen.newCSN(), |
| | | personWithUUIDEntry.getDN().toString(), |
| | | personWithUUIDEntry.getDN(), |
| | | user1entryUUID, baseUUID, |
| | | personWithUUIDEntry.getObjectClassAttribute(), |
| | | personWithUUIDEntry.getAttributes(), new ArrayList<Attribute>()); |
| | |
| | | // send a modify operation with a wrong unique ID but the same DN |
| | | mods = generatemods("telephonenumber", "02 01 03 05"); |
| | | modMsg = new ModifyMsg(gen.newCSN(), |
| | | DN.decode(user1dn), mods, "10000000-9abc-def0-1234-1234567890ab"); |
| | | updateMonitorCount(baseDn, resolvedMonitorAttr); |
| | | user1dn, mods, "10000000-9abc-def0-1234-1234567890ab"); |
| | | updateMonitorCount(baseDN, resolvedMonitorAttr); |
| | | AlertCount = DummyAlertHandler.getAlertCount(); |
| | | broker.publish(modMsg); |
| | | |
| | |
| | | */ |
| | | // send a delete operation with a wrong dn but the unique ID of the entry |
| | | // used above |
| | | DeleteMsg delMsg = |
| | | new DeleteMsg("cn=anotherdn,ou=People," + TEST_ROOT_DN_STRING, |
| | | gen.newCSN(), user1entryUUID); |
| | | updateMonitorCount(baseDn, resolvedMonitorAttr); |
| | | DN delDN = DN.decode("cn=anotherdn,ou=People," + TEST_ROOT_DN_STRING); |
| | | DeleteMsg delMsg = new DeleteMsg(delDN, gen.newCSN(), user1entryUUID); |
| | | updateMonitorCount(baseDN, resolvedMonitorAttr); |
| | | AlertCount = DummyAlertHandler.getAlertCount(); |
| | | broker.publish(delMsg); |
| | | |
| | |
| | | |
| | | // create an entry with a given DN and unique ID |
| | | addMsg = new AddMsg(gen.newCSN(), |
| | | personWithUUIDEntry.getDN().toString(), |
| | | personWithUUIDEntry.getDN(), |
| | | user1entryUUID, baseUUID, |
| | | personWithUUIDEntry.getObjectClassAttribute(), |
| | | personWithUUIDEntry.getAttributes(), new ArrayList<Attribute>()); |
| | |
| | | |
| | | // create an entry with the same DN and another unique ID |
| | | addMsg = new AddMsg(gen.newCSN(), |
| | | personWithSecondUniqueID.getDN().toString(), |
| | | personWithSecondUniqueID.getDN(), |
| | | user1entrysecondUUID, baseUUID, |
| | | personWithSecondUniqueID.getObjectClassAttribute(), |
| | | personWithSecondUniqueID.getAttributes(), new ArrayList<Attribute>()); |
| | | updateMonitorCount(baseDn, unresolvedMonitorAttr); |
| | | updateMonitorCount(baseDN, unresolvedMonitorAttr); |
| | | AlertCount = DummyAlertHandler.getAlertCount(); |
| | | broker.publish(addMsg); |
| | | |
| | |
| | | |
| | | |
| | | // delete the entries to clean the database. |
| | | delMsg = |
| | | new DeleteMsg(personWithUUIDEntry.getDN().toString(), |
| | | gen.newCSN(), user1entryUUID); |
| | | delMsg = new DeleteMsg(personWithUUIDEntry.getDN(), gen.newCSN(), user1entryUUID); |
| | | broker.publish(delMsg); |
| | | delMsg = |
| | | new DeleteMsg(personWithSecondUniqueID.getDN().toString(), |
| | | gen.newCSN(), user1entrysecondUUID); |
| | | delMsg = new DeleteMsg(personWithSecondUniqueID.getDN(), gen.newCSN(), user1entrysecondUUID); |
| | | broker.publish(delMsg); |
| | | resultEntry = getEntry(personWithUUIDEntry.getDN(), 10000, false); |
| | | resultEntry = getEntry(personWithSecondUniqueID.getDN(), 10000, false); |
| | |
| | | * Simulate this by trying to add an entry below a DN that does not |
| | | * exist but with a parent ID that exist. |
| | | */ |
| | | String addDN = "uid=new person,o=nothere,o=below,ou=People," + TEST_ROOT_DN_STRING; |
| | | addMsg = new AddMsg(gen.newCSN(), |
| | | "uid=new person,o=nothere,o=below,ou=People," + TEST_ROOT_DN_STRING, |
| | | DN.decode(addDN), |
| | | user1entryUUID, |
| | | baseUUID, |
| | | personWithUUIDEntry.getObjectClassAttribute(), |
| | | personWithUUIDEntry.getAttributes(), new ArrayList<Attribute>()); |
| | | updateMonitorCount(baseDn, resolvedMonitorAttr); |
| | | updateMonitorCount(baseDN, resolvedMonitorAttr); |
| | | AlertCount = DummyAlertHandler.getAlertCount(); |
| | | broker.publish(addMsg); |
| | | |
| | | // Check that the entry has been created in the local DS. |
| | | resultEntry = getEntry( |
| | | DN.decode("uid=new person,ou=People," + TEST_ROOT_DN_STRING), 10000, true); |
| | | DN newPersonDN = DN.decode("uid=new person,ou=People," + TEST_ROOT_DN_STRING); |
| | | resultEntry = getEntry(newPersonDN, 10000, true); |
| | | assertNotNull(resultEntry, |
| | | "The ADD replication message was not applied"); |
| | | assertEquals(getMonitorDelta(), 1); |
| | |
| | | * To achieve this send a delete operation with a correct DN |
| | | * but a wrong unique ID. |
| | | */ |
| | | |
| | | delMsg = |
| | | new DeleteMsg("uid=new person,ou=People," + TEST_ROOT_DN_STRING, |
| | | gen.newCSN(), "11111111-9abc-def0-1234-1234567890ab"); |
| | | updateMonitorCount(baseDn, resolvedMonitorAttr); |
| | | delMsg = new DeleteMsg(newPersonDN, gen.newCSN(), "11111111-9abc-def0-1234-1234567890ab"); |
| | | updateMonitorCount(baseDN, resolvedMonitorAttr); |
| | | AlertCount = DummyAlertHandler.getAlertCount(); |
| | | broker.publish(delMsg); |
| | | resultEntry = getEntry( |
| | | DN.decode("uid=new person,ou=People," + TEST_ROOT_DN_STRING), 10000, true); |
| | | resultEntry = getEntry(newPersonDN, 10000, true); |
| | | |
| | | // check that the delete operation has not been applied |
| | | assertNotNull(resultEntry, |
| | |
| | | */ |
| | | |
| | | ModifyDNMsg modDnMsg = new ModifyDNMsg( |
| | | "uid=new person,ou=People," + TEST_ROOT_DN_STRING, gen.newCSN(), |
| | | newPersonDN, gen.newCSN(), |
| | | user1entryUUID, baseUUID, false, |
| | | "uid=wrong, ou=people," + TEST_ROOT_DN_STRING, |
| | | "uid=newrdn"); |
| | | updateMonitorCount(baseDn, resolvedMonitorAttr); |
| | | updateMonitorCount(baseDN, resolvedMonitorAttr); |
| | | AlertCount = DummyAlertHandler.getAlertCount(); |
| | | broker.publish(modDnMsg); |
| | | |
| | |
| | | * same test but by giving a bad entry DN |
| | | */ |
| | | |
| | | modDnMsg = new ModifyDNMsg( |
| | | "uid=wrong,ou=People," + TEST_ROOT_DN_STRING, gen.newCSN(), |
| | | DN modDN = DN.decode("uid=wrong,ou=People," + TEST_ROOT_DN_STRING); |
| | | modDnMsg = new ModifyDNMsg(modDN, gen.newCSN(), |
| | | user1entryUUID, null, false, null, "uid=reallynewrdn"); |
| | | updateMonitorCount(baseDn, resolvedMonitorAttr); |
| | | updateMonitorCount(baseDN, resolvedMonitorAttr); |
| | | AlertCount = DummyAlertHandler.getAlertCount(); |
| | | broker.publish(modDnMsg); |
| | | |
| | | resultEntry = getEntry( |
| | | DN.decode("uid=reallynewrdn,ou=People," + TEST_ROOT_DN_STRING), 10000, true); |
| | | DN reallyNewDN = DN.decode("uid=reallynewrdn,ou=People," + TEST_ROOT_DN_STRING); |
| | | resultEntry = getEntry(reallyNewDN, 10000, true); |
| | | |
| | | // check that the operation has been correctly relayed |
| | | assertNotNull(resultEntry, |
| | |
| | | broker.publish(addMsg); |
| | | |
| | | // check that the second entry has been added |
| | | resultEntry = getEntry(DN.decode(user1dn), 10000, true); |
| | | resultEntry = getEntry(user1dn, 10000, true); |
| | | |
| | | // check that the add operation has been applied |
| | | assertNotNull(resultEntry, "The add operation was not replayed"); |
| | |
| | | // try to rename the first entry |
| | | modDnMsg = new ModifyDNMsg(user1dn, gen.newCSN(), |
| | | user1entrysecondUUID, baseUUID, false, |
| | | baseDn.toString(), "uid=reallynewrdn"); |
| | | updateMonitorCount(baseDn, unresolvedMonitorAttr); |
| | | baseDN.toString(), "uid=reallynewrdn"); |
| | | updateMonitorCount(baseDN, unresolvedMonitorAttr); |
| | | AlertCount = DummyAlertHandler.getAlertCount(); |
| | | broker.publish(modDnMsg); |
| | | |
| | |
| | | |
| | | |
| | | // delete the entries to clean the database |
| | | delMsg = |
| | | new DeleteMsg("entryUUID = " + user1entrysecondUUID + "+" + |
| | | DN.decode(user1dn).getRDN().toString() + |
| | | ",ou=People," + TEST_ROOT_DN_STRING, |
| | | gen.newCSN(), user1entrysecondUUID); |
| | | DN delDN2 = DN.decode("entryUUID = " + user1entrysecondUUID + "+" |
| | | + user1dn.getRDN() + ",ou=People," + TEST_ROOT_DN_STRING); |
| | | delMsg = new DeleteMsg(delDN2, gen.newCSN(), user1entrysecondUUID); |
| | | broker.publish(delMsg); |
| | | resultEntry = getEntry( |
| | | DN.decode("entryUUID = " + user1entrysecondUUID + "+" + |
| | | DN.decode(user1dn).getRDN().toString() + |
| | | ",ou=People," + TEST_ROOT_DN_STRING), 10000, false); |
| | | resultEntry = getEntry(delDN2, 10000, false); |
| | | |
| | | // check that the delete operation has been applied |
| | | assertNull(resultEntry, |
| | | "The DELETE replication message was not replayed"); |
| | | |
| | | delMsg = |
| | | new DeleteMsg("uid=reallynewrdn,ou=People," + TEST_ROOT_DN_STRING, |
| | | gen.newCSN(), user1entryUUID); |
| | | delMsg = new DeleteMsg(reallyNewDN, gen.newCSN(), user1entryUUID); |
| | | broker.publish(delMsg); |
| | | resultEntry = getEntry( |
| | | DN.decode("uid=reallynewrdn,ou=People," + TEST_ROOT_DN_STRING), 10000, false); |
| | | resultEntry = getEntry(reallyNewDN, 10000, false); |
| | | |
| | | // check that the delete operation has been applied |
| | | assertNull(resultEntry, |
| | |
| | | */ |
| | | |
| | | // - create parent entry 1 with baseDn1 |
| | | String[] topEntries = new String[1]; |
| | | topEntries[0] = "dn: ou=baseDn1,"+baseDn+"\n" + "objectClass: top\n" |
| | | String[] topEntries = new String[]{ |
| | | "dn: ou=baseDn1,"+baseDN+"\n" + "objectClass: top\n" |
| | | + "objectClass: organizationalUnit\n" |
| | | + "entryUUID: 55555555-5555-5555-5555-555555555555\n"; |
| | | Entry entry; |
| | | + "entryUUID: 55555555-5555-5555-5555-555555555555\n"}; |
| | | for (String entryStr : topEntries) |
| | | { |
| | | entry = TestCaseUtils.entryFromLdifString(entryStr); |
| | | Entry entry = TestCaseUtils.entryFromLdifString(entryStr); |
| | | AddOperationBasis addOp = new AddOperationBasis(connection, |
| | | InternalClientConnection.nextOperationID(), InternalClientConnection |
| | | .nextMessageID(), null, entry.getDN(), entry.getObjectClasses(), |
| | |
| | | addOp.setInternalOperation(true); |
| | | addOp.run(); |
| | | } |
| | | resultEntry = getEntry( |
| | | DN.decode("ou=baseDn1,"+baseDn), 10000, true); |
| | | assertNotNull(resultEntry, |
| | | "Entry not added: ou=baseDn1,"+baseDn); |
| | | resultEntry = getEntry(DN.decode("ou=baseDn1," + baseDN), 10000, true); |
| | | assertNotNull(resultEntry, "Entry not added: ou=baseDn1," + baseDN); |
| | | |
| | | // - create Add Msg for user1 with parent entry 1 UUID |
| | | DN newPersonDN2 = DN.decode("uid=new person,ou=baseDn1," + baseDN); |
| | | addMsg = new AddMsg(gen.newCSN(), |
| | | "uid=new person,ou=baseDn1,"+baseDn, |
| | | newPersonDN2, |
| | | user1entryUUID, |
| | | getEntryUUID(DN.decode("ou=baseDn1,"+baseDn)), |
| | | getEntryUUID(DN.decode("ou=baseDn1," + baseDN)), |
| | | personWithUUIDEntry.getObjectClassAttribute(), |
| | | personWithUUIDEntry.getAttributes(), new ArrayList<Attribute>()); |
| | | |
| | |
| | | ModifyDNOperationBasis modDNOp = new ModifyDNOperationBasis(connection, |
| | | InternalClientConnection.nextOperationID(), InternalClientConnection |
| | | .nextMessageID(), null, |
| | | DN.decode("ou=baseDn1,"+baseDn), |
| | | DN.decode("ou=baseDN1," + baseDN), |
| | | RDN.decode("ou=baseDn2"), true, |
| | | baseDn); |
| | | baseDN); |
| | | modDNOp.run(); |
| | | |
| | | resultEntry = getEntry( |
| | | DN.decode("ou=baseDn2,"+baseDn), 10000, true); |
| | | resultEntry = getEntry(DN.decode("ou=baseDn2," + baseDN), 10000, true); |
| | | assertNotNull(resultEntry, |
| | | "Entry not moved from ou=baseDn1,"+baseDn+" to ou=baseDn2,"+baseDn); |
| | | "Entry not moved from ou=baseDn1,"+baseDN+" to ou=baseDn2,"+baseDN); |
| | | |
| | | // - add new parent entry 2 with baseDn1 |
| | | String p2 = "dn: ou=baseDn1,"+baseDn+"\n" + "objectClass: top\n" |
| | | String p2 = "dn: ou=baseDn1,"+baseDN+"\n" + "objectClass: top\n" |
| | | + "objectClass: organizationalUnit\n" |
| | | + "entryUUID: 66666666-6666-6666-6666-666666666666\n"; |
| | | entry = TestCaseUtils.entryFromLdifString(p2); |
| | | Entry entry = TestCaseUtils.entryFromLdifString(p2); |
| | | AddOperationBasis addOp = new AddOperationBasis(connection, |
| | | InternalClientConnection.nextOperationID(), InternalClientConnection |
| | | .nextMessageID(), null, entry.getDN(), entry.getObjectClasses(), |
| | |
| | | |
| | | |
| | | // - publish msg |
| | | updateMonitorCount(baseDn, resolvedMonitorAttr); |
| | | updateMonitorCount(baseDN, resolvedMonitorAttr); |
| | | AlertCount = DummyAlertHandler.getAlertCount(); |
| | | broker.publish(addMsg); |
| | | |
| | | // - check that the DN has been changed to baseDn2 |
| | | resultEntry = getEntry( |
| | | DN.decode("uid=new person,ou=baseDn1,"+baseDn), 10000, false); |
| | | assertNull(resultEntry, |
| | | "The ADD replication message was applied under ou=baseDn1,"+baseDn); |
| | | resultEntry = getEntry(newPersonDN2, 10000, false); |
| | | assertNull(resultEntry, "The ADD replication message was applied under ou=baseDn1," + baseDN); |
| | | |
| | | resultEntry = getEntry( |
| | | DN.decode("uid=new person,ou=baseDn2,"+baseDn), 10000, true); |
| | | assertNotNull(resultEntry, |
| | | "The ADD replication message was NOT applied under ou=baseDn2,"+baseDn); |
| | | resultEntry = getEntry(DN.decode("uid=new person,ou=baseDn2," + baseDN), 10000, true); |
| | | assertNotNull(resultEntry, "The ADD replication message was NOT applied under ou=baseDn2," + baseDN); |
| | | assertEquals(getMonitorDelta(), 1); |
| | | |
| | | // Check that there was no administrative alert generated |
| | |
| | | addEntry(domain1); |
| | | CSN olderCSN = gen.newCSN(); |
| | | Thread.sleep(1000); |
| | | domain1uid = getEntryUUID(DN.decode(domain1dn)); |
| | | domain1uid = getEntryUUID(domain1dn); |
| | | addEntry(domain2); |
| | | domain2uid = getEntryUUID(DN.decode(domain2dn)); |
| | | domain2uid = getEntryUUID(domain2dn); |
| | | addEntry(domain3); |
| | | domain3uid = getEntryUUID(DN.decode(domain3dn)); |
| | | domain3uid = getEntryUUID(domain3dn); |
| | | DN conflictDomain2dn = DN.decode( |
| | | "entryUUID = " + domain2uid + "+dc=domain2,ou=people," + TEST_ROOT_DN_STRING); |
| | | DN conflictDomain3dn = DN.decode( |
| | | "entryUUID = " + domain3uid + "+dc=domain3,ou=people," + TEST_ROOT_DN_STRING); |
| | | |
| | | updateMonitorCount(baseDn, unresolvedMonitorAttr); |
| | | updateMonitorCount(baseDN, unresolvedMonitorAttr); |
| | | AlertCount = DummyAlertHandler.getAlertCount(); |
| | | |
| | | // delete domain1 |
| | |
| | | broker.publish(delMsg); |
| | | |
| | | // check that the domain1 has correctly been deleted |
| | | assertNull(getEntry(DN.decode(domain1dn), 10000, false), |
| | | assertNull(getEntry(domain1dn, 10000, false), |
| | | "The DELETE replication message was not replayed"); |
| | | |
| | | // check that domain2 and domain3 have been renamed |
| | |
| | | |
| | | // check that the 2 conflicting entries have been correctly marked |
| | | assertTrue(checkEntryHasAttribute(conflictDomain2dn, |
| | | LDAPReplicationDomain.DS_SYNC_CONFLICT, domain2dn, 1000, true)); |
| | | LDAPReplicationDomain.DS_SYNC_CONFLICT, domain2dn.toString(), 1000, true)); |
| | | assertTrue(checkEntryHasAttribute(conflictDomain3dn, |
| | | LDAPReplicationDomain.DS_SYNC_CONFLICT, domain3dn, 1000, true)); |
| | | LDAPReplicationDomain.DS_SYNC_CONFLICT, domain3dn.toString(), 1000, true)); |
| | | |
| | | // check that unresolved conflict count has been incremented |
| | | assertEquals(getMonitorDelta(), 1); |
| | |
| | | // |
| | | // add domain1 entry with 2 children : domain2 and domain3 |
| | | addEntry(domain1); |
| | | domain1uid = getEntryUUID(DN.decode(domain1dn)); |
| | | domain1uid = getEntryUUID(domain1dn); |
| | | addEntry(domain2); |
| | | domain2uid = getEntryUUID(DN.decode(domain2dn)); |
| | | domain2uid = getEntryUUID(domain2dn); |
| | | CSN addCSN = addEntry(domain3); |
| | | gen.adjust(addCSN); |
| | | domain3uid = getEntryUUID(DN.decode(domain3dn)); |
| | | domain3uid = getEntryUUID(domain3dn); |
| | | |
| | | updateMonitorCount(baseDn, unresolvedMonitorAttr); |
| | | updateMonitorCount(baseDN, unresolvedMonitorAttr); |
| | | AlertCount = DummyAlertHandler.getAlertCount(); |
| | | |
| | | // delete domain1 |
| | |
| | | broker.publish(delMsg); |
| | | |
| | | // check that the domain1 has correctly been deleted |
| | | assertNull(getEntry(DN.decode(domain1dn), 10000, false), |
| | | assertNull(getEntry(domain1dn, 10000, false), |
| | | "The DELETE replication message was not replayed"); |
| | | |
| | | // check that domain2 and domain3 have been renamed as conflicting |
| | |
| | | |
| | | // check that the entry have been correctly marked as conflicting. |
| | | assertTrue(checkEntryHasAttribute(conflictDomain2dn, |
| | | LDAPReplicationDomain.DS_SYNC_CONFLICT, domain2dn, 1000, true)); |
| | | LDAPReplicationDomain.DS_SYNC_CONFLICT, domain2dn.toString(), 1000, true)); |
| | | |
| | | // check that unresolved conflict count has been incremented |
| | | assertEquals(getMonitorDelta(), 1); |
| | |
| | | // this is correctly detected as a resolved conflict. |
| | | // To simulate this simply try a modifyDN on a non existent uid. |
| | | modDnMsg = new ModifyDNMsg( |
| | | "uid=new person,ou=People," + TEST_ROOT_DN_STRING, gen.newCSN(), |
| | | newPersonDN, gen.newCSN(), |
| | | "33343333-3533-3633-3373-333333833333", baseUUID, false, |
| | | "uid=wrong, ou=people," + TEST_ROOT_DN_STRING, |
| | | "uid=newrdn"); |
| | | updateMonitorCount(baseDn, resolvedMonitorAttr); |
| | | updateMonitorCount(baseDN, resolvedMonitorAttr); |
| | | AlertCount = DummyAlertHandler.getAlertCount(); |
| | | broker.publish(modDnMsg); |
| | | // unfortunately it is difficult to check that the operation |
| | |
| | | * Check that a conflict is detected when an entry is |
| | | * moved below an entry that does not exist. |
| | | */ |
| | | updateMonitorCount(baseDn, unresolvedMonitorAttr); |
| | | updateMonitorCount(baseDN, unresolvedMonitorAttr); |
| | | AlertCount = DummyAlertHandler.getAlertCount(); |
| | | modDnMsg = new ModifyDNMsg( |
| | | "uid=new person,ou=People," + TEST_ROOT_DN_STRING, gen.newCSN(), |
| | | newPersonDN, gen.newCSN(), |
| | | "33333333-3333-3333-3333-333333333333", |
| | | "12343333-3533-3633-3333-333333833333" , false, |
| | | "uid=wrong, ou=people," + TEST_ROOT_DN_STRING, |
| | |
| | | |
| | | // check that the entry have been correctly marked as conflicting. |
| | | assertTrue(checkEntryHasAttribute( |
| | | DN.decode("uid=new person,ou=baseDn2,"+baseDn), |
| | | DN.decode("uid=new person,ou=baseDn2," + baseDN), |
| | | LDAPReplicationDomain.DS_SYNC_CONFLICT, |
| | | "uid=newrdn,ou=baseDn2,ou=People," + TEST_ROOT_DN_STRING, 1000, true)); |
| | | } |
| | |
| | | // Cleanup from previous run |
| | | cleanupTest(); |
| | | |
| | | final DN baseDn = DN.decode("ou=People," + TEST_ROOT_DN_STRING); |
| | | final DN baseDN = DN.decode("ou=People," + TEST_ROOT_DN_STRING); |
| | | |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, 27, 100, replServerPort, 2000, true); |
| | | openReplicationSession(baseDN, 27, 100, replServerPort, 2000, true); |
| | | |
| | | try { |
| | | CSNGenerator gen = new CSNGenerator( 27, 0); |
| | |
| | | assertTrue(OperationType.ADD.compareTo(receivedOp.getOperationType()) == 0, |
| | | "The received replication message is not an ADD msg : " + addMsg); |
| | | |
| | | assertEquals(DN.decode(addMsg.getDn()),personEntry.getDN(), |
| | | "The received ADD replication message is not for the excepted DN : " + addMsg); |
| | | assertEquals(addMsg.getDN(), personEntry.getDN(), |
| | | "The received ADD replication message is not for the excepted DN : " + addMsg); |
| | | } |
| | | |
| | | // Modify the entry |
| | |
| | | ModifyMsg modMsg = (ModifyMsg) msg; |
| | | |
| | | modMsg.createOperation(connection); |
| | | assertTrue(DN.decode(modMsg.getDn()).compareTo(personEntry.getDN()) == 0, |
| | | assertEquals(modMsg.getDN(), personEntry.getDN(), |
| | | "The received MODIFY replication message is not for the excepted DN : " + modMsg); |
| | | |
| | | // Modify the entry DN |
| | | DN newDN = DN.decode("uid= new person,ou=People," + TEST_ROOT_DN_STRING) ; |
| | | DN newDN = DN.decode("uid= new person,ou=People," + TEST_ROOT_DN_STRING); |
| | | ModifyDNOperationBasis modDNOp = new ModifyDNOperationBasis(connection, |
| | | InternalClientConnection.nextOperationID(), InternalClientConnection |
| | | .nextMessageID(), null, personEntry.getDN(), RDN |
| | |
| | | ModifyDNMsg moddnMsg = (ModifyDNMsg) msg; |
| | | moddnMsg.createOperation(connection); |
| | | |
| | | assertTrue(DN.decode(moddnMsg.getDn()).compareTo(personEntry.getDN()) == 0, |
| | | assertEquals(moddnMsg.getDN(), personEntry.getDN(), |
| | | "The received MODIFY_DN message is not for the excepted DN : " + moddnMsg); |
| | | |
| | | // Delete the entry |
| | | DeleteOperationBasis delOp = new DeleteOperationBasis(connection, |
| | | InternalClientConnection.nextOperationID(), InternalClientConnection |
| | | .nextMessageID(), null, DN |
| | | .decode("uid= new person,ou=People," + TEST_ROOT_DN_STRING)); |
| | | .nextMessageID(), null, newDN); |
| | | delOp.run(); |
| | | assertFalse(DirectoryServer.entryExists(newDN), |
| | | "Unable to delete the new person Entry"); |
| | |
| | | "The received replication message is not a MODIFY DN msg : " + msg); |
| | | DeleteMsg delMsg = (DeleteMsg) msg; |
| | | delMsg.createOperation(connection); |
| | | assertTrue(DN.decode(delMsg.getDn()).compareTo(DN |
| | | .decode("uid= new person,ou=People," + TEST_ROOT_DN_STRING)) == 0, |
| | | assertEquals(delMsg.getDN(), newDN, |
| | | "The received DELETE message is not for the excepted DN : " + delMsg); |
| | | |
| | | /* |
| | |
| | | * Start by testing the Add message reception |
| | | */ |
| | | AddMsg addMsg = new AddMsg(gen.newCSN(), |
| | | personWithUUIDEntry.getDN().toString(), |
| | | personWithUUIDEntry.getDN(), |
| | | user1entryUUID, baseUUID, |
| | | personWithUUIDEntry.getObjectClassAttribute(), |
| | | personWithUUIDEntry.getAttributes(), new ArrayList<Attribute>()); |
| | |
| | | /* |
| | | * Test the Reception of Modify Dn Msg |
| | | */ |
| | | moddnMsg = new ModifyDNMsg(personWithUUIDEntry.getDN().toString(), |
| | | moddnMsg = new ModifyDNMsg(personWithUUIDEntry.getDN(), |
| | | gen.newCSN(), |
| | | user1entryUUID, null, |
| | | true, null, "uid= new person"); |
| | |
| | | moddnMsg.setAssured(true); |
| | | broker.publish(moddnMsg); |
| | | |
| | | resultEntry = getEntry( |
| | | DN.decode("uid= new person,ou=People," + TEST_ROOT_DN_STRING), 10000, true); |
| | | resultEntry = getEntry(newDN, 10000, true); |
| | | |
| | | assertNotNull(resultEntry, |
| | | "The modify DN replication message was not applied"); |
| | |
| | | /* |
| | | * Test the Reception of Delete Msg |
| | | */ |
| | | delMsg = new DeleteMsg("uid= new person,ou=People," + TEST_ROOT_DN_STRING, |
| | | gen.newCSN(), user1entryUUID); |
| | | delMsg = new DeleteMsg(newDN, gen.newCSN(), user1entryUUID); |
| | | if (assured) |
| | | delMsg.setAssured(true); |
| | | broker.publish(delMsg); |
| | | resultEntry = getEntry( |
| | | DN.decode("uid= new person,ou=People," + TEST_ROOT_DN_STRING), 10000, false); |
| | | resultEntry = getEntry(newDN, 10000, false); |
| | | |
| | | assertNull(resultEntry, |
| | | "The DELETE replication message was not replayed"); |
| | |
| | | logError(Message.raw(Category.SYNC, Severity.INFORMATION, |
| | | "Starting replication test : infiniteReplayLoop")); |
| | | |
| | | final DN baseDn = DN.decode("ou=People," + TEST_ROOT_DN_STRING); |
| | | final DN baseDN = DN.decode("ou=People," + TEST_ROOT_DN_STRING); |
| | | |
| | | // Clean replication server database from previous run |
| | | cleanUpReplicationServersDB(); |
| | | |
| | | Thread.sleep(2000); |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, 11, 100, replServerPort, 1000, true); |
| | | openReplicationSession(baseDN, 11, 100, replServerPort, 1000, true); |
| | | try |
| | | { |
| | | CSNGenerator gen = new CSNGenerator( 11, 0); |
| | |
| | | addOp.run(); |
| | | assertEquals(addOp.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | long initialCount = getMonitorAttrValue(baseDn, "replayed-updates"); |
| | | long initialCount = getMonitorAttrValue(baseDN, "replayed-updates"); |
| | | |
| | | // Get the UUID of the test entry. |
| | | Entry resultEntry = getEntry(tmp.getDN(), 1, true); |
| | |
| | | try |
| | | { |
| | | // Publish a delete message for this test entry. |
| | | DeleteMsg delMsg = new DeleteMsg(tmp.getDN().toString(), |
| | | gen.newCSN(), |
| | | uuid); |
| | | DeleteMsg delMsg = new DeleteMsg(tmp.getDN(), gen.newCSN(), uuid); |
| | | broker.publish(delMsg); |
| | | |
| | | // Wait for the operation to be replayed. |
| | | long endTime = System.currentTimeMillis() + 5000; |
| | | while (getMonitorAttrValue(baseDn, "replayed-updates") == initialCount && |
| | | while (getMonitorAttrValue(baseDN, "replayed-updates") == initialCount && |
| | | System.currentTimeMillis() < endTime) |
| | | { |
| | | Thread.sleep(100); |
| | |
| | | |
| | | // If the replication replay loop was detected and broken then the |
| | | // counter will still be updated even though the replay was unsuccessful. |
| | | if (getMonitorAttrValue(baseDn, "replayed-updates") == initialCount) |
| | | if (getMonitorAttrValue(baseDN, "replayed-updates") == initialCount) |
| | | { |
| | | fail("Operation was not replayed"); |
| | | } |
| | |
| | | * @param enable Specifies whether the receive status should be enabled |
| | | * or disabled. |
| | | */ |
| | | private static void setReceiveStatus(String syncConfigDN, boolean enable) |
| | | private static void setReceiveStatus(DN syncConfigDN, boolean enable) |
| | | { |
| | | ArrayList<ByteString> valueList = new ArrayList<ByteString>(1); |
| | | if (enable) |
| | | { |
| | | valueList.add(ByteString.valueOf("TRUE")); |
| | | } |
| | | else |
| | | { |
| | | valueList.add(ByteString.valueOf("FALSE")); |
| | | } |
| | | valueList.add(ByteString.valueOf(enable ? "TRUE" : "FALSE")); |
| | | LDAPAttribute a = new LDAPAttribute("ds-cfg-receive-status", valueList); |
| | | |
| | | LDAPModification m = new LDAPModification(ModificationType.REPLACE, a); |
| | | |
| | | ArrayList<RawModification> modList = new ArrayList<RawModification>(1); |
| | | List<RawModification> modList = new ArrayList<RawModification>(1); |
| | | modList.add(m); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ByteString rawEntryDN = |
| | | ByteString.valueOf(syncConfigDN); |
| | | InternalClientConnection conn = InternalClientConnection.getRootConnection(); |
| | | ByteString rawEntryDN = ByteString.valueOf(syncConfigDN.toString()); |
| | | ModifyOperation internalModify = conn.processModify(rawEntryDN, modList); |
| | | |
| | | ResultCode resultCode = internalModify.getResultCode(); |
| | |
| | | logError(Message.raw(Category.SYNC, Severity.INFORMATION, |
| | | "Starting synchronization test : CSNGeneratorAdjust")); |
| | | |
| | | final DN baseDn = DN.decode("ou=People," + TEST_ROOT_DN_STRING); |
| | | final DN baseDN = DN.decode("ou=People," + TEST_ROOT_DN_STRING); |
| | | |
| | | // Clean replication server database from previous run |
| | | cleanUpReplicationServersDB(); |
| | |
| | | * This must use a different serverId to that of the directory server. |
| | | */ |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, serverId, 100, replServerPort, 1000, true); |
| | | openReplicationSession(baseDN, serverId, 100, replServerPort, 1000, true); |
| | | |
| | | try |
| | | { |
| | |
| | | // Create and publish an update message to add an entry. |
| | | AddMsg addMsg = new AddMsg( |
| | | gen.newCSN(), |
| | | user3dn.toString(), |
| | | user3dn, |
| | | user3UUID, |
| | | baseUUID, |
| | | user3Entry.getObjectClassAttribute(), |
| | |
| | | "The MOD timestamp should have been adjusted to the ADD one"); |
| | | |
| | | // Delete the entries to clean the database. |
| | | DeleteMsg delMsg = |
| | | new DeleteMsg( |
| | | user3Entry.getDN().toString(), |
| | | gen.newCSN(), |
| | | user3UUID); |
| | | DeleteMsg delMsg = new DeleteMsg(user3Entry.getDN(), gen.newCSN(), user3UUID); |
| | | broker.publish(delMsg); |
| | | |
| | | // Check that the delete operation has been applied. |
| | |
| | | private final int degradedStatusThreshold = 5000; |
| | | |
| | | // Parameters set with received server start message |
| | | private String baseDn; |
| | | private DN baseDN; |
| | | private long generationId = -1L; |
| | | private ServerState serverState; |
| | | private int windowSize = -1; |
| | |
| | | |
| | | /** parameters at handshake are ok */ |
| | | private boolean handshakeOk = false; |
| | | /** |
| | | /** |
| | | * signal that the current scenario the RS must execute reached the point |
| | | * where the main code can perform test assertion. |
| | | */ |
| | |
| | | // Receive server start |
| | | ServerStartMsg serverStartMsg = (ServerStartMsg) session.receive(); |
| | | |
| | | baseDn = serverStartMsg.getBaseDn(); |
| | | baseDN = serverStartMsg.getBaseDN(); |
| | | serverState = serverStartMsg.getServerState(); |
| | | generationId = serverStartMsg.getGenerationId(); |
| | | windowSize = serverStartMsg.getWindowSize(); |
| | |
| | | // Send replication server start |
| | | String serverURL = ("localhost:" + port); |
| | | ReplServerStartMsg replServerStartMsg = new ReplServerStartMsg(serverId, |
| | | serverURL, baseDn, windowSize, serverState, |
| | | generationId, sslEncryption, |
| | | serverURL, baseDN, windowSize, serverState, generationId, sslEncryption, |
| | | groupId, degradedStatusThreshold); |
| | | session.publish(replServerStartMsg); |
| | | |
| | |
| | | try |
| | | { |
| | | AddMsg addMsg = |
| | | new AddMsg(gen.newCSN(), entry.getDN().toString(), UUID.randomUUID().toString(), |
| | | new AddMsg(gen.newCSN(), entry.getDN(), UUID.randomUUID().toString(), |
| | | parentUid, |
| | | entry.getObjectClassAttribute(), |
| | | entry.getAttributes(), null ); |
| | |
| | | { |
| | | assertEquals(updateMsg.isAssured(), isAssured, |
| | | "msg=" + ((updateMsg instanceof AddMsg)? |
| | | ((AddMsg)updateMsg).getDn():updateMsg.getCSN())); |
| | | ((AddMsg)updateMsg).getDN():updateMsg.getCSN())); |
| | | if (isAssured) |
| | | { |
| | | assertEquals(updateMsg.getAssuredMode(), assuredMode); |
| | |
| | | replicationServer.shutdown(); |
| | | } |
| | | |
| | | if (safeDataDomainCfgEntry != null) |
| | | { |
| | | removeDomain(safeDataDomainCfgEntry); |
| | | } |
| | | |
| | | if (safeReadDomainCfgEntry != null) |
| | | { |
| | | removeDomain(safeReadDomainCfgEntry); |
| | | } |
| | | |
| | | if (notAssuredDomainCfgEntry != null) |
| | | { |
| | | removeDomain(notAssuredDomainCfgEntry); |
| | | } |
| | | removeDomain(safeDataDomainCfgEntry, safeReadDomainCfgEntry, notAssuredDomainCfgEntry); |
| | | } |
| | | |
| | | /** |
| | |
| | | * - assured-sr-server-not-acknowledged-updates in SR mode |
| | | * - assured-sd-server-timeout-updates in SD mode |
| | | */ |
| | | protected Map<Integer,Integer> getErrorsByServers(DN baseDn, |
| | | protected Map<Integer,Integer> getErrorsByServers(DN baseDN, |
| | | AssuredMode assuredMode) throws Exception |
| | | { |
| | | // Find monitoring entry for requested base DN |
| | | String monitorFilter = |
| | | "(&(cn=Directory server*)(domain-name=" + baseDn + "))"; |
| | | "(&(cn=Directory server*)(domain-name=" + baseDN + "))"; |
| | | |
| | | InternalSearchOperation op; |
| | | int count = 0; |
| | |
| | | public class FractionalReplicationTest extends ReplicationTestCase { |
| | | |
| | | /** The RS */ |
| | | private ReplicationServer replicationServer = null; |
| | | private ReplicationServer replicationServer; |
| | | /** RS port */ |
| | | private int replServerPort = -1; |
| | | /** Represents the real domain to test (replays and filters) */ |
| | | private Entry fractionalDomainCfgEntry = null; |
| | | private Entry fractionalDomainCfgEntry; |
| | | /** The domain used to send updates to the real domain */ |
| | | private FakeReplicationDomain replicationDomain = null; |
| | | private FakeReplicationDomain replicationDomain; |
| | | |
| | | /** Ids of servers */ |
| | | private static final int DS1_ID = 1; // fractional domain |
| | | private static final int DS2_ID = 2; // fake domain |
| | | private static final int RS_ID = 91; // replication server |
| | | |
| | | private final String testName = this.getClass().getSimpleName(); |
| | | private final String testName = getClass().getSimpleName(); |
| | | |
| | | /** Fractional mode */ |
| | | private static final int EXCLUDE_FRAC_MODE = 0; |
| | | private static final int INCLUDE_FRAC_MODE = 1; |
| | | |
| | | int initWindow = 100; |
| | | private CSNGenerator gen = null; |
| | | private CSNGenerator gen; |
| | | |
| | | /** The tracer object for the debug logger */ |
| | | private static final DebugTracer TRACER = getTracer(); |
| | |
| | | replicationDomain = null; |
| | | } |
| | | |
| | | if (fractionalDomainCfgEntry != null) |
| | | { |
| | | removeDomain(fractionalDomainCfgEntry); |
| | | fractionalDomainCfgEntry = null; |
| | | } |
| | | removeDomain(fractionalDomainCfgEntry); |
| | | fractionalDomainCfgEntry = null; |
| | | |
| | | remove(replicationServer); |
| | | replicationServer = null; |
| | |
| | | |
| | | private long readGenIdFromSuffixRootEntry(String rootDn) throws Exception |
| | | { |
| | | DN baseDn = DN.decode(rootDn); |
| | | Entry resultEntry = getEntry(baseDn, 1000, true); |
| | | DN baseDN = DN.decode(rootDn); |
| | | Entry resultEntry = getEntry(baseDN, 1000, true); |
| | | if (resultEntry == null) |
| | | { |
| | | debugInfo("Entry not found <" + rootDn + ">"); |
| | |
| | | |
| | | // Create an update message to add an entry. |
| | | AddMsg addMsg = new AddMsg(gen.newCSN(), |
| | | entry.getDN().toString(), |
| | | entry.getDN(), |
| | | ENTRY_UUID, |
| | | null, |
| | | entry.getObjectClassAttribute(), |
| | |
| | | mods.add(mod); |
| | | |
| | | // Add modification for the synchro attribute (added attribute) |
| | | attr = |
| | | Attributes.create(SYNCHRO_OPTIONAL_ATTR.toLowerCase(), SYNCHRO_OPTIONAL_ATTR + "Value"); |
| | | attr = Attributes.create(SYNCHRO_OPTIONAL_ATTR.toLowerCase(), SYNCHRO_OPTIONAL_ATTR + "Value"); |
| | | mod = new Modification(ModificationType.ADD, attr); |
| | | mods.add(mod); |
| | | |
| | | DN entryDn = DN.decode((firstBackend ? ENTRY_DN : ENTRY_DN2)); |
| | | ModifyMsg modifyMsg = new ModifyMsg(gen.newCSN(), entryDn, mods, |
| | | ENTRY_UUID); |
| | | |
| | | DN entryDn = DN.decode(firstBackend ? ENTRY_DN : ENTRY_DN2); |
| | | ModifyMsg modifyMsg = new ModifyMsg(gen.newCSN(), entryDn, mods, ENTRY_UUID); |
| | | replicationDomain.publish(modifyMsg); |
| | | } |
| | | |
| | |
| | | |
| | | // Create an update message to add an entry. |
| | | AddMsg addMsg = new AddMsg(gen.newCSN(), |
| | | entry.getDN().toString(), |
| | | entry.getDN(), |
| | | ENTRY_UUID, |
| | | null, |
| | | entry.getObjectClassAttribute(), |
| | |
| | | |
| | | // Create an update message to add an entry. |
| | | addMsg = new AddMsg(gen.newCSN(), |
| | | entry.getDN().toString(), |
| | | entry.getDN(), |
| | | ENTRY_UUID2, |
| | | null, |
| | | entry.getObjectClassAttribute(), |
| | |
| | | |
| | | // Create an update message to add an entry. |
| | | AddMsg addMsg = new AddMsg(gen.newCSN(), |
| | | entry.getDN().toString(), |
| | | entry.getDN(), |
| | | ENTRY_UUID, |
| | | null, |
| | | entry.getObjectClassAttribute(), |
| | |
| | | |
| | | // Create an update message to add an entry. |
| | | addMsg = new AddMsg(gen.newCSN(), |
| | | entry.getDN().toString(), |
| | | entry.getDN(), |
| | | ENTRY_UUID2, |
| | | null, |
| | | entry.getObjectClassAttribute(), |
| | |
| | | |
| | | // Create an update message to add an entry. |
| | | AddMsg addMsg = new AddMsg(gen.newCSN(), |
| | | entry.getDN().toString(), |
| | | entry.getDN(), |
| | | ENTRY_UUID, |
| | | null, |
| | | entry.getObjectClassAttribute(), |
| | |
| | | DN newEntryDn = DN.decode(newEntryName); |
| | | |
| | | // Create modify dn message to modify the entry. |
| | | ModifyDNMsg modDnMsg = new ModifyDNMsg(entryName, gen.newCSN(), |
| | | ModifyDNMsg modDnMsg = new ModifyDNMsg(DN.decode(entryName), gen.newCSN(), |
| | | ENTRY_UUID, ENTRY_UUID3, false, TEST_ROOT_DN_STRING, |
| | | "displayName=ValueToBeKept", null); |
| | | |
| | |
| | | |
| | | // Create an update message to add an entry. |
| | | AddMsg addMsg = new AddMsg(gen.newCSN(), |
| | | entry.getDN().toString(), |
| | | entry.getDN(), |
| | | ENTRY_UUID, |
| | | null, |
| | | entry.getObjectClassAttribute(), |
| | |
| | | DN newEntryDn = DN.decode(newEntryName); |
| | | |
| | | // Create modify dn message to modify the entry. |
| | | ModifyDNMsg modDnMsg = new ModifyDNMsg(entryName, gen.newCSN(), |
| | | ModifyDNMsg modDnMsg = new ModifyDNMsg(DN.decode(entryName), gen.newCSN(), |
| | | ENTRY_UUID, ENTRY_UUID3, false, TEST_ROOT_DN_STRING, |
| | | "displayName=ValueToBeKept", null); |
| | | |
| | |
| | | throws Exception |
| | | { |
| | | final int serverId = 123; |
| | | final DN baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | final DN baseDN = DN.decode(TEST_ROOT_DN_STRING); |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | ReplicationServer rs = createReplicationServer(); |
| | | // Create Replication Server and Domain |
| | |
| | | try |
| | | { |
| | | long startTime = TimeThread.getTime(); |
| | | final DN dn1 = DN.decode("cn=test1," + baseDn.toString()); |
| | | final DN dn1 = DN.decode("cn=test1," + baseDN.toString()); |
| | | final AttributeType histType = |
| | | DirectoryServer.getAttributeType(EntryHistorical.HISTORICAL_ATTRIBUTE_NAME); |
| | | |
| | |
| | | |
| | | // Add the first test entry. |
| | | TestCaseUtils.addEntry( |
| | | "dn: cn=test1," + baseDn.toString(), |
| | | "dn: cn=test1," + baseDN.toString(), |
| | | "displayname: Test1", |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | |
| | | |
| | | // Perform a first modification to update the historical attribute |
| | | int resultCode = TestCaseUtils.applyModifications(false, |
| | | "dn: cn=test1," + baseDn.toString(), |
| | | "dn: cn=test1," + baseDN.toString(), |
| | | "changetype: modify", |
| | | "add: description", |
| | | "description: foo"); |
| | |
| | | // Perform a 2nd modification to update the hist attribute with |
| | | // a second value |
| | | resultCode = TestCaseUtils.applyModifications(false, |
| | | "dn: cn=test1," + baseDn.toString(), |
| | | "dn: cn=test1," + baseDN.toString(), |
| | | "changetype: modify", |
| | | "add: description", |
| | | "description: bar"); |
| | |
| | | } |
| | | finally |
| | | { |
| | | MultimasterReplication.deleteDomain(baseDn); |
| | | MultimasterReplication.deleteDomain(baseDN); |
| | | remove(rs); |
| | | } |
| | | } |
| | |
| | | public void buildAndPublishMissingChangesSeveralEntriesTest() |
| | | throws Exception |
| | | { |
| | | final DN baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | final DN baseDN = DN.decode(TEST_ROOT_DN_STRING); |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | ReplicationServer rs = createReplicationServer(); |
| | | // Create Replication Server and Domain |
| | |
| | | "Starting replication test : changesCmpTest")); |
| | | |
| | | // Add 3 entries. |
| | | String dnTest1 = "cn=test1," + baseDn.toString(); |
| | | String dnTest2 = "cn=test2," + baseDn.toString(); |
| | | String dnTest3 = "cn=test3," + baseDn.toString(); |
| | | DN dnTest1 = DN.decode("cn=test1," + baseDN.toString()); |
| | | DN dnTest2 = DN.decode("cn=test2," + baseDN.toString()); |
| | | DN dnTest3 = DN.decode("cn=test3," + baseDN.toString()); |
| | | TestCaseUtils.addEntry( |
| | | "dn: " + dnTest3, |
| | | "displayname: Test1", |
| | |
| | | "cn: test1", |
| | | "sn: test" |
| | | ); |
| | | TestCaseUtils.deleteEntry(DN.decode(dnTest3)); |
| | | TestCaseUtils.deleteEntry(dnTest3); |
| | | TestCaseUtils.addEntry( |
| | | "dn: " + dnTest2, |
| | | "displayname: Test1", |
| | |
| | | |
| | | // Perform modifications on the 2 entries |
| | | int resultCode = TestCaseUtils.applyModifications(false, |
| | | "dn: cn=test2," + baseDn.toString(), |
| | | "dn: cn=test2," + baseDN, |
| | | "changetype: modify", |
| | | "add: description", |
| | | "description: foo"); |
| | | resultCode = TestCaseUtils.applyModifications(false, |
| | | "dn: cn=test1," + baseDn.toString(), |
| | | "dn: cn=test1," + baseDN, |
| | | "changetype: modify", |
| | | "add: description", |
| | | "description: foo"); |
| | |
| | | assertEquals(opList.size(), 5, "buildAndPublishMissingChanges should return 5 operations"); |
| | | ReplicationMsg msg = opList.removeFirst(); |
| | | assertTrue(msg.getClass().equals(AddMsg.class)); |
| | | assertEquals(((LDAPUpdateMsg) msg).getDn(), dnTest1); |
| | | assertEquals(((LDAPUpdateMsg) msg).getDN(), dnTest1); |
| | | msg = opList.removeFirst(); |
| | | assertTrue(msg.getClass().equals(DeleteMsg.class)); |
| | | assertEquals(((LDAPUpdateMsg) msg).getDn(), dnTest3); |
| | | assertEquals(((LDAPUpdateMsg) msg).getDN(), dnTest3); |
| | | msg = opList.removeFirst(); |
| | | assertTrue(msg.getClass().equals(AddMsg.class)); |
| | | assertEquals(((LDAPUpdateMsg) msg).getDn(), dnTest2); |
| | | assertEquals(((LDAPUpdateMsg) msg).getDN(), dnTest2); |
| | | msg = opList.removeFirst(); |
| | | assertTrue(msg.getClass().equals(ModifyMsg.class)); |
| | | assertEquals(((LDAPUpdateMsg) msg).getDn(), dnTest2); |
| | | assertEquals(((LDAPUpdateMsg) msg).getDN(), dnTest2); |
| | | msg = opList.removeFirst(); |
| | | assertTrue(msg.getClass().equals(ModifyMsg.class)); |
| | | assertEquals(((LDAPUpdateMsg) msg).getDn(), dnTest1); |
| | | assertEquals(((LDAPUpdateMsg) msg).getDN(), dnTest1); |
| | | } |
| | | finally |
| | | { |
| | | MultimasterReplication.deleteDomain(baseDn); |
| | | MultimasterReplication.deleteDomain(baseDN); |
| | | rs.remove(); |
| | | } |
| | | } |
| | |
| | | private LDAPReplicationDomain createReplicationDomain(int dsId) |
| | | throws DirectoryException, ConfigException |
| | | { |
| | | DN baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | DN baseDN = DN.decode(TEST_ROOT_DN_STRING); |
| | | DomainFakeCfg domainConf = |
| | | new DomainFakeCfg(baseDn, dsId, replServers, AssuredType.NOT_ASSURED, |
| | | new DomainFakeCfg(baseDN, dsId, replServers, AssuredType.NOT_ASSURED, |
| | | 2, 1, 0, null); |
| | | LDAPReplicationDomain replicationDomain = |
| | | MultimasterReplication.createNewDomain(domainConf); |
| | |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.testng.Assert.*; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Tests the Historical class. |
| | |
| | | { |
| | | final DN dn1 = DN.decode("cn=test1," + TEST_ROOT_DN_STRING); |
| | | final DN dn2 = DN.decode("cn=test2," + TEST_ROOT_DN_STRING); |
| | | final DN baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | final DN baseDN = DN.decode(TEST_ROOT_DN_STRING); |
| | | final AttributeType attrType = |
| | | DirectoryServer.getAttributeType("displayname"); |
| | | final AttributeType entryuuidType = |
| | |
| | | * This must use a different serverId to that of the directory server. |
| | | */ |
| | | ReplicationBroker broker = |
| | | openReplicationSession(baseDn, 2, 100, replServerPort, 1000, true); |
| | | openReplicationSession(baseDN, 2, 100, replServerPort, 1000, true); |
| | | |
| | | |
| | | // Clear the backend and create top entrye |
| | |
| | | FakeAddOperation addOp = (FakeAddOperation) op; |
| | | assertTrue(addOp.getCSN() != null); |
| | | AddMsg addmsg = addOp.generateMessage(); |
| | | assertTrue(dn1.equals(DN.decode(addmsg.getDn()))); |
| | | assertTrue(addmsg.getEntryUUID().equals(EntryHistorical.getEntryUUID(entry))); |
| | | assertEquals(dn1, addmsg.getDN()); |
| | | assertEquals(addmsg.getEntryUUID(), EntryHistorical.getEntryUUID(entry)); |
| | | String parentId = LDAPReplicationDomain.findEntryUUID(dn1.getParent()); |
| | | assertTrue(addmsg.getParentEntryUUID().equals(parentId)); |
| | | assertEquals(addmsg.getParentEntryUUID(), parentId); |
| | | addmsg.createOperation(InternalClientConnection.getRootConnection()); |
| | | } |
| | | else if (count == 1) |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | final DN baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | final DN baseDN = DN.decode(TEST_ROOT_DN_STRING); |
| | | |
| | | TestSynchronousReplayQueue queue = new TestSynchronousReplayQueue(); |
| | | DomainFakeCfg conf = new DomainFakeCfg(baseDn, 1, new TreeSet<String>()); |
| | | DomainFakeCfg conf = new DomainFakeCfg(baseDN, 1, new TreeSet<String>()); |
| | | conf.setIsolationPolicy(IsolationPolicy.ACCEPT_ALL_UPDATES); |
| | | |
| | | LDAPReplicationDomain domain = |
| | |
| | | CSN csn2 = gen.newCSN(); |
| | | |
| | | ModifyDNMsg modDnMsg = new ModifyDNMsg( |
| | | entry.getDN().toNormalizedString(), csn2, |
| | | entry.getDN(), csn2, |
| | | entryUUID, parentUUID, false, |
| | | TEST_ROOT_DN_STRING, |
| | | "uid=simultaneous2"); |
| | |
| | | // This MODIFY DN uses an older DN and should therefore be cancelled |
| | | // at replay time. |
| | | modDnMsg = new ModifyDNMsg( |
| | | entry.getDN().toNormalizedString(), csn1, |
| | | entry.getDN(), csn1, |
| | | entryUUID, parentUUID, false, |
| | | TEST_ROOT_DN_STRING, |
| | | "uid=simulatneouswrong"); |
| | |
| | | } |
| | | finally |
| | | { |
| | | MultimasterReplication.deleteDomain(baseDn); |
| | | MultimasterReplication.deleteDomain(baseDN); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | final DN baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | final DN baseDN = DN.decode(TEST_ROOT_DN_STRING); |
| | | |
| | | TestSynchronousReplayQueue queue = new TestSynchronousReplayQueue(); |
| | | DomainFakeCfg conf = new DomainFakeCfg(baseDn, 1, new TreeSet<String>()); |
| | | DomainFakeCfg conf = new DomainFakeCfg(baseDN, 1, new TreeSet<String>()); |
| | | conf.setIsolationPolicy(IsolationPolicy.ACCEPT_ALL_UPDATES); |
| | | |
| | | LDAPReplicationDomain domain = |
| | |
| | | // Now try to add the same entry with same DN but a different |
| | | // unique ID though the replication |
| | | AddMsg addMsg = new AddMsg(csn1, |
| | | entry.getDN().toNormalizedString(), |
| | | entry.getDN(), |
| | | "c9cb8c3c-615a-4122-865d-50323aaaed48", parentUUID, |
| | | entry.getObjectClasses(), entry.getUserAttributes(), |
| | | null); |
| | |
| | | } |
| | | finally |
| | | { |
| | | MultimasterReplication.deleteDomain(baseDn); |
| | | MultimasterReplication.deleteDomain(baseDN); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | final DN baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | final DN baseDN = DN.decode(TEST_ROOT_DN_STRING); |
| | | |
| | | TestSynchronousReplayQueue queue = new TestSynchronousReplayQueue(); |
| | | DomainFakeCfg conf = new DomainFakeCfg(baseDn, 1, new TreeSet<String>()); |
| | | DomainFakeCfg conf = new DomainFakeCfg(baseDN, 1, new TreeSet<String>()); |
| | | conf.setIsolationPolicy(IsolationPolicy.ACCEPT_ALL_UPDATES); |
| | | |
| | | LDAPReplicationDomain domain = |
| | |
| | | // Now try to add the same entry with same DN but a different |
| | | // unique ID though the replication |
| | | AddMsg addMsg = new AddMsg(csn1, |
| | | entry.getDN().toNormalizedString(), |
| | | entry.getDN(), |
| | | "c9cb8c3c-615a-4122-865d-50323aaaed48", parentUUID, |
| | | entry.getObjectClasses(), entry.getUserAttributes(), |
| | | null); |
| | |
| | | } |
| | | finally |
| | | { |
| | | MultimasterReplication.deleteDomain(baseDn); |
| | | MultimasterReplication.deleteDomain(baseDN); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | final DN baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | final DN baseDN = DN.decode(TEST_ROOT_DN_STRING); |
| | | |
| | | TestSynchronousReplayQueue queue = new TestSynchronousReplayQueue(); |
| | | DomainFakeCfg conf = new DomainFakeCfg(baseDn, 1, new TreeSet<String>()); |
| | | DomainFakeCfg conf = new DomainFakeCfg(baseDN, 1, new TreeSet<String>()); |
| | | conf.setIsolationPolicy(IsolationPolicy.ACCEPT_ALL_UPDATES); |
| | | |
| | | LDAPReplicationDomain domain = |
| | |
| | | String parentUUID = getEntryUUID(parentEntry.getDN()); |
| | | |
| | | CSN csn2 = gen.newCSN(); |
| | | |
| | | DeleteMsg delMsg = new DeleteMsg( |
| | | parentEntry.getDN().toNormalizedString(), |
| | | csn2, |
| | | parentUUID); |
| | | DeleteMsg delMsg = new DeleteMsg(parentEntry.getDN(), csn2, parentUUID); |
| | | delMsg.setSubtreeDelete(true); |
| | | |
| | | // Put the message in the replay queue |
| | |
| | | } |
| | | finally |
| | | { |
| | | MultimasterReplication.deleteDomain(baseDn); |
| | | MultimasterReplication.deleteDomain(baseDN); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | final DN baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | final DN baseDN = DN.decode(TEST_ROOT_DN_STRING); |
| | | |
| | | TestSynchronousReplayQueue queue = new TestSynchronousReplayQueue(); |
| | | DomainFakeCfg conf = new DomainFakeCfg(baseDn, 1, new TreeSet<String>()); |
| | | DomainFakeCfg conf = new DomainFakeCfg(baseDN, 1, new TreeSet<String>()); |
| | | conf.setIsolationPolicy(IsolationPolicy.ACCEPT_ALL_UPDATES); |
| | | |
| | | LDAPReplicationDomain domain = |
| | |
| | | String childUUID = getEntryUUID(childEntry.getDN()); |
| | | |
| | | CSN csn2 = gen.newCSN(); |
| | | |
| | | DeleteMsg delMsg = new DeleteMsg( |
| | | parentEntry.getDN().toNormalizedString(), |
| | | csn2, |
| | | parentUUID); |
| | | DeleteMsg delMsg = new DeleteMsg(parentEntry.getDN(), csn2, parentUUID); |
| | | // NOT SUBTREE |
| | | |
| | | // Put the message in the replay queue |
| | |
| | | } |
| | | finally |
| | | { |
| | | MultimasterReplication.deleteDomain(baseDn); |
| | | MultimasterReplication.deleteDomain(baseDN); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | final DN baseDn = DN.decode(TEST_ROOT_DN_STRING); |
| | | final DN baseDN = DN.decode(TEST_ROOT_DN_STRING); |
| | | |
| | | TestSynchronousReplayQueue queue = new TestSynchronousReplayQueue(); |
| | | DomainFakeCfg conf = new DomainFakeCfg(baseDn, 1, new TreeSet<String>()); |
| | | DomainFakeCfg conf = new DomainFakeCfg(baseDN, 1, new TreeSet<String>()); |
| | | conf.setIsolationPolicy(IsolationPolicy.ACCEPT_ALL_UPDATES); |
| | | |
| | | LDAPReplicationDomain domain = |
| | |
| | | String childUUID = "44444444-4444-4444-4444-444444444444"; |
| | | AddMsg addMsg = new AddMsg( |
| | | csn1, |
| | | childEntry.getDN().toString(), |
| | | childEntry.getDN(), |
| | | childUUID, |
| | | parentUUID, |
| | | childEntry.getObjectClassAttribute(), |
| | |
| | | } |
| | | finally |
| | | { |
| | | MultimasterReplication.deleteDomain(baseDn); |
| | | MultimasterReplication.deleteDomain(baseDN); |
| | | } |
| | | } |
| | | } |
| | |
| | | this.nEntries = nEntries; |
| | | |
| | | // Send init msg to warn dest server it is going do be initialized |
| | | RoutableMsg initTargetMsg = null; |
| | | |
| | | initTargetMsg = |
| | | new InitializeTargetMsg(EXAMPLE_DN, serverId, destId, |
| | | serverId, nEntries, initWindow); |
| | | |
| | | RoutableMsg initTargetMsg = new InitializeTargetMsg( |
| | | EXAMPLE_DN_, serverId, destId, serverId, nEntries, initWindow); |
| | | rb.publish(initTargetMsg); |
| | | |
| | | // Send top entry for the domain |
| | |
| | | |
| | | // Create an update message to add an entry. |
| | | return new AddMsg(gen.newCSN(), |
| | | personWithUUIDEntry.getDN().toString(), |
| | | personWithUUIDEntry.getDN(), |
| | | userEntryUUID, |
| | | null, |
| | | personWithUUIDEntry.getObjectClassAttribute(), |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.opends.server.replication.protocol.OperationContext.*; |
| | | import static org.opends.server.replication.protocol.ProtocolVersion.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | @DataProvider(name="createReplServerStartData") |
| | | public Object [][] createReplServerStartData() throws Exception |
| | | { |
| | | String baseDN = "o=test"; |
| | | DN baseDN = DN.decode("o=test"); |
| | | ServerState state = new ServerState(); |
| | | state.update(new CSN(0, 0,0)); |
| | | Object[] set1 = new Object[] {1, baseDN, 0, "localhost:8989", state, 0L, (byte)0, 0}; |
| | | |
| | | baseDN = "dc=example,dc=com"; |
| | | baseDN = DN.decode("dc=example,dc=com"); |
| | | state = new ServerState(); |
| | | state.update(new CSN(75, 5,263)); |
| | | Object[] set2 = new Object[] {16, baseDN, 100, "anotherHost:1025", state, 1245L, (byte)25, 3456}; |
| | |
| | | * using protocol VLAST and V2 are working. |
| | | */ |
| | | @Test(dataProvider="createReplServerStartData") |
| | | public void replServerStartMsgTestVLASTV2(int serverId, String baseDN, int window, |
| | | public void replServerStartMsgTestVLASTV2(int serverId, DN baseDN, int window, |
| | | String url, ServerState state, long genId, byte groupId, int degTh) throws Exception |
| | | { |
| | | // TODO: replServerStartMsgTestV3V2 as soon as V3 will have any incompatibility with V2 |
| | | } |
| | | |
| | | @Test(dataProvider="createReplServerStartData") |
| | | public void replServerStartMsgTestVLASTV1(int serverId, String baseDN, int window, |
| | | public void replServerStartMsgTestVLASTV1(int serverId, DN baseDN, int window, |
| | | String url, ServerState state, long genId, byte groupId, int degTh) throws Exception |
| | | { |
| | | // Create message with no version. |
| | |
| | | assertEquals(msg.getGenerationId(), newMsg.getGenerationId()); |
| | | assertEquals(msg.getServerId(), newMsg.getServerId()); |
| | | assertEquals(msg.getServerURL(), newMsg.getServerURL()); |
| | | assertEquals(msg.getBaseDn(), newMsg.getBaseDn()); |
| | | assertEquals(msg.getBaseDN(), newMsg.getBaseDN()); |
| | | assertEquals(msg.getWindowSize(), newMsg.getWindowSize()); |
| | | assertEquals(msg.getServerState().getCSN(1), newMsg.getServerState().getCSN(1)); |
| | | assertEquals(msg.getSSLEncryption(), newMsg.getSSLEncryption()); |
| | |
| | | assertEquals(msg.getGenerationId(), vlastMsg.getGenerationId()); |
| | | assertEquals(msg.getServerId(), vlastMsg.getServerId()); |
| | | assertEquals(msg.getServerURL(), vlastMsg.getServerURL()); |
| | | assertEquals(msg.getBaseDn(), vlastMsg.getBaseDn()); |
| | | assertEquals(msg.getBaseDN(), vlastMsg.getBaseDN()); |
| | | assertEquals(msg.getWindowSize(), vlastMsg.getWindowSize()); |
| | | assertEquals(msg.getServerState().getCSN(1), vlastMsg.getServerState().getCSN(1)); |
| | | assertEquals(msg.getSSLEncryption(), vlastMsg.getSSLEncryption()); |
| | |
| | | byte safeDataLevel, List<Attribute> entryAttrList) |
| | | throws Exception |
| | | { |
| | | final DN dn = DN.decode(rawDN); |
| | | |
| | | // Create VLAST message |
| | | Attribute objectClass = Attributes.create(DirectoryServer |
| | | .getObjectClassAttributeType(), "organization"); |
| | |
| | | |
| | | CSN csn = new CSN(TimeThread.getTime(), 123, 45); |
| | | |
| | | AddMsg msg = new AddMsg(csn, rawDN, "thisIsaUniqueID", "parentUniqueId", |
| | | AddMsg msg = new AddMsg(csn, dn, "thisIsaUniqueID", "parentUniqueId", |
| | | objectClass, userAttributes, |
| | | operationalAttributes); |
| | | |
| | |
| | | |
| | | // Check fields common to both versions |
| | | assertEquals(newMsg.getEntryUUID(), msg.getEntryUUID()); |
| | | assertEquals(newMsg.getDn(), msg.getDn()); |
| | | assertEquals(newMsg.getDN(), msg.getDN()); |
| | | assertEquals(newMsg.getCSN(), msg.getCSN()); |
| | | assertEquals(newMsg.isAssured(), msg.isAssured()); |
| | | assertEquals(newMsg.getParentEntryUUID(), msg.getParentEntryUUID()); |
| | | |
| | | // Create an add operation from each message to compare attributes (kept encoded in messages) |
| | | Operation op = msg.createOperation(connection, rawDN); |
| | | Operation generatedOperation = newMsg.createOperation(connection, rawDN); |
| | | Operation op = msg.createOperation(connection, dn); |
| | | Operation generatedOperation = newMsg.createOperation(connection, dn); |
| | | |
| | | assertEquals(op.getClass(), AddOperationBasis.class); |
| | | assertEquals(generatedOperation.getClass(), AddOperationBasis.class); |
| | |
| | | |
| | | // Check we retrieve original VLAST message (VLAST fields) |
| | | assertEquals(msg.getEntryUUID(), vlastMsg.getEntryUUID()); |
| | | assertEquals(msg.getDn(), vlastMsg.getDn()); |
| | | assertEquals(msg.getDN(), vlastMsg.getDN()); |
| | | assertEquals(msg.getCSN(), vlastMsg.getCSN()); |
| | | assertEquals(msg.getParentEntryUUID(), vlastMsg.getParentEntryUUID()); |
| | | assertEquals(msg.isAssured(), vlastMsg.isAssured()); |
| | |
| | | } |
| | | |
| | | // Create an add operation from each message to compare attributes (kept encoded in messages) |
| | | op = msg.createOperation(connection, rawDN); |
| | | generatedOperation = vlastMsg.createOperation(connection, rawDN); |
| | | op = msg.createOperation(connection, dn); |
| | | generatedOperation = vlastMsg.createOperation(connection, dn); |
| | | |
| | | assertEquals(op.getClass(), AddOperationBasis.class); |
| | | assertEquals(generatedOperation.getClass(), AddOperationBasis.class); |
| | |
| | | byte safeDataLevel, List<Attribute> entryAttrList) |
| | | throws Exception |
| | | { |
| | | final DN dn = DN.decode(rawDN); |
| | | |
| | | CSN csn = new CSN(TimeThread.getTime(), 123, 45); |
| | | DeleteMsg msg = new DeleteMsg(rawDN, csn, "thisIsaUniqueID"); |
| | | DeleteMsg msg = new DeleteMsg(dn, csn, "thisIsaUniqueID"); |
| | | |
| | | msg.setAssured(isAssured); |
| | | msg.setAssuredMode(assuredMode); |
| | |
| | | |
| | | // Check fields common to both versions |
| | | assertEquals(newMsg.getEntryUUID(), msg.getEntryUUID()); |
| | | assertEquals(newMsg.getDn(), msg.getDn()); |
| | | assertEquals(newMsg.getDN(), msg.getDN()); |
| | | assertEquals(newMsg.getCSN(), msg.getCSN()); |
| | | assertEquals(newMsg.isAssured(), msg.isAssured()); |
| | | |
| | |
| | | |
| | | // Check we retrieve original VLAST message (VLAST fields) |
| | | assertEquals(msg.getEntryUUID(), vlastMsg.getEntryUUID()); |
| | | assertEquals(msg.getDn(), vlastMsg.getDn()); |
| | | assertEquals(msg.getDN(), vlastMsg.getDN()); |
| | | assertEquals(msg.getCSN(), vlastMsg.getCSN()); |
| | | assertEquals(msg.isAssured(), vlastMsg.isAssured()); |
| | | assertEquals(msg.getAssuredMode(), vlastMsg.getAssuredMode()); |
| | |
| | | |
| | | // Check fields common to both versions |
| | | assertEquals(newv1Msg.getEntryUUID(), origVlastMsg.getEntryUUID()); |
| | | assertEquals(newv1Msg.getDn(), origVlastMsg.getDn()); |
| | | assertEquals(newv1Msg.getDN(), origVlastMsg.getDN()); |
| | | assertEquals(newv1Msg.getCSN(), origVlastMsg.getCSN()); |
| | | assertEquals(newv1Msg.isAssured(), origVlastMsg.isAssured()); |
| | | |
| | |
| | | |
| | | // Check we retrieve original VLAST message (VLAST fields) |
| | | assertEquals(origVlastMsg.getEntryUUID(), generatedVlastMsg.getEntryUUID()); |
| | | assertEquals(origVlastMsg.getDn(), generatedVlastMsg.getDn()); |
| | | assertEquals(origVlastMsg.getDN(), generatedVlastMsg.getDN()); |
| | | assertEquals(origVlastMsg.getCSN(), generatedVlastMsg.getCSN()); |
| | | assertEquals(origVlastMsg.isAssured(), generatedVlastMsg.isAssured()); |
| | | assertEquals(origVlastMsg.getAssuredMode(), generatedVlastMsg.getAssuredMode()); |
| | |
| | | List<Attribute> entryAttrList) |
| | | throws Exception |
| | | { |
| | | final DN dn = DN.decode(rawDN); |
| | | |
| | | // Create VLAST message |
| | | CSN csn = new CSN(TimeThread.getTime(), 596, 13); |
| | | ModifyDNMsg msg = new ModifyDNMsg(rawDN, csn, uid, |
| | | ModifyDNMsg msg = new ModifyDNMsg(dn, csn, uid, |
| | | newParentUid, deleteOldRdn, |
| | | newSuperior, newRdn, mods); |
| | | |
| | |
| | | |
| | | // Check fields common to both versions |
| | | assertEquals(newMsg.getEntryUUID(), msg.getEntryUUID()); |
| | | assertEquals(newMsg.getDn(), msg.getDn()); |
| | | assertEquals(newMsg.getDN(), msg.getDN()); |
| | | assertEquals(newMsg.getCSN(), msg.getCSN()); |
| | | assertEquals(newMsg.isAssured(), msg.isAssured()); |
| | | assertEquals(newMsg.getNewRDN(), msg.getNewRDN()); |
| | |
| | | |
| | | // Check we retrieve original VLAST message (VLAST fields) |
| | | assertEquals(msg.getEntryUUID(), vlastMsg.getEntryUUID()); |
| | | assertEquals(msg.getDn(), vlastMsg.getDn()); |
| | | assertEquals(msg.getDN(), vlastMsg.getDN()); |
| | | assertEquals(msg.getCSN(), vlastMsg.getCSN()); |
| | | assertEquals(msg.isAssured(), vlastMsg.isAssured()); |
| | | assertEquals(msg.getAssuredMode(), vlastMsg.getAssuredMode()); |
| | |
| | | { |
| | | LDAPUpdateMsg msg = (LDAPUpdateMsg) ReplicationMsg.generateMsg( |
| | | hexStringToByteArray(encodedString), ProtocolVersion.REPLICATION_PROTOCOL_V3); |
| | | assertEquals(msg.getDn(), dn); |
| | | assertEquals(msg.getDN(), DN.decode(dn)); |
| | | assertEquals(msg.getCSN(), csn); |
| | | assertEquals(msg.getClass(), msgType); |
| | | BigInteger bi = new BigInteger(msg.getBytes(ProtocolVersion.REPLICATION_PROTOCOL_V3)); |
| | |
| | | // parameters |
| | | ServerStartMsg msg = new ServerStartMsg(hexStringToByteArray(oldPdu)); |
| | | assertEquals(msg.getServerId(), serverId); |
| | | assertEquals(msg.getBaseDn(), dn); |
| | | assertEquals(msg.getBaseDN(), DN.decode(dn)); |
| | | assertEquals(msg.getGroupId(), groupId); |
| | | BigInteger bi = new BigInteger(msg.getBytes(getCurrentVersion())); |
| | | assertEquals(bi.toString(16), oldPdu); |
| | |
| | | public void oldReplServerStartPDUs( |
| | | String oldPdu, int serverId, String dn, byte groupId) throws Exception |
| | | { |
| | | // This is a ServerStartMSg with ServerId=16, baseDn=o=test and groupID=31 |
| | | // This is a ServerStartMSg with ServerId=16, baseDN=o=test and groupID=31 |
| | | // For now this test only checks those parameters. |
| | | // It would be nice to complete it with checks for ServerState and other |
| | | // parameters. |
| | | ReplServerStartMsg msg = new ReplServerStartMsg(hexStringToByteArray(oldPdu)); |
| | | assertEquals(msg.getServerId(), serverId); |
| | | assertEquals(msg.getBaseDn(), dn); |
| | | assertEquals(msg.getBaseDN(), DN.decode(dn)); |
| | | assertEquals(msg.getGroupId(), groupId); |
| | | BigInteger bi = new BigInteger(msg.getBytes(ProtocolVersion.REPLICATION_PROTOCOL_V3)); |
| | | assertEquals(bi.toString(16), oldPdu); |
| | |
| | | { |
| | | int sender = 1; |
| | | int dest = 2; |
| | | String baseDn = "dc=whatever"; |
| | | DN baseDN = DN.decode("dc=whatever"); |
| | | int initWindow = 22; |
| | | Object[] set1 = new Object[] {sender, dest, baseDn, initWindow }; |
| | | Object[] set1 = new Object[] { sender, dest, baseDN, initWindow }; |
| | | return new Object [][] { set1}; |
| | | } |
| | | |
| | |
| | | */ |
| | | @Test(enabled=true, dataProvider="createInitializationRequestMsgData") |
| | | public void initializationRequestMsgTestVLASTV3(int sender, int dest, |
| | | String baseDn, int initWindow) |
| | | throws Exception |
| | | DN baseDN, int initWindow) throws Exception |
| | | { |
| | | // Create VLAST message |
| | | InitializeRequestMsg msg = new InitializeRequestMsg(baseDn, sender, dest, initWindow); |
| | | InitializeRequestMsg msg = new InitializeRequestMsg(baseDN, sender, dest, initWindow); |
| | | |
| | | // Serialize in V3 |
| | | byte[] v3MsgBytes = msg.getBytes(ProtocolVersion.REPLICATION_PROTOCOL_V3); |
| | |
| | | // Check fields common to both versions |
| | | assertEquals(msg.getSenderID(), newMsg.getSenderID()); |
| | | assertEquals(msg.getDestination(), newMsg.getDestination()); |
| | | assertEquals(msg.getBaseDn(), newMsg.getBaseDn()); |
| | | assertEquals(msg.getBaseDN(), newMsg.getBaseDN()); |
| | | |
| | | // Check default value for only post V3 fields |
| | | assertEquals(newMsg.getInitWindow(), 0); |
| | |
| | | // Check we retrieve original VLAST message (VLAST fields) |
| | | assertEquals(msg.getSenderID(), vlastMsg.getSenderID()); |
| | | assertEquals(msg.getDestination(), vlastMsg.getDestination()); |
| | | assertEquals(msg.getBaseDn(), vlastMsg.getBaseDn()); |
| | | assertEquals(msg.getBaseDN(), vlastMsg.getBaseDN()); |
| | | assertEquals(msg.getInitWindow(), vlastMsg.getInitWindow()); |
| | | } |
| | | |
| | |
| | | int sender = 1; |
| | | int dest = 2; |
| | | int initiator = 3; |
| | | String baseDn = "dc=whatever"; |
| | | DN baseDN = DN.decode("dc=whatever"); |
| | | int entryCount = 56; |
| | | int initWindow = 22; |
| | | Object[] set1 = new Object[] {sender, dest, initiator, baseDn, |
| | | entryCount, initWindow }; |
| | | Object[] set1 = new Object[] {sender, dest, initiator, baseDN, entryCount, initWindow }; |
| | | return new Object [][] { set1}; |
| | | } |
| | | |
| | |
| | | */ |
| | | @Test(enabled=true, dataProvider="createInitializeTargetMsgData") |
| | | public void initializeTargetMsgTestVLASTV3(int sender, int dest, |
| | | int initiator, String baseDn, int entryCount, int initWindow) |
| | | int initiator, DN baseDN, int entryCount, int initWindow) |
| | | throws Exception |
| | | { |
| | | // Create VLAST message |
| | | InitializeTargetMsg msg = new InitializeTargetMsg(baseDn, sender, dest, |
| | | InitializeTargetMsg msg = new InitializeTargetMsg(baseDN, sender, dest, |
| | | initiator, entryCount, initWindow); |
| | | |
| | | // Serialize in V3 |
| | |
| | | ProtocolVersion.REPLICATION_PROTOCOL_V3); |
| | | assertEquals(msg.getDestination(), dest); |
| | | assertEquals(msg.getSenderID(), sender); |
| | | assertEquals(msg.getBaseDn().toString(), baseDN); |
| | | assertEquals(msg.getBaseDN().toString(), baseDN); |
| | | } |
| | | } |
| | |
| | | import java.util.*; |
| | | import java.util.zip.DataFormatException; |
| | | |
| | | import org.assertj.core.api.Assertions; |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.controls.SubtreeDeleteControl; |
| | | import org.opends.server.core.*; |
| | |
| | | @SuppressWarnings("javadoc") |
| | | public class SynchronizationMsgTest extends ReplicationTestCase |
| | | { |
| | | |
| | | private DN TEST_ROOT_DN; |
| | | |
| | | /** |
| | | * Set up the environment for performing the tests in this Class. |
| | | * |
| | |
| | | public void setUp() throws Exception |
| | | { |
| | | super.setUp(); |
| | | TEST_ROOT_DN = DN.decode(TEST_ROOT_DN_STRING); |
| | | } |
| | | |
| | | /** |
| | |
| | | // Get ECL entry attributes |
| | | assertAttributesEqual(entryAttrList, generatedMsg.getEclIncludes()); |
| | | |
| | | Operation op = msg.createOperation(connection); |
| | | Operation generatedOperation = generatedMsg.createOperation(connection); |
| | | |
| | | assertEquals(op.getClass(), ModifyOperationBasis.class); |
| | | assertEquals(generatedOperation.getClass(), ModifyOperationBasis.class); |
| | | |
| | | ModifyOperation mod1 = (ModifyOperation) op; |
| | | ModifyOperation mod2 = (ModifyOperation) generatedOperation; |
| | | ModifyOperation mod1 = (ModifyOperation) msg.createOperation(connection); |
| | | ModifyOperation mod2 = (ModifyOperation) generatedMsg.createOperation(connection); |
| | | |
| | | assertEquals(mod1.getRawEntryDN(), mod2.getRawEntryDN()); |
| | | assertEquals( mod1.getAttachment(SYNCHROCONTEXT), |
| | | mod2.getAttachment(SYNCHROCONTEXT)); |
| | | assertEquals(mod1.getAttachment(SYNCHROCONTEXT), |
| | | mod2.getAttachment(SYNCHROCONTEXT)); |
| | | assertEquals(mod1.getModifications(), mod2.getModifications()); |
| | | } |
| | | |
| | |
| | | assertFalse(msg.equals(new Object())); |
| | | |
| | | // Check CSN |
| | | assertTrue(msg.equals(generatedMsg)); |
| | | assertEquals(msg, generatedMsg); |
| | | |
| | | // Check hashCode |
| | | assertEquals(msg.hashCode(), generatedMsg.hashCode()); |
| | |
| | | assertEquals(msg.compareTo(generatedMsg), 0); |
| | | |
| | | // Check Get / Set DN |
| | | assertTrue(DN.decode(msg.getDn()).equals(DN.decode(generatedMsg.getDn()))); |
| | | assertEquals(msg.getDN(), generatedMsg.getDN()); |
| | | |
| | | String fakeDN = "cn=fake cn"; |
| | | msg.setDn(fakeDN) ; |
| | | assertEquals(msg.getDn(), fakeDN) ; |
| | | DN fakeDN = DN.decode("cn=fake cn"); |
| | | msg.setDN(fakeDN) ; |
| | | assertEquals(msg.getDN(), fakeDN) ; |
| | | |
| | | // Check uuid |
| | | assertEquals(msg.getEntryUUID(), generatedMsg.getEntryUUID()); |
| | |
| | | // Get ECL entry attributes |
| | | assertAttributesEqual(entryAttrList, generatedMsg.getEclIncludes()); |
| | | |
| | | Operation generatedOperation = generatedMsg.createOperation(connection); |
| | | |
| | | assertEquals(generatedOperation.getClass(), DeleteOperationBasis.class); |
| | | assertTrue( |
| | | (subtree?(generatedOperation.getRequestControl(SubtreeDeleteControl.DECODER)!=null): |
| | | (generatedOperation.getRequestControl(SubtreeDeleteControl.DECODER)==null))); |
| | | |
| | | DeleteOperation mod2 = (DeleteOperationBasis) generatedOperation; |
| | | DeleteOperation mod2 = (DeleteOperation) generatedMsg.createOperation(connection); |
| | | assertEquals(mod2.getRequestControl(SubtreeDeleteControl.DECODER) != null, subtree); |
| | | assertEquals(op.getRawEntryDN(), mod2.getRawEntryDN()); |
| | | |
| | | // Create an update message from this op |
| | |
| | | // Get ECL entry attributes |
| | | assertAttributesEqual(entryAttrList, generatedMsg.getEclIncludes()); |
| | | |
| | | Operation oriOp = msg.createOperation(connection); |
| | | Operation generatedOperation = generatedMsg.createOperation(connection); |
| | | |
| | | assertEquals(oriOp.getClass(), ModifyDNOperationBasis.class); |
| | | assertEquals(generatedOperation.getClass(), ModifyDNOperationBasis.class); |
| | | |
| | | ModifyDNOperation moddn1 = (ModifyDNOperation) oriOp; |
| | | ModifyDNOperation moddn2 = (ModifyDNOperation) generatedOperation; |
| | | ModifyDNOperation moddn1 = (ModifyDNOperation) msg.createOperation(connection); |
| | | ModifyDNOperation moddn2 = (ModifyDNOperation) generatedMsg.createOperation(connection); |
| | | |
| | | assertEquals(msg.getCSN(), generatedMsg.getCSN()); |
| | | assertEquals(moddn1.getRawEntryDN(), moddn2.getRawEntryDN()); |
| | |
| | | byte safeDataLevel, List<Attribute> entryAttrList) |
| | | throws Exception |
| | | { |
| | | final DN dn = DN.decode(rawDN); |
| | | |
| | | Attribute objectClass = Attributes.create(DirectoryServer |
| | | .getObjectClassAttributeType(), "organization"); |
| | | Map<ObjectClass, String> objectClassList = |
| | |
| | | |
| | | CSN csn = new CSN(TimeThread.getTime(), 123, 45); |
| | | |
| | | AddMsg msg = new AddMsg(csn, rawDN, "thisIsaUniqueID", "parentUniqueId", |
| | | AddMsg msg = new AddMsg(csn, dn, "thisIsaUniqueID", "parentUniqueId", |
| | | objectClass, userAttributes, |
| | | operationalAttributes); |
| | | |
| | |
| | | // Create an new Add Operation from the current addMsg |
| | | InternalClientConnection connection = |
| | | InternalClientConnection.getRootConnection(); |
| | | Operation op = msg.createOperation(connection, rawDN); |
| | | Operation generatedOperation = generatedMsg.createOperation(connection, rawDN); |
| | | |
| | | assertEquals(op.getClass(), AddOperationBasis.class); |
| | | assertEquals(generatedOperation.getClass(), AddOperationBasis.class); |
| | | |
| | | AddOperation addOp = (AddOperation) op; |
| | | AddOperation genAddOp = (AddOperation) generatedOperation; |
| | | AddOperation addOp = msg.createOperation(connection, dn); |
| | | AddOperation genAddOp = generatedMsg.createOperation(connection, dn); |
| | | |
| | | assertEquals(addOp.getRawEntryDN(), genAddOp.getRawEntryDN()); |
| | | assertEquals(addOp.getAttachment(SYNCHROCONTEXT), genAddOp.getAttachment(SYNCHROCONTEXT)); |
| | |
| | | assertEquals(msg.toString(), generatedMsg.toString()); |
| | | |
| | | //Create an Add operation and generate and Add msg from it |
| | | DN dn = DN.decode(rawDN); |
| | | |
| | | AddOperation addOpB = new AddOperationBasis(connection, |
| | | 1, 1, null, dn, objectClassList, userAttList, opList); |
| | | LocalBackendAddOperation localAddOp = new LocalBackendAddOperation(addOpB); |
| | |
| | | DeleteMsg delmsg = new DeleteMsg(op); |
| | | long changeNumber = 21; |
| | | |
| | | String baseDN = "dc=example,dc=com"; |
| | | DN baseDN = DN.decode("dc=example,dc=com"); |
| | | |
| | | // create a cookie |
| | | MultiDomainServerState cookie = |
| | |
| | | // Constructor test |
| | | ECLUpdateMsg msg1 = new ECLUpdateMsg(delmsg, cookie, baseDN, changeNumber); |
| | | assertTrue(msg1.getCookie().equalsTo(cookie)); |
| | | assertTrue(msg1.getBaseDN().equalsIgnoreCase(baseDN)); |
| | | assertEquals(msg1.getBaseDN(), baseDN); |
| | | assertEquals(msg1.getChangeNumber(), changeNumber); |
| | | DeleteMsg delmsg2 = (DeleteMsg)msg1.getUpdateMsg(); |
| | | assertEquals(delmsg.compareTo(delmsg2), 0); |
| | |
| | | ECLUpdateMsg msg2 = new ECLUpdateMsg(msg1.getBytes(getCurrentVersion())); |
| | | assertTrue(msg2.getCookie().equalsTo(msg2.getCookie())); |
| | | assertTrue(msg2.getCookie().equalsTo(cookie)); |
| | | assertTrue(msg2.getBaseDN().equalsIgnoreCase(msg1.getBaseDN())); |
| | | assertTrue(msg2.getBaseDN().equalsIgnoreCase(baseDN)); |
| | | assertEquals(msg2.getBaseDN(), msg1.getBaseDN()); |
| | | assertEquals(msg2.getBaseDN(), baseDN); |
| | | assertEquals(msg2.getChangeNumber(), msg1.getChangeNumber()); |
| | | assertEquals(msg2.getChangeNumber(), changeNumber); |
| | | |
| | |
| | | @DataProvider(name="createServerStartData") |
| | | public Object [][] createServerStartData() throws Exception |
| | | { |
| | | String baseDN = TEST_ROOT_DN_STRING; |
| | | DN baseDN = TEST_ROOT_DN; |
| | | ServerState state = new ServerState(); |
| | | state.update(new CSN(0, 0,0)); |
| | | Object[] set1 = new Object[] {1, baseDN, 0, state, 0L, false, (byte)0}; |
| | |
| | | * by checking that : msg == new ServerStartMsg(msg.getBytes()). |
| | | */ |
| | | @Test(enabled=true,dataProvider="createServerStartData") |
| | | public void serverStartMsgTest(int serverId, String baseDN, int window, |
| | | public void serverStartMsgTest(int serverId, DN baseDN, int window, |
| | | ServerState state, long genId, boolean sslEncryption, byte groupId) throws Exception |
| | | { |
| | | ServerStartMsg msg = new ServerStartMsg( |
| | |
| | | ServerStartMsg newMsg = new ServerStartMsg(msg.getBytes(getCurrentVersion())); |
| | | assertEquals(msg.getServerId(), newMsg.getServerId()); |
| | | assertEquals(msg.getServerURL(), newMsg.getServerURL()); |
| | | assertEquals(msg.getBaseDn(), newMsg.getBaseDn()); |
| | | assertEquals(msg.getBaseDN(), newMsg.getBaseDN()); |
| | | assertEquals(msg.getWindowSize(), newMsg.getWindowSize()); |
| | | assertEquals(msg.getHeartbeatInterval(), newMsg.getHeartbeatInterval()); |
| | | assertEquals(msg.getSSLEncryption(), newMsg.getSSLEncryption()); |
| | |
| | | @DataProvider(name="createReplServerStartData") |
| | | public Object [][] createReplServerStartData() throws Exception |
| | | { |
| | | String baseDN = TEST_ROOT_DN_STRING; |
| | | DN baseDN = TEST_ROOT_DN; |
| | | ServerState state = new ServerState(); |
| | | state.update(new CSN(0, 0,0)); |
| | | Object[] set1 = new Object[] {1, baseDN, 0, "localhost:8989", state, 0L, (byte)0, 0}; |
| | |
| | | * by checking that : msg == new ReplServerStartMsg(msg.getBytes()). |
| | | */ |
| | | @Test(enabled=true,dataProvider="createReplServerStartData") |
| | | public void replServerStartMsgTest(int serverId, String baseDN, int window, |
| | | public void replServerStartMsgTest(int serverId, DN baseDN, int window, |
| | | String url, ServerState state, long genId, byte groupId, int degTh) throws Exception |
| | | { |
| | | ReplServerStartMsg msg = new ReplServerStartMsg(serverId, |
| | | url, baseDN, window, state, genId, |
| | | true, groupId, degTh); |
| | | url, baseDN, window, state, genId, true, groupId, degTh); |
| | | ReplServerStartMsg newMsg = new ReplServerStartMsg(msg.getBytes(getCurrentVersion())); |
| | | assertEquals(msg.getServerId(), newMsg.getServerId()); |
| | | assertEquals(msg.getServerURL(), newMsg.getServerURL()); |
| | | assertEquals(msg.getBaseDn(), newMsg.getBaseDn()); |
| | | assertEquals(msg.getBaseDN(), newMsg.getBaseDN()); |
| | | assertEquals(msg.getWindowSize(), newMsg.getWindowSize()); |
| | | assertEquals(msg.getServerState().getCSN(1), |
| | | newMsg.getServerState().getCSN(1)); |
| | |
| | | @DataProvider(name="createReplServerStartDSData") |
| | | public Object [][] createReplServerStartDSData() throws Exception |
| | | { |
| | | String baseDN = TEST_ROOT_DN_STRING; |
| | | DN baseDN = TEST_ROOT_DN; |
| | | ServerState state = new ServerState(); |
| | | state.update(new CSN(0, 0, 0)); |
| | | Object[] set1 = new Object[] {1, baseDN, 0, "localhost:8989", state, 0L, (byte)0, 0, 0, 0}; |
| | |
| | | * by checking that : msg == new ReplServerStartMsg(msg.getBytes()). |
| | | */ |
| | | @Test(dataProvider="createReplServerStartDSData") |
| | | public void replServerStartDSMsgTest(int serverId, String baseDN, int window, |
| | | public void replServerStartDSMsgTest(int serverId, DN baseDN, int window, |
| | | String url, ServerState state, long genId, byte groupId, int degTh, |
| | | int weight, int connectedDSNumber) throws Exception |
| | | { |
| | |
| | | ReplServerStartDSMsg newMsg = new ReplServerStartDSMsg(msg.getBytes(getCurrentVersion())); |
| | | assertEquals(msg.getServerId(), newMsg.getServerId()); |
| | | assertEquals(msg.getServerURL(), newMsg.getServerURL()); |
| | | assertEquals(msg.getBaseDn(), newMsg.getBaseDn()); |
| | | assertEquals(msg.getBaseDN(), newMsg.getBaseDN()); |
| | | assertEquals(msg.getWindowSize(), newMsg.getWindowSize()); |
| | | assertEquals(msg.getServerState().getCSN(1), |
| | | newMsg.getServerState().getCSN(1)); |
| | |
| | | @DataProvider(name="createTopologyData") |
| | | public Object [][] createTopologyData() throws Exception |
| | | { |
| | | List<String> urls1 = new ArrayList<String>(); |
| | | urls1.add("ldap://ldap.iplanet.com/" + TEST_ROOT_DN_STRING + "??sub?(sn=Jensen)"); |
| | | urls1.add("ldaps://ldap.iplanet.com:4041/uid=bjensen,ou=People," + |
| | | TEST_ROOT_DN_STRING + "?cn,mail,telephoneNumber"); |
| | | |
| | | List<String> urls2 = new ArrayList<String>(); |
| | | |
| | | List<String> urls3 = new ArrayList<String>(); |
| | | urls3.add("ldaps://host:port/dc=foo??sub?(sn=One Entry)"); |
| | | |
| | | List<String> urls4 = new ArrayList<String>(); |
| | | urls4.add("ldaps://host:port/dc=foobar1??sub?(sn=Another Entry 1)"); |
| | | urls4.add("ldaps://host:port/dc=foobar2??sub?(sn=Another Entry 2)"); |
| | | |
| | | List<String> urls1 = newList( |
| | | "ldap://ldap.iplanet.com/" + TEST_ROOT_DN_STRING + "??sub?(sn=Jensen)", |
| | | "ldaps://ldap.iplanet.com:4041/uid=bjensen,ou=People," |
| | | + TEST_ROOT_DN_STRING + "?cn,mail,telephoneNumber"); |
| | | List<String> urls2 = newList(); |
| | | List<String> urls3 = newList("ldaps://host:port/dc=foo??sub?(sn=One Entry)"); |
| | | List<String> urls4 = newList( |
| | | "ldaps://host:port/dc=foobar1??sub?(sn=Another Entry 1)", |
| | | "ldaps://host:port/dc=foobar2??sub?(sn=Another Entry 2)"); |
| | | |
| | | Set<String> a1 = newSet(); |
| | | Set<String> a2 = newSet("dc"); |
| | |
| | | |
| | | DSInfo dsInfo1 = new DSInfo(13, "dsHost1:111", 26, 154631, ServerStatus.FULL_UPDATE_STATUS, |
| | | false, AssuredMode.SAFE_DATA_MODE, (byte)12, (byte)132, urls1, a1, a1, (short)1); |
| | | |
| | | DSInfo dsInfo2 = new DSInfo(-436, "dsHost2:222", 493, -227896, ServerStatus.DEGRADED_STATUS, |
| | | true, AssuredMode.SAFE_READ_MODE, (byte)-7, (byte)-265, urls2, a2, a2, (short)2); |
| | | |
| | | DSInfo dsInfo3 = new DSInfo(2436, "dsHost3:333", 591, 0, ServerStatus.NORMAL_STATUS, |
| | | false, AssuredMode.SAFE_READ_MODE, (byte)17, (byte)0, urls3, a3, a3, (short)3); |
| | | DSInfo dsInfo4 = new DSInfo(415, "dsHost4:444", 146, 0, ServerStatus.BAD_GEN_ID_STATUS, |
| | | true, AssuredMode.SAFE_DATA_MODE, (byte)2, (byte)15, urls4, a4, a4, (short)4); |
| | | |
| | | DSInfo dsInfo5 = new DSInfo(452436, "dsHost5:555", 45591, 0, ServerStatus.NORMAL_STATUS, |
| | | false, AssuredMode.SAFE_READ_MODE, (byte)17, (byte)0, urls3, a1, a1, (short)5); |
| | | false, AssuredMode.SAFE_READ_MODE, (byte)17, (byte)0, urls3, a1, a1, (short)5); |
| | | |
| | | List<DSInfo> dsList1 = newList(dsInfo1); |
| | | List<DSInfo> dsList2 = newList(); |
| | |
| | | assertEquals(msg.getAssuredMode(), newMsg.getAssuredMode()); |
| | | assertEquals(msg.getSafeDataLevel(), newMsg.getSafeDataLevel()); |
| | | assertEquals(msg.getReferralsURLs(), newMsg.getReferralsURLs()); |
| | | assertTrue(attrs.equals(newMsg.getEclIncludes())); |
| | | assertTrue(attrs.equals(newMsg.getEclIncludesForDeletes())); |
| | | Assertions.assertThat(attrs).isEqualTo(newMsg.getEclIncludes()); |
| | | Assertions.assertThat(attrs).isEqualTo(newMsg.getEclIncludesForDeletes()); |
| | | } |
| | | |
| | | /** |
| | |
| | | int sender = 1; |
| | | int target = 56789; |
| | | InitializeRequestMsg msg = new InitializeRequestMsg( |
| | | TEST_ROOT_DN_STRING, sender, target, 100); |
| | | TEST_ROOT_DN, sender, target, 100); |
| | | InitializeRequestMsg newMsg = new InitializeRequestMsg(msg.getBytes(getCurrentVersion()),getCurrentVersion()); |
| | | assertEquals(msg.getSenderID(), newMsg.getSenderID()); |
| | | assertEquals(msg.getDestination(), newMsg.getDestination()); |
| | | assertTrue(msg.getBaseDn().equals(newMsg.getBaseDn())); |
| | | assertEquals(msg.getBaseDN(), newMsg.getBaseDN()); |
| | | } |
| | | |
| | | /** |
| | |
| | | int initWindow = 100; |
| | | |
| | | InitializeTargetMsg msg = new InitializeTargetMsg( |
| | | TEST_ROOT_DN_STRING, senderID, targetID, requestorID, entryCount, initWindow); |
| | | TEST_ROOT_DN, senderID, targetID, requestorID, entryCount, initWindow); |
| | | InitializeTargetMsg newMsg = new InitializeTargetMsg(msg.getBytes(getCurrentVersion()),getCurrentVersion()); |
| | | assertEquals(msg.getSenderID(), newMsg.getSenderID()); |
| | | assertEquals(msg.getDestination(), newMsg.getDestination()); |
| | | assertEquals(msg.getInitiatorID(), newMsg.getInitiatorID()); |
| | | assertEquals(msg.getEntryCount(), newMsg.getEntryCount()); |
| | | assertTrue(msg.getBaseDN().equals(newMsg.getBaseDN())) ; |
| | | assertEquals(msg.getBaseDN(), newMsg.getBaseDN()); |
| | | |
| | | assertEquals(senderID, newMsg.getSenderID()); |
| | | assertEquals(targetID, newMsg.getDestination()); |
| | | assertEquals(requestorID, newMsg.getInitiatorID()); |
| | | assertEquals(entryCount, newMsg.getEntryCount()); |
| | | assertTrue(TEST_ROOT_DN_STRING.equals(newMsg.getBaseDN())) ; |
| | | |
| | | assertEquals(TEST_ROOT_DN, newMsg.getBaseDN()); |
| | | } |
| | | |
| | | /** |
| | |
| | | * by checking that : msg == new ServerStartMsg(msg.getBytes()). |
| | | */ |
| | | @Test(enabled=true,dataProvider="createServerStartData") |
| | | public void startECLMsgTest(int serverId, String baseDN, int window, |
| | | public void startECLMsgTest(int serverId, DN baseDN, int window, |
| | | ServerState state, long genId, boolean sslEncryption, byte groupId) throws Exception |
| | | { |
| | | ServerStartECLMsg msg = new ServerStartECLMsg( |
| | |
| | | |
| | | FakeReplicationServer fakeReplicationServer = new FakeReplicationServer( |
| | | rsPort, serverId, assured, assuredMode, (byte)safeDataLevel, (byte)groupId, |
| | | TEST_ROOT_DN_STRING, generationId); |
| | | DN.decode(TEST_ROOT_DN_STRING), generationId); |
| | | |
| | | // Connect fake RS to the real RS |
| | | fakeReplicationServer.connect(serverState); |
| | |
| | | public void sendNewFakeUpdate(boolean useAssured) throws TimeoutException |
| | | { |
| | | // Create a new delete update message (the simplest to create) |
| | | DeleteMsg delMsg = |
| | | new DeleteMsg(getBaseDNString(), gen.newCSN(), |
| | | UUID.randomUUID().toString()); |
| | | DeleteMsg delMsg = new DeleteMsg(getBaseDN(), gen.newCSN(), UUID.randomUUID().toString()); |
| | | |
| | | // Send it (this uses the defined assured conf at constructor time) |
| | | if (useAssured) |
| | |
| | | { |
| | | |
| | | private boolean shutdown = false; |
| | | private Session session = null; |
| | | private Session session; |
| | | |
| | | /** Parameters given at constructor time */ |
| | | private int port; |
| | | private int serverId = -1; |
| | | boolean isAssured = false; // Default value for config |
| | | AssuredMode assuredMode = AssuredMode.SAFE_DATA_MODE; // Default value for config |
| | | byte safeDataLevel = (byte) 1; // Default value for config |
| | | private String baseDn = null; |
| | | private boolean isAssured = false; // Default value for config |
| | | private AssuredMode assuredMode = AssuredMode.SAFE_DATA_MODE; // Default value for config |
| | | private byte safeDataLevel = 1; // Default value for config |
| | | private DN baseDN; |
| | | private long generationId = -1L; |
| | | private byte groupId = (byte) -1; |
| | | private byte groupId = -1; |
| | | private boolean sslEncryption = false; |
| | | /** The scenario this RS is expecting */ |
| | | private int scenario = -1; |
| | | |
| | | private CSNGenerator gen = null; |
| | | private CSNGenerator gen; |
| | | |
| | | /** False if a received update had assured parameters not as expected */ |
| | | private boolean everyUpdatesAreOk = true; |
| | |
| | | * @param assuredMode the expected assured mode of the incoming updates (also used for outgoing updates) |
| | | * @param safeDataLevel the expected safe data level of the incoming updates (also used for outgoing updates) |
| | | * @param groupId our group id |
| | | * @param baseDn the basedn we connect with, to the real RS |
| | | * @param baseDN the basedn we connect with, to the real RS |
| | | * @param generationId the generation id we use at connection to real RS |
| | | */ |
| | | public FakeReplicationServer(int port, int serverId, boolean assured, |
| | | AssuredMode assuredMode, int safeDataLevel, |
| | | byte groupId, String baseDn, long generationId) |
| | | byte groupId, DN baseDN, long generationId) |
| | | { |
| | | this.port = port; |
| | | this.serverId = serverId; |
| | | this.baseDn = baseDn; |
| | | this.baseDN = baseDN; |
| | | this.generationId = generationId; |
| | | this.groupId = groupId; |
| | | this.isAssured = assured; |
| | |
| | | public AckMsg sendNewFakeUpdate() throws Exception |
| | | { |
| | | // Create a new delete update message (the simplest to create) |
| | | DeleteMsg delMsg = new DeleteMsg(baseDn, gen.newCSN(), |
| | | DeleteMsg delMsg = new DeleteMsg(baseDN, gen.newCSN(), |
| | | UUID.randomUUID().toString()); |
| | | |
| | | // Send del message in assured mode |
| | |
| | | |
| | | // Send our repl server start msg |
| | | ReplServerStartMsg replServerStartMsg = new ReplServerStartMsg(serverId, |
| | | fakeUrl, baseDn, 100, serverState, |
| | | generationId, sslEncryption, |
| | | groupId, 5000); |
| | | fakeUrl, baseDN, 100, serverState, |
| | | generationId, sslEncryption, groupId, 5000); |
| | | session.publish(replServerStartMsg); |
| | | |
| | | // Read repl server start msg |
| | |
| | | long time = TimeThread.getTime(); |
| | | int ts = 1; |
| | | CSN csn1 = new CSN(time, ts++, SERVER_ID_1); |
| | | DeleteMsg delMsg1 = |
| | | new DeleteMsg("o=" + tn + "1," + TEST_ROOT_DN_STRING, csn1, |
| | | "ECLBasicMsg1uid"); |
| | | DeleteMsg delMsg1 = newDeleteMsg("o=" + tn + "1," + TEST_ROOT_DN_STRING, csn1, "ECLBasicMsg1uid"); |
| | | server01.publish(delMsg1); |
| | | debugInfo(tn, "publishes:" + delMsg1); |
| | | |
| | | CSN csn2 = new CSN(time, ts++, SERVER_ID_2); |
| | | DeleteMsg delMsg2 = |
| | | new DeleteMsg("o=" + tn + "2," + TEST_ROOT_DN_STRING2, csn2, |
| | | "ECLBasicMsg2uid"); |
| | | DeleteMsg delMsg2 = newDeleteMsg("o=" + tn + "2," + TEST_ROOT_DN_STRING2, csn2, "ECLBasicMsg2uid"); |
| | | server02.publish(delMsg2); |
| | | debugInfo(tn, "publishes:" + delMsg2); |
| | | |
| | |
| | | long time = TimeThread.getTime(); |
| | | |
| | | CSN csn1 = new CSN(time, 1, SERVER_ID_1); |
| | | DeleteMsg delMsg1 = new DeleteMsg("o=" + tn + "1," + TEST_ROOT_DN_STRING, csn1, "ECLBasicMsg1uid"); |
| | | DeleteMsg delMsg1 = newDeleteMsg("o=" + tn + "1," + TEST_ROOT_DN_STRING, csn1, "ECLBasicMsg1uid"); |
| | | server01.publish(delMsg1); |
| | | debugInfo(tn, "publishes:" + delMsg1); |
| | | |
| | |
| | | } |
| | | |
| | | private void publishDeleteMsgInOTest(ReplicationBroker broker, CSN csn, |
| | | String tn, int i) |
| | | String tn, int i) throws DirectoryException |
| | | { |
| | | publishDeleteMsg(broker, csn, tn, i, TEST_ROOT_DN_STRING); |
| | | } |
| | | |
| | | private void publishDeleteMsgInOTest2(ReplicationBroker broker, CSN csn, |
| | | String tn, int i) |
| | | String tn, int i) throws DirectoryException |
| | | { |
| | | publishDeleteMsg(broker, csn, tn, i, TEST_ROOT_DN_STRING2); |
| | | } |
| | | |
| | | private void publishDeleteMsg(ReplicationBroker broker, CSN csn, String tn, |
| | | int i, String baseDn) |
| | | int i, String baseDn) throws DirectoryException |
| | | { |
| | | String dn = "uid=" + tn + i + "," + baseDn; |
| | | DeleteMsg delMsg = new DeleteMsg(dn, csn, tn + "uuid" + i); |
| | | DeleteMsg delMsg = newDeleteMsg(dn, csn, tn + "uuid" + i); |
| | | broker.publish(delMsg); |
| | | debugInfo(tn, " publishes " + delMsg.getCSN()); |
| | | } |
| | | |
| | | private DeleteMsg newDeleteMsg(String dn, CSN csn, String entryUUID) throws DirectoryException |
| | | { |
| | | return new DeleteMsg(DN.decode(dn), csn, entryUUID); |
| | | } |
| | | |
| | | private InternalSearchOperation searchOnCookieChangelog(String filterString, |
| | | String cookie, String testName, ResultCode expectedResultCode) |
| | | throws Exception |
| | |
| | | Entry entry = TestCaseUtils.entryFromLdifString(lentry); |
| | | AddMsg addMsg = new AddMsg( |
| | | csns[csnCounter], |
| | | "uid="+tn+"2," + TEST_ROOT_DN_STRING, |
| | | DN.decode("uid="+tn+"2," + TEST_ROOT_DN_STRING), |
| | | user1entryUUID, |
| | | baseUUID, |
| | | entry.getObjectClassAttribute(), |
| | |
| | | |
| | | // Produce update on this suffix |
| | | DeleteMsg delMsg = |
| | | new DeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, csns[0], |
| | | newDeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, csns[0], |
| | | "11111111-1112-1113-1114-111111111114"); |
| | | debugInfo(tn, " publishing " + delMsg.getCSN()); |
| | | server01.publish(delMsg); |
| | |
| | | // Produces change 2 |
| | | final CSN csn = csns[1]; |
| | | String expectedDn = "uid=" + tn + "2," + TEST_ROOT_DN_STRING; |
| | | delMsg = new DeleteMsg(expectedDn, csn, |
| | | delMsg = newDeleteMsg(expectedDn, csn, |
| | | "11111111-1112-1113-1114-111111111115"); |
| | | debugInfo(tn, " publishing " + delMsg.getCSN()); |
| | | server01.publish(delMsg); |
| | |
| | | // Produce update 1 |
| | | CSN csn1 = new CSN(TimeThread.getTime(), ts++, SERVER_ID_1); |
| | | DeleteMsg delMsg1 = |
| | | new DeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, csn1, |
| | | newDeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, csn1, |
| | | "11111111-1111-1111-1111-111111111111"); |
| | | debugInfo(tn, " publishing " + delMsg1); |
| | | server01.publish(delMsg1); |
| | |
| | | // Produce update 2 |
| | | CSN csn2 = new CSN(TimeThread.getTime(), ts++, SERVER_ID_2); |
| | | DeleteMsg delMsg2 = |
| | | new DeleteMsg("uid=" + tn + "2," + TEST_ROOT_DN_STRING2, csn2, |
| | | newDeleteMsg("uid=" + tn + "2," + TEST_ROOT_DN_STRING2, csn2, |
| | | "22222222-2222-2222-2222-222222222222"); |
| | | debugInfo(tn, " publishing " + delMsg2); |
| | | server02.publish(delMsg2); |
| | |
| | | // Produce update 3 |
| | | CSN csn3 = new CSN(TimeThread.getTime(), ts++, SERVER_ID_2); |
| | | DeleteMsg delMsg3 = |
| | | new DeleteMsg("uid=" + tn + "3," + TEST_ROOT_DN_STRING2, csn3, |
| | | newDeleteMsg("uid=" + tn + "3," + TEST_ROOT_DN_STRING2, csn3, |
| | | "33333333-3333-3333-3333-333333333333"); |
| | | debugInfo(tn, " publishing " + delMsg3); |
| | | server02.publish(delMsg3); |
| | |
| | | // Produces additional change |
| | | CSN csn11 = new CSN(TimeThread.getTime(), 11, SERVER_ID_1); |
| | | String expectedDn11 = "uid=" + tn + "11," + TEST_ROOT_DN_STRING; |
| | | DeleteMsg delMsg11 = new DeleteMsg(expectedDn11, csn11, |
| | | DeleteMsg delMsg11 = newDeleteMsg(expectedDn11, csn11, |
| | | "44444444-4444-4444-4444-444444444444"); |
| | | debugInfo(tn, " publishing " + delMsg11); |
| | | server01.publish(delMsg11); |
| | |
| | | // Produces additional change |
| | | CSN csn12 = new CSN(TimeThread.getTime(), 12, SERVER_ID_2); |
| | | String expectedDn12 = "uid=" + tn + "12," + TEST_ROOT_DN_STRING2; |
| | | DeleteMsg delMsg12 = new DeleteMsg(expectedDn12, csn12, |
| | | DeleteMsg delMsg12 = newDeleteMsg(expectedDn12, csn12, |
| | | "55555555-5555-5555-5555-555555555555"); |
| | | debugInfo(tn, " publishing " + delMsg12 ); |
| | | server02.publish(delMsg12); |
| | |
| | | // Produces additional change |
| | | CSN csn13 = new CSN(TimeThread.getTime(), 13, SERVER_ID_2); |
| | | String expectedDn13 = "uid=" + tn + "13," + TEST_ROOT_DN_STRING2; |
| | | DeleteMsg delMsg13 = new DeleteMsg(expectedDn13, csn13, |
| | | DeleteMsg delMsg13 = newDeleteMsg(expectedDn13, csn13, |
| | | "66666666-6666-6666-6666-666666666666"); |
| | | debugInfo(tn, " publishing " + delMsg13); |
| | | server02.publish(delMsg13); |
| | |
| | | gblCSN = csns[1]; |
| | | |
| | | // Publish DEL |
| | | DeleteMsg delMsg = |
| | | new DeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, csns[0], |
| | | user1entryUUID); |
| | | DeleteMsg delMsg = newDeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, csns[0], user1entryUUID); |
| | | server01.publish(delMsg); |
| | | debugInfo(tn, " publishes " + delMsg.getCSN()); |
| | | |
| | |
| | | Entry entry = TestCaseUtils.entryFromLdifString(lentry); |
| | | AddMsg addMsg = new AddMsg( |
| | | gblCSN, |
| | | "uid="+tn+"2," + TEST_ROOT_DN_STRING, |
| | | DN.decode("uid="+tn+"2," + TEST_ROOT_DN_STRING), |
| | | user1entryUUID, |
| | | baseUUID, |
| | | entry.getObjectClassAttribute(), |
| | |
| | | |
| | | // Publish DEL |
| | | CSN csn1 = new CSN(TimeThread.getTime(), ts++, SERVER_ID_1); |
| | | DeleteMsg delMsg = new DeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, |
| | | DeleteMsg delMsg = newDeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, |
| | | csn1, user1entryUUID); |
| | | server01.publish(delMsg); |
| | | debugInfo(tn, " publishes " + delMsg.getCSN()); |
| | |
| | | 1000, replicationServerPort, brokerSessionTimeout, true); |
| | | |
| | | // Publish one first message |
| | | DeleteMsg delMsg = new DeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, csn1, |
| | | user1entryUUID); |
| | | DeleteMsg delMsg = newDeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, csn1, user1entryUUID); |
| | | server01.publish(delMsg); |
| | | debugInfo(tn, " publishes " + delMsg.getCSN()); |
| | | sleep(300); |
| | |
| | | assertEquals(rsdtest.getEligibleCount(fromStart, now()), 1); |
| | | |
| | | // Publish one second message |
| | | delMsg = new DeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, csn2, user1entryUUID); |
| | | delMsg = newDeleteMsg("uid=" + tn + "1," + TEST_ROOT_DN_STRING, csn2, user1entryUUID); |
| | | server01.publish(delMsg); |
| | | debugInfo(tn, " publishes " + delMsg.getCSN()); |
| | | sleep(300); |
| | |
| | | assertEquals(rsdtest.getEligibleCount(fromStateBeforeCSN2, now()), 0); |
| | | |
| | | // Publish one third message |
| | | delMsg = new DeleteMsg("uid="+tn+"1," + TEST_ROOT_DN_STRING, csn3, user1entryUUID); |
| | | delMsg = newDeleteMsg("uid="+tn+"1," + TEST_ROOT_DN_STRING, csn3, user1entryUUID); |
| | | server01.publish(delMsg); |
| | | debugInfo(tn, " publishes " + delMsg.getCSN()); |
| | | sleep(300); |
| | |
| | | for (int i=4; i<=maxMsg; i++) |
| | | { |
| | | CSN csnx = new CSN(TimeThread.getTime(), i, SERVER_ID_1); |
| | | delMsg = new DeleteMsg("uid="+tn+i+"," + TEST_ROOT_DN_STRING, csnx, user1entryUUID); |
| | | delMsg = newDeleteMsg("uid="+tn+i+"," + TEST_ROOT_DN_STRING, csnx, user1entryUUID); |
| | | server01.publish(delMsg); |
| | | } |
| | | sleep(1000); |
| | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | private static final int changelog2ID = 22; |
| | | private static final int changelog3ID = 23; |
| | | |
| | | private DN baseDn; |
| | | private ReplicationBroker broker2 = null; |
| | | private ReplicationBroker broker3 = null; |
| | | private ReplicationBroker broker4 = null; |
| | | private ReplicationServer replServer1 = null; |
| | | private ReplicationServer replServer2 = null; |
| | | private ReplicationServer replServer3 = null; |
| | | private LDAPReplicationDomain replDomain = null; |
| | | private String[] updatedEntries; |
| | | private DN baseDN; |
| | | private ReplicationBroker broker2; |
| | | private ReplicationBroker broker3; |
| | | private ReplicationBroker broker4; |
| | | private ReplicationServer replServer1; |
| | | private ReplicationServer replServer2; |
| | | private ReplicationServer replServer3; |
| | | private LDAPReplicationDomain replDomain; |
| | | |
| | | private static int[] replServerPort = new int[30]; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private void debugInfo(String message, Exception e) |
| | | { |
| | | debugInfo(message + stackTraceToSingleLineString(e)); |
| | | } |
| | | |
| | | /** |
| | | * Set up the environment for performing the tests in this Class. |
| | | * |
| | |
| | | { |
| | | super.setUp(); |
| | | |
| | | baseDn = DN.decode(baseDnStr); |
| | | |
| | | updatedEntries = newLDIFEntries(); |
| | | baseDN = DN.decode(baseDnStr); |
| | | } |
| | | |
| | | /** |
| | |
| | | private String[] newLDIFEntries() |
| | | { |
| | | return new String[]{ |
| | | "dn: " + baseDn + "\n" |
| | | "dn: " + baseDN + "\n" |
| | | + "objectClass: top\n" |
| | | + "objectClass: organization\n" |
| | | + "entryUUID: 21111111-1111-1111-1111-111111111111\n" |
| | | + "\n", |
| | | "dn: ou=People," + baseDn + "\n" |
| | | "dn: ou=People," + baseDN + "\n" |
| | | + "objectClass: top\n" |
| | | + "objectClass: organizationalUnit\n" |
| | | + "entryUUID: 21111111-1111-1111-1111-111111111112\n" |
| | | + "\n", |
| | | "dn: cn=Fiona Jensen,ou=people," + baseDn + "\n" |
| | | "dn: cn=Fiona Jensen,ou=people," + baseDN + "\n" |
| | | + "objectclass: top\n" |
| | | + "objectclass: person\n" |
| | | + "objectclass: organizationalPerson\n" |
| | |
| | | + "telephonenumber: +1 408 555 1212\n" |
| | | + "entryUUID: 21111111-1111-1111-1111-111111111113\n" |
| | | + "\n", |
| | | "dn: cn=Robert Langman,ou=people," + baseDn + "\n" |
| | | "dn: cn=Robert Langman,ou=people," + baseDN + "\n" |
| | | + "objectclass: top\n" |
| | | + "objectclass: person\n" |
| | | + "objectclass: organizationalPerson\n" |
| | |
| | | * @return The new created replication server. |
| | | */ |
| | | private ReplicationServer createReplicationServer(int changelogId, |
| | | boolean all, String suffix) |
| | | boolean all, String suffix) throws Exception |
| | | { |
| | | SortedSet<String> servers = new TreeSet<String>(); |
| | | try |
| | | if (all) |
| | | { |
| | | if (all) |
| | | { |
| | | if (changelogId != changelog1ID) |
| | | servers.add("localhost:" + getChangelogPort(changelog1ID)); |
| | | if (changelogId != changelog2ID) |
| | | servers.add("localhost:" + getChangelogPort(changelog2ID)); |
| | | } |
| | | int chPort = getChangelogPort(changelogId); |
| | | String chDir = "monitorTest"+changelogId+suffix+"Db"; |
| | | ReplServerFakeConfiguration conf = |
| | | if (changelogId != changelog1ID) |
| | | servers.add("localhost:" + getChangelogPort(changelog1ID)); |
| | | if (changelogId != changelog2ID) |
| | | servers.add("localhost:" + getChangelogPort(changelog2ID)); |
| | | } |
| | | int chPort = getChangelogPort(changelogId); |
| | | String chDir = "monitorTest" + changelogId + suffix + "Db"; |
| | | ReplServerFakeConfiguration conf = |
| | | new ReplServerFakeConfiguration(chPort, chDir, 0, changelogId, 0, 100, |
| | | servers); |
| | | ReplicationServer replicationServer = new ReplicationServer(conf); |
| | | Thread.sleep(1000); |
| | | ReplicationServer replicationServer = new ReplicationServer(conf); |
| | | Thread.sleep(1000); |
| | | |
| | | return replicationServer; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | fail("createChangelog" + stackTraceToSingleLineString(e)); |
| | | } |
| | | return null; |
| | | return replicationServer; |
| | | } |
| | | |
| | | /** |
| | |
| | | * replication Server ID. |
| | | * @param changelogID the replication server ID. |
| | | */ |
| | | private void connectServer1ToChangelog(int changelogID) |
| | | private void connectServer1ToChangelog(int changelogID) throws Exception |
| | | { |
| | | // Connect DS to the replicationServer |
| | | try |
| | | { |
| | | // suffix synchronized |
| | | String synchroServerLdif = |
| | |
| | | "Unable to add the synchronized server"); |
| | | configEntryList.add(synchroServerEntry.getDN()); |
| | | |
| | | replDomain = LDAPReplicationDomain.retrievesReplicationDomain(baseDn); |
| | | replDomain = LDAPReplicationDomain.retrievesReplicationDomain(baseDN); |
| | | |
| | | if (replDomain != null) |
| | | { |
| | |
| | | replDomain.ieRunning()); |
| | | } |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | debugInfo("connectToReplServer", e); |
| | | fail("connectToReplServer: " + e.getMessage() + " : " + e.getStackTrace(), e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | + "userPassword: password\n" + "initials: AA\n"; |
| | | } |
| | | |
| | | static private ReplicationMsg createAddMsg(CSN csn) |
| | | static private ReplicationMsg createAddMsg(CSN csn) throws Exception |
| | | { |
| | | Entry personWithUUIDEntry = null; |
| | | String user1entryUUID; |
| | |
| | | + "userPassword: password\n" + "initials: AA\n" |
| | | + "entryUUID: " + user1entryUUID + "\n"; |
| | | |
| | | try |
| | | { |
| | | personWithUUIDEntry = TestCaseUtils.entryFromLdifString(entryWithUUIDldif); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | fail(e.getMessage()); |
| | | } |
| | | personWithUUIDEntry = TestCaseUtils.entryFromLdifString(entryWithUUIDldif); |
| | | |
| | | // Create and publish an update message to add an entry. |
| | | return new AddMsg(csn, |
| | | personWithUUIDEntry.getDN().toString(), |
| | | personWithUUIDEntry.getDN(), |
| | | user1entryUUID, |
| | | baseUUID, |
| | | personWithUUIDEntry.getObjectClassAttribute(), |
| | |
| | | try |
| | | { |
| | | debugInfo("Connecting broker2 to replServer1"); |
| | | broker2 = openReplicationSession(baseDn, |
| | | broker2 = openReplicationSession(baseDN, |
| | | server2ID, 100, getChangelogPort(changelog1ID), |
| | | 1000, !emptyOldChanges); |
| | | Thread.sleep(1000); |
| | |
| | | try |
| | | { |
| | | debugInfo("Connecting broker3 to replServer2"); |
| | | broker3 = openReplicationSession(baseDn, |
| | | broker3 = openReplicationSession(baseDN, |
| | | server3ID, 100, getChangelogPort(changelog2ID), |
| | | 1000, !emptyOldChanges); |
| | | Thread.sleep(1000); |
| | |
| | | try |
| | | { |
| | | debugInfo("Connecting broker4 to replServer2"); |
| | | broker4 = openReplicationSession(baseDn, |
| | | broker4 = openReplicationSession(baseDN, |
| | | server4ID, 100, getChangelogPort(changelog2ID), |
| | | 1000, !emptyOldChanges); |
| | | Thread.sleep(1000); |
| | |
| | | } |
| | | |
| | | // Do a bunch of change |
| | | updatedEntries = newLDIFEntries(); |
| | | this.addTestEntriesToDB(updatedEntries); |
| | | addTestEntriesToDB(newLDIFEntries()); |
| | | |
| | | for (int i = 0; i < 200; i++) |
| | | { |
| | | String ent1[] = |
| | | { |
| | | String ent1[] = { |
| | | createEntry(UUID.randomUUID()) |
| | | }; |
| | | this.addTestEntriesToDB(ent1); |
| | | addTestEntriesToDB(ent1); |
| | | } |
| | | |
| | | /* |
| | |
| | | /** |
| | | * Disconnect broker and remove entries from the local DB |
| | | */ |
| | | private void postTest() |
| | | private void postTest() throws Exception |
| | | { |
| | | debugInfo("Post test cleaning."); |
| | | |
| | |
| | | super.cleanRealEntries(); |
| | | |
| | | Arrays.fill(replServerPort, 0); |
| | | |
| | | try |
| | | { |
| | | TestCaseUtils.initializeTestBackend(false); |
| | | } |
| | | catch (Exception e) {} |
| | | TestCaseUtils.initializeTestBackend(false); |
| | | } |
| | | |
| | | private static final ByteArrayOutputStream oStream = |
| | |
| | | LDAPSearch.mainSearch(args3, false, oStream, eStream); |
| | | String entries = oStream.toString(); |
| | | debugInfo("Entries:" + entries); |
| | | try |
| | | { |
| | | assertEquals(retVal, 0, "Returned error: " + eStream); |
| | | assertTrue(!entries.equalsIgnoreCase(""), "Returned entries: " + entries); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | if (debugEnabled()) |
| | | TRACER.debugInfo( |
| | | stackTraceToSingleLineString(new Exception())); |
| | | fail(e.getMessage()); |
| | | } |
| | | assertEquals(retVal, 0, "Returned error: " + eStream); |
| | | assertTrue(!entries.equalsIgnoreCase(""), "Returned entries: " + entries); |
| | | } |
| | | } |
| | |
| | | { |
| | | /** The tracer object for the debug logger */ |
| | | private static final DebugTracer TRACER = getTracer(); |
| | | /** |
| | | * The replicationServer that will be used in this test. |
| | | */ |
| | | private DN TEST_ROOT_DN; |
| | | private DN EXAMPLE_DN; |
| | | /** The replicationServer that will be used in this test. */ |
| | | private ReplicationServer replicationServer; |
| | | |
| | | /** |
| | |
| | | public void setUp() throws Exception |
| | | { |
| | | super.setUp(); |
| | | TEST_ROOT_DN = DN.decode(TEST_ROOT_DN_STRING); |
| | | EXAMPLE_DN = DN.decode("o=example," + TEST_ROOT_DN_STRING); |
| | | |
| | | // This test suite depends on having the schema available. |
| | | configure(); |
| | |
| | | /* |
| | | * Open a sender session and a receiver session to the replicationServer |
| | | */ |
| | | server1 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), 1, 100, replicationServerPort, |
| | | 1000, false); |
| | | server2 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), 2, 100, replicationServerPort, |
| | | 1000, false); |
| | | server1 = openReplicationSession(TEST_ROOT_DN, |
| | | 1, 100, replicationServerPort, 1000, false); |
| | | server2 = openReplicationSession(TEST_ROOT_DN, |
| | | 2, 100, replicationServerPort, 1000, false); |
| | | |
| | | assertTrue(server1.isConnected()); |
| | | assertTrue(server2.isConnected()); |
| | |
| | | /* |
| | | * Send and receive a Delete Msg from server 1 to server 2 |
| | | */ |
| | | DeleteMsg msg = |
| | | new DeleteMsg("o=example," + TEST_ROOT_DN_STRING, firstCSNServer1, |
| | | "uid"); |
| | | DeleteMsg msg = new DeleteMsg(EXAMPLE_DN, firstCSNServer1, "uid"); |
| | | server1.publish(msg); |
| | | ReplicationMsg msg2 = server2.receive(); |
| | | server2.updateWindowAfterReplay(); |
| | |
| | | /* |
| | | * Send and receive a second Delete Msg |
| | | */ |
| | | msg = new DeleteMsg(TEST_ROOT_DN_STRING, secondCSNServer1, "uid"); |
| | | msg = new DeleteMsg(TEST_ROOT_DN, secondCSNServer1, "uid"); |
| | | server1.publish(msg); |
| | | msg2 = server2.receive(); |
| | | server2.updateWindowAfterReplay(); |
| | |
| | | /* |
| | | * Send and receive a Delete Msg from server 2 to server 1 |
| | | */ |
| | | msg = |
| | | new DeleteMsg("o=example," + TEST_ROOT_DN_STRING, firstCSNServer2, |
| | | "other-uid"); |
| | | msg = new DeleteMsg(EXAMPLE_DN, firstCSNServer2, "other-uid"); |
| | | server2.publish(msg); |
| | | msg2 = server1.receive(); |
| | | server1.updateWindowAfterReplay(); |
| | |
| | | /* |
| | | * Send and receive a second Delete Msg |
| | | */ |
| | | msg = new DeleteMsg(TEST_ROOT_DN_STRING, secondCSNServer2, "uid"); |
| | | msg = new DeleteMsg(TEST_ROOT_DN, secondCSNServer2, "uid"); |
| | | server2.publish(msg); |
| | | msg2 = server1.receive(); |
| | | server1.updateWindowAfterReplay(); |
| | |
| | | ReplicationBroker broker = null; |
| | | |
| | | try { |
| | | broker = |
| | | openReplicationSession(DN.decode(TEST_ROOT_DN_STRING), 3, |
| | | 100, replicationServerPort, 1000, false); |
| | | |
| | | broker = openReplicationSession(TEST_ROOT_DN, |
| | | 3, 100, replicationServerPort, 1000, false); |
| | | assertTrue(broker.isConnected()); |
| | | |
| | | ReplicationMsg msg2 = broker.receive(); |
| | |
| | | |
| | | // Connect to the replicationServer using the state created above. |
| | | try { |
| | | broker = |
| | | openReplicationSession(DN.decode(TEST_ROOT_DN_STRING), 3, |
| | | 100, replicationServerPort, 5000, state); |
| | | broker = openReplicationSession(TEST_ROOT_DN, |
| | | 3, 100, replicationServerPort, 5000, state); |
| | | |
| | | ReplicationMsg msg2 = broker.receive(); |
| | | broker.updateWindowAfterReplay(); |
| | |
| | | /* |
| | | * Open a sender session |
| | | */ |
| | | server = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), 5, 100, replicationServerPort, |
| | | 100000, 1000, 0, false); |
| | | |
| | | server = openReplicationSession(TEST_ROOT_DN, |
| | | 5, 100, replicationServerPort, 100000, 1000, 0, false); |
| | | assertTrue(server.isConnected()); |
| | | |
| | | reader = new BrokerReader(server, TOTAL_MSG); |
| | |
| | | */ |
| | | for (int i =0; i< CLIENT_THREADS; i++) |
| | | { |
| | | clientBroker[i] = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), (100+i), 100, replicationServerPort, |
| | | 1000, true); |
| | | clientBroker[i] = openReplicationSession(TEST_ROOT_DN, |
| | | (100+i), 100, replicationServerPort, 1000, true); |
| | | assertTrue(clientBroker[i].isConnected()); |
| | | client[i] = new BrokerReader(clientBroker[i], TOTAL_MSG); |
| | | } |
| | |
| | | */ |
| | | for (int i = 0; i< TOTAL_MSG; i++) |
| | | { |
| | | DeleteMsg msg = |
| | | new DeleteMsg("o=example," + TEST_ROOT_DN_STRING, gen.newCSN(), |
| | | "uid"); |
| | | server.publish(msg); |
| | | server.publish(new DeleteMsg(EXAMPLE_DN, gen.newCSN(), "uid")); |
| | | } |
| | | debugInfo("Ending oneWriterMultipleReader"); |
| | | } |
| | |
| | | { |
| | | int serverId = 10 + i; |
| | | CSNGenerator gen = new CSNGenerator(serverId , 0); |
| | | broker[i] = |
| | | openReplicationSession( DN.decode(TEST_ROOT_DN_STRING), serverId, |
| | | 100, replicationServerPort, 3000, 1000, 0, true); |
| | | |
| | | broker[i] = openReplicationSession(TEST_ROOT_DN, |
| | | serverId, 100, replicationServerPort, 3000, 1000, 0, true); |
| | | assertTrue(broker[i].isConnected()); |
| | | |
| | | producer[i] = new BrokerWriter(broker[i], gen, TOTAL_MSG/THREADS); |
| | |
| | | |
| | | // - Create 2 connected replicationServer |
| | | ReplicationServer[] changelogs = new ReplicationServer[2]; |
| | | int[] changelogPorts = new int[2]; |
| | | int[] changelogIds = new int[2]; |
| | | int[] brokerIds = new int[2]; |
| | | int[] changelogPorts = TestCaseUtils.findFreePorts(2); |
| | | int[] changelogIds = new int[] { 80, 81 }; |
| | | int[] brokerIds = new int[] { 100, 101 }; |
| | | |
| | | // Find 2 free ports |
| | | for (int i = 0; i <= 1; i++) |
| | | { |
| | | changelogPorts[i] = TestCaseUtils.findFreePort(); |
| | | changelogIds[i] = i + 80; |
| | | brokerIds[i] = 100 + i; |
| | | } |
| | | |
| | | for (int i = 0; i <= ((itest == 0) ? 1 : 0); i++) |
| | | for (int i = 0; i < ((itest == 0) ? 2 : 1); i++) |
| | | { |
| | | changelogs[i] = null; |
| | | |
| | |
| | | // and client2 to changelog2 |
| | | // For itest=1, only create and connect client1 to changelog1 |
| | | // client2 will be created later |
| | | broker1 = openReplicationSession(DN.decode(TEST_ROOT_DN_STRING), |
| | | broker1 = openReplicationSession(TEST_ROOT_DN, |
| | | brokerIds[0], 100, changelogPorts[0], 1000, !emptyOldChanges); |
| | | |
| | | assertTrue(broker1.isConnected()); |
| | | |
| | | if (itest == 0) |
| | | { |
| | | broker2 = openReplicationSession(DN.decode(TEST_ROOT_DN_STRING), |
| | | broker2 = openReplicationSession(TEST_ROOT_DN, |
| | | brokerIds[1], 100, changelogPorts[0], 1000, !emptyOldChanges); |
| | | assertTrue(broker2.isConnected()); |
| | | } |
| | |
| | | int ts = 1; |
| | | CSN csn = new CSN(time, ts++, brokerIds[0]); |
| | | |
| | | DeleteMsg delMsg = new DeleteMsg("o=example" + itest + "," + TEST_ROOT_DN_STRING, csn, "uid"); |
| | | DN dn = DN.decode("o=example" + itest + "," + TEST_ROOT_DN_STRING); |
| | | DeleteMsg delMsg = new DeleteMsg(dn, csn, "uid"); |
| | | broker1.publish(delMsg); |
| | | |
| | | String user1entryUUID = "33333333-3333-3333-3333-333333333333"; |
| | |
| | | + "entryUUID: 11111111-1111-1111-1111-111111111111\n"; |
| | | Entry entry = TestCaseUtils.entryFromLdifString(lentry); |
| | | csn = new CSN(time, ts++, brokerIds[0]); |
| | | AddMsg addMsg = new AddMsg(csn, "o=example," + TEST_ROOT_DN_STRING, |
| | | user1entryUUID, baseUUID, entry.getObjectClassAttribute(), entry |
| | | .getAttributes(), new ArrayList<Attribute>()); |
| | | AddMsg addMsg = new AddMsg(csn, EXAMPLE_DN, |
| | | user1entryUUID, baseUUID, entry.getObjectClassAttribute(), |
| | | entry.getAttributes(), new ArrayList<Attribute>()); |
| | | broker1.publish(addMsg); |
| | | |
| | | // - Modify |
| | |
| | | List<Modification> mods = new ArrayList<Modification>(); |
| | | mods.add(mod1); |
| | | csn = new CSN(time, ts++, brokerIds[0]); |
| | | ModifyMsg modMsg = new ModifyMsg(csn, DN |
| | | .decode("o=example," + TEST_ROOT_DN_STRING), mods, "fakeuniqueid"); |
| | | ModifyMsg modMsg = new ModifyMsg(csn, EXAMPLE_DN, mods, "fakeuniqueid"); |
| | | broker1.publish(modMsg); |
| | | |
| | | // - ModifyDN |
| | | csn = new CSN(time, ts++, brokerIds[0]); |
| | | ModifyDNOperationBasis op = new ModifyDNOperationBasis(connection, 1, 1, null, DN |
| | | .decode("o=example," + TEST_ROOT_DN_STRING), RDN.decode("o=example2"), true, |
| | | null); |
| | | ModifyDNOperationBasis op = new ModifyDNOperationBasis(connection, 1, 1, null, |
| | | EXAMPLE_DN, RDN.decode("o=example2"), true, null); |
| | | op.setAttachment(SYNCHROCONTEXT, new ModifyDnContext(csn, "uniqueid", |
| | | "newparentId")); |
| | | LocalBackendModifyDNOperation localOp = |
| | |
| | | changelogs[1] = new ReplicationServer(conf); |
| | | |
| | | // Connect broker 2 to changelog2 |
| | | broker2 = openReplicationSession(DN.decode(TEST_ROOT_DN_STRING), |
| | | broker2 = openReplicationSession(TEST_ROOT_DN, |
| | | brokerIds[1], 100, changelogPorts[1], 2000, !emptyOldChanges); |
| | | assertTrue(broker2.isConnected()); |
| | | } |
| | |
| | | |
| | | if (msg2 instanceof DeleteMsg) |
| | | { |
| | | DeleteMsg delMsg2 = (DeleteMsg) msg2; |
| | | if (delMsg2.toString().equals(delMsg.toString())) |
| | | if (delMsg.equals(msg2)) |
| | | ts--; |
| | | } |
| | | else if (msg2 instanceof AddMsg) |
| | | { |
| | | AddMsg addMsg2 = (AddMsg) msg2; |
| | | if (addMsg2.toString().equals(addMsg.toString())) |
| | | if (addMsg.equals(msg2)) |
| | | ts--; |
| | | } |
| | | else if (msg2 instanceof ModifyMsg) |
| | | { |
| | | ModifyMsg modMsg2 = (ModifyMsg) msg2; |
| | | if (modMsg.equals(modMsg2)) |
| | | if (modMsg.equals(msg2)) |
| | | ts--; |
| | | } |
| | | else if (msg2 instanceof ModifyDNMsg) |
| | | { |
| | | ModifyDNMsg modDNMsg2 = (ModifyDNMsg) msg2; |
| | | if (modDNMsg.equals(modDNMsg2)) |
| | | if (modDNMsg.equals(msg2)) |
| | | ts--; |
| | | } |
| | | else if (msg2 instanceof TopologyMsg) |
| | |
| | | int timeoutMS = MultimasterReplication.getConnectionTimeoutMS(); |
| | | socket.connect(ServerAddr, timeoutMS); |
| | | ReplSessionSecurity replSessionSecurity = getReplSessionSecurity(); |
| | | Session session = replSessionSecurity.createClientSession(socket, |
| | | timeoutMS); |
| | | Session session = replSessionSecurity.createClientSession(socket, timeoutMS); |
| | | |
| | | boolean sslEncryption = |
| | | DirectoryConfig.getCryptoManager().isSslEncryption(); |
| | | boolean sslEncryption = DirectoryConfig.getCryptoManager().isSslEncryption(); |
| | | |
| | | try |
| | | { |
| | | // send a ServerStartMsg with an empty ServerState. |
| | | String url = socket.getLocalAddress().getCanonicalHostName() + ":" |
| | | + socket.getLocalPort(); |
| | | ServerStartMsg msg = |
| | | new ServerStartMsg( 1723, url, TEST_ROOT_DN_STRING, |
| | | WINDOW, 5000, new ServerState(), |
| | | 0, sslEncryption, (byte)-1); |
| | | ServerStartMsg msg = new ServerStartMsg(1723, url, TEST_ROOT_DN, |
| | | WINDOW, 5000, new ServerState(), 0, sslEncryption, (byte)-1); |
| | | session.publish(msg); |
| | | |
| | | // Read the Replication Server state from the ReplServerStartDSMsg that |
| | | // comes back. |
| | | ReplServerStartDSMsg replStartDSMsg = |
| | | (ReplServerStartDSMsg) session.receive(); |
| | | ReplServerStartDSMsg replStartDSMsg = (ReplServerStartDSMsg) session.receive(); |
| | | int serverwindow = replStartDSMsg.getWindowSize(); |
| | | |
| | | if (!sslEncryption) |
| | | { |
| | | session.stopEncryption(); |
| | |
| | | private ReplicationBroker broker; |
| | | private int numMsgRcv = 0; |
| | | private final int numMsgExpected; |
| | | public Exception exc; |
| | | public String errDetails = null; |
| | | private Exception exc; |
| | | private String errDetails; |
| | | |
| | | /** |
| | | * Creates a new Stress Test Reader |
| | |
| | | */ |
| | | private class BrokerWriter extends Thread |
| | | { |
| | | int count; |
| | | private int count; |
| | | private ReplicationBroker broker; |
| | | CSNGenerator gen; |
| | | private CSNGenerator gen; |
| | | |
| | | public BrokerWriter(ReplicationBroker broker, CSNGenerator gen, |
| | | int count) |
| | | public BrokerWriter(ReplicationBroker broker, CSNGenerator gen, int count) |
| | | { |
| | | this.broker = broker; |
| | | this.count = count; |
| | |
| | | { |
| | | count--; |
| | | |
| | | DeleteMsg msg = |
| | | new DeleteMsg("o=example," + TEST_ROOT_DN_STRING, gen.newCSN(), |
| | | "uid"); |
| | | DeleteMsg msg = new DeleteMsg(EXAMPLE_DN, gen.newCSN(), "uid"); |
| | | broker.publish(msg); |
| | | |
| | | if ((count % 10) == 0) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /* |
| | | * Test backup and restore of the Replication server backend |
| | | /** |
| | | * Test backup and restore of the Replication server backend. |
| | | */ |
| | | private void backupRestore() throws Exception |
| | | { |
| | |
| | | |
| | | try |
| | | { |
| | | server1 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), 1, 100, |
| | | replicationServerPort, |
| | | 1000, true); |
| | | server2 = openReplicationSession( |
| | | DN.decode("dc=domain2,dc=com"), 2, 100, |
| | | replicationServerPort, |
| | | 1000, true); |
| | | server1 = openReplicationSession(TEST_ROOT_DN, |
| | | 1, 100, replicationServerPort, 1000, true); |
| | | server2 = openReplicationSession(DN.decode("dc=domain2,dc=com"), |
| | | 2, 100, replicationServerPort, 1000, true); |
| | | |
| | | assertTrue(server1.isConnected()); |
| | | assertTrue(server2.isConnected()); |
| | | |
| | | debugInfo("Publish changes"); |
| | | List<UpdateMsg> msgs = createChanges(TEST_ROOT_DN_STRING, 1); |
| | | for (UpdateMsg msg : msgs) |
| | | { |
| | | server1.publish(msg); |
| | | } |
| | | List<UpdateMsg> msgs2 = createChanges("dc=domain2,dc=com", 2); |
| | | for (UpdateMsg msg : msgs2) |
| | | { |
| | | server2.publish(msg); |
| | | } |
| | | publishAll(server1, createChanges(TEST_ROOT_DN_STRING, 1)); |
| | | publishAll(server2, createChanges("dc=domain2,dc=com", 2)); |
| | | |
| | | debugInfo("Export all"); |
| | | Entry exportTask = createExportAllTask(); |
| | |
| | | + "entryUUID: 11111111-1111-1111-1111-111111111111\n"; |
| | | Entry entry = TestCaseUtils.entryFromLdifString(lentry); |
| | | CSN csn = new CSN(time, ts++, serverId); |
| | | AddMsg addMsg = new AddMsg(csn, "o=example,"+suffix, |
| | | user1entryUUID, baseUUID, entry.getObjectClassAttribute(), entry |
| | | .getAttributes(), new ArrayList<Attribute>()); |
| | | DN exampleSuffixDN = DN.decode("o=example," + suffix); |
| | | AddMsg addMsg = new AddMsg(csn, exampleSuffixDN, |
| | | user1entryUUID, baseUUID, entry.getObjectClassAttribute(), |
| | | entry.getAttributes(), new ArrayList<Attribute>()); |
| | | l.add(addMsg); |
| | | |
| | | // - Add |
| | |
| | | + "userpassword: fjen$$en" + "\n"; |
| | | Entry uentry = TestCaseUtils.entryFromLdifString(luentry); |
| | | csn = new CSN(time, ts++, serverId); |
| | | DN newPersonDN = DN.decode("uid=new person,ou=People,"+suffix); |
| | | AddMsg addMsg2 = new AddMsg( |
| | | csn, |
| | | "uid=new person,ou=People,"+suffix, |
| | | newPersonDN, |
| | | user1entryUUID, |
| | | baseUUID, |
| | | uentry.getObjectClassAttribute(), |
| | |
| | | Modification mod2 = new Modification(ModificationType.REPLACE, attr2); |
| | | Attribute attr3 = Attributes.create("modifyTimestamp", "20070917172420Z"); |
| | | Modification mod3 = new Modification(ModificationType.REPLACE, attr3); |
| | | List<Modification> mods = new ArrayList<Modification>(); |
| | | |
| | | mods.add(mod1); |
| | | mods.add(mod2); |
| | | mods.add(mod3); |
| | | List<Modification> mods = Arrays.asList(mod1, mod2, mod3); |
| | | |
| | | csn = new CSN(time, ts++, serverId); |
| | | DN dn = DN.decode("o=example,"+suffix); |
| | | DN dn = exampleSuffixDN; |
| | | ModifyMsg modMsg = new ModifyMsg(csn, dn, |
| | | mods, "fakeuniqueid"); |
| | | l.add(modMsg); |
| | | |
| | | // Modify DN |
| | | csn = new CSN(time, ts++, serverId); |
| | | ModifyDNMsg modDnMsg = new ModifyDNMsg( |
| | | "uid=new person,ou=People,"+suffix, csn, |
| | | ModifyDNMsg modDnMsg = new ModifyDNMsg(newPersonDN, csn, |
| | | user1entryUUID, baseUUID, false, |
| | | "uid=wrong, ou=people,"+suffix, |
| | | "uid=newrdn"); |
| | | "uid=wrong, ou=people,"+suffix, "uid=newrdn"); |
| | | l.add(modDnMsg); |
| | | |
| | | // Del |
| | | csn = new CSN(time, ts++, serverId); |
| | | DeleteMsg delMsg = new DeleteMsg("o=example,"+suffix, csn, "uid"); |
| | | DeleteMsg delMsg = new DeleteMsg(exampleSuffixDN, csn, "uid"); |
| | | l.add(delMsg); |
| | | } |
| | | return l; |
| | |
| | | |
| | | debugInfo("Create broker"); |
| | | |
| | | server1 = openReplicationSession( |
| | | DN.decode(TEST_ROOT_DN_STRING), 1, 100, replicationServerPort, |
| | | 1000, true); |
| | | server1 = openReplicationSession(TEST_ROOT_DN, |
| | | 1, 100, replicationServerPort, 1000, true); |
| | | |
| | | assertTrue(server1.isConnected()); |
| | | |
| | | debugInfo("Publish changes"); |
| | | List<UpdateMsg> msgs = createChanges(TEST_ROOT_DN_STRING, 1); |
| | | for(UpdateMsg msg : msgs ) |
| | | { |
| | | server1.publish(msg); |
| | | } |
| | | publishAll(server1, msgs); |
| | | Thread.sleep(500); |
| | | |
| | | // Sets manually the association backend-replication server since |
| | |
| | | } |
| | | } |
| | | |
| | | private void publishAll(ReplicationBroker broker, List<UpdateMsg> msgs) |
| | | { |
| | | for (UpdateMsg msg : msgs) |
| | | { |
| | | broker.publish(msg); |
| | | } |
| | | } |
| | | |
| | | private InternalSearchOperation assertSearchResult(String baseDN, |
| | | String filterString, ResultCode rc, int nbEntriesReturned) |
| | | throws Exception |
| | |
| | | |
| | | // - Create 2 connected replicationServer |
| | | ReplicationServer[] changelogs = new ReplicationServer[2]; |
| | | int[] changelogPorts = new int[2]; |
| | | int[] changelogIds = new int[2]; |
| | | int[] brokerIds = new int[2]; |
| | | int[] changelogPorts = TestCaseUtils.findFreePorts(2); |
| | | int[] changelogIds = new int[] { 90, 91 }; |
| | | int[] brokerIds = new int[] { 100, 101 }; |
| | | |
| | | // Find 2 free ports |
| | | for (int i = 0; i <= 1; i++) |
| | | { |
| | | changelogPorts[i] = TestCaseUtils.findFreePort(); |
| | | changelogIds[i] = i + 90; |
| | | brokerIds[i] = 100+i; |
| | | } |
| | | |
| | | for (int i = 0; i <= 1; i++) |
| | | for (int i = 0; i < 2; i++) |
| | | { |
| | | changelogs[i] = null; |
| | | // create the 2 replicationServer |
| | |
| | | { |
| | | // Create and connect client1 to changelog1 |
| | | // and client2 to changelog2 |
| | | broker1 = openReplicationSession(DN.decode(TEST_ROOT_DN_STRING), |
| | | broker1 = openReplicationSession(TEST_ROOT_DN, |
| | | brokerIds[0], 100, changelogPorts[0], 1000, emptyOldChanges); |
| | | |
| | | broker2 = openReplicationSession(DN.decode(TEST_ROOT_DN_STRING), |
| | | broker2 = openReplicationSession(TEST_ROOT_DN, |
| | | brokerIds[1], 100, changelogPorts[1], 1000, emptyOldChanges); |
| | | |
| | | assertTrue(broker1.isConnected()); |
| | |
| | | + "entryUUID: " + user1entryUUID + "\n"; |
| | | Entry entry = TestCaseUtils.entryFromLdifString(lentry); |
| | | csn = new CSN(time, ts++, brokerIds[0]); |
| | | AddMsg addMsg = new AddMsg(csn, "o=example," + TEST_ROOT_DN_STRING, |
| | | AddMsg addMsg = new AddMsg(csn, EXAMPLE_DN, |
| | | user1entryUUID, baseUUID, entry.getObjectClassAttribute(), entry |
| | | .getAttributes(), new ArrayList<Attribute>()); |
| | | broker1.publish(addMsg); |
| | |
| | | List<Modification> mods = new ArrayList<Modification>(); |
| | | mods.add(mod1); |
| | | csn = new CSN(time, ts++, brokerIds[0]); |
| | | ModifyMsg modMsg = new ModifyMsg(csn, DN |
| | | .decode("o=example," + TEST_ROOT_DN_STRING), mods, "fakeuniqueid"); |
| | | ModifyMsg modMsg = new ModifyMsg(csn, EXAMPLE_DN, mods, "fakeuniqueid"); |
| | | broker1.publish(modMsg); |
| | | |
| | | // - Check msg received by broker, through changeLog2 |
| | |
| | | |
| | | if (msg2 instanceof AddMsg) |
| | | { |
| | | AddMsg addMsg2 = (AddMsg) msg2; |
| | | if (addMsg2.toString().equals(addMsg.toString())) |
| | | if (addMsg.equals(msg2)) |
| | | ts--; |
| | | } |
| | | else if (msg2 instanceof ModifyMsg) |
| | | { |
| | | ModifyMsg modMsg2 = (ModifyMsg) msg2; |
| | | if (modMsg.equals(modMsg2)) |
| | | if (modMsg.equals(msg2)) |
| | | ts--; |
| | | } |
| | | else |
| | |
| | | { |
| | | // - Del |
| | | csn = new CSN(time, ts++, brokerIds[0]); |
| | | DeleteMsg delMsg = new DeleteMsg("o=example," + TEST_ROOT_DN_STRING, csn, user1entryUUID); |
| | | DeleteMsg delMsg = new DeleteMsg(EXAMPLE_DN, csn, user1entryUUID); |
| | | broker1.publish(delMsg); |
| | | // Should receive some TopologyMsg messages for disconnection |
| | | // between the 2 RSs |
| | |
| | | import org.opends.server.replication.server.changelog.api.ReplicaDBCursor; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | |
| | | { |
| | | /** The tracer object for the debug logger */ |
| | | private static final DebugTracer TRACER = getTracer(); |
| | | private DN TEST_ROOT_DN; |
| | | |
| | | /** |
| | | * Utility - log debug message - highlight it is from the test and not |
| | |
| | | } |
| | | } |
| | | |
| | | @BeforeClass |
| | | public void setup() throws Exception |
| | | { |
| | | TEST_ROOT_DN = DN.decode(TEST_ROOT_DN_STRING); |
| | | } |
| | | |
| | | @Test(enabled=true) |
| | | void testDbHandlerTrim() throws Exception |
| | | { |
| | |
| | | testRoot = createCleanDir(); |
| | | |
| | | dbEnv = new ReplicationDbEnv(testRoot.getPath(), replicationServer); |
| | | handler = new DbHandler(1, DN.decode(TEST_ROOT_DN_STRING), replicationServer, dbEnv, 5000); |
| | | handler = new DbHandler(1, TEST_ROOT_DN, replicationServer, dbEnv, 5000); |
| | | |
| | | CSNGenerator gen = new CSNGenerator( 1, 0); |
| | | CSN csn1 = gen.newCSN(); |
| | |
| | | CSN csn4 = gen.newCSN(); |
| | | CSN csn5 = gen.newCSN(); |
| | | |
| | | handler.add(new DeleteMsg(TEST_ROOT_DN_STRING, csn1, "uid")); |
| | | handler.add(new DeleteMsg(TEST_ROOT_DN_STRING, csn2, "uid")); |
| | | handler.add(new DeleteMsg(TEST_ROOT_DN_STRING, csn3, "uid")); |
| | | DeleteMsg update4 = new DeleteMsg(TEST_ROOT_DN_STRING, csn4, "uid"); |
| | | handler.add(new DeleteMsg(TEST_ROOT_DN, csn1, "uid")); |
| | | handler.add(new DeleteMsg(TEST_ROOT_DN, csn2, "uid")); |
| | | handler.add(new DeleteMsg(TEST_ROOT_DN, csn3, "uid")); |
| | | DeleteMsg update4 = new DeleteMsg(TEST_ROOT_DN, csn4, "uid"); |
| | | |
| | | //-- |
| | | // Iterator tests with memory queue only populated |
| | |
| | | |
| | | testRoot = createCleanDir(); |
| | | dbEnv = new ReplicationDbEnv(testRoot.getPath(), replicationServer); |
| | | handler = new DbHandler(1, DN.decode(TEST_ROOT_DN_STRING), replicationServer, dbEnv, 5000); |
| | | handler = new DbHandler(1, TEST_ROOT_DN, replicationServer, dbEnv, 5000); |
| | | |
| | | // Creates changes added to the dbHandler |
| | | CSNGenerator gen = new CSNGenerator( 1, 0); |
| | |
| | | CSN csn3 = gen.newCSN(); |
| | | |
| | | // Add the changes |
| | | handler.add(new DeleteMsg(TEST_ROOT_DN_STRING, csn1, "uid")); |
| | | handler.add(new DeleteMsg(TEST_ROOT_DN_STRING, csn2, "uid")); |
| | | handler.add(new DeleteMsg(TEST_ROOT_DN_STRING, csn3, "uid")); |
| | | handler.add(new DeleteMsg(TEST_ROOT_DN, csn1, "uid")); |
| | | handler.add(new DeleteMsg(TEST_ROOT_DN, csn2, "uid")); |
| | | handler.add(new DeleteMsg(TEST_ROOT_DN, csn3, "uid")); |
| | | |
| | | // Check they are here |
| | | assertEquals(csn1, handler.getOldestCSN()); |
| | |
| | | |
| | | testRoot = createCleanDir(); |
| | | dbEnv = new ReplicationDbEnv(testRoot.getPath(), replicationServer); |
| | | handler = new DbHandler(1, DN.decode(TEST_ROOT_DN_STRING), replicationServer, dbEnv, 10); |
| | | handler = new DbHandler(1, TEST_ROOT_DN, replicationServer, dbEnv, 10); |
| | | handler.setCounterWindowSize(counterWindow); |
| | | |
| | | // Populate the db with 'max' msg |
| | |
| | | { |
| | | csnArray[i] = new CSN(now + i, mySeqnum, 1); |
| | | mySeqnum+=2; |
| | | DeleteMsg update1 = new DeleteMsg(TEST_ROOT_DN_STRING, csnArray[i], "uid"); |
| | | DeleteMsg update1 = new DeleteMsg(TEST_ROOT_DN, csnArray[i], "uid"); |
| | | handler.add(update1); |
| | | } |
| | | handler.flush(); |
| | |
| | | debugInfo(tn,"SHUTDOWN handler and recreate"); |
| | | handler.shutdown(); |
| | | |
| | | handler = new DbHandler(1, DN.decode(TEST_ROOT_DN_STRING), replicationServer, dbEnv, 10); |
| | | handler = new DbHandler(1, TEST_ROOT_DN, replicationServer, dbEnv, 10); |
| | | handler.setCounterWindowSize(counterWindow); |
| | | |
| | | // Test first and last |
| | |
| | | { |
| | | csnArray[i] = new CSN(now+i, mySeqnum, 1); |
| | | mySeqnum+=2; |
| | | DeleteMsg update1 = new DeleteMsg(TEST_ROOT_DN_STRING, csnArray[i], "uid"); |
| | | DeleteMsg update1 = new DeleteMsg(TEST_ROOT_DN, csnArray[i], "uid"); |
| | | handler.add(update1); |
| | | } |
| | | handler.flush(); |