Class ReplicationServer

  • All Implemented Interfaces:
    ConfigurationChangeListener<ReplicationServerCfg>

    public class ReplicationServer
    extends Object
    implements ConfigurationChangeListener<ReplicationServerCfg>
    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 Detail

      • ReplicationServer

        public ReplicationServer​(ReplicationServerCfg cfg)
                          throws ConfigException
        Creates a new Replication server using the provided configuration entry.

        The synchronization object this creates is its own, so the resulting server does not synchronize its shutdown with a collocated directory server. A server which has to must be built with ReplicationServer(ReplicationServerCfg, DSRSShutdownSync), passing the instance the directory server side records its ReplicaOfflineMsgs on.

        Parameters:
        cfg - The configuration of this replication server.
        Throws:
        ConfigException - When Configuration is invalid.
      • ReplicationServer

        public ReplicationServer​(ReplicationServerCfg cfg,
                                 DSRSShutdownSync dsrsShutdownSync)
                          throws ConfigException
        Creates a new Replication server using the provided configuration entry and shutdown synchronization object.
        Parameters:
        cfg - The configuration of this replication server.
        dsrsShutdownSync - Synchronization object for shutdown of combined DS/RS instances.
        Throws:
        ConfigException - When Configuration is invalid.
      • ReplicationServer

        public ReplicationServer​(ReplicationServerCfg cfg,
                                 DSRSShutdownSync dsrsShutdownSync,
                                 ECLEnabledDomainPredicate predicate)
                          throws ConfigException
        Creates a new Replication server using the provided configuration entry, shutdown synchronization object and domain predicate.
        Parameters:
        cfg - The configuration of this replication server.
        dsrsShutdownSync - Synchronization object for shutdown of combined DS/RS instances.
        predicate - Indicates whether a domain is enabled for the external changelog.
        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.
      • isListening

        public boolean isListening()
        Indicates whether this replication server has bound its listen port, i.e. whether it can accept connections from directory servers and from other replication servers.
        Returns:
        true if this replication server is listening
      • 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.
      • validateCookie

        public void validateCookie​(MultiDomainServerState cookie,
                                   Set<DN> ignoredBaseDNs)
                            throws DirectoryException
        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:
        DirectoryException - 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.
      • shutdown

        public void shutdown()
        Shutdown the Replication Server service and all its connections.
      • getPurgeDelay

        public long getPurgeDelay()
        Retrieves the time after which changes must be deleted from the persistent storage (in milliseconds).
        Returns:
        The time after which changes must be deleted from the persistent storage (in milliseconds).
      • isConfigurationAcceptable

        public static boolean isConfigurationAcceptable​(ReplicationServerCfg configuration,
                                                        List<org.forgerock.i18n.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.
      • isConfigurationChangeAcceptable

        public boolean isConfigurationChangeAcceptable​(ReplicationServerCfg configuration,
                                                       List<org.forgerock.i18n.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<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, or false 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 int getServerId()
        Get the serverId for this replication server.
        Returns:
        The value of the serverId.
      • remove

        public void remove()
        Do what needed when the config object related to this replication server is deleted from the server configuration.
      • getDomainIterator

        public Iterator<ReplicationServerDomain> getDomainIterator()
        Returns an iterator on the list of replicationServerDomain. Returns null if none.
        Returns:
        the iterator.
      • getAssuredTimeout

        public long getAssuredTimeout()
        Get the assured mode timeout.

        It is the Timeout (in milliseconds) when waiting for acknowledgments.

        Returns:
        The assured mode timeout.
      • getGroupId

        public byte getGroupId()
        Get The replication server group id.
        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.
      • getMonitoringPublisherPeriod

        public long getMonitoringPublisherPeriod()
        Get the monitoring publisher period value.

        It is the number of milliseconds to wait before sending new monitoring messages. If value is 0, monitoring publisher is disabled.

        Returns:
        the monitoring publisher period value.
      • getMonitorInstanceName

        public String getMonitorInstanceName()
        Retrieves a printable name for this Replication Server Instance.
        Returns:
        A printable name for this Replication Server Instance.
      • getReplicationPort

        public int getReplicationPort()
        Retrieves the port used by this ReplicationServer.
        Returns:
        The port used by this ReplicationServer.
      • getServerURL

        public String getServerURL()
        Getter on the server URL.
        Returns:
        the server URL.
      • onlyForTestsAddlocalReplicationServer

        public static void onlyForTestsAddlocalReplicationServer​(String server)
        WARNING : only use this methods for tests purpose. Add the Replication Server given as a parameter in the list of local replication servers.
        Parameters:
        server - The server to be added.
      • onlyForTestsClearLocalReplicationServerList

        public static void onlyForTestsClearLocalReplicationServerList()
        WARNING : only use this methods for tests purpose. Clear the list of local Replication Servers
      • isLocalReplicationServerPort

        public static boolean isLocalReplicationServerPort​(int port)
        Returns true if the provided port is one of the ports that this replication server is listening on.
        Parameters:
        port - The port to be checked.
        Returns:
        true if the provided port is one of the ports that this replication server is listening on.
      • getOldestChangeNumber

        public long getOldestChangeNumber()
                                   throws DirectoryException
        Returns the oldest change number in the change number index DB.
        Returns:
        the oldest change number in the change number index DB
        Throws:
        DirectoryException - When a problem happens
      • getNewestChangeNumber

        public long getNewestChangeNumber()
                                   throws DirectoryException
        Returns the newest change number in the change number index DB.
        Returns:
        the newest change number in the change number index DB
        Throws:
        DirectoryException - When a problem happens
      • getNewestECLCookie

        public MultiDomainServerState getNewestECLCookie​(Set<DN> excludedBaseDNs)
        Returns the newest cookie value.
        Parameters:
        excludedBaseDNs - The set of baseDNs excluded from ECL.
        Returns:
        the newest cookie value.
      • 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
      • 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.
      • isECLEnabled

        public boolean isECLEnabled()
        Returns whether the external change-log contains data from at least a domain.
        Returns:
        whether the external change-log contains data from at least a domain
      • isEncrypted

        public boolean isEncrypted()
        Return whether change-log records should be encrypted.
        Returns:
        trus if change-log records should be encrypted