The message set containing log entries
The offset index
A lower bound on the offsets in this segment
The approximate number of bytes between entries in the index
The time instance
Append the given messages starting with the given offset.
Append the given messages starting with the given offset. Add an entry to the index if needed.
It is assumed this method is being called from within a lock.
The first offset in the message set.
The messages to append.
A lower bound on the offsets in this segment
Change the suffix for the index and log file for this log segment
Close this log segment
Delete this log segment from the filesystem.
Delete this log segment from the filesystem.
if the delete fails.
Flush this log segment to disk
Flush this log segment to disk
The offset index
The approximate number of bytes between entries in the index
The last modified time of this log segment as a unix time stamp
Change the last modified time for this log segment
The message set containing log entries
Calculate the offset that would be used for the next message to be append to this segment.
Calculate the offset that would be used for the next message to be append to this segment. Note that this is expensive.
Read a message set from this segment beginning with the first offset >= startOffset.
Read a message set from this segment beginning with the first offset >= startOffset. The message set will include no more than maxSize bytes and will end before maxOffset if a maxOffset is specified.
A lower bound on the first offset to include in the message set we read
An optional maximum offset for the message set we read
The maximum number of bytes to include in the message set we read
The fetched data and the offset metadata of the first message whose offset is >= startOffset, or null if the startOffset is larger than the largest offset in this log
Run recovery on the given segment.
Run recovery on the given segment. This will rebuild the index from the log file and lop off any invalid bytes from the end of the log and index.
A bound the memory allocation in the case of a corrupt message size--we will assume any message larger than this is corrupt.
The number of bytes truncated from the log
Truncate off all index and log entries with offsets >= the given offset.
Truncate off all index and log entries with offsets >= the given offset. If the given offset is larger than the largest message in this segment, do nothing.
The offset to truncate to
The number of log bytes truncated
A segment of the log. Each segment has two components: a log and an index. The log is a FileMessageSet containing the actual messages. The index is an OffsetIndex that maps from logical offsets to physical file positions. Each segment has a base offset which is an offset <= the least offset of any message in this segment and > any offset in any previous segment.
A segment with a base offset of [base_offset] would be stored in two files, a [base_offset].index and a [base_offset].log file.