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
public final class LDAPReplicationDomain extends ReplicationDomain implements 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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.opends.server.replication.service.ReplicationDomain
ReplicationDomain.ImportExportContext
-
-
Field Summary
Fields Modifier and Type Field Description static String
DS_SYNC_CONFLICT
The attribute used to mark conflicting entries.-
Fields inherited from class org.opends.server.replication.service.ReplicationDomain
broker, canPersistROM, config, generationId, replicationPurgeDelayInMs, serverContext
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAdditionalMonitoring(MeterRegistryHolder registry)
Subclasses should use this method to add additional monitoring information in the ReplicationDomain.ConfigChangeResult
applyConfigurationChange(ReplicationDomainCfg configuration)
Applies the configuration changes to this change listener.long
countEntries()
This method should return the total number of objects in the replicated domain.ReplicaId
decodeSource(String sourceReplicaName)
Verifies that the given string represents a valid source from which this server can be initialized.void
dispatchUpdateForReplay(UpdateMsg updateMsg)
The listener thread takes care of processing dependencies between messages viaReplicationDomain.dispatchUpdateForReplay(UpdateMsg)
, dispatching updates to the replay threads.protected void
exportBackend(OutputStream output)
This method trigger an export of the replicated data.Map<String,String>
getAlerts()
Retrieves information about the set of alerts that this generator may produce.Dn
getComponentEntryDN()
Retrieves the DN of the configuration entry with which this alert generator is associated.protected void
importBackend(InputStream input)
This method triggers an import of the replicated data.protected void
initializeRemote(ReplicaId target, ReplicaId requestorID, Task initTask, int initWindow)
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.boolean
isConfigurationChangeAcceptable(ReplicationDomainCfg configuration, List<LocalizableMessage> unacceptableReasons)
Indicates whether the proposed change to the configuration is acceptable to this change listener.void
performBackendPostInitializationProcessing(LocalBackend<?> backend)
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,.void
performBackendPreFinalizationProcessing(LocalBackend<?> backend)
Performs any processing that may be required before starting the finalisation cycle, that is invoked before any listener receive the Finalization event.void
processServerShutdown(LocalizableMessage reason)
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.void
publishHeartbeatMsg()
Publishes a heartbeat message if all pending changes for current replica have been sent out.void
publishReplicaOfflineMsg()
Publishes a replica offline message if all pending changes for current replica have been sent out.void
purgeConflictsHistorical(PurgeConflictsHistoricalTask task, Duration purgeTaskMaxDuration)
Check and purge the historical attribute on all eligible entries under this domain.protected byte[]
receiveEntryBytes()
Receives bytes related to an entry in the context of an import to initialize the domain (called by ReplLDIFInputStream).void
resume()
Restart replication for this domain after a previous suspend.static LDAPReplicationDomain
retrievesReplicationDomain(Dn baseDN, ServerContext serverContext)
Retrieves a replication domain based on the baseDN.void
sessionInitiated(ServerStatus initStatus, ServerState rsState, ServerState newestChangelogStateOfReplica)
Set the initial status of the domain and perform necessary initializations.void
shutdown()
Shutdown this ReplicationDomain.void
start()
Starts the Replication Domain.void
suspend()
Suspends replication on this domain.protected void
updateState()
Once the updates are completed by the replay threads (concurrently), dependency data and the server state are cleaned up.-
Methods inherited from class org.opends.server.replication.service.ReplicationDomain
changeConfig, decodeTarget, getBaseDN, getCsnGenerator, getEclIncludes, getEclIncludesForDeletes, getGenerationID, getHealthStatus, getImportExportContext, getLastLocalChange, getReplicaId, getReplicationServerPort, getServerState, getStatus, hasConnectionError, ieRunning, initializeFromRemote, initializeRemote, isConnected, isListenerShuttingDown, isSuspending, processUpdateAfterReplay, publish, recreateRemoteReplicasFromState, replicaIsTooLate, resetGenerationId, resumeService, setEclIncludes, startListenService, startPublishService, suspendService, toBadDataStatus, toString, toTooLateStatus, trace, trace
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.opends.server.api.AlertGenerator
getClassName
-
Methods inherited from interface org.opends.server.api.LocalBackendInitializationListener
performBackendPostFinalizationProcessing, performBackendPreInitializationProcessing
-
-
-
-
Field Detail
-
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:
- Constant Field Values
-
-
Method Detail
-
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 interfaceServerShutdownListener
- 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 interfaceLocalBackendInitializationListener
- 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 interfaceLocalBackendInitializationListener
- 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 classReplicationDomain
- 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 classReplicationDomain
- 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 classReplicationDomain
-
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 classReplicationDomain
-
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 classReplicationDomain
- 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 classReplicationDomain
- 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 retrieveserverContext
- 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 interfaceConfigurationChangeListener<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 interfaceConfigurationChangeListener<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, orfalse
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 interfaceAlertGenerator
- 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 interfaceAlertGenerator
- 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 classReplicationDomain
- 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 classReplicationDomain
- 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 viaReplicationDomain.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 classReplicationDomain
- Parameters:
updateMsg
- TheUpdateMsg
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 classReplicationDomain
-
addAdditionalMonitoring
public void addAdditionalMonitoring(MeterRegistryHolder registry)
Description copied from class:ReplicationDomain
Subclasses should use this method to add additional monitoring information in the ReplicationDomain.- Overrides:
addAdditionalMonitoring
in classReplicationDomain
- Parameters:
registry
- where to additional monitoring attributes
-
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.
-
-