Second set of renaming for issue 1090
Rename org.opends.server.replication.changelog into org.opends.server.synchronization.changelog
Use replication instead of synchronization in many places in the code/comment/file names
32 files renamed
51 files modified
| | |
| | | TaskMessages.registerMessages(); |
| | | AdminMessages.registerMessages(); |
| | | AciMessages.registerMessages(); |
| | | SynchronizationMessages.registerMessages(); |
| | | ReplicationMessages.registerMessages(); |
| | | } |
| | | |
| | | |
| File was renamed from opends/src/server/org/opends/server/messages/SynchronizationMessages.java |
| | |
| | | |
| | | /** |
| | | * This class defines the set of message IDs and default format strings for |
| | | * messages associated with the Synchronization. |
| | | * messages associated with the Replication. |
| | | */ |
| | | public class SynchronizationMessages { |
| | | public class ReplicationMessages { |
| | | |
| | | /** |
| | | * Name used to store attachment of historical information in the |
| | |
| | | /** |
| | | * Exception while receiving a message. |
| | | */ |
| | | public static final int MSGID_EXCEPTION_RECEIVING_SYNCHRONIZATION_MESSAGE = |
| | | public static final int MSGID_EXCEPTION_RECEIVING_REPLICATION_MESSAGE = |
| | | CATEGORY_MASK_SYNC | SEVERITY_MASK_SEVERE_ERROR | 34; |
| | | |
| | | /** |
| | |
| | | "An unexpected error happened sending an ack to %s." + |
| | | "This connection is going to be closed. "); |
| | | registerMessage( |
| | | MSGID_EXCEPTION_RECEIVING_SYNCHRONIZATION_MESSAGE, |
| | | "An Exception was caught while receiving synchronization message : %s"); |
| | | MSGID_EXCEPTION_RECEIVING_REPLICATION_MESSAGE, |
| | | "An Exception was caught while receiving replication message : %s"); |
| | | registerMessage(MSGID_LOOP_REPLAYING_OPERATION, |
| | | "A loop was detected while replaying operation: %s"); |
| | | registerMessage(MSGID_FILE_CHECK_CREATE_FAILED, |
| | |
| | | " The Changelog servers will queue up to this number of messages" + |
| | | " in its memory queue and save the older messages to persistent" + |
| | | " storage. Using a larger size may improve performances when" + |
| | | " The synchronization delay is larger than this size but at the cost" + |
| | | " The replication delay is larger than this size but at the cost" + |
| | | " of using more memory"); |
| | | registerMessage(MSGID_CHANGELOG_DIR_PATH_ATTR, |
| | | "Specifies the Changelog Server directory. The Changelog server" + |
| | |
| | | * <li> |
| | | * <A HREF="ServerState.html"><B>ServerState</B></A> |
| | | * This class is used to define and store the updatedness of any component |
| | | * of the synchronization architecture (i.e : to know which changes |
| | | * of the replication architecture (i.e : to know which changes |
| | | * it has already processed). |
| | | * </li> |
| | | * </ul> |
| | |
| | | */ |
| | | |
| | | /** |
| | | * This package contains the code for the synchronization feature |
| | | * which provides a Multi-Master replication system. |
| | | * This package contains the code for the Multi-Master replication. |
| | | */ |
| | | package org.opends.server.replication; |
| | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugInfo; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.SynchronizationMessages.*; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | |
| | | import java.util.Collection; |
| | |
| | | import org.opends.server.replication.protocol.ProtocolSession; |
| | | import org.opends.server.replication.protocol.ServerStartMessage; |
| | | import org.opends.server.replication.protocol.SocketSession; |
| | | import org.opends.server.replication.protocol.SynchronizationMessage; |
| | | import org.opends.server.replication.protocol.ReplicationMessage; |
| | | import org.opends.server.replication.protocol.UpdateMessage; |
| | | import org.opends.server.replication.protocol.WindowMessage; |
| | | import org.opends.server.types.DN; |
| | |
| | | |
| | | |
| | | /** |
| | | * The broker for Multimaster Synchronization. |
| | | * The broker for Multi-master Replication. |
| | | */ |
| | | public class ChangelogBroker implements InternalSearchListener |
| | | { |
| | |
| | | private int timeout = 0; |
| | | |
| | | /** |
| | | * The time in milliseconds between heartbeats from the synchronization |
| | | * The time in milliseconds between heartbeats from the replication |
| | | * server. Zero means heartbeats are off. |
| | | */ |
| | | private long heartbeatInterval = 0; |
| | |
| | | |
| | | |
| | | /** |
| | | * Creates a new Changelog Broker for a particular SynchronizationDomain. |
| | | * Creates a new Changelog Broker for a particular ReplicationDomain. |
| | | * |
| | | * @param state The ServerState that should be used by this broker |
| | | * when negociating the session with the changelog servers. |
| | |
| | | if (heartbeatInterval > 0) |
| | | { |
| | | heartbeatMonitor = |
| | | new HeartbeatMonitor("Synchronization Heartbeat Monitor", session, |
| | | new HeartbeatMonitor("Replication Heartbeat Monitor", session, |
| | | heartbeatInterval); |
| | | heartbeatMonitor.start(); |
| | | } |
| | |
| | | * Publish a message to the other servers. |
| | | * @param msg the message to publish |
| | | */ |
| | | public void publish(SynchronizationMessage msg) |
| | | public void publish(ReplicationMessage msg) |
| | | { |
| | | boolean done = false; |
| | | ProtocolSession failingSession = session; |
| | |
| | | * @throws SocketTimeoutException if the timeout set by setSoTimeout |
| | | * has expired |
| | | */ |
| | | public SynchronizationMessage receive() throws SocketTimeoutException |
| | | public ReplicationMessage receive() throws SocketTimeoutException |
| | | { |
| | | while (shutdown == false) |
| | | { |
| | | ProtocolSession failingSession = session; |
| | | try |
| | | { |
| | | SynchronizationMessage msg = session.receive(); |
| | | ReplicationMessage msg = session.receive(); |
| | | if (msg instanceof WindowMessage) |
| | | { |
| | | WindowMessage windowMsg = (WindowMessage) msg; |
| | |
| | | import org.opends.server.admin.std.server.ChangelogServerCfg; |
| | | import org.opends.server.admin.std.server.MultimasterSynchronizationProviderCfg; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.replication.changelog.Changelog; |
| | | import org.opends.server.replication.server.Changelog; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | |
| | | package org.opends.server.replication.plugin; |
| | | |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | import org.opends.server.replication.protocol.SynchronizationMessage; |
| | | import org.opends.server.replication.protocol.ReplicationMessage; |
| | | import org.opends.server.types.Modification; |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * Generate a SynchronizationMessage from this fake operation. |
| | | * The SynchronizationMessage is used to send the informations about |
| | | * Generate a ReplicationMessage from this fake operation. |
| | | * The ReplicationMessage is used to send the informations about |
| | | * this operation to the other servers. |
| | | * |
| | | * @return A SynchronizationMessage that can be used to send information |
| | | * @return A ReplicationMessage that can be used to send information |
| | | * about this operation to remote servers. |
| | | */ |
| | | abstract public SynchronizationMessage generateMessage(); |
| | | abstract public ReplicationMessage generateMessage(); |
| | | |
| | | /** |
| | | * Add a modification to the list of modification included |
| | |
| | | |
| | | /** |
| | | * This class implements a thread to monitor heartbeat messages from the |
| | | * synchronization server. Each broker runs one of these threads. |
| | | * replication server. Each broker runs one of these threads. |
| | | */ |
| | | public class HeartbeatMonitor extends DirectoryThread |
| | | { |
| | |
| | | |
| | | |
| | | /** |
| | | * The time in milliseconds between heartbeats from the synchronization |
| | | * The time in milliseconds between heartbeats from the replication |
| | | * server. Zero means heartbeats are off. |
| | | */ |
| | | private long heartbeatInterval; |
| | |
| | | * operation so there is no need to check the historical information |
| | | * for conflicts. |
| | | * If this is a local operation, the this code is run during |
| | | * the pre-operation phase (TODO : should make sure that synchronization |
| | | * the pre-operation phase (TODO : should make sure that replication |
| | | * is always run after all other plugins) |
| | | * If this is a non-conflicting replicated operation, this code is run |
| | | * during the handleConflictResolution(). |
| | |
| | | /** |
| | | * Get the Entry Unique Id from an add operation. |
| | | * This must be called after the entry uuid preop plugin (i.e no |
| | | * sooner than the synchronization provider pre-op) |
| | | * sooner than the replication provider pre-op) |
| | | * |
| | | * @param op The operation |
| | | * @return The Entry Unique Id String form. |
| | |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.SynchronizationMessages.*; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | |
| | | import org.opends.server.api.DirectoryThread; |
| | |
| | | */ |
| | | public class ListenerThread extends DirectoryThread |
| | | { |
| | | private SynchronizationDomain listener; |
| | | private ReplicationDomain listener; |
| | | private boolean shutdown = false; |
| | | |
| | | /** |
| | |
| | | * |
| | | * @param listener the Plugin that created this thread |
| | | */ |
| | | public ListenerThread(SynchronizationDomain listener) |
| | | public ListenerThread(ReplicationDomain listener) |
| | | { |
| | | super("Synchronization Listener thread"); |
| | | super("Replication Listener thread"); |
| | | this.listener = listener; |
| | | } |
| | | |
| | |
| | | * catch all exceptions happening in listener.receive and listener.replay |
| | | * so that the thread never dies even in case of problems. |
| | | */ |
| | | int msgID = MSGID_EXCEPTION_RECEIVING_SYNCHRONIZATION_MESSAGE; |
| | | int msgID = MSGID_EXCEPTION_RECEIVING_REPLICATION_MESSAGE; |
| | | String message = getMessage(msgID, stackTraceToSingleLineString(e)); |
| | | logError(ErrorLogCategory.SYNCHRONIZATION, |
| | | ErrorLogSeverity.SEVERE_ERROR, message, msgID); |
| | |
| | | |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | import org.opends.server.replication.protocol.ModifyMsg; |
| | | import org.opends.server.replication.protocol.SynchronizationMessage; |
| | | import org.opends.server.replication.protocol.ReplicationMessage; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Modification; |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public SynchronizationMessage generateMessage() |
| | | public ReplicationMessage generateMessage() |
| | | { |
| | | return new ModifyMsg(super.getChangeNumber(), dn, mods, entryuuid); |
| | | } |
| File was renamed from opends/src/server/org/opends/server/replication/plugin/MultimasterSynchronization.java |
| | |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.types.SynchronizationProviderResult; |
| | | |
| | | import static org.opends.server.messages.SynchronizationMessages.*; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | |
| | | /** |
| | | * This class is used to load the Synchronization code inside the JVM |
| | | * and to trigger initialization of the synchronization. |
| | | * This class is used to load the Replication code inside the JVM |
| | | * and to trigger initialization of the replication. |
| | | * |
| | | * It also extends the SynchronizationProvider class in order to have some |
| | | * synchronization code running during the operation process |
| | | * replication code running during the operation process |
| | | * as pre-op, conflictRsolution, and post-op. |
| | | */ |
| | | public class MultimasterSynchronization |
| | | public class MultimasterReplication |
| | | extends SynchronizationProvider<MultimasterSynchronizationProviderCfg> |
| | | implements ConfigurationAddListener<MultimasterDomainCfg>, |
| | | ConfigurationDeleteListener<MultimasterDomainCfg>, |
| | |
| | | "ds-cfg-synchronization-provider-config"; |
| | | |
| | | private ChangelogListener changelog = null; |
| | | private static Map<DN, SynchronizationDomain> domains = |
| | | new HashMap<DN, SynchronizationDomain>() ; |
| | | private static Map<DN, ReplicationDomain> domains = |
| | | new HashMap<DN, ReplicationDomain>() ; |
| | | |
| | | |
| | | /** |
| | |
| | | for (String name : configuration.listMultimasterDomains()) |
| | | { |
| | | MultimasterDomainCfg domain = configuration.getMultimasterDomain(name); |
| | | createNewSynchronizationDomain(domain); |
| | | createNewDomain(domain); |
| | | } |
| | | |
| | | /* |
| | |
| | | public boolean isConfigurationAddAcceptable( |
| | | MultimasterDomainCfg configuration, List<String> unacceptableReasons) |
| | | { |
| | | return SynchronizationDomain.isConfigurationAcceptable( |
| | | return ReplicationDomain.isConfigurationAcceptable( |
| | | configuration, unacceptableReasons); |
| | | } |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | createNewSynchronizationDomain(configuration); |
| | | createNewDomain(configuration); |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | } catch (ConfigException e) |
| | | { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Creates a New Synchronization domain from its configEntry, do the |
| | | * Creates a new domain from its configEntry, do the |
| | | * necessary initialization and starts it so that it is |
| | | * fully operational when this method returns. |
| | | * @param configuration The entry whith the configuration of this domain. |
| | | * @throws ConfigException When the configuration is not valid. |
| | | */ |
| | | private void createNewSynchronizationDomain( |
| | | private void createNewDomain( |
| | | MultimasterDomainCfg configuration) |
| | | throws ConfigException |
| | | { |
| | | SynchronizationDomain domain; |
| | | domain = new SynchronizationDomain(configuration); |
| | | ReplicationDomain domain; |
| | | domain = new ReplicationDomain(configuration); |
| | | domains.put(domain.getBaseDN(), domain); |
| | | domain.start(); |
| | | } |
| | |
| | | public SynchronizationProviderResult handleConflictResolution( |
| | | ModifyOperation modifyOperation) |
| | | { |
| | | SynchronizationDomain domain = |
| | | ReplicationDomain domain = |
| | | findDomain(modifyOperation.getEntryDN(), modifyOperation); |
| | | if (domain == null) |
| | | return new SynchronizationProviderResult(true); |
| | |
| | | public SynchronizationProviderResult handleConflictResolution( |
| | | AddOperation addOperation) throws DirectoryException |
| | | { |
| | | SynchronizationDomain domain = |
| | | ReplicationDomain domain = |
| | | findDomain(addOperation.getEntryDN(), addOperation); |
| | | if (domain == null) |
| | | return new SynchronizationProviderResult(true); |
| | |
| | | public SynchronizationProviderResult handleConflictResolution( |
| | | DeleteOperation deleteOperation) throws DirectoryException |
| | | { |
| | | SynchronizationDomain domain = |
| | | ReplicationDomain domain = |
| | | findDomain(deleteOperation.getEntryDN(), deleteOperation); |
| | | if (domain == null) |
| | | return new SynchronizationProviderResult(true); |
| | |
| | | public SynchronizationProviderResult handleConflictResolution( |
| | | ModifyDNOperation modifyDNOperation) throws DirectoryException |
| | | { |
| | | SynchronizationDomain domain = |
| | | ReplicationDomain domain = |
| | | findDomain(modifyDNOperation.getEntryDN(), modifyDNOperation); |
| | | if (domain == null) |
| | | return new SynchronizationProviderResult(true); |
| | |
| | | doPreOperation(ModifyOperation modifyOperation) |
| | | { |
| | | DN operationDN = modifyOperation.getEntryDN(); |
| | | SynchronizationDomain domain = findDomain(operationDN, modifyOperation); |
| | | ReplicationDomain domain = findDomain(operationDN, modifyOperation); |
| | | |
| | | if ((domain == null) || (!domain.solveConflict())) |
| | | return new SynchronizationProviderResult(true); |
| | |
| | | @Override |
| | | public SynchronizationProviderResult doPreOperation(AddOperation addOperation) |
| | | { |
| | | SynchronizationDomain domain = |
| | | ReplicationDomain domain = |
| | | findDomain(addOperation.getEntryDN(), addOperation); |
| | | if (domain == null) |
| | | return new SynchronizationProviderResult(true); |
| | |
| | | @Override |
| | | public void finalizeSynchronizationProvider() |
| | | { |
| | | // shutdown all the Synchronization domains |
| | | for (SynchronizationDomain domain : domains.values()) |
| | | // shutdown all the domains |
| | | for (ReplicationDomain domain : domains.values()) |
| | | { |
| | | domain.shutdown(); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * Finds the Synchronization domain for a given DN. |
| | | * Finds the domain for a given DN. |
| | | * |
| | | * @param dn The DN for which the domain must be returned. |
| | | * @param op An optional operation for which the check is done. |
| | | * Can be null is the request has no associated operation. |
| | | * @return The Synchronization domain for this DN. |
| | | * @return The domain for this DN. |
| | | */ |
| | | public static SynchronizationDomain findDomain(DN dn, Operation op) |
| | | public static ReplicationDomain findDomain(DN dn, Operation op) |
| | | { |
| | | /* |
| | | * Don't run the special synchronization code on Operation that are |
| | | * Don't run the special replication code on Operation that are |
| | | * specifically marked as don't synchronize. |
| | | */ |
| | | if ((op != null) && op.dontSynchronize()) |
| | | return null; |
| | | |
| | | SynchronizationDomain domain = null; |
| | | ReplicationDomain domain = null; |
| | | DN temp = dn; |
| | | do |
| | | { |
| | |
| | | */ |
| | | private void genericPostOperation(Operation operation, DN dn) |
| | | { |
| | | SynchronizationDomain domain = findDomain(dn, operation); |
| | | ReplicationDomain domain = findDomain(dn, operation); |
| | | if (domain == null) |
| | | return; |
| | | |
| | |
| | | * This method is called whenever the server detects a modification |
| | | * of the schema done by directly modifying the backing files |
| | | * of the schema backend. |
| | | * Call the schema Synchronization Domain if it exists. |
| | | * Call the schema Domain if it exists. |
| | | * |
| | | * @param modifications The list of modifications that was |
| | | * applied to the schema. |
| | |
| | | @Override |
| | | public void processSchemaChange(List<Modification> modifications) |
| | | { |
| | | SynchronizationDomain domain = |
| | | ReplicationDomain domain = |
| | | findDomain(DirectoryServer.getSchemaDN(), null); |
| | | if (domain != null) |
| | | domain.synchronizeModifications(modifications); |
| | |
| | | { |
| | | for (DN dn : backend.getBaseDNs()) |
| | | { |
| | | SynchronizationDomain domain = findDomain(dn, null); |
| | | ReplicationDomain domain = findDomain(dn, null); |
| | | if (domain != null) |
| | | domain.backupStart(); |
| | | } |
| | |
| | | { |
| | | for (DN dn : backend.getBaseDNs()) |
| | | { |
| | | SynchronizationDomain domain = findDomain(dn, null); |
| | | ReplicationDomain domain = findDomain(dn, null); |
| | | if (domain != null) |
| | | domain.backupEnd(); |
| | | } |
| | |
| | | { |
| | | for (DN dn : backend.getBaseDNs()) |
| | | { |
| | | SynchronizationDomain domain = findDomain(dn, null); |
| | | ReplicationDomain domain = findDomain(dn, null); |
| | | if (domain != null) |
| | | domain.disable(); |
| | | } |
| | |
| | | { |
| | | for (DN dn : backend.getBaseDNs()) |
| | | { |
| | | SynchronizationDomain domain = findDomain(dn, null); |
| | | ReplicationDomain domain = findDomain(dn, null); |
| | | if (domain != null) |
| | | domain.enable(); |
| | | } |
| | |
| | | { |
| | | for (DN dn : backend.getBaseDNs()) |
| | | { |
| | | SynchronizationDomain domain = findDomain(dn, null); |
| | | ReplicationDomain domain = findDomain(dn, null); |
| | | if (domain != null) |
| | | domain.disable(); |
| | | } |
| | |
| | | { |
| | | for (DN dn : backend.getBaseDNs()) |
| | | { |
| | | SynchronizationDomain domain = findDomain(dn, null); |
| | | ReplicationDomain domain = findDomain(dn, null); |
| | | if (domain != null) |
| | | domain.enable(); |
| | | } |
| | |
| | | { |
| | | for (DN dn : backend.getBaseDNs()) |
| | | { |
| | | SynchronizationDomain domain = findDomain(dn, null); |
| | | ReplicationDomain domain = findDomain(dn, null); |
| | | if (domain != null) |
| | | domain.backupStart(); |
| | | } |
| | |
| | | { |
| | | for (DN dn : backend.getBaseDNs()) |
| | | { |
| | | SynchronizationDomain domain = findDomain(dn, null); |
| | | ReplicationDomain domain = findDomain(dn, null); |
| | | if (domain != null) |
| | | domain.backupEnd(); |
| | | } |
| | |
| | | MultimasterDomainCfg configuration) |
| | | { |
| | | DN dn = configuration.getSynchronizationDN(); |
| | | SynchronizationDomain domain = domains.remove(dn); |
| | | ReplicationDomain domain = domains.remove(dn); |
| | | if (domain != null) |
| | | domain.shutdown(); |
| | | |
| | |
| | | |
| | | /** |
| | | * Get the message associated to this PendingChange. |
| | | * @return the message if operation was a synchronization operation |
| | | * @return the message if operation was a replication operation |
| | | * null if the operation was a local operation |
| | | */ |
| | | public UpdateMessage getMsg() |
| | |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.SynchronizationMessages.*; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashSet; |
| | |
| | | /** |
| | | * The attribute name used to store the state in the backend. |
| | | */ |
| | | protected static final String SYNCHRONIZATION_STATE = "ds-sync-state"; |
| | | protected static final String REPLICATION_STATE = "ds-sync-state"; |
| | | |
| | | /** |
| | | * create a new ServerState. |
| | |
| | | * save the ServerState |
| | | */ |
| | | LinkedHashSet<String> attributes = new LinkedHashSet<String>(1); |
| | | attributes.add(SYNCHRONIZATION_STATE); |
| | | attributes.add(REPLICATION_STATE); |
| | | InternalSearchOperation search = conn.processSearch(asn1BaseDn, |
| | | SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.DEREF_ALWAYS, 0, 0, false, |
| | |
| | | if (search.getResultCode() == ResultCode.SUCCESS) |
| | | { |
| | | /* |
| | | * Read the serverState from the SYNCHRONIZATION_STATE attribute |
| | | * Read the serverState from the REPLICATION_STATE attribute |
| | | */ |
| | | LinkedList<SearchResultEntry> result = search.getSearchEntries(); |
| | | resultEntry = result.getFirst(); |
| | | if (resultEntry != null) |
| | | { |
| | | AttributeType synchronizationStateType = |
| | | DirectoryServer.getAttributeType(SYNCHRONIZATION_STATE); |
| | | DirectoryServer.getAttributeType(REPLICATION_STATE); |
| | | List<Attribute> attrs = |
| | | resultEntry.getAttribute(synchronizationStateType); |
| | | if (attrs != null) |
| | |
| | | return ResultCode.SUCCESS; |
| | | |
| | | LDAPAttribute attr = |
| | | new LDAPAttribute(SYNCHRONIZATION_STATE, values); |
| | | new LDAPAttribute(REPLICATION_STATE, values); |
| | | LDAPModification mod = new LDAPModification(ModificationType.REPLACE, attr); |
| | | ArrayList<RawModification> mods = new ArrayList<RawModification>(1); |
| | | mods.add(mod); |
| File was renamed from opends/src/server/org/opends/server/replication/plugin/SynchroLDIFInputStream.java |
| | |
| | | * This class creates an input stream that can be used to read entries generated |
| | | * by SynchroLDIF as if they were being read from another source like a file. |
| | | */ |
| | | public class SynchroLDIFInputStream |
| | | public class ReplLDIFInputStream |
| | | extends InputStream |
| | | { |
| | | // Indicates whether this input stream has been closed. |
| | | private boolean closed; |
| | | |
| | | // The synchronization domain associated to this import. |
| | | SynchronizationDomain domain; |
| | | // The domain associated to this import. |
| | | ReplicationDomain domain; |
| | | |
| | | /** |
| | | * Creates a new SynchroLDIFInputStream that will import entries |
| | | * Creates a new ReplLDIFInputStream that will import entries |
| | | * for a synchronzation domain. |
| | | * |
| | | * @param domain The synchronization domain |
| | | * @param domain The replication domain |
| | | */ |
| | | public SynchroLDIFInputStream(SynchronizationDomain domain) |
| | | public ReplLDIFInputStream(ReplicationDomain domain) |
| | | { |
| | | this.domain = domain; |
| | | closed = false; |
| | |
| | | throws IOException |
| | | { |
| | | // This method is not supposed to be called to make an LDIF import |
| | | // for synchronization. |
| | | // for replication. |
| | | throw new IOException("Not implemented"); |
| | | } |
| | | } |
| File was renamed from opends/src/server/org/opends/server/replication/plugin/SynchroLDIFOutputStream.java |
| | |
| | | * This class creates an output stream that can be used to export entries |
| | | * to a synchonization domain. |
| | | */ |
| | | public class SynchroLDIFOutputStream |
| | | public class ReplLDIFOutputStream |
| | | extends OutputStream |
| | | { |
| | | SynchronizationDomain domain; |
| | | ReplicationDomain domain; |
| | | String entryBuffer = ""; |
| | | |
| | | /** |
| | | * Creates a new SynchroLDIFOutputStream related to a synchronization |
| | | * Creates a new ReplLDIFOutputStream related to a replication |
| | | * domain. |
| | | * |
| | | * @param domain The synchronization domain |
| | | * @param domain The replication domain |
| | | */ |
| | | public SynchroLDIFOutputStream(SynchronizationDomain domain) |
| | | public ReplLDIFOutputStream(ReplicationDomain domain) |
| | | { |
| | | this.domain = domain; |
| | | } |
| File was renamed from opends/src/server/org/opends/server/replication/plugin/SynchronizationDomain.java |
| | |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import static org.opends.server.messages.SynchronizationMessages.*; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | import static org.opends.server.replication.plugin.Historical.ENTRYUIDNAME; |
| | | import static org.opends.server.replication.protocol.OperationContext.*; |
| | | import static org.opends.server.util.StaticUtils.createEntry; |
| | |
| | | import org.opends.server.backends.jeb.BackendImpl; |
| | | import org.opends.server.backends.task.Task; |
| | | import org.opends.server.backends.task.TaskState; |
| | | import org.opends.server.config.ConfigAttribute; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.config.DNConfigAttribute; |
| | |
| | | import org.opends.server.replication.protocol.ModifyDnContext; |
| | | import org.opends.server.replication.protocol.OperationContext; |
| | | import org.opends.server.replication.protocol.RoutableMessage; |
| | | import org.opends.server.replication.protocol.SynchronizationMessage; |
| | | import org.opends.server.replication.protocol.ReplicationMessage; |
| | | import org.opends.server.replication.protocol.UpdateMessage; |
| | | import org.opends.server.tasks.InitializeTargetTask; |
| | | import org.opends.server.tasks.InitializeTask; |
| | |
| | | |
| | | /** |
| | | * This class implements the bulk part of the.of the Directory Server side |
| | | * of the synchronization code. |
| | | * of the replication code. |
| | | * It contains the root method for publishing a change, |
| | | * processing a change received from the changelog service, |
| | | * handle conflict resolution, |
| | | * handle protocol messages from the changelog server. |
| | | */ |
| | | public class SynchronizationDomain extends DirectoryThread |
| | | public class ReplicationDomain extends DirectoryThread |
| | | implements ConfigurationChangeListener<MultimasterDomainCfg> |
| | | { |
| | | private SynchronizationMonitor monitor; |
| | | private ReplicationMonitor monitor; |
| | | |
| | | private ChangeNumberGenerator changeNumberGenerator; |
| | | private ChangelogBroker broker; |
| | |
| | | private int maxSendDelay = 0; |
| | | |
| | | /** |
| | | * The time in milliseconds between heartbeats from the synchronization |
| | | * The time in milliseconds between heartbeats from the replication |
| | | * server. Zero means heartbeats are off. |
| | | */ |
| | | private long heartbeatInterval = 0; |
| | |
| | | // The task that initiated the operation. |
| | | Task initializeTask; |
| | | // The input stream for the import |
| | | SynchroLDIFInputStream ldifImportInputStream = null; |
| | | ReplLDIFInputStream ldifImportInputStream = null; |
| | | // The target in the case of an export |
| | | short exportTarget = RoutableMessage.UNKNOWN_SERVER; |
| | | // The source in the case of an import |
| | |
| | | |
| | | private DN baseDN; |
| | | |
| | | private List<ConfigAttribute> configAttributes = |
| | | new ArrayList<ConfigAttribute>(); |
| | | |
| | | private boolean shutdown = false; |
| | | |
| | | private InternalClientConnection conn = |
| | |
| | | |
| | | |
| | | /** |
| | | * Creates a new SynchronizationDomain using configuration from configEntry. |
| | | * Creates a new ReplicationDomain using configuration from configEntry. |
| | | * |
| | | * @param configuration The configuration of this SynchronizationDomain. |
| | | * @param configuration The configuration of this ReplicationDomain. |
| | | * @throws ConfigException In case of invalid configuration. |
| | | */ |
| | | public SynchronizationDomain(MultimasterDomainCfg configuration) |
| | | public ReplicationDomain(MultimasterDomainCfg configuration) |
| | | throws ConfigException |
| | | { |
| | | super("Synchronization flush"); |
| | | super("replication flush"); |
| | | |
| | | // Read the configuration parameters. |
| | | changelogServers = configuration.getChangelogServer(); |
| | |
| | | state = new PersistentServerState(baseDN); |
| | | |
| | | /* |
| | | * Create a Synchronization monitor object responsible for publishing |
| | | * Create a replication monitor object responsible for publishing |
| | | * monitoring information below cn=monitor. |
| | | */ |
| | | monitor = new SynchronizationMonitor(this); |
| | | monitor = new ReplicationMonitor(this); |
| | | DirectoryServer.registerMonitorProvider(monitor); |
| | | |
| | | /* |
| | | * ChangeNumberGenerator is used to create new unique ChangeNumbers |
| | | * for each operation done on the synchronization domain. |
| | | * for each operation done on the replication domain. |
| | | */ |
| | | changeNumberGenerator = new ChangeNumberGenerator(serverId, state); |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * Returns the base DN of this SynchronizationDomain. |
| | | * Returns the base DN of this ReplicationDomain. |
| | | * |
| | | * @return The base DN of this SynchronizationDomain |
| | | * @return The base DN of this ReplicationDomain |
| | | */ |
| | | public DN getBaseDN() |
| | | { |
| | |
| | | if (ctx != null) |
| | | { |
| | | /* |
| | | * This is a synchronization operation |
| | | * This is a replication operation |
| | | * Check that the modified entry has the same entryuuid |
| | | * has was in the original message. |
| | | */ |
| | |
| | | } |
| | | else |
| | | { |
| | | // There is no Synchronization context attached to the operation |
| | | // so this is not a synchronization operation. |
| | | // There is no replication context attached to the operation |
| | | // so this is not a replication operation. |
| | | ChangeNumber changeNumber = generateChangeNumber(deleteOperation); |
| | | String modifiedEntryUUID = Historical.getEntryUuid(deletedEntry); |
| | | ctx = new DeleteContext(changeNumber, modifiedEntryUUID); |
| | |
| | | && (!parentDnFromCtx.equals(parentDnFromEntryDn))) |
| | | { |
| | | // parentEntry has been renamed |
| | | // Synchronization name conflict resolution is expected to fix that |
| | | // replication name conflict resolution is expected to fix that |
| | | // later in the flow |
| | | addOperation.setResultCode(ResultCode.NO_SUCH_OBJECT); |
| | | return new SynchronizationProviderResult(false); |
| | |
| | | if (ctx != null) |
| | | { |
| | | /* |
| | | * This is a synchronization operation |
| | | * This is a replication operation |
| | | * Check that the modified entry has the same entryuuid |
| | | * as was in the original message. |
| | | */ |
| | |
| | | } |
| | | else |
| | | { |
| | | // There is no Synchronization context attached to the operation |
| | | // so this is not a synchronization operation. |
| | | // There is no replication context attached to the operation |
| | | // so this is not a replication operation. |
| | | ChangeNumber changeNumber = generateChangeNumber(modifyDNOperation); |
| | | String newParentId = null; |
| | | if (modifyDNOperation.getNewSuperior() != null) |
| | |
| | | Entry modifiedEntry = modifyOperation.getModifiedEntry(); |
| | | if (ctx == null) |
| | | { |
| | | // There is no Synchronization context attached to the operation |
| | | // so this is not a synchronization operation. |
| | | // There is no replication context attached to the operation |
| | | // so this is not a replication operation. |
| | | ChangeNumber changeNumber = generateChangeNumber(modifyOperation); |
| | | String modifiedEntryUUID = Historical.getEntryUuid(modifiedEntry); |
| | | if (modifiedEntryUUID == null) |
| | |
| | | |
| | | /** |
| | | * The preOperation phase for the add Operation. |
| | | * Its job is to generate the Synchronization context associated to the |
| | | * Its job is to generate the replication context associated to the |
| | | * operation. It is necessary to do it in this phase because contrary to |
| | | * the other operations, the entry uid is not set when the handleConflict |
| | | * phase is called. |
| | |
| | | UpdateMessage update = null; |
| | | while (update == null) |
| | | { |
| | | SynchronizationMessage msg; |
| | | ReplicationMessage msg; |
| | | try |
| | | { |
| | | msg = broker.receive(); |
| | |
| | | } |
| | | UpdateMessage msg = null; |
| | | |
| | | // Note that a failed non-synchronization operation might not have a change |
| | | // Note that a failed non-replication operation might not have a change |
| | | // number. |
| | | ChangeNumber curChangeNumber = OperationContext.getChangeNumber(op); |
| | | |
| | |
| | | |
| | | if ((result == ResultCode.SUCCESS) && (!op.isSynchronizationOperation())) |
| | | { |
| | | // Generate a synchronization message for a successful non-synchronization |
| | | // Generate a replication message for a successful non-replication |
| | | // operation. |
| | | msg = UpdateMessage.generateMsg(op, isAssured); |
| | | |
| | |
| | | } |
| | | else if (!op.isSynchronizationOperation()) |
| | | { |
| | | // Remove an unsuccessful non-synchronization operation from the pending |
| | | // Remove an unsuccessful non-replication operation from the pending |
| | | // changes list. |
| | | if (curChangeNumber != null) |
| | | { |
| | |
| | | } |
| | | |
| | | /** |
| | | * get the number of updates received by the synchronization plugin. |
| | | * get the number of updates received by the replication plugin. |
| | | * |
| | | * @return the number of updates received |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Get the number of updates sent by the synchronization plugin. |
| | | * Get the number of updates sent by the replication plugin. |
| | | * |
| | | * @return the number of updates sent |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * get the number of updates replayed by the synchronization. |
| | | * get the number of updates replayed by the replication. |
| | | * |
| | | * @return The number of updates replayed by the synchronization |
| | | * @return The number of updates replayed by the replication |
| | | */ |
| | | public int getNumProcessedUpdates() |
| | | { |
| | |
| | | } |
| | | |
| | | /** |
| | | * get the number of updates replayed successfully by the synchronization. |
| | | * get the number of updates replayed successfully by the replication. |
| | | * |
| | | * @return The number of updates replayed successfully |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Shutdown this SynchronizationDomain. |
| | | * Shutdown this ReplicationDomain. |
| | | */ |
| | | public void shutdown() |
| | | { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Get the number of times the synchronization connection was lost. |
| | | * @return The number of times the synchronization connection was lost. |
| | | * Get the number of times the replication connection was lost. |
| | | * @return The number of times the replication connection was lost. |
| | | */ |
| | | public int getNumLostConnections() |
| | | { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Disable the Synchronization on this domain. |
| | | * The session to the Synchronization server will be stopped. |
| | | * Disable the replication on this domain. |
| | | * The session to the replication server will be stopped. |
| | | * The domain will not be destroyed but call to the pre-operation |
| | | * methods will result in failure. |
| | | * The listener threads will be destroyed. |
| | |
| | | |
| | | /** |
| | | * Enable back the domain after a previous disable. |
| | | * The domain will connect back to a Synchronization Server and |
| | | * The domain will connect back to a replication Server and |
| | | * will recreate threads to listen for messages from the Sycnhronization |
| | | * server. |
| | | * The ServerState will also be read again from the local database. |
| | |
| | | |
| | | /** |
| | | * Receives bytes related to an entry in the context of an import to |
| | | * initialize the domain (called by SynchronizationDomainLDIFInputStream). |
| | | * initialize the domain (called by ReplLDIFInputStream). |
| | | * |
| | | * @return The bytes. Null when the Done or Err message has been received |
| | | */ |
| | | public byte[] receiveEntryBytes() |
| | | { |
| | | SynchronizationMessage msg; |
| | | ReplicationMessage msg; |
| | | while (true) |
| | | { |
| | | try |
| | |
| | | int msgID = MSGID_UNKNOWN_TYPE; |
| | | logError(ErrorLogCategory.SYNCHRONIZATION, |
| | | ErrorLogSeverity.NOTICE, |
| | | "SynchronizationDomain/ " + message, msgID); |
| | | "ReplicationDomain/ " + message, msgID); |
| | | } |
| | | } |
| | | |
| | |
| | | ResultCode.OTHER, message, msgID, null); |
| | | } |
| | | |
| | | SynchroLDIFOutputStream os = new SynchroLDIFOutputStream(this); |
| | | ReplLDIFOutputStream os = new ReplLDIFOutputStream(this); |
| | | |
| | | LDIFExportConfig exportConfig = new LDIFExportConfig(os); |
| | | |
| | |
| | | preBackendImport(this.backend, this.backendConfigEntry); |
| | | |
| | | DN[] baseDNs = {baseDN}; |
| | | ieContext.ldifImportInputStream = new SynchroLDIFInputStream(this); |
| | | ieContext.ldifImportInputStream = new ReplLDIFInputStream(this); |
| | | importConfig = |
| | | new LDIFImportConfig(ieContext.ldifImportInputStream); |
| | | importConfig.setIncludeBranches(this.branches); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Retrieves a synchronization domain based on the baseDN. |
| | | * Retrieves a replication domain based on the baseDN. |
| | | * |
| | | * @param baseDN The baseDN of the domain to retrieve |
| | | * @return The domain retrieved |
| | | * @throws DirectoryException When an error occured. |
| | | */ |
| | | public static SynchronizationDomain retrievesSynchronizationDomain(DN baseDN) |
| | | public static ReplicationDomain retrievesReplicationDomain(DN baseDN) |
| | | throws DirectoryException |
| | | { |
| | | SynchronizationDomain synchronizationDomain = null; |
| | | ReplicationDomain replicationDomain = null; |
| | | |
| | | // Retrieves the domain |
| | | DirectoryServer.getSynchronizationProviders(); |
| | | for (SynchronizationProvider provider : |
| | | DirectoryServer.getSynchronizationProviders()) |
| | | { |
| | | if (!( provider instanceof MultimasterSynchronization)) |
| | | if (!( provider instanceof MultimasterReplication)) |
| | | { |
| | | int msgID = MSGID_INVALID_PROVIDER; |
| | | String message = getMessage(msgID); |
| | |
| | | message, msgID); |
| | | } |
| | | |
| | | // From the domainDN retrieves the synchronization domain |
| | | SynchronizationDomain sdomain = |
| | | MultimasterSynchronization.findDomain(baseDN, null); |
| | | // From the domainDN retrieves the replication domain |
| | | ReplicationDomain sdomain = |
| | | MultimasterReplication.findDomain(baseDN, null); |
| | | if (sdomain == null) |
| | | { |
| | | int msgID = MSGID_NO_MATCHING_DOMAIN; |
| | |
| | | message, msgID); |
| | | } |
| | | |
| | | if (synchronizationDomain != null) |
| | | if (replicationDomain != null) |
| | | { |
| | | // Should never happen |
| | | int msgID = MSGID_MULTIPLE_MATCHING_DOMAIN; |
| | |
| | | throw new DirectoryException(ResultCode.OTHER, |
| | | message, msgID); |
| | | } |
| | | synchronizationDomain = sdomain; |
| | | replicationDomain = sdomain; |
| | | } |
| | | return synchronizationDomain; |
| | | return replicationDomain; |
| | | } |
| | | |
| | | /** |
| | |
| | | // Check that there is not already a domain with the same DN |
| | | // TODO : Check that the server id is a short |
| | | DN dn = configuration.getSynchronizationDN(); |
| | | if (MultimasterSynchronization.findDomain(dn,null) != null) |
| | | if (MultimasterReplication.findDomain(dn,null) != null) |
| | | { |
| | | String message = getMessage(MSGID_SYNC_INVALID_DN, dn.toString()); |
| | | unacceptableReasons.add(message); |
| File was renamed from opends/src/server/org/opends/server/replication/plugin/SynchronizationMonitor.java |
| | |
| | | import org.opends.server.types.AttributeValue; |
| | | |
| | | /** |
| | | * Class used to generate monitoring information for the Synchronization. |
| | | * Class used to generate monitoring information for the replication. |
| | | */ |
| | | public class SynchronizationMonitor extends MonitorProvider |
| | | public class ReplicationMonitor extends MonitorProvider |
| | | { |
| | | private SynchronizationDomain domain; // the synchronization plugin |
| | | private ReplicationDomain domain; // the replication plugin |
| | | |
| | | /** |
| | | * Create a new Synchronization monitor. |
| | | * Create a new replication monitor. |
| | | * @param domain the plugin which created the monitor |
| | | */ |
| | | public SynchronizationMonitor(SynchronizationDomain domain) |
| | | public ReplicationMonitor(ReplicationDomain domain) |
| | | { |
| | | super("Synchronization monitor " + domain.getBaseDN().toString()); |
| | | super("Replication monitor " + domain.getBaseDN().toString()); |
| | | this.domain = domain; |
| | | } |
| | | |
| | |
| | | @Override |
| | | public String getMonitorInstanceName() |
| | | { |
| | | return "synchronization plugin " + domain.getBaseDN().toString(); |
| | | return "Replication plugin " + domain.getBaseDN().toString(); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | |
| | | /** |
| | | * This package contains the part of the Multimaster |
| | | * synchronization code that works on the Directory Server side. |
| | | * This package contains the part of the Multi-master |
| | | * replication code that works on the Directory Server side. |
| | | * <br> |
| | | * The main classes of this core are : |
| | | * <ul> |
| | | * <li> |
| | | * <A HREF="MultimasterSynchronization.html"><B>MultimasterSynchronization |
| | | * <A HREF="MultimasterReplication.html"><B>MultimasterReplication |
| | | * </B></A>contains the synchronization provider |
| | | * code and more generally all the code that makes the glue between the core |
| | | * server and the synchronization code. |
| | | * server and the replication code. |
| | | * </li> |
| | | * <li> |
| | | * <A HREF="SynchronizationDomain.html"><B>SynchronizationDomain</B></A> |
| | | * <A HREF="ReplicationDomain.html"><B>ReplicationDomain</B></A> |
| | | * contains the bulk of the Directory Server side of the |
| | | * synchronization code. Most notably it contains the root method for |
| | | * replication code. Most notably it contains the root method for |
| | | * publishing a change, processing a change received from the changelog |
| | | * service, handle conflict resolution, handle protocol messages from the |
| | | * changelog server. |
| | |
| | | /** |
| | | * Used to send acks between LDAP and changelog servers. |
| | | */ |
| | | public class AckMessage extends SynchronizationMessage |
| | | public class AckMessage extends ReplicationMessage |
| | | { |
| | | // ChangeNumber of the update that was acked. |
| | | private ChangeNumber changeNumber; |
| | |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | |
| | | /** |
| | | * This class describe the Synchronization contexte that is attached to |
| | | * This class describe the contexte that is attached to |
| | | * Add Operation. |
| | | */ |
| | | public class AddContext extends OperationContext |
| | |
| | | /** |
| | | * Message sent by a changelog server to another changelog server at Startup. |
| | | */ |
| | | public class ChangelogStartMessage extends SynchronizationMessage implements |
| | | public class ChangelogStartMessage extends ReplicationMessage implements |
| | | Serializable |
| | | { |
| | | private static final long serialVersionUID = -5871385537169856856L; |
| | |
| | | import java.util.zip.DataFormatException; |
| | | |
| | | /** |
| | | * This message is part of the synchronization protocol. |
| | | * This message is part of the replication protocol. |
| | | * This message is sent by a server to one or several other servers after the |
| | | * last entry sent in the context of a total update and signals to the server |
| | | * that receives it that the export is now finished. |
| | |
| | | import java.util.zip.DataFormatException; |
| | | |
| | | /** |
| | | * This message is part of the synchronization protocol. |
| | | * This message is part of the replication protocol. |
| | | * This message is sent by a server to one or several other servers and |
| | | * contain one entry to be sent over the protocol in the context of |
| | | * an import/export over the protocol. |
| | |
| | | import java.util.zip.DataFormatException; |
| | | |
| | | /** |
| | | * This message is part of the synchronization protocol. |
| | | * This message is part of the replication protocol. |
| | | * This message is sent by a server or a changelog server when an error |
| | | * is detected in the context of a total update. |
| | | */ |
| | |
| | | import java.util.zip.DataFormatException; |
| | | |
| | | /** |
| | | * This message is sent at regular intervals by the synchronization server |
| | | * This message is sent at regular intervals by the replication server |
| | | * when it is sending no other messages. It allows the directory server to |
| | | * detect a problem sooner when a synchronization server has crashed or has |
| | | * been isolated from the network. |
| | | */ |
| | | public class HeartbeatMessage extends SynchronizationMessage |
| | | public class HeartbeatMessage extends ReplicationMessage |
| | | { |
| | | /** |
| | | * Create a new HeartbeatMessage. |
| | |
| | | |
| | | /** |
| | | * This thread publishes a heartbeat message on a given protocol session at |
| | | * regular intervals when there are no other synchronization messages being |
| | | * regular intervals when there are no other replication messages being |
| | | * published. |
| | | */ |
| | | public class HeartbeatThread extends DirectoryThread |
| | |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | /** |
| | | * This message is part of the synchronization protocol. |
| | | * This message is part of the replication protocol. |
| | | * This message is sent by a server to another server in order to |
| | | * request this other server to do an export to the server sender |
| | | * of this message. |
| | |
| | | /** |
| | | * Creates a InitializeRequestMessage message. |
| | | * |
| | | * @param baseDn The base DN of the synchronization domain. |
| | | * @param baseDn The base DN of the replication domain. |
| | | * @param destination destination of this message |
| | | * @param senderID serverID of the server that will send this message |
| | | */ |
| | |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | /** |
| | | * This message is part of the synchronization protocol. |
| | | * This message is part of the replication protocol. |
| | | * This message is sent by a server to one or several servers as the |
| | | * first message of an export, before sending the entries. |
| | | */ |
| | |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | |
| | | /** |
| | | * This class describe the synchronization context that is attached to |
| | | * This class describe the replication context that is attached to |
| | | * Modify operation. |
| | | */ |
| | | public class ModifyContext extends OperationContext |
| | |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | |
| | | /** |
| | | * This class describe the synchronization context that is attached to |
| | | * This class describe the replication context that is attached to |
| | | * ModifyDN operation. |
| | | */ |
| | | public class ModifyDnContext extends OperationContext |
| | |
| | | import org.opends.server.types.Operation; |
| | | |
| | | /** |
| | | * This class describe the Synchronization context that is attached |
| | | * This class describe the replication context that is attached |
| | | * to each Operation using the SYNCHROCONTEXT key. |
| | | */ |
| | | public abstract class OperationContext |
| | |
| | | /** |
| | | * The identifier used to attach the context to operations. |
| | | */ |
| | | public static final String SYNCHROCONTEXT = "synchronizationContext"; |
| | | public static final String SYNCHROCONTEXT = "replicationContext"; |
| | | |
| | | /** |
| | | * The change Number of the Operation. |
| | |
| | | |
| | | /** |
| | | * The ProtocolSession interface should be implemented by a class that |
| | | * implement the send/reception part of the Multimaster synchronization |
| | | * implement the send/reception part of the Multi-master replication |
| | | * protocol. |
| | | * |
| | | * This interface is designed to make easy the move from one format |
| | | * of the SynchronizationMessage on the wire to another format. |
| | | * of the ReplicationMessage on the wire to another format. |
| | | */ |
| | | public interface ProtocolSession |
| | | { |
| | |
| | | public abstract void close() throws IOException; |
| | | |
| | | /** |
| | | * This method is called when a SynchronizationMessage must be sent to |
| | | * This method is called when a ReplicationMessage must be sent to |
| | | * the remote entity. |
| | | * |
| | | * It can be called by several threads and must implement appropriate |
| | | * synchronization (typically, this method or a part of it should be |
| | | * replication (typically, this method or a part of it should be |
| | | * synchronized). |
| | | * |
| | | * @param msg The SynchronizationMessage that must be sent. |
| | | * @param msg The ReplicationMessage that must be sent. |
| | | * @throws IOException If an IO error happen during the publish process. |
| | | */ |
| | | public abstract void publish(SynchronizationMessage msg) |
| | | public abstract void publish(ReplicationMessage msg) |
| | | throws IOException; |
| | | |
| | | /** |
| | | * Attempt to receive a SynchronizationMessage. |
| | | * Attempt to receive a ReplicationMessage. |
| | | * This method should block the calling thread until a |
| | | * SynchronizationMessage is available or until an error condition. |
| | | * ReplicationMessage is available or until an error condition. |
| | | * |
| | | * This method can only be called by a single thread and therefore does not |
| | | * neet to implement any synchronization. |
| | | * neet to implement any replication. |
| | | * |
| | | * @return The SynchronizationMessage that was received. |
| | | * @return The ReplicationMessage that was received. |
| | | * @throws IOException When error happened durin IO process. |
| | | * @throws ClassNotFoundException When the data received does extend the |
| | | * SynchronizationMessage class. |
| | | * ReplicationMessage class. |
| | | * @throws DataFormatException When the data received is not formatted as a |
| | | * SynchronizationMessage. |
| | | * ReplicationMessage. |
| | | */ |
| | | public abstract SynchronizationMessage receive() |
| | | public abstract ReplicationMessage receive() |
| | | throws IOException, ClassNotFoundException, |
| | | DataFormatException; |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * Gets the time the last synchronization message was published on this |
| | | * Gets the time the last replication message was published on this |
| | | * session. |
| | | * @return The timestamp in milliseconds of the last message published. |
| | | */ |
| | |
| | | |
| | | |
| | | /** |
| | | * Gets the time the last synchronization message was received on this |
| | | * Gets the time the last replication message was received on this |
| | | * session. |
| | | * @return The timestamp in milliseconds of the last message received. |
| | | */ |
| File was renamed from opends/src/server/org/opends/server/replication/protocol/SynchronizationMessage.java |
| | |
| | | |
| | | /** |
| | | * Abstract class that must be used when defining messages that can |
| | | * be sent for synchronization purpose between servers. |
| | | * be sent for replication purpose between servers. |
| | | * |
| | | * When extending this class one should also create a new MSG_TYPE |
| | | * and should update the generateMsg() method. |
| | | */ |
| | | public abstract class SynchronizationMessage |
| | | public abstract class ReplicationMessage |
| | | { |
| | | static final byte MSG_TYPE_MODIFY_REQUEST = 1; |
| | | static final byte MSG_TYPE_ADD_REQUEST = 2; |
| | |
| | | |
| | | |
| | | /** |
| | | * Generates a SynchronizationMessage from its encoded form. |
| | | * Generates a ReplicationMessage from its encoded form. |
| | | * |
| | | * @param buffer The encode form of the SynchronizationMessage. |
| | | * @param buffer The encode form of the ReplicationMessage. |
| | | * @return the generated SycnhronizationMessage. |
| | | * @throws DataFormatException if the encoded form was not a valid msg. |
| | | * @throws UnsupportedEncodingException if UTF8 is not supported. |
| | | */ |
| | | public static SynchronizationMessage generateMsg(byte[] buffer) |
| | | public static ReplicationMessage generateMsg(byte[] buffer) |
| | | throws DataFormatException, UnsupportedEncodingException |
| | | { |
| | | SynchronizationMessage msg = null; |
| | | ReplicationMessage msg = null; |
| | | switch (buffer[0]) |
| | | { |
| | | case MSG_TYPE_MODIFY_REQUEST: |
| | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * This is an abstract class of messages of the synchronization protocol |
| | | * This is an abstract class of messages of the replication protocol |
| | | * for message that needs to contain information about the server that |
| | | * send them and the destination servers to whitch they should be sent. |
| | | */ |
| | | public abstract class RoutableMessage extends SynchronizationMessage implements |
| | | public abstract class RoutableMessage extends ReplicationMessage implements |
| | | Serializable |
| | | { |
| | | |
| | |
| | | */ |
| | | public static final short UNKNOWN_SERVER = -1; |
| | | /** |
| | | * Specifies all servers in the synchronization domain. |
| | | * Specifies all servers in the replication domain. |
| | | */ |
| | | public static final short ALL_SERVERS = -2; |
| | | /** |
| | |
| | | * to a changelog server to let them know who they are and what is their state |
| | | * (their RUV) |
| | | */ |
| | | public class ServerStartMessage extends SynchronizationMessage implements |
| | | public class ServerStartMessage extends ReplicationMessage implements |
| | | Serializable |
| | | { |
| | | private static final long serialVersionUID = 8649393307038290287L; |
| | |
| | | private ServerState serverState = null; |
| | | |
| | | /** |
| | | * The time in milliseconds between heartbeats from the synchronization |
| | | * The time in milliseconds between heartbeats from the replication |
| | | * server. Zero means heartbeats are off. |
| | | */ |
| | | private long heartbeatInterval = 0; |
| | |
| | | |
| | | /** |
| | | * This class Implement a protocol session using a basic socket and relying on |
| | | * the innate encoding/decoding capabilities of the SynchronizationMessage |
| | | * the innate encoding/decoding capabilities of the ReplicationMessage |
| | | * by using the getBytes() and generateMsg() methods of those classes. |
| | | * |
| | | * TODO : should have some versioning in the packets so that |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public synchronized void publish(SynchronizationMessage msg) |
| | | public synchronized void publish(ReplicationMessage msg) |
| | | throws IOException |
| | | { |
| | | byte[] buffer = msg.getBytes(); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public SynchronizationMessage receive() throws IOException, |
| | | public ReplicationMessage receive() throws IOException, |
| | | ClassNotFoundException, DataFormatException |
| | | { |
| | | /* Read the first 8 bytes containing the packet length */ |
| | |
| | | /* We do not want the heartbeat to close the session when */ |
| | | /* we are processing a message even a time consuming one. */ |
| | | lastReceiveTime=0; |
| | | return SynchronizationMessage.generateMsg(buffer); |
| | | return ReplicationMessage.generateMsg(buffer); |
| | | } |
| | | catch (OutOfMemoryError e) |
| | | { |
| | |
| | | * Abstract class that must be extended to define a message |
| | | * used for sending Updates between servers. |
| | | */ |
| | | public abstract class UpdateMessage extends SynchronizationMessage |
| | | public abstract class UpdateMessage extends ReplicationMessage |
| | | implements Serializable, |
| | | Comparable<UpdateMessage> |
| | | { |
| | |
| | | /** |
| | | * Creates a new UpdateMessage with the given informations. |
| | | * |
| | | * @param ctx The Synchronization Context of the operation for which the |
| | | * @param ctx The replication Context of the operation for which the |
| | | * update message must be created,. |
| | | * @param dn The dn of the entry on which the change |
| | | * that caused the creation of this object happened |
| | |
| | | |
| | | /** |
| | | * Get a boolean indicating if the Update must be processed as an |
| | | * Asynchronous or as an assured synchronization. |
| | | * Asynchronous or as an assured replication. |
| | | * |
| | | * @return Returns the assuredFlag. |
| | | */ |
| | |
| | | * to a changelog server to let them know who they are and what is their state |
| | | * (their RUV) |
| | | */ |
| | | public class WindowMessage extends SynchronizationMessage implements |
| | | public class WindowMessage extends ReplicationMessage implements |
| | | Serializable |
| | | { |
| | | private static final long serialVersionUID = 8442267608764026867L; |
| | |
| | | * implements the ProtocolSession interface that is |
| | | * used by the changelog server and the directory server to communicate. |
| | | * This is done by using the innate encoding/decoding capabilities of the |
| | | * SynchronizationMessages objects. This class is used by both the |
| | | * changelog and the synchronization package. |
| | | * ReplicationMessages objects. This class is used by both the |
| | | * changelog and the replication package. |
| | | * </li> |
| | | * <li><A HREF="SynchronizationMessage.html"><B>SynchronizationMessage</B></A> |
| | | * <li><A HREF="ReplicationMessage.html"><B>ReplicationMessage</B></A> |
| | | * This class and the class that inherit from it contain the |
| | | * messages that are used for communication between the changelog and the |
| | | * Directory Server as well as the methods fro encoding/decoding them. |
| File was renamed from opends/src/server/org/opends/server/replication/changelog/AckMessageList.java |
| | |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | import java.util.LinkedList; |
| | | |
| File was renamed from opends/src/server/org/opends/server/replication/changelog/AckMessageListComparator.java |
| | |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | import java.util.Comparator; |
| | | |
| File was renamed from opends/src/server/org/opends/server/replication/changelog/Changelog.java |
| | |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.SynchronizationMessages.*; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.getFileForPath; |
| | | |
| File was renamed from opends/src/server/org/opends/server/replication/changelog/ChangelogAckMessageList.java |
| | |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | |
| File was renamed from opends/src/server/org/opends/server/replication/changelog/ChangelogCache.java |
| | |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.SynchronizationMessages.*; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | |
| | | import java.io.IOException; |
| File was renamed from opends/src/server/org/opends/server/replication/changelog/ChangelogDB.java |
| | |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.SynchronizationMessages.*; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | |
| | | import java.util.List; |
| File was renamed from opends/src/server/org/opends/server/replication/changelog/ChangelogDBException.java |
| | |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | |
| | | |
| File was renamed from opends/src/server/org/opends/server/replication/changelog/ChangelogData.java |
| | |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | import com.sleepycat.je.DatabaseEntry; |
| | | |
| | | import org.opends.server.replication.protocol.SynchronizationMessage; |
| | | import org.opends.server.replication.protocol.ReplicationMessage; |
| | | import org.opends.server.replication.protocol.UpdateMessage; |
| | | |
| | | /** |
| | |
| | | public static UpdateMessage generateChange(byte[] data) |
| | | throws Exception |
| | | { |
| | | return (UpdateMessage) SynchronizationMessage.generateMsg(data); |
| | | return (UpdateMessage) ReplicationMessage.generateMsg(data); |
| | | } |
| | | } |
| File was renamed from opends/src/server/org/opends/server/replication/changelog/ChangelogDbEnv.java |
| | |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.SynchronizationMessages.*; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | |
| | | import java.io.File; |
| File was renamed from opends/src/server/org/opends/server/replication/changelog/ChangelogIterator.java |
| | |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | import com.sleepycat.je.DatabaseException; |
| | | |
| | | import org.opends.server.replication.changelog.ChangelogDB.ChangelogCursor; |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | import org.opends.server.replication.protocol.UpdateMessage; |
| | | import org.opends.server.replication.server.ChangelogDB.ChangelogCursor; |
| | | |
| | | /** |
| | | * This class allows to iterate through the changes received from a given |
| File was renamed from opends/src/server/org/opends/server/replication/changelog/ChangelogIteratorComparator.java |
| | |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | import java.util.Comparator; |
| | | |
| File was renamed from opends/src/server/org/opends/server/replication/changelog/ChangelogKey.java |
| | |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | |
| File was renamed from opends/src/server/org/opends/server/replication/changelog/DbHandler.java |
| | |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.SynchronizationMessages.*; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.util.TimeThread; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.replication.changelog.ChangelogDB.ChangelogCursor; |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | import org.opends.server.replication.protocol.UpdateMessage; |
| | | import org.opends.server.replication.server.ChangelogDB.ChangelogCursor; |
| | | |
| | | import com.sleepycat.je.DatabaseException; |
| | | |
| File was renamed from opends/src/server/org/opends/server/replication/changelog/MsgQueue.java |
| | |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | import java.util.SortedMap; |
| | | import java.util.TreeMap; |
| File was renamed from opends/src/server/org/opends/server/replication/changelog/ServerHandler.java |
| | |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugInfo; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.SynchronizationMessages.*; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | |
| | | import java.io.IOException; |
| | |
| | | import org.opends.server.replication.protocol.ProtocolSession; |
| | | import org.opends.server.replication.protocol.RoutableMessage; |
| | | import org.opends.server.replication.protocol.ServerStartMessage; |
| | | import org.opends.server.replication.protocol.SynchronizationMessage; |
| | | import org.opends.server.replication.protocol.ReplicationMessage; |
| | | import org.opends.server.replication.protocol.UpdateMessage; |
| | | import org.opends.server.replication.protocol.WindowMessage; |
| | | import org.opends.server.types.Attribute; |
| | |
| | | private short changelogId; |
| | | |
| | | /** |
| | | * The time in milliseconds between heartbeats from the synchronization |
| | | * The time in milliseconds between heartbeats from the replication |
| | | * server. Zero means heartbeats are off. |
| | | */ |
| | | private long heartbeatInterval = 0; |
| | |
| | | session.publish(msg); |
| | | } |
| | | |
| | | SynchronizationMessage msg = session.receive(); |
| | | ReplicationMessage msg = session.receive(); |
| | | if (msg instanceof ServerStartMessage) |
| | | { |
| | | ServerStartMessage receivedMsg = (ServerStartMessage) msg; |
| | |
| | | // Create a thread to send heartbeat messages. |
| | | if (heartbeatInterval > 0) |
| | | { |
| | | heartbeatThread = new HeartbeatThread("Synchronization Heartbeat", |
| | | heartbeatThread = new HeartbeatThread("replication Heartbeat", |
| | | session, heartbeatInterval); |
| | | heartbeatThread.start(); |
| | | } |
| File was renamed from opends/src/server/org/opends/server/replication/changelog/ServerReader.java |
| | |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.SynchronizationMessages.*; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | |
| | | import java.io.IOException; |
| | | |
| | |
| | | import org.opends.server.replication.protocol.InitializeRequestMessage; |
| | | import org.opends.server.replication.protocol.InitializeTargetMessage; |
| | | import org.opends.server.replication.protocol.ProtocolSession; |
| | | import org.opends.server.replication.protocol.SynchronizationMessage; |
| | | import org.opends.server.replication.protocol.ReplicationMessage; |
| | | import org.opends.server.replication.protocol.UpdateMessage; |
| | | import org.opends.server.replication.protocol.WindowMessage; |
| | | import org.opends.server.types.ErrorLogCategory; |
| | |
| | | { |
| | | while (true) |
| | | { |
| | | SynchronizationMessage msg = session.receive(); |
| | | ReplicationMessage msg = session.receive(); |
| | | |
| | | if (msg == null) |
| | | { |
| File was renamed from opends/src/server/org/opends/server/replication/changelog/ServerWriter.java |
| | |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.messages.SynchronizationMessages.*; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.net.SocketException; |
| File was renamed from opends/src/server/org/opends/server/replication/changelog/UpdateComparator.java |
| | |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | import java.util.Comparator; |
| | | |
| File was renamed from opends/src/server/org/opends/server/replication/changelog/package-info.java |
| | |
| | | |
| | | /** |
| | | * This package contains the code for the changelog service part |
| | | * of the Multimaster synchronization feature. |
| | | * of the Multimaster replication feature. |
| | | * <br> |
| | | * |
| | | * A changelog server is responsible for : |
| | |
| | | * implements the ProtocolSession interface that is |
| | | * used by the changelog server and the directory server to communicate. |
| | | * This is done by using the innate encoding/decoding capabilities of the |
| | | * SynchronizationMessages objects. This class is used by both the |
| | | * changelog and the synchronization package. |
| | | * ReplicationMessages objects. This class is used by both the |
| | | * changelog and the replication package. |
| | | * </li> |
| | | * <li><A HREF="ChangelogCache.html"><B>ChangelogCache</B></A> |
| | | * implements the multiplexing part of the changelog |
| | |
| | | * </ul> |
| | | */ |
| | | |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | |
| | | import org.opends.server.backends.task.TaskState; |
| | | import org.opends.server.messages.TaskMessages; |
| | | import org.opends.server.protocols.asn1.ASN1OctetString; |
| | | import org.opends.server.replication.plugin.SynchronizationDomain; |
| | | import org.opends.server.replication.plugin.ReplicationDomain; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | |
| | | boolean isEncrypted = false; |
| | | boolean skipSchemaValidation = false; |
| | | String domainString = null; |
| | | SynchronizationDomain domain = null; |
| | | ReplicationDomain domain = null; |
| | | short target; |
| | | long total; |
| | | long left; |
| | |
| | | throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, |
| | | message, msgID); |
| | | } |
| | | domain=SynchronizationDomain.retrievesSynchronizationDomain(domainDN); |
| | | domain=ReplicationDomain.retrievesReplicationDomain(domainDN); |
| | | |
| | | attrList = taskEntry.getAttribute(typeScope); |
| | | String targetString = TaskUtils.getSingleValueString(attrList); |
| | |
| | | import org.opends.server.backends.task.TaskState; |
| | | import org.opends.server.messages.TaskMessages; |
| | | import org.opends.server.protocols.asn1.ASN1OctetString; |
| | | import org.opends.server.replication.plugin.SynchronizationDomain; |
| | | import org.opends.server.replication.plugin.ReplicationDomain; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | |
| | | |
| | | /** |
| | | * This class provides an implementation of a Directory Server task that can |
| | | * be used to import data over the synchronization protocol from another |
| | | * server hosting the same synchronization domain. |
| | | * be used to import data over the replication protocol from another |
| | | * server hosting the same replication domain. |
| | | */ |
| | | public class InitializeTask extends Task |
| | | { |
| | |
| | | boolean skipSchemaValidation = false; |
| | | String domainString = null; |
| | | short source; |
| | | SynchronizationDomain domain = null; |
| | | ReplicationDomain domain = null; |
| | | TaskState initState; |
| | | |
| | | // The total number of entries expected to be processed when this import |
| | |
| | | message, msgID); |
| | | } |
| | | |
| | | domain=SynchronizationDomain.retrievesSynchronizationDomain(domainDN); |
| | | domain=ReplicationDomain.retrievesReplicationDomain(domainDN); |
| | | |
| | | |
| | | attrList = taskEntry.getAttribute(typeSourceScope); |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | |
| | | /** |
| | | * An abstract class that all synchronization unit test should extend. |
| | | * An abstract class that all control unit test should extend. |
| | | */ |
| | | @Test(groups = { "precommit", "controls" }) |
| | | public abstract class ControlsTestCase extends DirectoryServerTestCase |
| | |
| | | import org.opends.server.messages.TaskMessages; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.replication.changelog.Changelog; |
| | | import org.opends.server.replication.changelog.ChangelogFakeConfiguration; |
| | | import org.opends.server.replication.plugin.ChangelogBroker; |
| | | import org.opends.server.replication.plugin.SynchronizationDomain; |
| | | import org.opends.server.replication.plugin.ReplicationDomain; |
| | | import org.opends.server.replication.protocol.DoneMessage; |
| | | import org.opends.server.replication.protocol.EntryMessage; |
| | | import org.opends.server.replication.protocol.ErrorMessage; |
| | |
| | | import org.opends.server.replication.protocol.InitializeTargetMessage; |
| | | import org.opends.server.replication.protocol.RoutableMessage; |
| | | import org.opends.server.replication.protocol.SocketSession; |
| | | import org.opends.server.replication.protocol.SynchronizationMessage; |
| | | import org.opends.server.replication.protocol.ReplicationMessage; |
| | | import org.opends.server.replication.server.Changelog; |
| | | import org.opends.server.replication.server.ChangelogFakeConfiguration; |
| | | import org.opends.server.schema.DirectoryStringSyntax; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | |
| | | import org.opends.server.types.SearchScope; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | import static org.opends.server.messages.SynchronizationMessages.*; |
| | | import static org.opends.server.messages.ReplicationMessages.*; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | |
| | | /** |
| | |
| | | * InitializeTarget task |
| | | */ |
| | | |
| | | public class InitOnLineTest extends SynchronizationTestCase |
| | | public class InitOnLineTest extends ReplicationTestCase |
| | | { |
| | | private static final int WINDOW_SIZE = 10; |
| | | private static final int CHANGELOG_QUEUE_SIZE = 100; |
| | | |
| | | private static final String SYNCHRONIZATION_STRESS_TEST = |
| | | "Synchronization Stress Test"; |
| | | |
| | | /** |
| | | * A "person" entry |
| | | */ |
| | |
| | | Changelog changelog1 = null; |
| | | Changelog changelog2 = null; |
| | | boolean emptyOldChanges = true; |
| | | SynchronizationDomain sd = null; |
| | | ReplicationDomain sd = null; |
| | | |
| | | private void log(String s) |
| | | { |
| | |
| | | |
| | | /** |
| | | * Set up the environment for performing the tests in this Class. |
| | | * synchronization |
| | | * |
| | | * @throws Exception |
| | | * If the environment could not be set up. |
| | |
| | | synchroServerEntry = null; |
| | | |
| | | // Add config entries to the current DS server based on : |
| | | // Add the synchronization plugin: synchroPluginEntry & synchroPluginStringDN |
| | | // Add the replication plugin: synchroPluginEntry & synchroPluginStringDN |
| | | // Add synchroServerEntry |
| | | // Add changeLogEntry |
| | | configureSynchronization(); |
| | | configureReplication(); |
| | | |
| | | taskInitFromS2 = TestCaseUtils.makeEntry( |
| | | "dn: ds-task-id=" + UUID.randomUUID() + |
| | |
| | | String[] updatedEntries) |
| | | { |
| | | // Expect the broker to receive the entries |
| | | SynchronizationMessage msg; |
| | | ReplicationMessage msg; |
| | | short entriesReceived = 0; |
| | | while (true) |
| | | { |
| | |
| | | "Unable to add the synchronized server"); |
| | | entryList.add(synchroServerEntry.getDN()); |
| | | |
| | | sd = SynchronizationDomain.retrievesSynchronizationDomain(baseDn); |
| | | sd = ReplicationDomain.retrievesReplicationDomain(baseDn); |
| | | |
| | | // Clear the backend |
| | | SynchronizationDomain.clearJEBackend(false, |
| | | ReplicationDomain.clearJEBackend(false, |
| | | sd.getBackend().getBackendID(), |
| | | baseDn.toNormalizedString()); |
| | | |
| | | } |
| | | if (sd != null) |
| | | { |
| | | log("SynchronizationDomain: Import/Export is running ? " + sd.ieRunning()); |
| | | log("ReplicationDomain: Import/Export is running ? " + sd.ieRunning()); |
| | | } |
| | | } |
| | | catch(Exception e) |
| | |
| | | addTask(taskInitFromS2, ResultCode.SUCCESS, 0); |
| | | |
| | | // S2 should receive init msg |
| | | SynchronizationMessage msg; |
| | | ReplicationMessage msg; |
| | | msg = server2.receive(); |
| | | if (!(msg instanceof InitializeRequestMessage)) |
| | | { |
| | |
| | | @Test(enabled=false) |
| | | public void InitializeExport() throws Exception |
| | | { |
| | | String testCase = "Synchronization/InitializeExport"; |
| | | String testCase = "Replication/InitializeExport"; |
| | | |
| | | log("Starting "+testCase); |
| | | |
| | |
| | | @Test(enabled=false) |
| | | public void InitializeTargetExport() throws Exception |
| | | { |
| | | String testCase = "Synchronization/InitializeTargetExport"; |
| | | String testCase = "Replication/InitializeTargetExport"; |
| | | |
| | | log("Starting " + testCase); |
| | | |
| | |
| | | @Test(enabled=false) |
| | | public void InitializeTargetExportAll() throws Exception |
| | | { |
| | | String testCase = "Synchronization/InitializeTargetExportAll"; |
| | | String testCase = "Replication/InitializeTargetExportAll"; |
| | | |
| | | log("Starting " + testCase); |
| | | |
| | |
| | | @Test(enabled=false) |
| | | public void InitializeTargetExportMultiSS() throws Exception |
| | | { |
| | | String testCase = "Synchronization/InitializeTargetExportMultiSS"; |
| | | String testCase = "Replication/InitializeTargetExportMultiSS"; |
| | | |
| | | log("Starting " + testCase); |
| | | |
| | |
| | | @Test(enabled=false) |
| | | public void InitializeExportMultiSS() throws Exception |
| | | { |
| | | String testCase = "Synchronization/InitializeExportMultiSS"; |
| | | String testCase = "Replication/InitializeExportMultiSS"; |
| | | log("Starting "+testCase); |
| | | |
| | | // Create 2 changelogs |
| | |
| | | |
| | | if (sd != null) |
| | | { |
| | | log("SynchronizationDomain: Import/Export is running ? " + sd.ieRunning()); |
| | | log("ReplicationDomain: Import/Export is running ? " + sd.ieRunning()); |
| | | } |
| | | |
| | | log("Successfully ending "+testCase); |
| | |
| | | |
| | | if (sd != null) |
| | | { |
| | | log("SynchronizationDomain: Import/Export is running ? " + sd.ieRunning()); |
| | | log("ReplicationDomain: Import/Export is running ? " + sd.ieRunning()); |
| | | } |
| | | |
| | | log("Successfully ending "+testCase); |
| | |
| | | |
| | | if (sd != null) |
| | | { |
| | | log("SynchronizationDomain: Import/Export is running ? " + sd.ieRunning()); |
| | | log("ReplicationDomain: Import/Export is running ? " + sd.ieRunning()); |
| | | } |
| | | |
| | | // Clean brokers |
| | |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.replication.plugin.ChangelogBroker; |
| | | import org.opends.server.replication.protocol.AddMsg; |
| | | import org.opends.server.replication.protocol.SynchronizationMessage; |
| | | import org.opends.server.replication.protocol.ReplicationMessage; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test the contructors, encoders and decoders of the synchronization AckMsg, |
| | | * Test the contructors, encoders and decoders of the Replication AckMsg, |
| | | * ModifyMsg, ModifyDnMsg, AddMsg and Delete Msg |
| | | */ |
| | | public class ProtocolWindowTest extends SynchronizationTestCase |
| | | public class ProtocolWindowTest extends ReplicationTestCase |
| | | { |
| | | private static final int WINDOW_SIZE = 10; |
| | | private static final int CHANGELOG_QUEUE_SIZE = 100; |
| | | |
| | | private static final String SYNCHRONIZATION_STRESS_TEST = |
| | | "Synchronization Stress Test"; |
| | | private static final String REPLICATION_STRESS_TEST = |
| | | "Replication Stress Test"; |
| | | |
| | | /** |
| | | * A "person" entry |
| | |
| | | { |
| | | logError(ErrorLogCategory.SYNCHRONIZATION, |
| | | ErrorLogSeverity.NOTICE, |
| | | "Starting synchronization ProtocolWindowTest : saturateAndRestart" , 1); |
| | | "Starting Replication ProtocolWindowTest : saturateAndRestart" , 1); |
| | | |
| | | final DN baseDn = DN.decode("ou=People,dc=example,dc=com"); |
| | | |
| | |
| | | "The Add Entry operation failed"); |
| | | |
| | | // Check if the client has received the msg |
| | | SynchronizationMessage msg = broker.receive(); |
| | | ReplicationMessage msg = broker.receive(); |
| | | assertTrue(msg instanceof AddMsg, |
| | | "The received synchronization message is not an ADD msg"); |
| | | "The received Replication message is not an ADD msg"); |
| | | AddMsg addMsg = (AddMsg) msg; |
| | | |
| | | Operation receivedOp = addMsg.createOperation(connection); |
| | | assertTrue(OperationType.ADD.compareTo(receivedOp.getOperationType()) == 0, |
| | | "The received synchronization message is not an ADD msg"); |
| | | "The received Replication message is not an ADD msg"); |
| | | |
| | | assertEquals(DN.decode(addMsg.getDn()),personEntry.getDN(), |
| | | "The received ADD synchronization message is not for the excepted DN"); |
| | | "The received ADD Replication message is not for the excepted DN"); |
| | | |
| | | // send (2 * window + changelog queue) modify operations |
| | | // so that window + changelog queue get stuck in the changelog queue |
| | |
| | | } |
| | | finally { |
| | | broker.stop(); |
| | | DirectoryServer.deregisterMonitorProvider(SYNCHRONIZATION_STRESS_TEST); |
| | | DirectoryServer.deregisterMonitorProvider(REPLICATION_STRESS_TEST); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * Set up the environment for performing the tests in this Class. |
| | | * synchronization |
| | | * Replication |
| | | * |
| | | * @throws Exception |
| | | * If the environment could not be set up. |
| | |
| | | + "userPassword: password\n" + "initials: AA\n"; |
| | | personEntry = TestCaseUtils.entryFromLdifString(personLdif); |
| | | |
| | | configureSynchronization(); |
| | | configureReplication(); |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * Test re-synchronization after after backup/restore and LDIF import. |
| | | */ |
| | | public class ReSyncTest extends SynchronizationTestCase |
| | | public class ReSyncTest extends ReplicationTestCase |
| | | { |
| | | /** |
| | | * Set up the environment for performing the tests in this Class. |
| | |
| | | public void setup() throws Exception |
| | | { |
| | | /* |
| | | * - Start a server and a changelog server, configure synchronization |
| | | * - Start a server and a changelog server, configure replication |
| | | * - Do some changes. |
| | | */ |
| | | TestCaseUtils.startServer(); |
| | |
| | | + "ds-cfg-directory-server-id: 123\n"; |
| | | synchroServerEntry = TestCaseUtils.entryFromLdifString(synchroServerLdif); |
| | | |
| | | configureSynchronization(); |
| | | configureReplication(); |
| | | |
| | | // Give some time to the synchronization to setup |
| | | // Give some time to the replication to setup |
| | | Thread.sleep(1000); |
| | | |
| | | // Create a dummy entry |
| File was renamed from opends/tests/unit-tests-testng/src/server/org/opends/server/replication/SynchronizationTestCase.java |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | |
| | | /** |
| | | * An abstract class that all synchronization unit test should extend. |
| | | * An abstract class that all Replication unit test should extend. |
| | | */ |
| | | @Test(groups = { "precommit", "synchronization" }) |
| | | public abstract class SynchronizationTestCase extends DirectoryServerTestCase |
| | | @Test(groups = { "precommit", "replication" }) |
| | | public abstract class ReplicationTestCase extends DirectoryServerTestCase |
| | | { |
| | | |
| | | /** |
| | |
| | | protected boolean schemaCheck; |
| | | |
| | | /** |
| | | * The synchronization plugin entry |
| | | * The replication plugin entry |
| | | */ |
| | | protected String synchroPluginStringDN = |
| | | "cn=Multimaster Synchronization, cn=Synchronization Providers,cn=config"; |
| | |
| | | { |
| | | logError(ErrorLogCategory.SYNCHRONIZATION, |
| | | ErrorLogSeverity.NOTICE, |
| | | "SynchronizationTestCase/openChangelogSession" + e.getMessage(), 1); |
| | | "ReplicationTestCase/openChangelogSession" + e.getMessage(), 1); |
| | | } |
| | | } |
| | | return broker; |
| | |
| | | { |
| | | logError(ErrorLogCategory.SYNCHRONIZATION, |
| | | ErrorLogSeverity.NOTICE, |
| | | "SynchronizationTestCase/Cleaning config entries" , 1); |
| | | "ReplicationTestCase/Cleaning config entries" , 1); |
| | | |
| | | DeleteOperation op; |
| | | // Delete entries |
| | |
| | | { |
| | | logError(ErrorLogCategory.SYNCHRONIZATION, |
| | | ErrorLogSeverity.NOTICE, |
| | | "SynchronizationTestCase/Cleaning entries" , 1); |
| | | "ReplicationTestCase/Cleaning entries" , 1); |
| | | |
| | | DeleteOperation op; |
| | | // Delete entries |
| | |
| | | } |
| | | |
| | | /** |
| | | * Configure the Synchronization for this test. |
| | | * Configure the replication for this test. |
| | | */ |
| | | protected void configureSynchronization() throws Exception |
| | | protected void configureReplication() throws Exception |
| | | { |
| | | // Add the Multimaster synchronization plugin |
| | | // Add the Multimaster replication plugin |
| | | String synchroPluginLdif = "dn: " + synchroPluginStringDN + "\n" |
| | | + "objectClass: top\n" |
| | | + "objectClass: ds-cfg-synchronization-provider\n" |
| | | + "objectClass: ds-cfg-multimaster-synchronization-provider\n" |
| | | + "ds-cfg-synchronization-provider-enabled: true\n" |
| | | + "ds-cfg-synchronization-provider-class: " + |
| | | "org.opends.server.replication.plugin.MultimasterSynchronization\n"; |
| | | "org.opends.server.replication.plugin.MultimasterReplication\n"; |
| | | Entry synchroPluginEntry = TestCaseUtils.entryFromLdifString(synchroPluginLdif); |
| | | DirectoryServer.getConfigHandler().addEntry(synchroPluginEntry, null); |
| | | configEntryList.add(synchroPluginEntry.getDN()); |
| | | assertNotNull(DirectoryServer.getConfigEntry(DN |
| | | .decode(synchroPluginStringDN)), |
| | | "Unable to add the Multimaster synchronization plugin"); |
| | | "Unable to add the Multimaster replication plugin"); |
| | | |
| | | // domains container entry. |
| | | String domainsLdif = "dn: " |
| | |
| | | configEntryList.add(domainsEntry.getDN()); |
| | | assertNotNull(DirectoryServer.getConfigEntry( |
| | | DN.decode(synchroPluginStringDN)), |
| | | "Unable to add the Multimaster synchronization plugin"); |
| | | "Unable to add the Multimaster replication plugin"); |
| | | |
| | | |
| | | // Add the changelog server |
| | |
| | | "Unable to add the changeLog server"); |
| | | configEntryList.add(changeLogEntry.getDN()); |
| | | |
| | | // We also have a replicated suffix (synchronization domain) |
| | | // We also have a replicated suffix (replication domain) |
| | | DirectoryServer.getConfigHandler().addEntry(synchroServerEntry, null); |
| | | assertNotNull(DirectoryServer.getConfigEntry(synchroServerEntry.getDN()), |
| | | "Unable to add the synchronized server"); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Retrieve the number of replayed updates for a given synchronization |
| | | * Retrieve the number of replayed updates for a given replication |
| | | * domain from the monitor entry. |
| | | * @return The number of replayed updates. |
| | | * @throws Exception If an error occurs. |
| File was renamed from opends/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaSynchronizationTest.java |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.ldap.LDAPModification; |
| | | import org.opends.server.replication.common.ChangeNumberGenerator; |
| | | import org.opends.server.replication.plugin.ChangelogBroker; |
| | | import org.opends.server.replication.protocol.ModifyMsg; |
| | | import org.opends.server.replication.protocol.SynchronizationMessage; |
| | | import org.opends.server.replication.protocol.ReplicationMessage; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test for the schema synchronization. |
| | | * Test for the schema replication. |
| | | */ |
| | | public class SchemaSynchronizationTest extends SynchronizationTestCase |
| | | public class SchemaReplicationTest extends ReplicationTestCase |
| | | { |
| | | |
| | | private ArrayList<Modification> rcvdMods = null; |
| | |
| | | |
| | | /** |
| | | * Set up the environment for performing the tests in this Class. |
| | | * synchronization |
| | | * |
| | | * @throws Exception |
| | | * If the environment could not be set up. |
| | |
| | | + "ds-cfg-directory-server-id: 1\n"; |
| | | synchroServerEntry = TestCaseUtils.entryFromLdifString(synchroServerLdif); |
| | | |
| | | configureSynchronization(); |
| | | configureReplication(); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | logError(ErrorLogCategory.SYNCHRONIZATION, |
| | | ErrorLogSeverity.NOTICE, |
| | | "Starting synchronization test : pushSchemaChange ", 1); |
| | | "Starting replication test : pushSchemaChange ", 1); |
| | | |
| | | final DN baseDn = DN.decode("cn=schema"); |
| | | |
| | |
| | | "The original operation failed"); |
| | | |
| | | // See if the client has received the msg |
| | | SynchronizationMessage msg = broker.receive(); |
| | | ReplicationMessage msg = broker.receive(); |
| | | |
| | | assertTrue(msg instanceof ModifyMsg, |
| | | "The received synchronization message is not a MODIFY msg"); |
| | | "The received replication message is not a MODIFY msg"); |
| | | ModifyMsg modMsg = (ModifyMsg) msg; |
| | | |
| | | Operation receivedOp = modMsg.createOperation(connection); |
| | |
| | | "The received message is not for cn=schema"); |
| | | |
| | | assertTrue(receivedOp instanceof ModifyOperation, |
| | | "The received synchronization message is not a MODIFY msg"); |
| | | "The received replication message is not a MODIFY msg"); |
| | | ModifyOperation receivedModifyOperation = (ModifyOperation) receivedOp; |
| | | |
| | | List<RawModification> rcvdRawMods = |
| | |
| | | |
| | | /** |
| | | * Checks that changes to the schema pushed to the changelog |
| | | * are received and correctly replayed by synchronization plugin. |
| | | * are received and correctly replayed by replication plugin. |
| | | */ |
| | | @Test(dependsOnMethods = { "pushSchemaChange" }) |
| | | public void replaySchemaChange() throws Exception |
| | | { |
| | | logError(ErrorLogCategory.SYNCHRONIZATION, |
| | | ErrorLogSeverity.NOTICE, |
| | | "Starting synchronization test : pushSchemaChange ", 1); |
| | | "Starting replication test : pushSchemaChange ", 1); |
| | | |
| | | final DN baseDn = DN.decode("cn=schema"); |
| | | |
| | |
| | | { |
| | | logError(ErrorLogCategory.SYNCHRONIZATION, |
| | | ErrorLogSeverity.NOTICE, |
| | | "Starting synchronization test : pushSchemaFilesChange ", 1); |
| | | "Starting replication test : pushSchemaFilesChange ", 1); |
| | | |
| | | final DN baseDn = DN.decode("cn=schema"); |
| | | |
| | |
| | | } |
| | | |
| | | // receive the message on the broker side. |
| | | SynchronizationMessage msg = broker.receive(); |
| | | ReplicationMessage msg = broker.receive(); |
| | | |
| | | assertTrue(msg instanceof ModifyMsg, |
| | | "The received synchronization message is not a MODIFY msg"); |
| | | "The received replication message is not a MODIFY msg"); |
| | | ModifyMsg modMsg = (ModifyMsg) msg; |
| | | |
| | | Operation receivedOp = modMsg.createOperation(connection); |
| | |
| | | "The received message is not for cn=schema"); |
| | | |
| | | assertTrue(receivedOp instanceof ModifyOperation, |
| | | "The received synchronization message is not a MODIFY msg"); |
| | | "The received replication message is not a MODIFY msg"); |
| | | ModifyOperation receivedModifyOperation = (ModifyOperation) receivedOp; |
| | | |
| | | List<RawModification> rcvdRawMods = |
| | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.replication.plugin.ChangelogBroker; |
| | | import org.opends.server.replication.protocol.AddMsg; |
| | | import org.opends.server.replication.protocol.SynchronizationMessage; |
| | | import org.opends.server.replication.protocol.ReplicationMessage; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | |
| | | /** |
| | | * Stress test for the synchronization code using the ChangelogBroker API. |
| | | */ |
| | | public class StressTest extends SynchronizationTestCase |
| | | public class StressTest extends ReplicationTestCase |
| | | { |
| | | private static final String SYNCHRONIZATION_STRESS_TEST = |
| | | "Synchronization Stress Test"; |
| | | private static final String REPLICATION_STRESS_TEST = |
| | | "Replication Stress Test"; |
| | | |
| | | /** |
| | | * The Synchronization config manager entry |
| | | * The replication config manager entry |
| | | */ |
| | | private String synchroStringDN; |
| | | |
| | |
| | | { |
| | | logError(ErrorLogCategory.SYNCHRONIZATION, |
| | | ErrorLogSeverity.NOTICE, |
| | | "Starting Synchronization StressTest : fromServertoBroker" , 1); |
| | | "Starting replication StressTest : fromServertoBroker" , 1); |
| | | |
| | | final DN baseDn = DN.decode("ou=People,dc=example,dc=com"); |
| | | final int TOTAL_MESSAGES = 1000; |
| | |
| | | if (ResultCode.SUCCESS == addOp.getResultCode()) |
| | | { |
| | | // Check if the client has received the msg |
| | | SynchronizationMessage msg = broker.receive(); |
| | | ReplicationMessage msg = broker.receive(); |
| | | |
| | | assertTrue(msg instanceof AddMsg, |
| | | "The received synchronization message is not an ADD msg"); |
| | | "The received replication message is not an ADD msg"); |
| | | AddMsg addMsg = (AddMsg) msg; |
| | | |
| | | Operation receivedOp = addMsg.createOperation(connection); |
| | | assertTrue(OperationType.ADD.compareTo(receivedOp.getOperationType()) == 0, |
| | | "The received synchronization message is not an ADD msg"); |
| | | "The received replication message is not an ADD msg"); |
| | | |
| | | assertEquals(DN.decode(addMsg.getDn()),personEntry.getDN(), |
| | | "The received ADD synchronization message is not for the excepted DN"); |
| | | "The received ADD replication message is not for the excepted DN"); |
| | | } |
| | | |
| | | reader = new BrokerReader(broker); |
| | |
| | | |
| | | } |
| | | finally { |
| | | DirectoryServer.deregisterMonitorProvider(SYNCHRONIZATION_STRESS_TEST); |
| | | DirectoryServer.deregisterMonitorProvider(REPLICATION_STRESS_TEST); |
| | | broker.stop(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Set up the environment for performing the tests in this Class. |
| | | * synchronization |
| | | * |
| | | * @throws Exception |
| | | * If the environment could not be set up. |
| | |
| | | + "userPassword: password\n" + "initials: AA\n"; |
| | | personEntry = TestCaseUtils.entryFromLdifString(personLdif); |
| | | |
| | | configureSynchronization(); |
| | | configureReplication(); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | while (true) |
| | | { |
| | | SynchronizationMessage msg = broker.receive(); |
| | | ReplicationMessage msg = broker.receive(); |
| | | if (msg == null) |
| | | break; |
| | | count ++; |
| | |
| | | @Override |
| | | public String getMonitorInstanceName() |
| | | { |
| | | return SYNCHRONIZATION_STRESS_TEST; |
| | | return REPLICATION_STRESS_TEST; |
| | | } |
| | | |
| | | @Override |
| | |
| | | import org.opends.server.replication.protocol.HeartbeatThread; |
| | | import org.opends.server.replication.protocol.ModifyDNMsg; |
| | | import org.opends.server.replication.protocol.ModifyMsg; |
| | | import org.opends.server.replication.protocol.SynchronizationMessage; |
| | | import org.opends.server.replication.protocol.ReplicationMessage; |
| | | import org.opends.server.schema.DirectoryStringSyntax; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DeleteOperation; |
| | |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test synchronization update operations on the directory server and through |
| | | * the synchronization server broker interface. |
| | | * Test synchronization of update operations on the directory server and through |
| | | * the replication server broker interface. |
| | | */ |
| | | public class UpdateOperationTest extends SynchronizationTestCase |
| | | public class UpdateOperationTest extends ReplicationTestCase |
| | | { |
| | | /** |
| | | * An entry with a entryUUID |
| | |
| | | personWithSecondUniqueID = |
| | | TestCaseUtils.entryFromLdifString(entryWithSecondUUID); |
| | | |
| | | configureSynchronization(); |
| | | configureReplication(); |
| | | } |
| | | |
| | | /** |
| | |
| | | // Check that the entry has not been created in the directory server. |
| | | resultEntry = getEntry(personWithUUIDEntry.getDN(), 1000, true); |
| | | assertNull(resultEntry, |
| | | "The synchronization message was replayed while the server " + |
| | | "The replication message was replayed while the server " + |
| | | "receive status was disabled"); |
| | | |
| | | // Enable the directory server receive status. |
| | |
| | | // Check that the entry has been created in the directory server. |
| | | resultEntry = getEntry(personWithUUIDEntry.getDN(), 10000, true); |
| | | assertNotNull(resultEntry, |
| | | "The synchronization message was not replayed after the server " + |
| | | "The replication message was not replayed after the server " + |
| | | "receive status was enabled"); |
| | | |
| | | // Delete the entries to clean the database. |
| | |
| | | |
| | | // Check that the delete operation has been applied. |
| | | assertNull(resultEntry, |
| | | "The DELETE synchronization message was not replayed"); |
| | | "The DELETE replication message was not replayed"); |
| | | broker.stop(); |
| | | } |
| | | |
| | | /** |
| | | * Tests whether the synchronization provider fails over when it loses |
| | | * the heartbeat from the synchronization server. |
| | | * the heartbeat from the replication server. |
| | | */ |
| | | @Test(groups = "slow") |
| | | public void lostHeartbeatFailover() throws Exception |
| | | { |
| | | logError(ErrorLogCategory.SYNCHRONIZATION, |
| | | ErrorLogSeverity.NOTICE, |
| | | "Starting synchronization test : lostHeartbeatFailover" , 1); |
| | | "Starting replication test : lostHeartbeatFailover" , 1); |
| | | |
| | | cleanRealEntries(); |
| | | |
| | |
| | | // Check that the entry has been created in the directory server. |
| | | resultEntry = getEntry(personWithUUIDEntry.getDN(), 10000, true); |
| | | assertNotNull(resultEntry, |
| | | "The ADD synchronization message was not replayed"); |
| | | "The ADD replication message was not replayed"); |
| | | |
| | | // Send a first modify operation message. |
| | | List<Modification> mods = generatemods("telephonenumber", "01 02 45"); |
| | |
| | | |
| | | // Check that the delete operation has been applied. |
| | | assertNull(resultEntry, |
| | | "The DELETE synchronization message was not replayed"); |
| | | "The DELETE replication message was not replayed"); |
| | | broker.stop(); |
| | | } |
| | | |
| | |
| | | { |
| | | logError(ErrorLogCategory.SYNCHRONIZATION, |
| | | ErrorLogSeverity.NOTICE, |
| | | "Starting synchronization test : namingConflicts" , 1); |
| | | "Starting replication test : namingConflicts" , 1); |
| | | |
| | | final DN baseDn = DN.decode("ou=People,dc=example,dc=com"); |
| | | |
| | |
| | | // Check that the entry has been created in the local DS. |
| | | Entry resultEntry = getEntry(personWithUUIDEntry.getDN(), 10000, true); |
| | | assertNotNull(resultEntry, |
| | | "The send ADD synchronization message was not applied"); |
| | | "The send ADD replication message was not applied"); |
| | | entryList.add(resultEntry.getDN()); |
| | | |
| | | // send a modify operation with the correct unique ID but another DN |
| | |
| | | // Check that the entry has been created in the local DS. |
| | | resultEntry = getEntry(personWithUUIDEntry.getDN(), 10000, true); |
| | | assertNotNull(resultEntry, |
| | | "The ADD synchronization message was not applied"); |
| | | "The ADD replication message was not applied"); |
| | | entryList.add(resultEntry.getDN()); |
| | | |
| | | // send a modify operation with a wrong unique ID but the same DN |
| | |
| | | resultEntry = getEntry(personWithUUIDEntry.getDN(), 10000, false); |
| | | |
| | | assertNull(resultEntry, |
| | | "The DELETE synchronization message was not replayed"); |
| | | "The DELETE replication message was not replayed"); |
| | | |
| | | /* |
| | | * Test that two adds with the same DN but a different unique ID result |
| | |
| | | // Check that the entry has been created in the local DS. |
| | | resultEntry = getEntry(personWithUUIDEntry.getDN(), 10000, true); |
| | | assertNotNull(resultEntry, |
| | | "The ADD synchronization message was not applied"); |
| | | "The ADD replication message was not applied"); |
| | | entryList.add(resultEntry.getDN()); |
| | | |
| | | // create an entry with the same DN and another unique ID |
| | |
| | | DN.decode("entryuuid=" + user1entrysecondUUID +" + " + user1dn), |
| | | 10000, true); |
| | | assertNotNull(resultEntry, |
| | | "The ADD synchronization message was not applied"); |
| | | "The ADD replication message was not applied"); |
| | | |
| | | // delete the entries to clean the database. |
| | | delMsg = |
| | |
| | | |
| | | // check that the delete operation has been applied |
| | | assertNull(resultEntry, |
| | | "The DELETE synchronization message was not replayed"); |
| | | "The DELETE replication message was not replayed"); |
| | | /* |
| | | * Check that and added entry is correctly added below it's |
| | | * parent entry when this parent entry has been renamed. |
| | |
| | | resultEntry = getEntry( |
| | | DN.decode("uid=new person,ou=People,dc=example,dc=com"), 10000, true); |
| | | assertNotNull(resultEntry, |
| | | "The ADD synchronization message was not applied"); |
| | | "The ADD replication message was not applied"); |
| | | |
| | | /* |
| | | * Check that when replaying delete the naming conflict code |
| | |
| | | |
| | | // check that the delete operation has not been applied |
| | | assertNotNull(resultEntry, |
| | | "The DELETE synchronization message was replayed when it should not"); |
| | | "The DELETE replication message was replayed when it should not"); |
| | | |
| | | |
| | | /* |
| | |
| | | |
| | | // check that the delete operation has been applied |
| | | assertNull(resultEntry, |
| | | "The DELETE synchronization message was not replayed"); |
| | | "The DELETE replication message was not replayed"); |
| | | |
| | | delMsg = |
| | | new DeleteMsg("entryUUID = " + user1entrysecondUUID + "+" + |
| | |
| | | |
| | | // check that the delete operation has been applied |
| | | assertNull(resultEntry, |
| | | "The DELETE synchronization message was not replayed"); |
| | | "The DELETE replication message was not replayed"); |
| | | |
| | | /* |
| | | * When replaying add operations it is possible that the parent entry has |
| | | * been renamed before and that another entry have taken the former dn of |
| | | * the parent entry. In such case the synchronization replay code should |
| | | * the parent entry. In such case the replication replay code should |
| | | * detect that the parent has been renamed and should add the entry below |
| | | * the new dn of the parent (thus changing the original dn with which the |
| | | * entry had been created) |
| | |
| | | resultEntry = getEntry( |
| | | DN.decode("uid=new person,ou=baseDn1,"+baseDn), 10000, false); |
| | | assertNull(resultEntry, |
| | | "The ADD synchronization message was applied under ou=baseDn1,"+baseDn); |
| | | "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 synchronization message was NOT applied under ou=baseDn2,"+baseDn); |
| | | "The ADD replication message was NOT applied under ou=baseDn2,"+baseDn); |
| | | entryList.add(resultEntry.getDN()); |
| | | |
| | | |
| | |
| | | { |
| | | logError(ErrorLogCategory.SYNCHRONIZATION, |
| | | ErrorLogSeverity.NOTICE, |
| | | "Starting synchronization test : updateOperations " + assured , 1); |
| | | "Starting replication test : updateOperations " + assured , 1); |
| | | |
| | | final DN baseDn = DN.decode("ou=People,dc=example,dc=com"); |
| | | |
| | |
| | | if (ResultCode.SUCCESS.equals(addOp.getResultCode())) |
| | | { |
| | | // Check if the client has received the msg |
| | | SynchronizationMessage msg = broker.receive(); |
| | | ReplicationMessage msg = broker.receive(); |
| | | assertTrue(msg instanceof AddMsg, |
| | | "The received synchronization message is not an ADD msg"); |
| | | "The received replication message is not an ADD msg"); |
| | | AddMsg addMsg = (AddMsg) msg; |
| | | |
| | | Operation receivedOp = addMsg.createOperation(connection); |
| | | assertTrue(OperationType.ADD.compareTo(receivedOp.getOperationType()) == 0, |
| | | "The received synchronization message is not an ADD msg"); |
| | | "The received replication message is not an ADD msg"); |
| | | |
| | | assertEquals(DN.decode(addMsg.getDn()),personEntry.getDN(), |
| | | "The received ADD synchronization message is not for the excepted DN"); |
| | | "The received ADD replication message is not for the excepted DN"); |
| | | } |
| | | |
| | | // Modify the entry |
| | |
| | | modOp.run(); |
| | | |
| | | // See if the client has received the msg |
| | | SynchronizationMessage msg = broker.receive(); |
| | | ReplicationMessage msg = broker.receive(); |
| | | assertTrue(msg instanceof ModifyMsg, |
| | | "The received synchronization message is not a MODIFY msg"); |
| | | "The received replication message is not a MODIFY msg"); |
| | | ModifyMsg modMsg = (ModifyMsg) msg; |
| | | |
| | | modMsg.createOperation(connection); |
| | | assertTrue(DN.decode(modMsg.getDn()).compareTo(personEntry.getDN()) == 0, |
| | | "The received MODIFY synchronization message is not for the excepted DN"); |
| | | "The received MODIFY replication message is not for the excepted DN"); |
| | | |
| | | // Modify the entry DN |
| | | DN newDN = DN.decode("uid= new person,ou=People,dc=example,dc=com") ; |
| | |
| | | // See if the client has received the msg |
| | | msg = broker.receive(); |
| | | assertTrue(msg instanceof ModifyDNMsg, |
| | | "The received synchronization message is not a MODIFY DN msg"); |
| | | "The received replication message is not a MODIFY DN msg"); |
| | | ModifyDNMsg moddnMsg = (ModifyDNMsg) msg; |
| | | moddnMsg.createOperation(connection); |
| | | |
| | |
| | | // See if the client has received the msg |
| | | msg = broker.receive(); |
| | | assertTrue(msg instanceof DeleteMsg, |
| | | "The received synchronization message is not a MODIFY DN msg"); |
| | | "The received replication message is not a MODIFY DN msg"); |
| | | DeleteMsg delMsg = (DeleteMsg) msg; |
| | | delMsg.createOperation(connection); |
| | | assertTrue(DN.decode(delMsg.getDn()).compareTo(DN |
| | |
| | | */ |
| | | Entry resultEntry = getEntry(personWithUUIDEntry.getDN(), 10000, true); |
| | | assertNotNull(resultEntry, |
| | | "The send ADD synchronization message was not applied for "+personWithUUIDEntry.getDN().toString()); |
| | | "The send ADD replication message was not applied for "+personWithUUIDEntry.getDN().toString()); |
| | | entryList.add(resultEntry.getDN()); |
| | | |
| | | /* |
| | |
| | | DN.decode("uid= new person,ou=People,dc=example,dc=com"), 10000, true); |
| | | |
| | | assertNotNull(resultEntry, |
| | | "The modify DN synchronization message was not applied"); |
| | | "The modify DN replication message was not applied"); |
| | | |
| | | /* |
| | | * Test the Reception of Delete Msg |
| | |
| | | DN.decode("uid= new person,ou=People,dc=example,dc=com"), 10000, false); |
| | | |
| | | assertNull(resultEntry, |
| | | "The DELETE synchronization message was not replayed"); |
| | | "The DELETE replication message was not replayed"); |
| | | } |
| | | finally |
| | | { |
| | |
| | | { |
| | | logError(ErrorLogCategory.SYNCHRONIZATION, |
| | | ErrorLogSeverity.NOTICE, |
| | | "Starting synchronization test : deleteNoSuchObject" , 1); |
| | | "Starting replication test : deleteNoSuchObject" , 1); |
| | | |
| | | DN dn = DN.decode("cn=No Such Object,ou=People,dc=example,dc=com"); |
| | | Operation op = |
| | |
| | | { |
| | | logError(ErrorLogCategory.SYNCHRONIZATION, |
| | | ErrorLogSeverity.NOTICE, |
| | | "Starting synchronization test : infiniteReplayLoop" , 1); |
| | | "Starting replication test : infiniteReplayLoop" , 1); |
| | | |
| | | final DN baseDn = DN.decode("ou=People,dc=example,dc=com"); |
| | | |
| | |
| | | DirectoryStringSyntax.DECODER); |
| | | |
| | | // Register a short circuit that will fake a no-such-object result code |
| | | // on a delete. This will cause a synchronization replay loop. |
| | | // on a delete. This will cause a replication replay loop. |
| | | ShortCircuitPlugin.registerShortCircuit(OperationType.DELETE, |
| | | "PreParse", 32); |
| | | try |
| | |
| | | "PreParse"); |
| | | } |
| | | |
| | | // If the synchronization replay loop was detected and broken then the |
| | | // If the replication replay loop was detected and broken then the |
| | | // counter will still be updated even though the replay was unsuccessful. |
| | | if (getReplayedUpdatesCount(baseDn) == initialCount) |
| | | { |
| | | fail("Synchronization operation was not replayed"); |
| | | fail("Operation was not replayed"); |
| | | } |
| | | } |
| | | finally |
| | |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import org.opends.server.replication.SynchronizationTestCase; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | import org.opends.server.replication.common.ChangeNumberGenerator; |
| | | import org.opends.server.util.TimeThread; |
| | | import org.testng.annotations.Test; |
| | | |
| | | public class ChangeNumberGeneratorTest extends SynchronizationTestCase |
| | | public class ChangeNumberGeneratorTest extends ReplicationTestCase |
| | | { |
| | | /** |
| | | * Test the adjust method of ChangeNumberGenerator |
| | |
| | | import static org.testng.Assert.*; |
| | | |
| | | |
| | | import org.opends.server.replication.SynchronizationTestCase; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | import org.opends.server.replication.common.ChangeNumberGenerator; |
| | | import org.opends.server.util.TimeThread; |
| | |
| | | /** |
| | | * Test ChangeNumber and ChangeNumberGenerator |
| | | */ |
| | | public class ChangeNumberTest extends SynchronizationTestCase |
| | | public class ChangeNumberTest extends ReplicationTestCase |
| | | { |
| | | |
| | | /** |
| | |
| | | |
| | | import java.util.Set; |
| | | |
| | | import org.opends.server.replication.SynchronizationTestCase; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | import org.opends.server.replication.common.ServerState; |
| | | import org.opends.server.util.TimeThread; |
| | |
| | | /** |
| | | * Test the ServerState |
| | | */ |
| | | public class ServerStateTest extends SynchronizationTestCase |
| | | public class ServerStateTest extends ReplicationTestCase |
| | | { |
| | | |
| | | /** |
| | |
| | | import java.util.LinkedHashSet; |
| | | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.replication.SynchronizationTestCase; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | import org.opends.server.replication.plugin.AttrInfo; |
| | | import org.opends.server.replication.plugin.ValueInfo; |
| | |
| | | * Test AttrInfo and AttrInfoWithOptions |
| | | */ |
| | | public class AttrInfoTest |
| | | extends SynchronizationTestCase |
| | | extends ReplicationTestCase |
| | | { |
| | | /** |
| | | * Build some data for the AttrInfo test below. |
| | |
| | | |
| | | package org.opends.server.replication.plugin; |
| | | |
| | | import org.opends.server.replication.SynchronizationTestCase; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | import org.opends.server.replication.plugin.ChangelogBroker; |
| | | import org.opends.server.replication.plugin.Historical; |
| | |
| | | * Tests the Historical class. |
| | | */ |
| | | public class HistoricalTest |
| | | extends SynchronizationTestCase |
| | | extends ReplicationTestCase |
| | | { |
| | | /** |
| | | * Set up synchronization on the test backend. |
| | | * Set up replication on the test backend. |
| | | * @throws Exception If an error occurs. |
| | | */ |
| | | @BeforeClass |
| | |
| | | // Create an internal connection. |
| | | connection = InternalClientConnection.getRootConnection(); |
| | | |
| | | // The synchronization server. |
| | | // The replication server. |
| | | String changeLogStringDN = "cn=Changelog Server, " + synchroPluginStringDN; |
| | | String changeLogLdif = "dn: " + changeLogStringDN + "\n" |
| | | + "objectClass: top\n" |
| | |
| | | + "ds-cfg-receive-status: true\n"; |
| | | synchroServerEntry = TestCaseUtils.entryFromLdifString(synchroServerLdif); |
| | | |
| | | configureSynchronization(); |
| | | configureReplication(); |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * The scenario for this test case is that two modify operations occur at |
| | | * two different servers at nearly the same time, each operation adding a |
| | | * different value for a single-valued attribute. Synchronization then |
| | | * different value for a single-valued attribute. Replication then |
| | | * replays the operations and we expect the conflict to be resolved on both |
| | | * servers by keeping whichever value was actually added first. |
| | | * For the unit test, we employ a single directory server. We use the |
| | |
| | | |
| | | // It would be nice to avoid these sleeps. |
| | | // We need to preserve the replay order but the order could be changed |
| | | // due to the multi-threaded nature of the synchronization replay. |
| | | // due to the multi-threaded nature of the replication replay. |
| | | // Putting a sentinel value in the modification is not foolproof since |
| | | // the operation might not get replayed at all. |
| | | Thread.sleep(2000); |
| | |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.asn1.ASN1OctetString; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.replication.SynchronizationTestCase; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | import org.opends.server.replication.plugin.FakeOperation; |
| | | import org.opends.server.replication.plugin.FakeOperationComparator; |
| | | import org.opends.server.replication.plugin.Historical; |
| | | import org.opends.server.replication.protocol.ModifyContext; |
| | | import org.opends.server.replication.protocol.SynchronizationMessage; |
| | | import org.opends.server.replication.protocol.ReplicationMessage; |
| | | import org.opends.server.replication.protocol.UpdateMessage; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | |
| | | */ |
| | | |
| | | public class ModifyConflictTest |
| | | extends SynchronizationTestCase |
| | | extends ReplicationTestCase |
| | | { |
| | | |
| | | /** |
| | |
| | | FakeOperation fk = fks.iterator().next(); |
| | | assertTrue(new FakeOperationComparator().compare(fk, fk) == 0); |
| | | assertTrue(new FakeOperationComparator().compare(null , fk) < 0); |
| | | SynchronizationMessage generatedMsg = fk.generateMessage() ; |
| | | ReplicationMessage generatedMsg = fk.generateMessage() ; |
| | | if (generatedMsg instanceof UpdateMessage) |
| | | { |
| | | UpdateMessage new_name = (UpdateMessage) generatedMsg; |
| | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.replication.SynchronizationTestCase; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | import org.opends.server.replication.common.ChangeNumberGenerator; |
| | | import org.opends.server.replication.plugin.PersistentServerState; |
| | |
| | | /** |
| | | * Test the PersistentServerState class. |
| | | */ |
| | | public class PersistentServerStateTest extends SynchronizationTestCase |
| | | public class PersistentServerStateTest extends ReplicationTestCase |
| | | { |
| | | /** |
| | | * Set up the environment for performing the tests in this suite. |
| | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.replication.SynchronizationTestCase; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | import org.opends.server.replication.common.ChangeNumberGenerator; |
| | | import org.opends.server.replication.plugin.PersistentServerState; |
| | |
| | | /** |
| | | * Test the PersistentServerState class. |
| | | */ |
| | | public class PersistentStateTest extends SynchronizationTestCase |
| | | public class PersistentStateTest extends ReplicationTestCase |
| | | { |
| | | /** |
| | | * Set up the environment for performing the tests in this suite. |
| | |
| | | package org.opends.server.replication.plugin; |
| | | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.replication.SynchronizationTestCase; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | import org.opends.server.replication.plugin.ValueInfo; |
| | | import org.opends.server.types.AttributeType; |
| | |
| | | /** |
| | | * Test of ValueInfo |
| | | */ |
| | | public class ValueInfoTest extends SynchronizationTestCase |
| | | public class ValueInfoTest extends ReplicationTestCase |
| | | { |
| | | /** |
| | | * Build some data for the ValueInfo test below. |
| | |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.replication.SynchronizationTestCase; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | import org.opends.server.replication.common.ServerState; |
| | | import org.opends.server.replication.plugin.PendingChange; |
| | |
| | | import org.opends.server.replication.protocol.ModifyMsg; |
| | | import org.opends.server.replication.protocol.OperationContext; |
| | | import org.opends.server.replication.protocol.ServerStartMessage; |
| | | import org.opends.server.replication.protocol.SynchronizationMessage; |
| | | import org.opends.server.replication.protocol.ReplicationMessage; |
| | | import org.opends.server.replication.protocol.UpdateMessage; |
| | | import org.opends.server.replication.protocol.WindowMessage; |
| | | import org.opends.server.types.Attribute; |
| | |
| | | * Test the contructors, encoders and decoders of the synchronization |
| | | * AckMsg, ModifyMsg, ModifyDnMsg, AddMsg and Delete Msg |
| | | */ |
| | | public class SynchronizationMsgTest extends SynchronizationTestCase |
| | | public class SynchronizationMsgTest extends ReplicationTestCase |
| | | { |
| | | /** |
| | | * Build some data for the ModifyMsg test below. |
| | |
| | | InternalClientConnection connection = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyMsg msg = new ModifyMsg(changeNumber, dn, mods, "fakeuniqueid"); |
| | | ModifyMsg generatedMsg = (ModifyMsg) SynchronizationMessage |
| | | ModifyMsg generatedMsg = (ModifyMsg) ReplicationMessage |
| | | .generateMsg(msg.getBytes()); |
| | | |
| | | |
| | |
| | | assertTrue(msg.isAssured()); |
| | | |
| | | // Check equals |
| | | ModifyMsg generatedMsg = (ModifyMsg) SynchronizationMessage |
| | | ModifyMsg generatedMsg = (ModifyMsg) ReplicationMessage |
| | | .generateMsg(msg.getBytes()); |
| | | assertFalse(msg.equals(null)); |
| | | assertFalse(msg.equals(new Object())); |
| | |
| | | (short) 123, (short) 45); |
| | | op.setAttachment(SYNCHROCONTEXT, new DeleteContext(cn, "uniqueid")); |
| | | DeleteMsg msg = new DeleteMsg(op); |
| | | DeleteMsg generatedMsg = (DeleteMsg) SynchronizationMessage |
| | | DeleteMsg generatedMsg = (DeleteMsg) ReplicationMessage |
| | | .generateMsg(msg.getBytes()); |
| | | |
| | | assertEquals(msg.toString(), generatedMsg.toString()); |
| | |
| | | op.setAttachment(SYNCHROCONTEXT, |
| | | new ModifyDnContext(cn, "uniqueid", "newparentId")); |
| | | ModifyDNMsg msg = new ModifyDNMsg(op); |
| | | ModifyDNMsg generatedMsg = (ModifyDNMsg) SynchronizationMessage |
| | | ModifyDNMsg generatedMsg = (ModifyDNMsg) ReplicationMessage |
| | | .generateMsg(msg.getBytes()); |
| | | Operation generatedOperation = generatedMsg.createOperation(connection); |
| | | ModifyDNOperation mod2 = (ModifyDNOperation) generatedOperation; |
| | |
| | | AddMsg msg = new AddMsg(cn, rawDN, "thisIsaUniqueID", "parentUniqueId", |
| | | objectClass, userAttributes, |
| | | operationalAttributes); |
| | | AddMsg generatedMsg = (AddMsg) SynchronizationMessage.generateMsg(msg |
| | | AddMsg generatedMsg = (AddMsg) ReplicationMessage.generateMsg(msg |
| | | .getBytes()); |
| | | assertEquals(msg.getBytes(), generatedMsg.getBytes()); |
| | | assertEquals(msg.toString(), generatedMsg.toString()); |
| | |
| | | |
| | | // Check invalid bytes for constructor |
| | | byte[] b = msg1.getBytes(); |
| | | b[0] = SynchronizationMessage.MSG_TYPE_ADD_REQUEST ; |
| | | b[0] = ReplicationMessage.MSG_TYPE_ADD_REQUEST ; |
| | | try |
| | | { |
| | | // This should generated an exception |
| | |
| | | } |
| | | |
| | | // Check that retrieved CN is OK |
| | | msg2 = (AckMessage) SynchronizationMessage.generateMsg(msg1.getBytes()); |
| | | msg2 = (AckMessage) ReplicationMessage.generateMsg(msg1.getBytes()); |
| | | } |
| | | |
| | | @DataProvider(name="serverStart") |
| | |
| | | /** |
| | | * Test PendingChange |
| | | */ |
| | | private void testPendingChange(ChangeNumber cn, Operation op, SynchronizationMessage msg) |
| | | private void testPendingChange(ChangeNumber cn, Operation op, ReplicationMessage msg) |
| | | { |
| | | if (! (msg instanceof UpdateMessage)) |
| | | { |
| File was renamed from opends/tests/unit-tests-testng/src/server/org/opends/server/replication/changelog/ChangelogFakeConfiguration.java |
| | |
| | | * |
| | | * Portions Copyright 2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | import java.util.SortedSet; |
| | | |
| File was renamed from opends/tests/unit-tests-testng/src/server/org/opends/server/replication/changelog/ChangelogTest.java |
| | |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | import static org.testng.Assert.assertTrue; |
| | | import static org.testng.Assert.fail; |
| | |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.replication.SynchronizationTestCase; |
| | | import org.opends.server.replication.changelog.Changelog; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | import org.opends.server.replication.common.ChangeNumberGenerator; |
| | | import org.opends.server.replication.common.ServerState; |
| | |
| | | import org.opends.server.replication.protocol.ModifyDNMsg; |
| | | import org.opends.server.replication.protocol.ModifyDnContext; |
| | | import org.opends.server.replication.protocol.ModifyMsg; |
| | | import org.opends.server.replication.protocol.SynchronizationMessage; |
| | | import org.opends.server.replication.protocol.ReplicationMessage; |
| | | import org.opends.server.replication.server.Changelog; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * Tests for the changelog service code. |
| | | */ |
| | | |
| | | public class ChangelogTest extends SynchronizationTestCase |
| | | public class ChangelogTest extends ReplicationTestCase |
| | | { |
| | | /** |
| | | * The changelog server that will be used in this test. |
| | |
| | | new DeleteMsg("o=test,dc=example,dc=com", firstChangeNumberServer1, |
| | | "uid"); |
| | | server1.publish(msg); |
| | | SynchronizationMessage msg2 = server2.receive(); |
| | | ReplicationMessage msg2 = server2.receive(); |
| | | if (msg2 instanceof DeleteMsg) |
| | | { |
| | | DeleteMsg del = (DeleteMsg) msg2; |
| | |
| | | openChangelogSession(DN.decode("dc=example,dc=com"), (short) 3, |
| | | 100, changelogPort, 1000, false); |
| | | |
| | | SynchronizationMessage msg2 = broker.receive(); |
| | | ReplicationMessage msg2 = broker.receive(); |
| | | if (!(msg2 instanceof DeleteMsg)) |
| | | fail("Changelog basic transmission failed"); |
| | | else |
| | |
| | | openChangelogSession(DN.decode("dc=example,dc=com"), (short) 3, |
| | | 100, changelogPort, 1000, state); |
| | | |
| | | SynchronizationMessage msg2 = broker.receive(); |
| | | ReplicationMessage msg2 = broker.receive(); |
| | | if (!(msg2 instanceof DeleteMsg)) |
| | | fail("Changelog basic transmission failed"); |
| | | else |
| | |
| | | // - Check msg receives by broker, through changeLog2 |
| | | while (ts > 1) |
| | | { |
| | | SynchronizationMessage msg2; |
| | | ReplicationMessage msg2; |
| | | try |
| | | { |
| | | msg2 = broker2.receive(); |
| | |
| | | { |
| | | while (true) |
| | | { |
| | | SynchronizationMessage msg = broker.receive(); |
| | | ReplicationMessage msg = broker.receive(); |
| | | if (msg == null) |
| | | break; |
| | | } |
| File was renamed from opends/tests/unit-tests-testng/src/server/org/opends/server/replication/changelog/UpdateComparatorTest.java |
| | |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | |
| | | |
| | | import org.opends.server.core.DeleteOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.replication.SynchronizationTestCase; |
| | | import org.opends.server.replication.changelog.UpdateComparator; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | import org.opends.server.replication.protocol.DeleteContext; |
| | | import org.opends.server.replication.protocol.DeleteMsg; |
| | | import org.opends.server.replication.protocol.UpdateMessage; |
| | | import org.opends.server.replication.server.UpdateComparator; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.util.TimeThread; |
| | |
| | | /** |
| | | * Test ChangeNumber and ChangeNumberGenerator |
| | | */ |
| | | public class UpdateComparatorTest extends SynchronizationTestCase |
| | | public class UpdateComparatorTest extends ReplicationTestCase |
| | | { |
| | | |
| | | /** |
| File was renamed from opends/tests/unit-tests-testng/src/server/org/opends/server/replication/changelog/dbHandlerTest.java |
| | |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.changelog; |
| | | package org.opends.server.replication.server; |
| | | |
| | | import java.io.File; |
| | | import java.net.ServerSocket; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.replication.SynchronizationTestCase; |
| | | import org.opends.server.replication.changelog.Changelog; |
| | | import org.opends.server.replication.changelog.ChangelogDbEnv; |
| | | import org.opends.server.replication.changelog.DbHandler; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.ChangeNumber; |
| | | import org.opends.server.replication.common.ChangeNumberGenerator; |
| | | import org.opends.server.replication.protocol.DeleteMsg; |
| | | import org.opends.server.replication.server.Changelog; |
| | | import org.opends.server.replication.server.ChangelogDbEnv; |
| | | import org.opends.server.replication.server.DbHandler; |
| | | import org.opends.server.types.DN; |
| | | import org.testng.annotations.Test; |
| | | import static org.testng.Assert.*; |
| | |
| | | /** |
| | | * Test the dbHandler class |
| | | */ |
| | | public class dbHandlerTest extends SynchronizationTestCase |
| | | public class dbHandlerTest extends ReplicationTestCase |
| | | { |
| | | @Test() |
| | | void testDbHandlerTrim() throws Exception |