pub struct KraftLog { /* private fields */ }Implementations§
Source§impl KraftLog
impl KraftLog
Sourcepub fn open(
dir: impl AsRef<Path>,
config: &MetadataLogConfig,
) -> Result<Self, RaftError>
pub fn open( dir: impl AsRef<Path>, config: &MetadataLogConfig, ) -> Result<Self, RaftError>
Opens or creates the metadata log in dir, the metadata partition
directory __cluster_metadata-0. The segments roll as config says.
§Errors
Returns RaftError if the log directory cannot be created or the
underlying krabka_log::Log fails to open, and
RaftError::PersistedFormat if the high-watermark file has a
version this build does not read or has no version marker.
Sourcepub fn failure(&self) -> Option<&str>
pub fn failure(&self) -> Option<&str>
The first I/O error a write to the metadata log directory returned, or
None while every write has succeeded.
pub fn log_start_offset(&self) -> Offset
pub fn log_end_offset(&self) -> Offset
pub fn hwm(&self) -> Offset
Sourcepub fn size(&self) -> ByteSize
pub fn size(&self) -> ByteSize
The size of every segment’s .log file together, Kafka’s
UnifiedLog.size, which the metadata log’s size retention weighs.
Sourcepub fn append(
&mut self,
batch: &mut RecordBatch,
append_timestamp_ms: i64,
) -> Result<Offset, RaftError>
pub fn append( &mut self, batch: &mut RecordBatch, append_timestamp_ms: i64, ) -> Result<Offset, RaftError>
Leader path: appends a batch stamped with append_timestamp_ms.
krabka-log assigns the offset and records the batch’s
partition_leader_epoch. Returns the assigned base offset.
The stamp is the batch’s create-time, as Kafka’s BatchAccumulator
stamps every batch the raft client appends with the current time. It is
what Self::last_committed_timestamp_ms reads back for a snapshot
header, and what a follower replicates verbatim through
Self::append_at.
§Errors
Returns RaftError if the underlying append fails.
Sourcepub fn append_at(
&mut self,
batch: &mut RecordBatch,
offset: Offset,
) -> Result<(), RaftError>
pub fn append_at( &mut self, batch: &mut RecordBatch, offset: Offset, ) -> Result<(), RaftError>
Sourcepub fn read_decoded(
&self,
offset: Offset,
max_size: ByteSize,
) -> Result<Vec<RecordBatch>, RaftError>
pub fn read_decoded( &self, offset: Offset, max_size: ByteSize, ) -> Result<Vec<RecordBatch>, RaftError>
Sourcepub fn timestamp_below(&self, end_offset: Offset) -> Option<i64>
pub fn timestamp_below(&self, end_offset: Offset) -> Option<i64>
The append timestamp of the last record below end_offset: the
max_timestamp of the batch that contains end_offset - 1.
KIP-630 stamps this into SnapshotHeaderRecord’s
last_contained_log_timestamp, where Kafka supplies the append time of
the last batch the snapshot contains. None when no such record is
readable here: the boundary is at or below the log start, because
everything under it was pruned or arrived inside an installed snapshot,
or it is beyond the log end.
Sourcepub fn last_committed_timestamp_ms(&self) -> Option<i64>
pub fn last_committed_timestamp_ms(&self) -> Option<i64>
The append timestamp of the last committed record (hwm - 1), for the
header of a snapshot taken at the high watermark.
Sourcepub fn read_committed(
&self,
offset: Offset,
max_size: ByteSize,
) -> Result<RawRead, RaftError>
pub fn read_committed( &self, offset: Offset, max_size: ByteSize, ) -> Result<RawRead, RaftError>
Sourcepub fn advance_hwm(&mut self, new_hwm: Offset)
pub fn advance_hwm(&mut self, new_hwm: Offset)
Advances the high watermark. The move is monotonic, and it never goes past the log end.
Sourcepub fn truncate_to(&mut self, offset: Offset) -> Result<(), RaftError>
pub fn truncate_to(&mut self, offset: Offset) -> Result<(), RaftError>
Sourcepub fn reap_retired_files(&mut self, now: SystemTime) -> Result<(), RaftError>
pub fn reap_retired_files(&mut self, now: SystemTime) -> Result<(), RaftError>
Deletes the files of every segment that Self::prune_to or
Self::install_snapshot retired at least file.delete.delay.ms
before now.
A retired segment is renamed to .deleted and stays readable for that
delay, Kafka’s 60-second default, as in Kafka’s KafkaRaftLog. Kafka’s
scheduler then deletes it. Without this call nothing would: the
broker’s retention sweep reaps the partitions it owns, and the metadata
log is not one of them, so every cleaning would leave its segments on
disk until the node restarted.
The unlinks run on a thread of their own, as the partition writer hands its due deletions to a background task: a metadata segment can be a GiB, and unlinking it on the engine would stall fetches, heartbeats and every controller command behind it. One deletion runs at a time. Each call first collects the one before it, and a failed one hands its remaining files back to the log, which retries them on a later call.
§Errors
Returns RaftError if the earlier deletion failed, or if the flush
that Log::maintain_deferring_deletions runs first fails.
It also returns one if the deletion thread panicked.
Sourcepub fn install_snapshot(&mut self, end_offset: Offset) -> Result<(), RaftError>
pub fn install_snapshot(&mut self, end_offset: Offset) -> Result<(), RaftError>
Trait Implementations§
Source§impl LogView for KraftLog
impl LogView for KraftLog
Source§fn end_offset(&self) -> i64
fn end_offset(&self) -> i64
Source§fn last_epoch(&self) -> Epoch
fn last_epoch(&self) -> Epoch
Source§fn end_offset_for_epoch(&self, epoch: Epoch) -> LogOffsetMetadata
fn end_offset_for_epoch(&self, epoch: Epoch) -> LogOffsetMetadata
RaftLog.endOffsetForEpoch: the largest epoch <= epoch that
this log holds, and the offset where that epoch ends. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for KraftLog
impl !UnwindSafe for KraftLog
impl Freeze for KraftLog
impl Send for KraftLog
impl Sync for KraftLog
impl Unpin for KraftLog
impl UnsafeUnpin for KraftLog
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<F> FnGhost for F
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);