Class ReplicationServer
- java.lang.Object
-
- org.opends.server.replication.server.ReplicationServer
-
- All Implemented Interfaces:
ConfigurationChangeListener<ReplicationServerCfg>
,DiskSpaceMonitorHandler
public class ReplicationServer extends Object implements ConfigurationChangeListener<ReplicationServerCfg>, DiskSpaceMonitorHandler
ReplicationServer Listener. This singleton is the main object of the replication server. It waits for the incoming connections and create listener and publisher objects for connection with LDAP servers and with replication servers It is responsible for creating the replication server replicationServerDomain and managing it
-
-
Constructor Summary
Constructors Constructor Description ReplicationServer(ServerContext serverContext, ReplicationServerCfg cfg, ShutdownSynchronizer shutdownSync)
Creates a new Replication server using the provided configuration entry and shutdown synchronization object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ConfigChangeResult
applyConfigurationChange(ReplicationServerCfg configuration)
Applies the configuration changes to this change listener.void
diskFullThresholdReached(File directory, long thresholdInBytes)
Notifies that the registered "full" threshold have been reached.void
diskLowThresholdReached(File directory, long thresholdInBytes)
Notifies that the registered "low" threshold have been reached.void
diskSpaceRestored(File directory, long lowThresholdInBytes, long fullThresholdInBytes)
Notifies that the free disk space is now above both "low" and "full" thresholds.static List<ReplicationServer>
getAllInstances()
Get the list of every replication servers instantiated in the current VM.ChangelogDB
getChangelogDB()
Returns the changelogDB.int
getDegradedStatusThreshold()
Get the degraded status threshold value for status analyzer.Set<Dn>
getExcludedChangelogDomains()
Returns the domain base DNs which are disabled for the external changelog (ECL).long
getGenerationId(Dn baseDN)
Get the value of generationId for the replication replicationServerDomain associated with the provided baseDN.GroupId
getGroupId()
Get The replication server group id.com.forgerock.opendj.util.HostPort
getHostPort()
Getter on the server host port.String
getName()
Returns a name that can be printed to logs for this Replication Server instance.long
getNewestChangeNumber()
Returns the newest change number in the change number index DB.MultiDomainServerState
getNewestECLCookie()
Returns the newest cookie value.long
getOldestChangeNumber()
Returns the oldest change number in the change number index DB.Duration
getPurgeDelay()
Retrieves the time interval after which changes must be deleted from the persistent storage.int
getReplicationPort()
Retrieves the port used by this ReplicationServer.ReplicationServerDomain
getReplicationServerDomain(Dn baseDN)
Get the ReplicationServerDomain associated to the base DN given in parameter.ReplicationServerDomain
getReplicationServerDomain(Dn baseDN, boolean create)
Get the ReplicationServerDomain associated to the base DN given in parameter.Collection<ReplicationServerDomain>
getReplicationServerDomains()
Returns the replication server domains managed by this replication server.ServerContext
getServerContext()
Returns the server context.ReplicationServerId
getServerId()
Get the replication server id.int
getWeight()
Gets the weight affected to the replication server.boolean
isChangeNumberEnabled()
Returns whether change-log indexing is enabled for this RS.static boolean
isConfigurationAcceptable(ReplicationServerCfg configuration, List<LocalizableMessage> unacceptableReasons)
Check if the provided configuration is acceptable for add.boolean
isConfigurationChangeAcceptable(ReplicationServerCfg configuration, List<LocalizableMessage> unacceptableReasons)
Indicates whether the proposed change to the configuration is acceptable to this change listener.boolean
isEclEnabledDomain(Dn baseDn)
Indicates whether the provided domain is enabled for the external changelog (ECL).boolean
isEncrypted()
Return whether change-log records should be encrypted.void
remove()
Do what needed when the config object related to this replication server is deleted from the server configuration.void
shutdown()
Shutdown the Replication Server service and all its connections.String
toString()
void
validateCookie(MultiDomainServerState cookie, Set<Dn> ignoredBaseDNs)
Validate that provided cookie is coherent with this replication server, when ignoring the provided set of DNs.
-
-
-
Constructor Detail
-
ReplicationServer
public ReplicationServer(ServerContext serverContext, ReplicationServerCfg cfg, ShutdownSynchronizer shutdownSync) throws ConfigException
Creates a new Replication server using the provided configuration entry and shutdown synchronization object.- Parameters:
serverContext
- The directory server contextcfg
- The configuration of this replication server.shutdownSync
- Synchronization object for shutdown of combined DS/RS instances.- Throws:
ConfigException
- When Configuration is invalid.
-
-
Method Detail
-
getAllInstances
public static List<ReplicationServer> getAllInstances()
Get the list of every replication servers instantiated in the current VM.- Returns:
- The list of every replication servers instantiated in the current VM.
-
isEclEnabledDomain
public boolean isEclEnabledDomain(Dn baseDn)
Indicates whether the provided domain is enabled for the external changelog (ECL).- Parameters:
baseDn
- the base DN of the domain.- Returns:
true
if the provided domain is enabled for the External Changelog (ECL).
-
getExcludedChangelogDomains
public Set<Dn> getExcludedChangelogDomains()
Returns the domain base DNs which are disabled for the external changelog (ECL).- Returns:
- the domain base DNs which are disabled for the external changelog (ECL)
-
getReplicationServerDomain
public ReplicationServerDomain getReplicationServerDomain(Dn baseDN)
Get the ReplicationServerDomain associated to the base DN given in parameter.- Parameters:
baseDN
- The base DN for which the ReplicationServerDomain must be returned- Returns:
- The ReplicationServerDomain associated to the base DN given in parameter,
or
null
if there is no ReplicationServerDomain associated to this baseDn
-
validateCookie
public void validateCookie(MultiDomainServerState cookie, Set<Dn> ignoredBaseDNs) throws LdapException
Validate that provided cookie is coherent with this replication server, when ignoring the provided set of DNs.The cookie is coherent if and only if it exactly has the set of DNs corresponding to the replication domains, and the states in the cookie are not older than oldest states in the server.
- Parameters:
cookie
- The multi domain state (cookie) to validate.ignoredBaseDNs
- The set of DNs to ignore when validating- Throws:
LdapException
- If the cookie is not valid
-
getReplicationServerDomain
public ReplicationServerDomain getReplicationServerDomain(Dn baseDN, boolean create)
Get the ReplicationServerDomain associated to the base DN given in parameter.- Parameters:
baseDN
- The base DN for which the ReplicationServerDomain must be returned.create
- Specifies whether to create the ReplicationServerDomain if it does not already exist.- Returns:
- The ReplicationServerDomain associated to the base DN given in parameter,
or
null
if there is no ReplicationServerDomain associated to this baseDn and the create parameter was false.
-
shutdown
public void shutdown()
Shutdown the Replication Server service and all its connections.
-
getPurgeDelay
public Duration getPurgeDelay()
Retrieves the time interval after which changes must be deleted from the persistent storage.- Returns:
- The time interval after which changes must be deleted from the persistent storage.
-
isConfigurationAcceptable
public static boolean isConfigurationAcceptable(ReplicationServerCfg configuration, List<LocalizableMessage> unacceptableReasons)
Check if the provided configuration is acceptable for add.- Parameters:
configuration
- The configuration to check.unacceptableReasons
- When the configuration is not acceptable, this table is use to return the reasons why this configuration is not acceptable.- Returns:
- true if the configuration is acceptable, false other wise.
-
applyConfigurationChange
public ConfigChangeResult applyConfigurationChange(ReplicationServerCfg configuration)
Description copied from interface:ConfigurationChangeListener
Applies the configuration changes to this change listener.- Specified by:
applyConfigurationChange
in interfaceConfigurationChangeListener<ReplicationServerCfg>
- Parameters:
configuration
- The new configuration containing the changes.- Returns:
- Returns information about the result of changing the configuration.
-
isConfigurationChangeAcceptable
public boolean isConfigurationChangeAcceptable(ReplicationServerCfg 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<ReplicationServerCfg>
- 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.
-
getGenerationId
public long getGenerationId(Dn baseDN)
Get the value of generationId for the replication replicationServerDomain associated with the provided baseDN.- Parameters:
baseDN
- The baseDN of the replicationServerDomain.- Returns:
- The value of the generationID.
-
getServerId
public ReplicationServerId getServerId()
Get the replication server id.- Returns:
- The replication server id
-
remove
public void remove()
Do what needed when the config object related to this replication server is deleted from the server configuration.
-
getGroupId
public GroupId getGroupId()
Get The replication server group id. Can bedefault
if not defined, but nevernull
.- Returns:
- The replication server group id.
-
getDegradedStatusThreshold
public int getDegradedStatusThreshold()
Get the degraded status threshold value for status analyzer.The degraded status threshold is the number of pending changes for a DS, considered as threshold value to put the DS in DEGRADED_STATUS. If value is 0, status analyzer is disabled.
- Returns:
- The degraded status threshold value for status analyzer.
-
getReplicationPort
public int getReplicationPort()
Retrieves the port used by this ReplicationServer.- Returns:
- The port used by this ReplicationServer.
-
getHostPort
public com.forgerock.opendj.util.HostPort getHostPort()
Getter on the server host port.- Returns:
- the server host port.
-
getOldestChangeNumber
public long getOldestChangeNumber() throws LdapException
Returns the oldest change number in the change number index DB.- Returns:
- the oldest change number in the change number index DB
- Throws:
LdapException
- When a problem happens
-
getNewestChangeNumber
public long getNewestChangeNumber() throws LdapException
Returns the newest change number in the change number index DB.- Returns:
- the newest change number in the change number index DB
- Throws:
LdapException
- When a problem happens
-
getNewestECLCookie
public MultiDomainServerState getNewestECLCookie()
Returns the newest cookie value.- Returns:
- the newest cookie value.
-
diskLowThresholdReached
public void diskLowThresholdReached(File directory, long thresholdInBytes)
Description copied from interface:DiskSpaceMonitorHandler
Notifies that the registered "low" threshold have been reached.- Specified by:
diskLowThresholdReached
in interfaceDiskSpaceMonitorHandler
- Parameters:
directory
- the directory for which the threshold has been triggeredthresholdInBytes
- the threshold value in bytes
-
diskFullThresholdReached
public void diskFullThresholdReached(File directory, long thresholdInBytes)
Description copied from interface:DiskSpaceMonitorHandler
Notifies that the registered "full" threshold have been reached.- Specified by:
diskFullThresholdReached
in interfaceDiskSpaceMonitorHandler
- Parameters:
directory
- the directory for which the threshold has been triggeredthresholdInBytes
- the threshold value in bytes
-
diskSpaceRestored
public void diskSpaceRestored(File directory, long lowThresholdInBytes, long fullThresholdInBytes)
Description copied from interface:DiskSpaceMonitorHandler
Notifies that the free disk space is now above both "low" and "full" thresholds.- Specified by:
diskSpaceRestored
in interfaceDiskSpaceMonitorHandler
- Parameters:
directory
- the directory for which the threshold has been triggeredTODOlowThresholdInBytes
- the low threshold value in bytesfullThresholdInBytes
- the full threshold value in bytes
-
getWeight
public int getWeight()
Gets the weight affected to the replication server.Each replication server of the topology has a weight. When combined together, the weights of the replication servers of a same group can be translated to a percentage that determines the quantity of directory servers of the topology that should be connected to a replication server.
For instance imagine a topology with 3 replication servers (with the same group id) with the following weights: RS1=1, RS2=1, RS3=2. This means that RS1 should have 25% of the directory servers connected in the topology, RS2 25%, and RS3 50%. This may be useful if the replication servers of the topology have a different power and one wants to spread the load between the replication servers according to their power.
- Returns:
- the weight
-
getReplicationServerDomains
public Collection<ReplicationServerDomain> getReplicationServerDomains()
Returns the replication server domains managed by this replication server.- Returns:
- the replication server domains managed by this replication server
-
getChangelogDB
public ChangelogDB getChangelogDB()
Returns the changelogDB.- Returns:
- the changelogDB.
-
isChangeNumberEnabled
public boolean isChangeNumberEnabled()
Returns whether change-log indexing is enabled for this RS.- Returns:
- true if change-log indexing is enabled for this RS.
-
isEncrypted
public boolean isEncrypted()
Return whether change-log records should be encrypted.- Returns:
true
if change-log records should be encrypted
-
getName
public String getName()
Returns a name that can be printed to logs for this Replication Server instance.- Returns:
- a name that can be printed to logs for this Replication Server instance.
-
getServerContext
public ServerContext getServerContext()
Returns the server context.- Returns:
- the server context
-
-