Class ReplicationEnvironment
- java.lang.Object
-
- org.opends.server.replication.server.changelog.file.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.
- 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.
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]
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ReplicationEnvironment.DomainState
This class represents the content of the domains state file.
-
Field Summary
Fields Modifier and Type Field Description static String
CN_INDEX_DB_DIRNAME
The change number index directory name.static String
DOMAIN_SUFFIX
The suffix of the domains changelog directories.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearDomainStateAndWriteGenId(Dn domainDn, long generationId)
Clears the domain state of the provided domain DN, and rewrite its generation id file with the provided generation id.ChangelogState
getChangelogState()
Returns the current state of the replication changelog.static ReplicationEnvironment
newReplicationEnvironment(Path rootPath, ReplicationServerId replicationServerId, LogCryptoCfg cryptoCfg, Clock clock)
Creates the replication environment that can modify the file system.static Set<ReplicationEnvironment.DomainState>
readDomainsState(Path replicationRootPath)
Returns the content of the domains state file.
-
-
-
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 idcryptoCfg
- TheLogCryptoCfg
to useclock
- The clock to use for timing.- Returns:
- A replication environment that can modify the file system
- Throws:
ChangelogException
- If an error occurs during initialization.
-
getChangelogState
public ChangelogState getChangelogState()
Description copied from interface:ChangelogStateProvider
Returns the current state of the replication changelog.- Specified by:
getChangelogState
in interfaceChangelogStateProvider
- Returns:
- current in-memory
ChangelogState
.
-
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 rewrittengenerationId
- The generation id to be used for the generation id file- Throws:
IOException
- If a problem occursChangelogException
- If a problem occurs
-
readDomainsState
public static Set<ReplicationEnvironment.DomainState> readDomainsState(Path replicationRootPath) throws ChangelogException
Returns the content of the domains state file.- Parameters:
replicationRootPath
- path of the changelog directory- Returns:
- the content of the domains state file
- Throws:
ChangelogException
- if a problem occurs
-
-