Class ReplicationEnvironment
java.lang.Object
org.opends.server.replication.server.changelog.file.ReplicationEnvironment
- All Implemented Interfaces:
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 ".cdb" 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.cdb [contains records with keys greater than or equal to 1
| \--- 51.cdb [contains last records written with keys greater than or equal to 51
| \--- rotationtime198745512.last
| \---1.domain
| \---generation1.id
| \---22.server
| \---00000163bbcbb2b0001600000001.cdb [contains last records written]
| \---33.server
| \---00000163bbcbb2b000210000002a.cdb [contains last records written]
| \---2.domain
| \---generation1.id
| \---22.server
| \---00000163bbcbeffb00160000002a.cdb [contains last records written]
| \---33.server
| \---00000163bbcbeffb002100000044.cdb [contains last records written]
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
This record represents the content of the domains state file. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoid
clearDomainStateAndWriteGenId
(Dn domainDn, GenerationId generationId) Clears the domain state of the provided domain DN, and rewrite its generation id file with the provided generation id.Returns the current state of the replication changelog.getOrCreateReplicaDB
(DomainReplicaId domainReplicaId, GenerationId generationId) Finds or creates the log used to store changes from the replication server with the given replica id and the given baseDN.static ReplicationEnvironment
newReplicationEnvironment
(Path rootPath, ReplicationServerId replicationServerId, LogFileCfg logFileCfg, Clock clock, FileChangelogDB.SynchronizationProviderType syncProviderType) Creates the replication environment that can modify the file system.readDomainsState
(Path replicationRootPath) Returns the content of the domains state file.
-
Field Details
-
CN_INDEX_DB_DIRNAME
The change number index directory name.- See Also:
-
DOMAIN_SUFFIX
The suffix of the domains changelog directories.- See Also:
-
-
Method Details
-
newReplicationEnvironment
public static ReplicationEnvironment newReplicationEnvironment(Path rootPath, ReplicationServerId replicationServerId, LogFileCfg logFileCfg, Clock clock, FileChangelogDB.SynchronizationProviderType syncProviderType) 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 idlogFileCfg
- TheLogFileCfg
to useclock
- The clock to use for timing.syncProviderType
- Whether the replication is multi-master or not.- Returns:
- A replication environment that can modify the file system
- Throws:
ChangelogException
- If an error occurs during initialization.
-
getChangelogState
Description copied from interface:ChangelogStateProvider
Returns the current state of the replication changelog.- Specified by:
getChangelogState
in interfaceChangelogStateProvider
- Returns:
- current in-memory
ChangelogState
.
-
getOrCreateReplicaDB
public org.opends.server.replication.server.changelog.file.Log<CSN,StreamId, getOrCreateReplicaDBUpdateMsg> (DomainReplicaId domainReplicaId, GenerationId generationId) throws ChangelogException Finds or creates the log used to store changes from the replication server with the given replica id and the given baseDN.- Parameters:
domainReplicaId
- The replica idgenerationId
- The generationId associated to this domain. This is particularly useful when the domain did not exist in this environment.- Returns:
- the log.
- Throws:
ChangelogException
- if an error occurs.
-
clearDomainStateAndWriteGenId
public void clearDomainStateAndWriteGenId(Dn domainDn, GenerationId 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
-