public class JEChangelogDB extends Object implements ChangelogDB, ReplicationDomainDB
Modifier and Type | Field and Description |
---|---|
protected static org.forgerock.i18n.slf4j.LocalizedLogger |
logger
The tracer object for the debug logger.
|
Constructor and Description |
---|
JEChangelogDB(ReplicationServer replicationServer,
ReplicationServerCfg config)
Creates a new changelog DB.
|
Modifier and Type | Method and Description |
---|---|
void |
clearDB()
Clears all records from the changelog (does not remove the changelog itself).
|
ChangeNumberIndexDB |
getChangeNumberIndexDB()
Returns the
ChangeNumberIndexDB object. |
DBCursor<UpdateMsg> |
getCursorFrom(DN baseDN,
int serverId,
CSN startCSN,
DBCursor.CursorOptions options)
|
DBCursor<UpdateMsg> |
getCursorFrom(DN baseDN,
ServerState startState,
DBCursor.CursorOptions options)
Generates a
DBCursor across all the replicaDBs for the specified
replication domain starting before, at or after the provided
ServerState for each replicaDB, depending on the provided matching
and positioning strategies. |
MultiDomainDBCursor |
getCursorFrom(MultiDomainServerState startState,
DBCursor.CursorOptions options)
Generates a
DBCursor across all the domains starting before, at or
after the provided MultiDomainServerState for each domain,
depending on the provided matching and positioning strategies. |
MultiDomainDBCursor |
getCursorFrom(MultiDomainServerState startState,
DBCursor.CursorOptions options,
Set<DN> excludedDomainDns)
Generates a
DBCursor across all the domains starting before, at or
after the provided MultiDomainServerState for each domain,
excluding a provided set of domain DNs. |
ServerState |
getDomainNewestCSNs(DN baseDN)
Returns the newest
CSN s from the replicaDBs for each serverId in
the specified replication domain. |
ServerState |
getDomainOldestCSNs(DN baseDN)
Returns the oldest
CSN s from the replicaDBs for each serverId in
the specified replication domain. |
ReplicationDomainDB |
getReplicationDomainDB()
Returns the
ReplicationDomainDB object. |
void |
initializeDB()
Initializes the replication database by reading its previous state and
building the relevant ReplicaDBs according to the previous state.
|
void |
notifyReplicaOffline(DN baseDN,
CSN offlineCSN)
Let the DB know this replica is going down.
|
boolean |
publishUpdateMsg(DN baseDN,
UpdateMsg updateMsg)
Publishes the provided change to the changelog DB for the specified
serverId and replication domain.
|
void |
removeDB()
Removes the changelog database directory.
|
void |
removeDomain(DN baseDN)
Removes all the data relating to the specified replication domain and
shutdown all its replica databases.
|
void |
replicaHeartbeat(DN baseDN,
CSN heartbeatCSN)
Let the DB know this replica is alive.
|
void |
setComputeChangeNumber(boolean computeChangeNumber)
Sets whether the replication database must compute change numbers for
replicated changes.
|
void |
setPurgeDelay(long purgeDelayInMillis)
Sets the purge delay for the replication database.
|
void |
shutdownDB()
Shutdown the replication database.
|
void |
unregisterCursor(DBCursor<?> cursor)
Unregisters the provided cursor from this replication domain.
|
protected static final org.forgerock.i18n.slf4j.LocalizedLogger logger
public JEChangelogDB(ReplicationServer replicationServer, ReplicationServerCfg config) throws ConfigException
replicationServer
- the local replication server.config
- the replication server configurationConfigException
- if a problem occurs opening the supplied directorypublic void initializeDB()
initializeDB
in interface ChangelogDB
public void shutdownDB() throws ChangelogException
shutdownDB
in interface ChangelogDB
ChangelogException
- If a database problem happenedpublic void clearDB() throws ChangelogException
ChangelogException
- If an error occurs when clearing the changelog.public void removeDB() throws ChangelogException
removeDB
in interface ChangelogDB
ChangelogException
- If a database problem happenedpublic ServerState getDomainOldestCSNs(DN baseDN)
CSN
s from the replicaDBs for each serverId in
the specified replication domain.getDomainOldestCSNs
in interface ReplicationDomainDB
baseDN
- the replication domain baseDNpublic ServerState getDomainNewestCSNs(DN baseDN)
CSN
s from the replicaDBs for each serverId in
the specified replication domain.getDomainNewestCSNs
in interface ReplicationDomainDB
baseDN
- the replication domain baseDNpublic void removeDomain(DN baseDN) throws ChangelogException
removeDomain
in interface ReplicationDomainDB
baseDN
- the replication domain baseDNChangelogException
- If a database problem happenedpublic void setPurgeDelay(long purgeDelayInMillis)
Purging happens on a best effort basis, i.e. the purge delay is used by the replication database to know which data can be purged, but there are no guarantees on when the purging will actually happen.
setPurgeDelay
in interface ChangelogDB
purgeDelayInMillis
- the purge delay in millisecondspublic void setComputeChangeNumber(boolean computeChangeNumber) throws ChangelogException
setComputeChangeNumber
in interface ChangelogDB
computeChangeNumber
- whether to compute change numbers for replicated changesChangelogException
- If a database problem happenedpublic ChangeNumberIndexDB getChangeNumberIndexDB()
ChangeNumberIndexDB
object.getChangeNumberIndexDB
in interface ChangelogDB
ChangeNumberIndexDB
objectpublic ReplicationDomainDB getReplicationDomainDB()
ReplicationDomainDB
object.getReplicationDomainDB
in interface ChangelogDB
ReplicationDomainDB
objectpublic MultiDomainDBCursor getCursorFrom(MultiDomainServerState startState, DBCursor.CursorOptions options) throws ChangelogException
DBCursor
across all the domains starting before, at or
after the provided MultiDomainServerState
for each domain,
depending on the provided matching and positioning strategies.
When the cursor is not used anymore, client code MUST call the
DBCursor.close()
method to free the resources and locks used by the
cursor.
getCursorFrom
in interface ReplicationDomainDB
startState
- Starting point for each domain cursor. If any ServerState
for a domain is null, then start from the oldest CSN for each
replicaDBsoptions
- The cursor optionsDBCursor
ChangelogException
- If a database problem happened#getCursorFrom(DN, ServerState, CursorOptions)
public MultiDomainDBCursor getCursorFrom(MultiDomainServerState startState, DBCursor.CursorOptions options, Set<DN> excludedDomainDns) throws ChangelogException
DBCursor
across all the domains starting before, at or
after the provided MultiDomainServerState
for each domain,
excluding a provided set of domain DNs.
When the cursor is not used anymore, client code MUST call the
DBCursor.close()
method to free the resources and locks used by the
cursor.
getCursorFrom
in interface ReplicationDomainDB
startState
- Starting point for each domain cursor. If any ServerState
for a domain is null, then start from the oldest CSN for each
replicaDBsoptions
- The cursor optionsexcludedDomainDns
- Every domain appearing in this set is excluded from the cursorDBCursor
ChangelogException
- If a database problem happened#getCursorFrom(DN, ServerState, CursorOptions)
public DBCursor<UpdateMsg> getCursorFrom(DN baseDN, ServerState startState, DBCursor.CursorOptions options) throws ChangelogException
DBCursor
across all the replicaDBs for the specified
replication domain starting before, at or after the provided
ServerState
for each replicaDB, depending on the provided matching
and positioning strategies.
When the cursor is not used anymore, client code MUST call the
DBCursor.close()
method to free the resources and locks used by the
cursor.
getCursorFrom
in interface ReplicationDomainDB
baseDN
- the replication domain baseDNstartState
- Starting point for each ReplicaDB cursor. If any CSN for a
replicaDB is null, then start from the oldest CSN for this
replicaDBoptions
- The cursor optionsDBCursor
ChangelogException
- If a database problem happened#getCursorFrom(DN, int, CSN, CursorOptions)
public DBCursor<UpdateMsg> getCursorFrom(DN baseDN, int serverId, CSN startCSN, DBCursor.CursorOptions options) throws ChangelogException
ReplicationDomainDB
DBCursor
for one replicaDB for the specified
replication domain and serverId starting before, at or after the provided
CSN
, depending on the provided matching and positioning strategies.
When the cursor is not used anymore, client code MUST call the
DBCursor.close()
method to free the resources and locks used by the
cursor.
getCursorFrom
in interface ReplicationDomainDB
baseDN
- the replication domain baseDN of the replicaDBserverId
- the serverId of the replicaDBstartCSN
- Starting point for the ReplicaDB cursor. If the CSN is null, then
start from the oldest CSN for this replicaDBoptions
- The cursor optionsDBCursor
ChangelogException
- If a database problem happenedpublic void unregisterCursor(DBCursor<?> cursor)
unregisterCursor
in interface ReplicationDomainDB
cursor
- the cursor to unregister.public boolean publishUpdateMsg(DN baseDN, UpdateMsg updateMsg) throws ChangelogException
publishUpdateMsg
in interface ReplicationDomainDB
baseDN
- the replication domain baseDNupdateMsg
- the update message to publish to the replicaDBChangelogException
- If a database problem happenedpublic void replicaHeartbeat(DN baseDN, CSN heartbeatCSN) throws ChangelogException
This method allows the medium consistency point to move forward in case this replica did not publish new changes.
replicaHeartbeat
in interface ReplicationDomainDB
baseDN
- the replication domain baseDNheartbeatCSN
- The CSN heartbeat sent by this replica (contains the serverId and
timestamp of the heartbeat)ChangelogException
- If a database problem happenedpublic void notifyReplicaOffline(DN baseDN, CSN offlineCSN) throws ChangelogException
This method allows to let the medium consistency point move forward while this replica is offline.
Note: This method must not be called to let the DB know the replica is not sending heartbeats anymore, i.e. it must not be used in case of suspected network partition.
notifyReplicaOffline
in interface ReplicationDomainDB
baseDN
- the replication domain baseDNofflineCSN
- The CSN (serverId and timestamp) for the replica's going offlineChangelogException
- If a database problem happenedCopyright © 2010-2015 ForgeRock AS. All Rights Reserved.