proxmox-rrd: rename RRDCacheState to JournalState
This commit is contained in:
parent
fce7cd0d36
commit
a291ab59ba
@ -24,7 +24,7 @@ pub struct RRDCache {
|
|||||||
apply_interval: f64,
|
apply_interval: f64,
|
||||||
basedir: PathBuf,
|
basedir: PathBuf,
|
||||||
file_options: CreateOptions,
|
file_options: CreateOptions,
|
||||||
state: RwLock<RRDCacheState>,
|
state: RwLock<JournalState>,
|
||||||
rrd_map: RwLock<RRDMap>,
|
rrd_map: RwLock<RRDMap>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ impl RRDMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// shared state behind RwLock
|
// shared state behind RwLock
|
||||||
struct RRDCacheState {
|
struct JournalState {
|
||||||
journal: File,
|
journal: File,
|
||||||
last_journal_flush: f64,
|
last_journal_flush: f64,
|
||||||
journal_applied: bool,
|
journal_applied: bool,
|
||||||
@ -155,7 +155,7 @@ impl RRDCache {
|
|||||||
let flags = OFlag::O_CLOEXEC|OFlag::O_WRONLY|OFlag::O_APPEND;
|
let flags = OFlag::O_CLOEXEC|OFlag::O_WRONLY|OFlag::O_APPEND;
|
||||||
let journal = atomic_open_or_create_file(&journal_path, flags, &[], file_options.clone())?;
|
let journal = atomic_open_or_create_file(&journal_path, flags, &[], file_options.clone())?;
|
||||||
|
|
||||||
let state = RRDCacheState {
|
let state = JournalState {
|
||||||
journal,
|
journal,
|
||||||
last_journal_flush: 0.0,
|
last_journal_flush: 0.0,
|
||||||
journal_applied: false,
|
journal_applied: false,
|
||||||
@ -243,7 +243,7 @@ impl RRDCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn append_journal_entry(
|
fn append_journal_entry(
|
||||||
state: &mut RRDCacheState,
|
state: &mut JournalState,
|
||||||
time: f64,
|
time: f64,
|
||||||
value: f64,
|
value: f64,
|
||||||
dst: DST,
|
dst: DST,
|
||||||
@ -260,7 +260,7 @@ impl RRDCache {
|
|||||||
self.apply_and_commit_journal_locked(&mut state)
|
self.apply_and_commit_journal_locked(&mut state)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_and_commit_journal_locked(&self, state: &mut RRDCacheState) -> Result<(), Error> {
|
fn apply_and_commit_journal_locked(&self, state: &mut JournalState) -> Result<(), Error> {
|
||||||
|
|
||||||
state.last_journal_flush = proxmox_time::epoch_f64();
|
state.last_journal_flush = proxmox_time::epoch_f64();
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ impl RRDCache {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_journal_locked(&self, state: &mut RRDCacheState) -> Result<usize, Error> {
|
fn apply_journal_locked(&self, state: &mut JournalState) -> Result<usize, Error> {
|
||||||
|
|
||||||
let mut journal_path = self.basedir.clone();
|
let mut journal_path = self.basedir.clone();
|
||||||
journal_path.push(RRD_JOURNAL_NAME);
|
journal_path.push(RRD_JOURNAL_NAME);
|
||||||
@ -327,7 +327,7 @@ impl RRDCache {
|
|||||||
Ok(linenr)
|
Ok(linenr)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn commit_journal_locked(&self, state: &mut RRDCacheState) -> Result<usize, Error> {
|
fn commit_journal_locked(&self, state: &mut JournalState) -> Result<usize, Error> {
|
||||||
|
|
||||||
// save all RRDs - we only need a read lock here
|
// save all RRDs - we only need a read lock here
|
||||||
let rrd_file_count = self.rrd_map.read().unwrap().flush_rrd_files()?;
|
let rrd_file_count = self.rrd_map.read().unwrap().flush_rrd_files()?;
|
||||||
|
Loading…
Reference in New Issue
Block a user