Interface ChangeNumberIndexDB
-
public interface ChangeNumberIndexDB
This class stores an index of all the changes seen by this server in the form ofChangeNumberIndexRecord
s. The records are sorted by a global ordering as defined in the CSN class. The index links achangeNumber
to the corresponding CSN. The CSN then links to a corresponding change in one of the ReplicaDBs.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description long
addRecord(ChangeNumberIndexRecord record)
Add an update to the list of messages that must be saved to this DB managed by this DB and return the changeNumber associated to this record.DBCursor<ChangeNumberIndexRecord>
getCursorFrom(long startChangeNumber)
Generate a newDBCursor
that allows to browse the db managed by this object and starting at the position defined by a given changeNumber.long
getLastGeneratedChangeNumber()
Returns the last generated change number.ChangeNumberIndexRecord
getNewestRecord()
Get the newest record stored in this DB.ChangeNumberIndexRecord
getOldestRecord()
Get the oldest record stored in this DB.Flowable<ChangeNumberIndexRecord>
getReader(String name, long startChangeNumber)
Returns a reader of the index database, starting at the position defined by the provided changeNumber, that completes when it reaches the most recent record.void
resetChangeNumberTo(long newFirstCN, Dn baseDN, CSN newFirstCSN)
Resets ChangeNumber index to the given number and CSN.
-
-
-
Method Detail
-
getLastGeneratedChangeNumber
long getLastGeneratedChangeNumber()
Returns the last generated change number.- Returns:
- the last generated change number
-
getOldestRecord
ChangeNumberIndexRecord getOldestRecord() throws ChangelogException
Get the oldest record stored in this DB.- Returns:
- Returns the oldest
ChangeNumberIndexRecord
in this DB, null when the DB is empty or closed - Throws:
ChangelogException
- if a database problem occurs.
-
getNewestRecord
ChangeNumberIndexRecord getNewestRecord() throws ChangelogException
Get the newest record stored in this DB.- Returns:
- Returns the newest
ChangeNumberIndexRecord
in this DB, null when the DB is empty or closed - Throws:
ChangelogException
- if a database problem occurs.
-
addRecord
long addRecord(ChangeNumberIndexRecord record) throws ChangelogException
Add an update to the list of messages that must be saved to this DB managed by this DB and return the changeNumber associated to this record.Note: this method disregards the changeNumber in the provided record.
- Parameters:
record
- TheChangeNumberIndexRecord
to add to this DB.- Returns:
- the change number associated to this record on adding to this DB
- Throws:
ChangelogException
- if a database problem occurs.
-
getCursorFrom
DBCursor<ChangeNumberIndexRecord> getCursorFrom(long startChangeNumber) throws ChangelogException
Generate a newDBCursor
that allows to browse the db managed by this object and starting at the position defined by a given changeNumber.- Parameters:
startChangeNumber
- The position where the iterator must start.- Returns:
- a new DBCursor that allows to browse this DB managed by this object and starting at the position defined by a given changeNumber.
- Throws:
ChangelogException
- if a database problem occurs.
-
getReader
Flowable<ChangeNumberIndexRecord> getReader(String name, long startChangeNumber)
Returns a reader of the index database, starting at the position defined by the provided changeNumber, that completes when it reaches the most recent record.Intended use case is to perform a search against cn=changelog.
Reading will start only when the returned
Flowable
has been subscribed to.- Parameters:
name
- The name of the reader.startChangeNumber
- The position where the reader must start. If the change number is not found, then aChangelogException
will be thrown- Returns:
- a reader of the index database, that completes when it reaches the most recent record.
-
resetChangeNumberTo
void resetChangeNumberTo(long newFirstCN, Dn baseDN, CSN newFirstCSN) throws ChangelogException
Resets ChangeNumber index to the given number and CSN.- Parameters:
newFirstCN
- the new change number to appear as first change in the external changelogbaseDN
- the new record for the first changenewFirstCSN
- the CSN of the new first change- Throws:
ChangelogException
- if an error occurs during reset
-
-