Skip to content

Commit

Permalink
dumps more info
Browse files Browse the repository at this point in the history
  • Loading branch information
toolslive committed Jun 21, 2012
1 parent ed3082a commit b2ef41c
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/node/dump_store.ml
@@ -1,15 +1,39 @@
open Lwt
open Routing

let try_fetch name (f:unit -> 'a Lwt.t) (r2s: 'a -> string) =
Lwt.catch
(fun () ->
f () >>= fun r ->
let s = r2s r in
Lwt_io.printlf "%s: %s" name s
)
(function
| Not_found -> Lwt_io.printlf "%s : --" name
| e -> Lwt_io.printlf "%s : %s" name (Printexc.to_string e)
)

let _interval2s ((a,b), (c,d)) =
let so2s so = Log_extra.string_option2s so in
Printf.sprintf "(%s,%s) (%s,%s)" (so2s a) (so2s b) (so2s c) (so2s d)

let _dump_routing store = try_fetch "routing" (store # get_routing) Routing.to_s

let _dump_interval store = try_fetch "interval" (store # get_interval) _interval2s

let summary store =
store # consensus_i () >>= fun consensus_i ->
store # who_master () >>= fun mdo ->
Lwt_io.printlf "i:%s" (Log_extra.option2s Sn.string_of consensus_i) >>= fun () ->
Lwt_io.printlf "i: %s" (Log_extra.option2s Sn.string_of consensus_i) >>= fun () ->
let s =
match mdo with
| None -> "None"
| Some (m,e) -> Printf.sprintf "Some(%s,%s)" m (Sn.string_of e)
in
Lwt_io.printlf "master:%s" s
Lwt_io.printlf "master: %s" s
>>= fun () ->
_dump_routing store >>= fun () ->
_dump_interval store

let dump_store filename =
let t () =
Expand Down

0 comments on commit b2ef41c

Please sign in to comment.