pub struct Engine<F = DefaultFileSystem, P = FilePipeLog<F>>where
F: FileSystem,
P: PipeLog,{ /* private fields */ }
Implementations§
Source§impl Engine<DefaultFileSystem, FilePipeLog<DefaultFileSystem>>
impl Engine<DefaultFileSystem, FilePipeLog<DefaultFileSystem>>
pub fn open( cfg: Config, ) -> Result<Engine<DefaultFileSystem, FilePipeLog<DefaultFileSystem>>>
pub fn open_with_listeners( cfg: Config, listeners: Vec<Arc<dyn EventListener>>, ) -> Result<Engine<DefaultFileSystem, FilePipeLog<DefaultFileSystem>>>
Source§impl<F> Engine<F, FilePipeLog<F>>where
F: FileSystem,
impl<F> Engine<F, FilePipeLog<F>>where
F: FileSystem,
pub fn open_with_file_system( cfg: Config, file_system: Arc<F>, ) -> Result<Engine<F, FilePipeLog<F>>>
pub fn open_with( cfg: Config, file_system: Arc<F>, listeners: Vec<Arc<dyn EventListener>>, ) -> Result<Engine<F, FilePipeLog<F>>>
Source§impl<F, P> Engine<F, P>where
F: FileSystem,
P: PipeLog,
impl<F, P> Engine<F, P>where
F: FileSystem,
P: PipeLog,
Sourcepub fn write(&self, log_batch: &mut LogBatch, sync: bool) -> Result<usize>
pub fn write(&self, log_batch: &mut LogBatch, sync: bool) -> Result<usize>
Writes the content of log_batch
into the engine and returns written
bytes. If sync
is true, the write will be followed by a call to
fdatasync
on the log file.
pub fn get_message<S: Message>( &self, region_id: u64, key: &[u8], ) -> Result<Option<S>>
pub fn get(&self, region_id: u64, key: &[u8]) -> Option<Vec<u8>>
Sourcepub fn scan_messages<S, C>(
&self,
region_id: u64,
start_key: Option<&[u8]>,
end_key: Option<&[u8]>,
reverse: bool,
callback: C,
) -> Result<()>
pub fn scan_messages<S, C>( &self, region_id: u64, start_key: Option<&[u8]>, end_key: Option<&[u8]>, reverse: bool, callback: C, ) -> Result<()>
Iterates over [start_key, end_key) range of Raft Group key-values and yields messages of the required type. Unparsable items are skipped.
Sourcepub fn scan_raw_messages<C>(
&self,
region_id: u64,
start_key: Option<&[u8]>,
end_key: Option<&[u8]>,
reverse: bool,
callback: C,
) -> Result<()>
pub fn scan_raw_messages<C>( &self, region_id: u64, start_key: Option<&[u8]>, end_key: Option<&[u8]>, reverse: bool, callback: C, ) -> Result<()>
Iterates over [start_key, end_key) range of Raft Group key-values and yields all key value pairs as bytes.
pub fn get_entry<M: MessageExt>( &self, region_id: u64, log_idx: u64, ) -> Result<Option<M::Entry>>
Sourcepub fn purge_expired_files(&self) -> Result<Vec<u64>>
pub fn purge_expired_files(&self) -> Result<Vec<u64>>
Purges expired logs files and returns a set of Raft group ids that need to be compacted.
Sourcepub fn fetch_entries_to<M: MessageExt>(
&self,
region_id: u64,
begin: u64,
end: u64,
max_size: Option<usize>,
vec: &mut Vec<M::Entry>,
) -> Result<usize>
pub fn fetch_entries_to<M: MessageExt>( &self, region_id: u64, begin: u64, end: u64, max_size: Option<usize>, vec: &mut Vec<M::Entry>, ) -> Result<usize>
Returns count of fetched entries.
pub fn first_index(&self, region_id: u64) -> Option<u64>
pub fn last_index(&self, region_id: u64) -> Option<u64>
Sourcepub fn compact_to(&self, region_id: u64, index: u64) -> u64
pub fn compact_to(&self, region_id: u64, index: u64) -> u64
Deletes log entries before index
in the specified Raft group. Returns
the number of deleted entries.
pub fn raft_groups(&self) -> Vec<u64>
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if the engine contains no Raft Group. Empty Raft Group
that isn’t cleaned is counted as well.
Sourcepub fn file_span(&self, queue: LogQueue) -> (u64, u64)
pub fn file_span(&self, queue: LogQueue) -> (u64, u64)
Returns the sequence number range of active log files in the specific log queue. For testing only.
pub fn get_used_size(&self) -> usize
pub fn path(&self) -> &str
pub fn purge_manager(&self) -> &PurgeManager<P>
Source§impl<F> Engine<F, FilePipeLog<F>>where
F: FileSystem,
impl<F> Engine<F, FilePipeLog<F>>where
F: FileSystem,
Sourcepub fn consistency_check_with_file_system(
path: &Path,
file_system: Arc<F>,
) -> Result<Vec<(u64, u64)>>
pub fn consistency_check_with_file_system( path: &Path, file_system: Arc<F>, ) -> Result<Vec<(u64, u64)>>
Returns a list of corrupted Raft groups, including their ids and last valid log index. Head or tail corruption cannot be detected.
pub fn unsafe_repair_with_file_system( path: &Path, queue: Option<LogQueue>, script: String, file_system: Arc<F>, ) -> Result<()>
Sourcepub fn dump_with_file_system(
path: &Path,
file_system: Arc<F>,
) -> Result<LogItemReader<F>>
pub fn dump_with_file_system( path: &Path, file_system: Arc<F>, ) -> Result<LogItemReader<F>>
Dumps all operations.
Source§impl<F: FileSystem> Engine<F, FilePipeLog<F>>
impl<F: FileSystem> Engine<F, FilePipeLog<F>>
Sourcepub fn fork<T: AsRef<Path>>(
source: &Config,
fs: Arc<F>,
target: T,
) -> Result<CopyDetails, String>
pub fn fork<T: AsRef<Path>>( source: &Config, fs: Arc<F>, target: T, ) -> Result<CopyDetails, String>
Make a copy from source
to target
. source
should exists but
target
shouldn’t. And source
shouldn’t be opened, otherwise
data corruption can happen.
symlink will be used if possbile, otherwise copy will be used instead. Generally all inactive log files will be symlinked, but the last active one will be copied.
After the copy is made both of 2 engines can be started and run at the same time.
It reports errors if the source instance
- is specified with
enable_log_recycle = true
.source
andtarget
can share log files, so log file reusing can cause data corruption. - is specified with
recovery_mode = TolerateAnyCorruption
, in which case symlink can’t be use. Users should consider to copy the instance directly.
Trait Implementations§
Auto Trait Implementations§
impl<F = DefaultFileSystem, P = DualPipes<F>> !Freeze for Engine<F, P>
impl<F = DefaultFileSystem, P = DualPipes<F>> !RefUnwindSafe for Engine<F, P>
impl<F, P> Send for Engine<F, P>
impl<F, P> Sync for Engine<F, P>
impl<F, P> Unpin for Engine<F, P>where
F: Unpin,
impl<F = DefaultFileSystem, P = DualPipes<F>> !UnwindSafe for Engine<F, P>
Blanket Implementations§
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more