Skip to main content

LogHistory

Struct LogHistory 

Source
pub struct LogHistory { /* private fields */ }
Expand description

ローカルログの歴史(要約)を保持するためのデータ構造.

スナップショット地点以降のローカルログに関して発生した、 重要な出来事(i.g., Termの変更)が記録されている.

それ以外に「ログの末尾(log_tail)」および「ログのコミット済み末尾(log_committed_tail)」、 「ログの消費済み末尾(log_consumed_tail)」の三つの地点を保持している.

それらの関してはlog_consumed_tail <= log_committed_tail <= log_tailの不変項が維持される.

Implementations§

Source§

impl LogHistory

Source

pub fn new(config: ClusterConfig) -> Self

初期クラスタ構成を与えて、新しいLogHistoryインスタンスを生成する.

Source

pub fn head(&self) -> LogPosition

ローカルログの先端位置を返す.

Source

pub fn tail(&self) -> LogPosition

ローカルログの終端位置を返す.

Source

pub fn committed_tail(&self) -> LogPosition

ローカルログのコミット済みの終端位置を返す.

「コミット済みの終端」==「未コミットの始端」

Source

pub fn consumed_tail(&self) -> LogPosition

ローカルログの適用済みの終端位置を返す.

Source

pub fn config(&self) -> &ClusterConfig

ローカルログに記録された最新のクラスタ構成を返す.

Source

pub fn last_record(&self) -> &HistoryRecord

最後に追加されたHistoryRecordを返す.

Source

pub fn get_record(&self, index: LogIndex) -> Option<&HistoryRecord>

指定されたインデックスが属するレコードを返す.

既に削除された領域が指定された場合にはNoneが返される.

Source

pub fn record_appended(&mut self, suffix: &LogSuffix) -> Result<()>

suffixがローカルログに追記されたことを記録する.

Source

pub fn record_committed(&mut self, new_tail_index: LogIndex) -> Result<()>

new_tail_indexまでコミット済み地点が進んだことを記録する.

Source

pub fn record_consumed(&mut self, new_tail_index: LogIndex) -> Result<()>

new_tailまでのログに含まれるコマンドが消費されたことを記録する.

ここでの“消費“とは「状態機械に入力として渡されて実行された」ことを意味する.

Source

pub fn record_rollback(&mut self, new_tail: LogPosition) -> Result<()>

「追記済み and 未コミット」な末尾領域がロールバック(破棄)されたことを記録する.

ログの新しい終端はnew_tailとなる.

Source

pub fn record_snapshot_installed( &mut self, new_head: LogPosition, config: ClusterConfig, ) -> Result<()>

スナップショットがインストールされたことを記録する.

new_headはスナップショットに含まれない最初のエントリのIDで、 configはスナップショット取得時のクラスタ構成、を示す.

new_headは、現在のログの末尾を超えていても良いが、 現在のログの先頭以前のものは許容されない. (スナップショット地点から現在までの歴史が消失してしまうため)

なお、head以前の記録は歴史から削除される.

Source

pub fn record_snapshot_loaded(&mut self, snapshot: &LogPrefix) -> Result<()>

スナップショットが読み込まれたことを記録する.

ローカルログ内のスナップショット地点までのエントリは、消費されたものとして扱われる.

Trait Implementations§

Source§

impl Clone for LogHistory

Source§

fn clone(&self) -> LogHistory

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LogHistory

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.