Package io.camunda.zeebe.journal
Interface Journal
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
SegmentedJournal
-
Method Summary
Modifier and TypeMethodDescriptionappend(long asqn, BufferWriter recordDataWriter) Appends a newJournalRecordthat contains the data to be written by the recordDataWriter.voidappend(JournalRecord record) Appends aJournalRecord.append(BufferWriter recordDataWriter) Appends a newJournalRecordthat contains the data to be written by the recordDataWriter.voiddeleteAfter(long indexExclusive) Delete all records after indexExclusive.booleandeleteUntil(long indexExclusive) Attempts to delete all records until indexExclusive.voidflush()Depending on the implementation, appends to the journal may not be immediately flushed to the persistent storage.longReturns the index of the first record.longReturns the index of last record in the journalbooleanisEmpty()Check if the journal is empty.booleanisOpen()Check if the journal is openOpens a newJournalReadervoidreset(long nextIndex) Delete all records in the journal and reset the next index to nextIndex.Methods inherited from interface java.lang.AutoCloseable
close
-
Method Details
-
append
Appends a newJournalRecordthat contains the data to be written by the recordDataWriter. Use this for records that do not have a specific applicationSqNum. Examples for such record is raft record that indicates a leader change.- Parameters:
recordDataWriter- a writer that outputs the data of the record- Returns:
- the journal record that was appended
-
append
Appends a newJournalRecordthat contains the data to be written by the recordDataWriter. asqn refers to Application Sequence Number. It is a sequence number provided by the application. The given asqn must be positive and, it must be greater than the asqn of the previous record.- Parameters:
asqn- A sequence number provided by the application.recordDataWriter- a writer that outputs the data of the record- Returns:
- the journal record that was appended
-
append
Appends aJournalRecord. If the index of the record is not the next expected index, the append will fail.- Parameters:
record- the record to be appended- Throws:
JournalException.InvalidIndex- if the index of record is not the next expected indexJournalException.InvalidChecksum- if the checksum in record does not match the checksum of the data
-
deleteAfter
void deleteAfter(long indexExclusive) Delete all records after indexExclusive. After a call to this method,getLastIndex()should return indexExclusive.- Parameters:
indexExclusive- the index after which the records will be deleted.
-
deleteUntil
boolean deleteUntil(long indexExclusive) Attempts to delete all records until indexExclusive. The records may be immediately deleted or marked to be deleted later depending on the implementation.- Parameters:
indexExclusive- the index until which will be deleted. The record at this index is not deleted.- Returns:
- true if anything was deleted, false otherwise
-
reset
void reset(long nextIndex) Delete all records in the journal and reset the next index to nextIndex. The following calls toappend(long, BufferWriter)will append at index nextIndex.After this operation, all readers must be reset explicitly. The readers that are not reset will return false for
Iterator.hasNext(), cannot read any record.- Parameters:
nextIndex- the next index of the journal.
-
getLastIndex
long getLastIndex()Returns the index of last record in the journal- Returns:
- the last index
-
getFirstIndex
long getFirstIndex()Returns the index of the first record.- Returns:
- the first index
-
isEmpty
boolean isEmpty()Check if the journal is empty.- Returns:
- true if empty, false otherwise.
-
flush
void flush()Depending on the implementation, appends to the journal may not be immediately flushed to the persistent storage. A call to this method guarantees that all records written are safely flushed to the persistent storage. -
openReader
JournalReader openReader()Opens a newJournalReader- Returns:
- a journal reader
-
isOpen
boolean isOpen()Check if the journal is open- Returns:
- true if open, false otherwise
-