mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-30 23:01:13 +00:00
rrd: cache: add update_value_ignore_old
This function is the same as the regular `update_value`, but it sets the `new_only` flag when updating the value in the rrd map. This avoids "time in past" messages being logged in case a data point happens to be added twice. This new function will just silently reject values that have an older timestamp than the most recent one. Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
This commit is contained in:
parent
4ca2e01442
commit
f01c1e0ce9
@ -190,6 +190,32 @@ impl Cache {
|
|||||||
time: f64,
|
time: f64,
|
||||||
value: f64,
|
value: f64,
|
||||||
dst: DataSourceType,
|
dst: DataSourceType,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
self.update_value_impl(rel_path, time, value, dst, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Update data in RAM and write file back to disk (journal)
|
||||||
|
///
|
||||||
|
/// This method is equivalent to `update_value`, but it ignores
|
||||||
|
/// the call if `time` is older than any previously stored data point.
|
||||||
|
/// A journal entry will still be created, but then also ignored when applying.
|
||||||
|
pub fn update_value_ignore_old(
|
||||||
|
&self,
|
||||||
|
rel_path: &str,
|
||||||
|
time: f64,
|
||||||
|
value: f64,
|
||||||
|
dst: DataSourceType,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
self.update_value_impl(rel_path, time, value, dst, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update_value_impl(
|
||||||
|
&self,
|
||||||
|
rel_path: &str,
|
||||||
|
time: f64,
|
||||||
|
value: f64,
|
||||||
|
dst: DataSourceType,
|
||||||
|
new_only: bool,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let journal_applied = self.apply_journal()?;
|
let journal_applied = self.apply_journal()?;
|
||||||
|
|
||||||
@ -202,7 +228,7 @@ impl Cache {
|
|||||||
self.rrd_map
|
self.rrd_map
|
||||||
.write()
|
.write()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.update(rel_path, time, value, dst, false)?;
|
.update(rel_path, time, value, dst, new_only)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user