Skip to content

Commit

Permalink
rrdd: add more comments about its datastructures
Browse files Browse the repository at this point in the history
Signed-off-by: Pau Ruiz Safont <[email protected]>
  • Loading branch information
psafont committed Dec 23, 2024
1 parent 74fe427 commit e4e20ad
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
6 changes: 3 additions & 3 deletions ocaml/libs/xapi-rrd/lib/rrd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,9 @@ let rrd_add_ds_unsafe rrd timestamp newds =
rrd.rrd_rras
}

(** Add in a new DS into a pre-existing RRD. Preserves data of all the other archives
and fills the new one full of NaNs. Note that this doesn't fill in the CDP values
correctly at the moment!
(** Add in a new DS into a pre-existing RRD. Preserves data of all the other
archives and fills the new one full of NaNs. Note that this doesn't fill
in the CDP values correctly at the moment!
*)

let rrd_add_ds rrd timestamp newds =
Expand Down
10 changes: 5 additions & 5 deletions ocaml/xcp-rrdd/bin/rrdd/rrdd_monitor.ml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ let merge_new_dss rrdi dss =
!Rrdd_shared.enable_all_dss || ds.ds_default
in
let default_dss = StringMap.filter should_enable_ds dss in
(* NOTE: It's enough to check if all the default datasources have been added
to the RRD_INFO, because if a non-default one has been enabled at runtime,
it's added to the RRD immediately and we don't need to bother *)
let new_dss =
(* NOTE: Only add enabled dss to the live rrd, ignoring non-default ones.
This is because non-default ones are added to the RRD when they are
enabled. *)
let new_enabled_dss =
StringMap.filter
(fun ds_name _ -> not (StringMap.mem ds_name rrdi.dss))
default_dss
Expand All @@ -73,7 +73,7 @@ let merge_new_dss rrdi dss =
rrd_add_ds_unsafe rrd timestamp
(Rrd.ds_create ds.ds_name ds.Ds.ds_type ~mrhb:300.0 Rrd.VT_Unknown)
)
new_dss rrdi.rrd
new_enabled_dss rrdi.rrd
)

module OwnerMap = Map.Make (struct
Expand Down
2 changes: 1 addition & 1 deletion ocaml/xcp-rrdd/bin/rrdd/rrdd_server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ let send_host_rrd_to_master master_address =
let fail_missing name = raise (Rrdd_error (Datasource_missing name))

(** {add_ds rrdi ds_name} creates a new time series (rrd) in {rrdi} with the
name {ds_name}. The operation fails if rrdi does not contain any live
name {ds_name}. The operation fails if rrdi does not contain any
datasource with the name {ds_name} *)
let add_ds ~rrdi ~ds_name =
match Rrd.StringMap.find_opt ds_name rrdi.dss with
Expand Down
9 changes: 6 additions & 3 deletions ocaml/xcp-rrdd/bin/rrdd/rrdd_shared.ml
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,13 @@ let mutex = Mutex.create ()

type rrd_info = {
rrd: Rrd.rrd
(** Contains the live metrics, i.e. The datasources that are enabled
and being collected .*)
; mutable dss: (float * Ds.ds) Rrd.StringMap.t
(* Important: this must contain the entire list of datasources associated
with the RRD, even the ones disabled by default, as rrd_add_ds calls
can enable DSs at runtime *)
(** Important: this must contain the entire list of datasources
associated with the RRD, even the ones disabled by default, because
functions like rrd_add_ds or rrd_remove_ds expect disabled
datasources to be present. e.g. to enable DSs at runtime *)
; mutable domid: int
}

Expand Down

0 comments on commit e4e20ad

Please sign in to comment.