Package io.camunda.zeebe.journal.file
Class SegmentedJournal
java.lang.Object
io.camunda.zeebe.journal.file.SegmentedJournal
- All Implemented Interfaces:
Journal,AutoCloseable
A file based journal. The journal is split into multiple segments files.
-
Field Summary
Fields -
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.static SegmentedJournalBuilderbuilder()Returns a new SegmentedJournal builder.voidclose()voidcloseReader(io.camunda.zeebe.journal.file.SegmentedJournalReader segmentedJournalReader) voiddeleteAfter(long indexExclusive) Delete all records after indexExclusive.booleandeleteUntil(long index) 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.io.camunda.zeebe.journal.file.JournalIndexlongReturns 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.
-
Field Details
-
ASQN_IGNORE
public static final long ASQN_IGNORE- See Also:
-
-
Method Details
-
builder
Returns a new SegmentedJournal builder.- Returns:
- A new Segmented journal builder.
-
append
Description copied from interface:JournalAppends 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. -
append
Description copied from interface:JournalAppends 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. -
append
Description copied from interface:JournalAppends aJournalRecord. If the index of the record is not the next expected index, the append will fail. -
deleteAfter
public void deleteAfter(long indexExclusive) Description copied from interface:JournalDelete all records after indexExclusive. After a call to this method,Journal.getLastIndex()should return indexExclusive.- Specified by:
deleteAfterin interfaceJournal- Parameters:
indexExclusive- the index after which the records will be deleted.
-
deleteUntil
public boolean deleteUntil(long index) Description copied from interface:JournalAttempts to delete all records until indexExclusive. The records may be immediately deleted or marked to be deleted later depending on the implementation.- Specified by:
deleteUntilin interfaceJournal- Parameters:
index- the index until which will be deleted. The record at this index is not deleted.- Returns:
- true if anything was deleted, false otherwise
-
reset
public void reset(long nextIndex) Description copied from interface:JournalDelete all records in the journal and reset the next index to nextIndex. The following calls toJournal.append(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. -
getLastIndex
public long getLastIndex()Description copied from interface:JournalReturns the index of last record in the journal- Specified by:
getLastIndexin interfaceJournal- Returns:
- the last index
-
getFirstIndex
public long getFirstIndex()Description copied from interface:JournalReturns the index of the first record.- Specified by:
getFirstIndexin interfaceJournal- Returns:
- the first index
-
isEmpty
public boolean isEmpty()Description copied from interface:JournalCheck if the journal is empty. -
flush
public void flush()Description copied from interface:JournalDepending 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
Description copied from interface:JournalOpens a newJournalReader- Specified by:
openReaderin interfaceJournal- Returns:
- a journal reader
-
isOpen
public boolean isOpen()Description copied from interface:JournalCheck if the journal is open -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
closeReader
public void closeReader(io.camunda.zeebe.journal.file.SegmentedJournalReader segmentedJournalReader) -
getJournalIndex
public io.camunda.zeebe.journal.file.JournalIndex getJournalIndex()
-