Skip to content

Commit

Permalink
add last_updated field for proxy namespace stats (#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
domsj committed Aug 23, 2017
1 parent 0d2ce26 commit 4aa7a29
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ocaml/src/nsm_model.ml
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ module Manifest = struct
version_id : version;
max_disks_per_node : int;

timestamp : float;
timestamp : timestamp;
}
[@@deriving show, yojson]

Expand Down
32 changes: 24 additions & 8 deletions ocaml/src/proxy_protocol.ml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module ProxyStatistics = struct
end

type ns_t = {
mutable last_updated : timestamp;
mutable upload: stat;
mutable download: stat;
mutable delete : stat;
Expand All @@ -61,7 +62,8 @@ module ProxyStatistics = struct
}[@@ deriving show, yojson]

let ns_make () =
{ upload = Stat.make();
{ last_updated = Unix.gettimeofday ();
upload = Stat.make();
download = Stat.make();
delete = Stat.make();
manifest_cached = 0;
Expand Down Expand Up @@ -91,7 +93,9 @@ module ProxyStatistics = struct
Stat_deser.to_buffer' buf t.partial_read_time;
Stat_deser.to_buffer' buf t.partial_read_objects;

Stat_deser.to_buffer' buf t.delete
Stat_deser.to_buffer' buf t.delete;

Llio.float_to buf t.last_updated


let ns_from buf =
Expand Down Expand Up @@ -131,7 +135,15 @@ module ProxyStatistics = struct
else Stat_deser.from_buffer' buf
in

{ upload ; download; delete;
let last_updated =
Llio.maybe_from_buffer
Llio.float_from
0.
buf
in

{ last_updated;
upload ; download; delete;
manifest_cached;
manifest_from_nsm;
manifest_stale;
Expand Down Expand Up @@ -193,11 +205,15 @@ module ProxyStatistics = struct

let find t ns =
Hashtbl.replace t.changed_ns_stats ns ();
try H.find t.t.ns_stats ns
with Not_found ->
let v = ns_make () in
let () = t.t.ns_stats <- H.add t.t.ns_stats ns v in
v
let r =
try H.find t.t.ns_stats ns
with Not_found ->
let v = ns_make () in
let () = t.t.ns_stats <- H.add t.t.ns_stats ns v in
v
in
r.last_updated <- Unix.gettimeofday ();
r

let forget t nss =
let r =
Expand Down

0 comments on commit 4aa7a29

Please sign in to comment.