Interface ReplicationDomainDB
-
- All Known Implementing Classes:
FileChangelogDB
public interface ReplicationDomainDBThis interface allows to query or control the replication domain database(s) (composed of one or more ReplicaDBs) and query/update each ReplicaDB.In particular, the
getCursorFom()methods allow to obtain a cursor at any level:- Across all the domains, provided a
MultiDomainServerState - Across all replicaDBs of a domain, provided a
ServerState - On one replica DB for a domain and serverId, provided a CSN
DBCursor.KeyMatchingStrategyand aDBCursor.PositionStrategy.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DBCursor<UpdateMsg>getCursorFrom(DN baseDN, int serverId, CSN startCSN, DBCursor.CursorOptions options)DBCursor<UpdateMsg>getCursorFrom(DN baseDN, ServerState startState, DBCursor.CursorOptions options)Generates aDBCursoracross all the replicaDBs for the specified replication domain starting before, at or after the providedServerStatefor each replicaDB, depending on the provided matching and positioning strategies.MultiDomainDBCursorgetCursorFrom(MultiDomainServerState startState, DBCursor.CursorOptions options)Generates aDBCursoracross all the domains starting before, at or after the providedMultiDomainServerStatefor each domain, depending on the provided matching and positioning strategies.MultiDomainDBCursorgetCursorFrom(MultiDomainServerState startState, DBCursor.CursorOptions options, Set<DN> excludedDomainDns)Generates aDBCursoracross all the domains starting before, at or after the providedMultiDomainServerStatefor each domain, excluding a provided set of domain DNs.ServerStategetDomainNewestCSNs(DN baseDN)Returns the newestCSNs from the replicaDBs for each serverId in the specified replication domain.ServerStategetDomainOldestCSNs(DN baseDN)Returns the oldestCSNs from the replicaDBs for each serverId in the specified replication domain.voidnotifyReplicaOffline(DN baseDN, CSN offlineCSN)Let the DB know this replica is going down.booleanpublishUpdateMsg(DN baseDN, UpdateMsg updateMsg)Publishes the provided change to the changelog DB for the specified serverId and replication domain.voidremoveDomain(DN baseDN)Removes all the data relating to the specified replication domain and shutdown all its replica databases.voidreplicaHeartbeat(DN baseDN, CSN heartbeatCSN)Let the DB know this replica is alive.voidunregisterCursor(DBCursor<?> cursor)Unregisters the provided cursor from this replication domain.
-
-
-
Method Detail
-
getDomainOldestCSNs
ServerState getDomainOldestCSNs(DN baseDN)
Returns the oldestCSNs from the replicaDBs for each serverId in the specified replication domain.- Parameters:
baseDN- the replication domain baseDN- Returns:
- a new ServerState object holding the {serverId => oldest CSN} mapping. If a replica DB is empty or closed, the oldest CSN will be null for that replica. The caller owns the generated ServerState.
-
getDomainNewestCSNs
ServerState getDomainNewestCSNs(DN baseDN)
Returns the newestCSNs from the replicaDBs for each serverId in the specified replication domain.- Parameters:
baseDN- the replication domain baseDN- Returns:
- a new ServerState object holding the {serverId => newest CSN} Map. If a replica DB is empty or closed, the newest CSN will be null for that replica. The caller owns the generated ServerState.
-
removeDomain
void removeDomain(DN baseDN) throws ChangelogException
Removes all the data relating to the specified replication domain and shutdown all its replica databases. In particular, it will:- remove all the changes from the replica databases
- remove all knowledge of the serverIds in this domain
- remove any knowledge of the current generationId for this domain
- Parameters:
baseDN- the replication domain baseDN- Throws:
ChangelogException- If a database problem happened
-
getCursorFrom
MultiDomainDBCursor getCursorFrom(MultiDomainServerState startState, DBCursor.CursorOptions options) throws ChangelogException
Generates aDBCursoracross all the domains starting before, at or after the providedMultiDomainServerStatefor 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.- Parameters:
startState- Starting point for each domain cursor. If anyServerStatefor a domain is null, then start from the oldest CSN for each replicaDBsoptions- The cursor options- Returns:
- a non null
DBCursor - Throws:
ChangelogException- If a database problem happened- See Also:
getCursorFrom(DN, ServerState, CursorOptions)
-
getCursorFrom
MultiDomainDBCursor getCursorFrom(MultiDomainServerState startState, DBCursor.CursorOptions options, Set<DN> excludedDomainDns) throws ChangelogException
Generates aDBCursoracross all the domains starting before, at or after the providedMultiDomainServerStatefor 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.- Parameters:
startState- Starting point for each domain cursor. If anyServerStatefor 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 cursor- Returns:
- a non null
DBCursor - Throws:
ChangelogException- If a database problem happened- See Also:
getCursorFrom(DN, ServerState, CursorOptions)
-
getCursorFrom
DBCursor<UpdateMsg> getCursorFrom(DN baseDN, ServerState startState, DBCursor.CursorOptions options) throws ChangelogException
Generates aDBCursoracross all the replicaDBs for the specified replication domain starting before, at or after the providedServerStatefor 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.- Parameters:
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 options- Returns:
- a non null
DBCursor - Throws:
ChangelogException- If a database problem happened- See Also:
getCursorFrom(DN, int, CSN, CursorOptions)
-
getCursorFrom
DBCursor<UpdateMsg> getCursorFrom(DN baseDN, int serverId, CSN startCSN, DBCursor.CursorOptions options) throws ChangelogException
Generates aDBCursorfor one replicaDB for the specified replication domain and serverId starting before, at or after the providedCSN, 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.- Parameters:
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 options- Returns:
- a non null
DBCursor - Throws:
ChangelogException- If a database problem happened
-
unregisterCursor
void unregisterCursor(DBCursor<?> cursor)
Unregisters the provided cursor from this replication domain.- Parameters:
cursor- the cursor to unregister.
-
publishUpdateMsg
boolean publishUpdateMsg(DN baseDN, UpdateMsg updateMsg) throws ChangelogException
Publishes the provided change to the changelog DB for the specified serverId and replication domain. After a change has been successfully published, it becomes available to be returned by the External ChangeLog.- Parameters:
baseDN- the replication domain baseDNupdateMsg- the update message to publish to the replicaDB- Returns:
- true if a db had to be created to publish this message
- Throws:
ChangelogException- If a database problem happened
-
replicaHeartbeat
void replicaHeartbeat(DN baseDN, CSN heartbeatCSN) throws ChangelogException
Let the DB know this replica is alive.This method allows the medium consistency point to move forward in case this replica did not publish new changes.
- Parameters:
baseDN- the replication domain baseDNheartbeatCSN- The CSN heartbeat sent by this replica (contains the serverId and timestamp of the heartbeat)- Throws:
ChangelogException- If a database problem happened
-
notifyReplicaOffline
void notifyReplicaOffline(DN baseDN, CSN offlineCSN) throws ChangelogException
Let the DB know this replica is going down.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.
- Parameters:
baseDN- the replication domain baseDNofflineCSN- The CSN (serverId and timestamp) for the replica's going offline- Throws:
ChangelogException- If a database problem happened
-
-