Class LDAPReplicationDomain

java.lang.Object
org.opends.server.replication.service.ReplicationDomain
org.opends.server.replication.plugin.LDAPReplicationDomain
All Implemented Interfaces:
ConfigurationChangeListener<ReplicationDomainCfg>, AlertGenerator, LocalBackendInitializationListener, ServerShutdownListener

This class implements the bulk part of the Directory Server side of the replication code. It contains the root method for publishing a change, processing a change received from the replicationServer service, handle conflict resolution, handle protocol messages from the replicationServer.
  • Field Details

    • DS_SYNC_CONFLICT

      public static final String DS_SYNC_CONFLICT
      The attribute used to mark conflicting entries. The value of this attribute should be the dn that this entry was supposed to have when it was marked as conflicting.
      See Also:
  • Method Details

    • processServerShutdown

      public void processServerShutdown(LocalizableMessage reason)
      Description copied from interface: ServerShutdownListener
      Indicates that the Directory Server has received a request to stop running and that this shutdown listener should take any action necessary to prepare for it.
      Specified by:
      processServerShutdown in interface ServerShutdownListener
      Parameters:
      reason - The human-readable reason for the shutdown.
    • performBackendPostInitializationProcessing

      public void performBackendPostInitializationProcessing(LocalBackend<?> backend)
      Description copied from interface: LocalBackendInitializationListener
      Performs any processing that may be required after the Initialisation cycle has been completed, that is all listeners have received the initialisation event, and the backend has been put into service,.
      Specified by:
      performBackendPostInitializationProcessing in interface LocalBackendInitializationListener
      Parameters:
      backend - The backend that has been initialized and has been put into service.
    • performBackendPreFinalizationProcessing

      public void performBackendPreFinalizationProcessing(LocalBackend<?> backend)
      Description copied from interface: LocalBackendInitializationListener
      Performs any processing that may be required before starting the finalisation cycle, that is invoked before any listener receive the Finalization event.
      Specified by:
      performBackendPreFinalizationProcessing in interface LocalBackendInitializationListener
      Parameters:
      backend - The backend that is about to be finalized.
    • receiveEntryBytes

      protected byte[] receiveEntryBytes()
      Receives bytes related to an entry in the context of an import to initialize the domain (called by ReplLDIFInputStream).

      This is overwritten to allow stopping the (online) import process by the fractional ldif import plugin when it detects that the (imported) remote data set is not consistent with the local fractional configuration.

      Overrides:
      receiveEntryBytes in class ReplicationDomain
      Returns:
      The bytes. Null when the Done or Err message has been received
    • initializeRemote

      protected void initializeRemote(ReplicaId target, ReplicaId requestorID, Task initTask, int initWindow) throws LdapException
      Process the initialization of some other server or servers in the topology specified by the target argument when this initialization specifying the server that requests the initialization.

      This is overwritten to allow stopping the (online) export process if the local domain is fractional and the destination is all other servers: This make no sense to have only fractional servers in a replicated topology. This prevents from administrator manipulation error that would lead to whole topology data corruption.

      Overrides:
      initializeRemote in class ReplicationDomain
      Parameters:
      target - The target replica that should be initialized.
      requestorID - The replica that initiated the export. It can be the replica id of this server, or the replica id of a remote replica.
      initTask - The task in this server that triggers this initialization and that should be updated with its progress. Null when the export is done following a request coming from a remote server (task is remote).
      initWindow - The value of the initialization window for flow control between the importer and the exporter.
      Throws:
      LdapException - When an error occurs. No exception raised means success.
    • publishHeartbeatMsg

      public void publishHeartbeatMsg()
      Description copied from class: ReplicationDomain
      Publishes a heartbeat message if all pending changes for current replica have been sent out.
      Overrides:
      publishHeartbeatMsg in class ReplicationDomain
    • publishReplicaOfflineMsg

      public void publishReplicaOfflineMsg()
      Description copied from class: ReplicationDomain
      Publishes a replica offline message if all pending changes for current replica have been sent out.
      Overrides:
      publishReplicaOfflineMsg in class ReplicationDomain
    • shutdown

      public void shutdown()
      Shutdown this ReplicationDomain.
    • suspend

      public void suspend()
      Suspends 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 thread will be destroyed. The monitor informations will still be accessible.
    • resume

      public void resume()
      Restart replication for this domain after a previous suspend. The domain will connect back to a replication Server and will recreate threads to listen for messages from the Synchronization server. The generationId will be retrieved or computed if necessary. The ServerState will also be read again from the local database.
    • exportBackend

      protected void exportBackend(OutputStream output) throws LdapException
      This method trigger an export of the replicated data.
      Specified by:
      exportBackend in class ReplicationDomain
      Parameters:
      output - The OutputStream where the export should be produced.
      Throws:
      LdapException - When needed.
    • importBackend

      protected void importBackend(InputStream input) throws LdapException
      This method triggers an import of the replicated data.
      Specified by:
      importBackend in class ReplicationDomain
      Parameters:
      input - The InputStream from which the data are read.
      Throws:
      LdapException - When needed.
    • retrievesReplicationDomain

      public static LDAPReplicationDomain retrievesReplicationDomain(Dn baseDN, ServerContext serverContext) throws LdapException
      Retrieves a replication domain based on the baseDN.
      Parameters:
      baseDN - The baseDN of the domain to retrieve
      serverContext - The server context
      Returns:
      The domain retrieved
      Throws:
      LdapException - When an error occurred or no domain match the provided baseDN.
    • applyConfigurationChange

      public ConfigChangeResult applyConfigurationChange(ReplicationDomainCfg configuration)
      Description copied from interface: ConfigurationChangeListener
      Applies the configuration changes to this change listener.
      Specified by:
      applyConfigurationChange in interface ConfigurationChangeListener<ReplicationDomainCfg>
      Parameters:
      configuration - The new configuration containing the changes.
      Returns:
      Returns information about the result of changing the configuration.
    • isConfigurationChangeAcceptable

      public boolean isConfigurationChangeAcceptable(ReplicationDomainCfg configuration, List<LocalizableMessage> unacceptableReasons)
      Description copied from interface: ConfigurationChangeListener
      Indicates whether the proposed change to the configuration is acceptable to this change listener.
      Specified by:
      isConfigurationChangeAcceptable in interface ConfigurationChangeListener<ReplicationDomainCfg>
      Parameters:
      configuration - The new configuration containing the changes.
      unacceptableReasons - A list that can be used to hold messages about why the provided configuration is not acceptable.
      Returns:
      Returns true if the proposed change is acceptable, or false if it is not.
    • getAlerts

      public Map<String,String> getAlerts()
      Description copied from interface: AlertGenerator
      Retrieves information about the set of alerts that this generator may produce. The map returned should be between the notification type for a particular notification and the human-readable description for that notification. This alert generator must not generate any alerts with types that are not contained in this list.
      Specified by:
      getAlerts in interface AlertGenerator
      Returns:
      Information about the set of alerts that this generator may produce.
    • getComponentEntryDN

      public Dn getComponentEntryDN()
      Description copied from interface: AlertGenerator
      Retrieves the DN of the configuration entry with which this alert generator is associated.
      Specified by:
      getComponentEntryDN in interface AlertGenerator
      Returns:
      The DN of the configuration entry with which this alert generator is associated.
    • start

      public void start()
      Starts the Replication Domain.
    • sessionInitiated

      public void sessionInitiated(ServerStatus initStatus, ServerState rsState, ServerState newestChangelogStateOfReplica)
      Description copied from class: ReplicationDomain
      Set the initial status of the domain and perform necessary initializations. This method will be called by the Broker each time the ReplicationBroker establish a new session to a Replication Server. Implementations may override this method when they need to perform additional computing after session establishment. The default implementation should be sufficient for ReplicationDomains that don't need to perform additional computing.
      Overrides:
      sessionInitiated in class ReplicationDomain
      Parameters:
      initStatus - The status to enter the state machine with.
      rsState - The ServerState of the ReplicationServer with which the session was established.
      newestChangelogStateOfReplica - The newest known ServerState of the change-log for this replica across the contacted ReplicationServers
    • countEntries

      public long countEntries() throws LdapException
      This method should return the total number of objects in the replicated domain. This count will be used for reporting.
      Specified by:
      countEntries in class ReplicationDomain
      Returns:
      The number of objects in the replication domain.
      Throws:
      LdapException - when needed.
    • dispatchUpdateForReplay

      public void dispatchUpdateForReplay(UpdateMsg updateMsg)
      The listener thread takes care of processing dependencies between messages via ReplicationDomain.dispatchUpdateForReplay(UpdateMsg), dispatching updates to the replay threads.

      Dependencies checking relies on non thread-safe data structures and is done here before dispatching updates to the replay threads.

      updateState() takes care of successive steps.

      Specified by:
      dispatchUpdateForReplay in class ReplicationDomain
      Parameters:
      updateMsg - The UpdateMsg to replay.
    • updateState

      protected void updateState()
      Once the updates are completed by the replay threads (concurrently), dependency data and the server state are cleaned up. This method is called also when no new updates are being received, so that updates being completed by the replay threads can be post-processed properly.
      Overrides:
      updateState in class ReplicationDomain
    • addMetricsForLocalReplica

      public void addMetricsForLocalReplica(MeterRegistryHolder registry)
      Description copied from class: ReplicationDomain
      Subclasses should use this method to add additional monitoring information in the ReplicationDomain.
      Overrides:
      addMetricsForLocalReplica in class ReplicationDomain
      Parameters:
      registry - where to additional monitoring attributes
    • addMetricsForRemoteReplica

      public void addMetricsForRemoteReplica(MeterRegistryHolder registry, ReplicaId remoteReplicaId)
      Description copied from class: ReplicationDomain
      Subclasses should use this method to add additional monitoring information in the Remote Replica Monitor.
      Overrides:
      addMetricsForRemoteReplica in class ReplicationDomain
      Parameters:
      registry - where to additional monitoring attributes
      remoteReplicaId - the remote replica for which monitoring data is requested
    • decodeSource

      public ReplicaId decodeSource(String sourceReplicaName) throws LdapException
      Verifies that the given string represents a valid source from which this server can be initialized.
      Parameters:
      sourceReplicaName - The string representing the name of the source
      Returns:
      the source ReplicaId
      Throws:
      LdapException - if the string is not valid
    • purgeConflictsHistorical

      public void purgeConflictsHistorical(PurgeConflictsHistoricalTask task, Duration purgeTaskMaxDuration) throws LdapException
      Check and purge the historical attribute on all eligible entries under this domain. The purging logic is the same applied to individual entries during modify operations. This task may be useful in scenarios where a large number of changes are made as a one-off occurrence. Running a purge-historical after the 'ds-cfg-conflicts-historical-purge-delay' period has elapsed would clear out obsolete historical data from all the modified entries reducing the overall database size.
      Parameters:
      task - the task raising this purge.
      purgeTaskMaxDuration - the maximum time allowed for this purge operation.
      Throws:
      LdapException - if the maximum time is reached or when an exception happens.