Skip to content

Commit e4e20ad

Browse files
committed
rrdd: add more comments about its datastructures
Signed-off-by: Pau Ruiz Safont <[email protected]>
1 parent 74fe427 commit e4e20ad

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

ocaml/libs/xapi-rrd/lib/rrd.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,9 +621,9 @@ let rrd_add_ds_unsafe rrd timestamp newds =
621621
rrd.rrd_rras
622622
}
623623

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

629629
let rrd_add_ds rrd timestamp newds =

ocaml/xcp-rrdd/bin/rrdd/rrdd_monitor.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ let merge_new_dss rrdi dss =
5151
!Rrdd_shared.enable_all_dss || ds.ds_default
5252
in
5353
let default_dss = StringMap.filter should_enable_ds dss in
54-
(* NOTE: It's enough to check if all the default datasources have been added
55-
to the RRD_INFO, because if a non-default one has been enabled at runtime,
56-
it's added to the RRD immediately and we don't need to bother *)
57-
let new_dss =
54+
(* NOTE: Only add enabled dss to the live rrd, ignoring non-default ones.
55+
This is because non-default ones are added to the RRD when they are
56+
enabled. *)
57+
let new_enabled_dss =
5858
StringMap.filter
5959
(fun ds_name _ -> not (StringMap.mem ds_name rrdi.dss))
6060
default_dss
@@ -73,7 +73,7 @@ let merge_new_dss rrdi dss =
7373
rrd_add_ds_unsafe rrd timestamp
7474
(Rrd.ds_create ds.ds_name ds.Ds.ds_type ~mrhb:300.0 Rrd.VT_Unknown)
7575
)
76-
new_dss rrdi.rrd
76+
new_enabled_dss rrdi.rrd
7777
)
7878

7979
module OwnerMap = Map.Make (struct

ocaml/xcp-rrdd/bin/rrdd/rrdd_server.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ let send_host_rrd_to_master master_address =
347347
let fail_missing name = raise (Rrdd_error (Datasource_missing name))
348348

349349
(** {add_ds rrdi ds_name} creates a new time series (rrd) in {rrdi} with the
350-
name {ds_name}. The operation fails if rrdi does not contain any live
350+
name {ds_name}. The operation fails if rrdi does not contain any
351351
datasource with the name {ds_name} *)
352352
let add_ds ~rrdi ~ds_name =
353353
match Rrd.StringMap.find_opt ds_name rrdi.dss with

ocaml/xcp-rrdd/bin/rrdd/rrdd_shared.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,13 @@ let mutex = Mutex.create ()
7777

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

0 commit comments

Comments
 (0)