Skip to content

Latest commit

 

History

History
143 lines (92 loc) · 3.88 KB

kafka-log-TransactionIndex.adoc

File metadata and controls

143 lines (92 loc) · 3.88 KB

TransactionIndex

TransactionIndex is a transaction index of a LogSegment.

TransactionIndex is created when:

Creating TransactionIndex Instance

TransactionIndex takes the following to be created:

  • Start offset

  • Underlying file (Java’s File)

TransactionIndex initializes the internal properties.

While being created, TransactionIndex opens a channel to the file if exists already.

append Method

append(
  abortedTxn: AbortedTxn): Unit

append…​FIXME

Note

append is used when:

flush Method

flush(): Unit

flush…​FIXME

Note
flush is used when LogSegment is requested to flush.

truncateTo Method

truncateTo(
  offset: Long): Unit

truncateTo…​FIXME

Note
truncateTo is used when LogSegment is requested to truncate (to a given offset).

deleteIfExists Method

deleteIfExists(): Boolean

deleteIfExists…​FIXME

Note
deleteIfExists is used when LogSegment is requested to deleteIfExists.

collectAbortedTxns Method

collectAbortedTxns(
  fetchOffset: Long,
  upperBoundOffset: Long): TxnIndexSearchResult

collectAbortedTxns…​FIXME

Note
collectAbortedTxns is used when LogSegment is requested to collectAbortedTxns.

Opening FileChannel — openChannel Internal Method

openChannel(): FileChannel

openChannel uses Java’s FileChannel utility to open a file channel to the underlying file for read and write access (and creating a new file unless it exists already).

openChannel registers the FileChannel with the maybeChannel internal registry.

openChannel sets the file position of the FileChannel to be the very end of the file.

Note
openChannel is used when TransactionIndex is created (and the underlying file is available) and requested for the FileChannel.

channel Internal Method

channel(): FileChannel

channel takes the FileChannel out from the maybeChannel internal registry (if available) or opens a new FileChannel.

Note
channel is used when TransactionIndex is requested to append and truncateTo.

Internal Properties

Name Description

lastOffset

lastOffset: Option[Long] = None

Used when…​FIXME

maybeChannel

maybeChannel: Option[FileChannel] = None

Used when…​FIXME