Class ReplicationEnvironment

  • All Implemented Interfaces:
    ChangelogStateProvider

    public class ReplicationEnvironment
    extends Object
    implements ChangelogStateProvider
    Represents the replication environment, which allows to manage the lifecycle of the replication changelog.

    A changelog has a root directory, under which the following directories and files are created :

    • A "changenumberindex" directory containing the log files for ChangeNumberIndexDB, and a file named "rotationtime[millis].last" where [millis] is the time of the last log file rotation in milliseconds
    • A "domains.state" file containing a mapping of each domain DN to an id. The id is used to name the corresponding domain directory.
    • One directory per domain, named after "[id].domain" where [id] is the id assigned to the domain, as specified in the "domains.state" file.

    Each domain directory contains the following directories and files :

    • A "generation[id].id" file, where [id] is the generation id
    • One directory per server id, named after "[id].server" where [id] is the id of the server.
    Each server id directory contains the following files:
    • the most recent log file (also known as "head" log file), if present, where new records are appended.
    • Zero to many read-only log files named after the lowest key present in the log file (they all end with the ".log" suffix.
    See Log class for details on the log files.

    Layout example with two domains "o=test1" and "o=test2", each having server ids 22 and 33, with server id 33 for domain "o=test1" being offline :

     
     +---changelog
     |   \---domains.state  [contains mapping: 1 => "o=test1", 2 => "o=test2"]
     |   \---changenumberindex
     |      \--- 1.log [contains records with keys greater than or equal to 1
     |      \--- 51.log [contains last records written with keys greater than or equal to 51
     |      \--- rotationtime198745512.last
     |   \---1.domain
     |       \---generation1.id
     |       \---22.server
     |           \---00000163bbcbb2b0001600000001.log [contains last records written]
     |       \---33.server
     |           \---00000163bbcbb2b000210000002a.log [contains last records written]
     |   \---2.domain
     |       \---generation1.id
     |       \---22.server
     |           \---00000163bbcbeffb00160000002a.log [contains last records written]
     |       \---33.server
     |           \---00000163bbcbeffb002100000044.log [contains last records written]
     
     
    • Field Detail

      • CN_INDEX_DB_DIRNAME

        public static final String CN_INDEX_DB_DIRNAME
        The change number index directory name.
        See Also:
        Constant Field Values
      • DOMAIN_SUFFIX

        public static final String DOMAIN_SUFFIX
        The suffix of the domains changelog directories.
        See Also:
        Constant Field Values
    • Method Detail

      • newReplicationEnvironment

        public static ReplicationEnvironment newReplicationEnvironment​(Path rootPath,
                                                                       ReplicationServerId replicationServerId,
                                                                       LogCryptoCfg cryptoCfg,
                                                                       Clock clock)
                                                                throws ChangelogException
        Creates the replication environment that can modify the file system.
        Parameters:
        rootPath - Root path where replication log is stored.
        replicationServerId - The underlying replication server id
        cryptoCfg - The LogCryptoCfg to use
        clock - The clock to use for timing.
        Returns:
        A replication environment that can modify the file system
        Throws:
        ChangelogException - If an error occurs during initialization.
      • clearDomainStateAndWriteGenId

        public void clearDomainStateAndWriteGenId​(Dn domainDn,
                                                  long generationId)
                                           throws IOException,
                                                  ChangelogException
        Clears the domain state of the provided domain DN, and rewrite its generation id file with the provided generation id.
        Parameters:
        domainDn - The domain DN for which the domain state must be cleared and the generation id file to be rewritten
        generationId - The generation id to be used for the generation id file
        Throws:
        IOException - If a problem occurs
        ChangelogException - If a problem occurs