Permalink
Browse files

Add timing stats to Cancel_tasks.update_all_allowed_operations

Signed-off-by: John Else <john.else@citrix.com>
  • Loading branch information...
johnelse authored and jonludlam committed Sep 20, 2012
1 parent 3569d51 commit ef7819c4b08fee94a48c2dc1485aaef5e8381645
Showing with 30 additions and 24 deletions.
  1. +30 −24 ocaml/xapi/cancel_tasks.ml
View
@@ -24,37 +24,43 @@ let safe_wrapper n f x =
log_backtrace () log_backtrace ()
let update_all_allowed_operations ~__context = let update_all_allowed_operations ~__context =
let open Stats in
let all_vms = Db.VM.get_all ~__context let all_vms = Db.VM.get_all ~__context
and all_vbds = Db.VBD.get_all ~__context and all_vbds = Db.VBD.get_all ~__context
and all_vifs = Db.VIF.get_all ~__context and all_vifs = Db.VIF.get_all ~__context
and all_vdis = Db.VDI.get_all ~__context and all_vdis = Db.VDI.get_all ~__context
and all_srs = Db.SR.get_all ~__context and all_srs = Db.SR.get_all ~__context
and all_pbds = Db.PBD.get_all ~__context and all_pbds = Db.PBD.get_all ~__context
and all_hosts = Db.Host.get_all ~__context in and all_hosts = Db.Host.get_all ~__context in
debug "Updating allowed operations: VM"; time_this "Cancel_tasks.update_all_allowed_operations: VM" (fun () ->
List.iter (safe_wrapper "allowed_ops - VMs" (fun self -> Xapi_vm_lifecycle.update_allowed_operations ~__context ~self)) all_vms; debug "Updating allowed operations: VM";
debug "Finished updating allowed operations: VM"; List.iter (safe_wrapper "allowed_ops - VMs" (fun self -> Xapi_vm_lifecycle.update_allowed_operations ~__context ~self)) all_vms;
debug "Updating allowed operations: VBD"; debug "Finished updating allowed operations: VM");
List.iter (safe_wrapper "allowed_ops - VBDs" (fun self -> Xapi_vbd_helpers.update_allowed_operations ~__context ~self)) all_vbds; time_this "Cancel_tasks.update_all_allowed_operations: VBD" (fun () ->
debug "Finished updating allowed operations: VBD"; debug "Updating allowed operations: VBD";
debug "Updating allowed operations: VIF"; List.iter (safe_wrapper "allowed_ops - VBDs" (fun self -> Xapi_vbd_helpers.update_allowed_operations ~__context ~self)) all_vbds;
List.iter (safe_wrapper "allowed_ops - VIFs" (fun self -> Xapi_vif_helpers.update_allowed_operations ~__context ~self)) all_vifs; debug "Finished updating allowed operations: VBD");
debug "Finished updating allowed operations: VIF"; time_this "Cancel_tasks.update_all_allowed_operations: VIF" (fun () ->
debug "Updating allowed operations: VDI"; debug "Updating allowed operations: VIF";
let sr_records = List.map (fun sr -> (sr, Db.SR.get_record_internal ~__context ~self:sr)) all_srs in List.iter (safe_wrapper "allowed_ops - VIFs" (fun self -> Xapi_vif_helpers.update_allowed_operations ~__context ~self)) all_vifs;
let pbd_records = List.map (fun pbd -> (pbd, Db.PBD.get_record ~__context ~self:pbd)) all_pbds in debug "Finished updating allowed operations: VIF");
let vbd_records = List.map (fun vbd -> (vbd, Db.VBD.get_record_internal ~__context ~self:vbd)) all_vbds in time_this "Cancel_tasks.update_all_allowed_operations: VDI" (fun () ->
List.iter (safe_wrapper "allowed_ops - VDIs" debug "Updating allowed operations: VDI";
(fun self -> Xapi_vdi.update_allowed_operations_internal ~__context ~self ~sr_records ~pbd_records ~vbd_records)) all_vdis; let sr_records = List.map (fun sr -> (sr, Db.SR.get_record_internal ~__context ~self:sr)) all_srs in
debug "Finished updating allowed operations: VDI"; let pbd_records = List.map (fun pbd -> (pbd, Db.PBD.get_record ~__context ~self:pbd)) all_pbds in
debug "Updating allowed operations: SR"; let vbd_records = List.map (fun vbd -> (vbd, Db.VBD.get_record_internal ~__context ~self:vbd)) all_vbds in
List.iter (safe_wrapper "allowed_ops" (fun self -> List.iter (safe_wrapper "allowed_ops - VDIs"
Db.SR.set_current_operations ~__context ~self ~value:[]; (fun self -> Xapi_vdi.update_allowed_operations_internal ~__context ~self ~sr_records ~pbd_records ~vbd_records)) all_vdis;
Xapi_sr.update_allowed_operations ~__context ~self)) all_srs; debug "Finished updating allowed operations: VDI");
debug "Finished updating allowed operations: SR"; time_this "Cancel_tasks.update_all_allowed_operations: SR" (fun () ->
debug "Updating allowed operations: host"; debug "Updating allowed operations: SR";
List.iter (safe_wrapper "allowed_ops - host" (fun self -> Xapi_host_helpers.update_allowed_operations ~__context ~self)) all_hosts; List.iter (safe_wrapper "allowed_ops" (fun self ->
debug "Finished updating allowed operations: host" Db.SR.set_current_operations ~__context ~self ~value:[];
Xapi_sr.update_allowed_operations ~__context ~self)) all_srs;
debug "Finished updating allowed operations: SR";
debug "Updating allowed operations: host";
List.iter (safe_wrapper "allowed_ops - host" (fun self -> Xapi_host_helpers.update_allowed_operations ~__context ~self)) all_hosts;
debug "Finished updating allowed operations: host")
(* !!! This code was written in a world when tasks, current_operations and allowed_operations were persistent. (* !!! This code was written in a world when tasks, current_operations and allowed_operations were persistent.
This is no longer the case (we changed this to reduce writes to flash for OEM case + to simplify xapi logic elsewhere). This is no longer the case (we changed this to reduce writes to flash for OEM case + to simplify xapi logic elsewhere).

0 comments on commit ef7819c

Please sign in to comment.