Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
Signed-off-by: Connor1996 <[email protected]>
  • Loading branch information
Connor1996 committed Sep 18, 2023
1 parent 56c40dc commit 58132d3
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 59 deletions.
47 changes: 1 addition & 46 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::time::{Duration, Instant};
use log::{error, info};
use protobuf::{parse_from_bytes, Message};

use crate::config::{Config, RecoveryMode};
use crate::consistency::ConsistencyChecker;
use crate::env::{DefaultFileSystem, FileSystem};
use crate::event_listener::EventListener;
Expand All @@ -21,40 +22,12 @@ use crate::metrics::*;
use crate::pipe_log::{FileBlockHandle, FileId, LogQueue, PipeLog};
use crate::purge::{PurgeHook, PurgeManager};
use crate::write_barrier::{WriteBarrier, Writer};
use crate::{
config::{Config, RecoveryMode},
env::HedgedFileSystem,
};
use crate::{perf_context, Error, GlobalStats, Result};

const METRICS_FLUSH_INTERVAL: Duration = Duration::from_secs(30);
/// Max times for `write`.
const MAX_WRITE_ATTEMPT: u64 = 2;

// pub struct HedgedEngine<F = DefaultFileSystem, P = FilePipeLog<F>>
// where
// F: FileSystem,
// P: PipeLog,
// {
// inner: Engine<HedgedFileSystem<F>, P>,
// fs: Arc<HedgedFileSystem<F>>,
// }

// impl<F> HedgedEngine<F,FilePipeLog<F>>
// where
// F: FileSystem,
// {

// }

// impl<F: FileSystem> Deref for HedgedEngine<F, FilePipeLog<F>> {
// type Target = Engine<F, FilePipeLog<F>>;

// fn deref(&self) -> &Self::Target {
// &self.inner
// }
// }

pub struct Engine<F = DefaultFileSystem, P = FilePipeLog<F>>
where
F: FileSystem,
Expand Down Expand Up @@ -90,24 +63,6 @@ impl Engine<DefaultFileSystem, FilePipeLog<DefaultFileSystem>> {
}
}

pub fn open_with_hedged_file_system(
cfg: Config,
file_system: Arc<DefaultFileSystem>,
) -> Result<Engine<HedgedFileSystem, FilePipeLog<HedgedFileSystem>>> {
let file_system = if let Some(ref sec_dir) = cfg.second_dir {
let fs = Arc::new(HedgedFileSystem::new(
file_system,
cfg.dir.clone().into(),
sec_dir.clone().into(),
));
fs.bootstrap()?;
fs
} else {
panic!()
};
Engine::open_with(cfg, file_system, vec![])
}

impl<F> Engine<F, FilePipeLog<F>>
where
F: FileSystem,
Expand Down
1 change: 0 additions & 1 deletion src/env/hedged/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ pub use sender::State;
/// 2. Raft log is read-only once it's sealed.
/// Here is the TLA+ proof https://github.com/pingcap/tla-plus/pull/41

// TODO: add metrics
// TODO: handle specially on config change(upgrade and downgrade)
// TODO: fallback to one disk, if the other disk is down for a long time and
// close to full
Expand Down
2 changes: 1 addition & 1 deletion src/env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub enum Permission {
}

/// FileSystem
pub trait FileSystem: Send + Sync + 'static {
pub trait FileSystem: Send + Sync {
type Handle: Send + Sync + Handle;
type Reader: Seek + Read + Send;
type Writer: Seek + Write + Send + WriteExt;
Expand Down
5 changes: 0 additions & 5 deletions src/file_pipe_log/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,6 @@ impl<F: FileSystem> PipeLog for DualPipes<F> {
queue: LogQueue,
bytes: &mut T,
) -> Result<FileBlockHandle> {
// if self.file_system.need_recover() {
// self.pipes[LogQueue::Append].rotate();
// self.pipes[LogQueue::Rewrite].rotate();
// self.file_system.trigger_recover();
// }
self.pipes[queue as usize].append(bytes)
}

Expand Down
6 changes: 0 additions & 6 deletions src/purge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ where

pub fn purge_expired_files(&self) -> Result<Vec<u64>> {
let _t = StopWatch::new(&*ENGINE_PURGE_DURATION_HISTOGRAM);
// Purge would delete files, whereas the files may be copied by recovery
// process, so do not purge when recovering.
// if self.file_system().is_in_recover() {
// info!("skip purge due to in recover");
// return Ok(vec![]);
// }
let guard = self.force_rewrite_candidates.try_lock();
if guard.is_none() {
warn!("Unable to purge expired files: locked");
Expand Down

0 comments on commit 58132d3

Please sign in to comment.