WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH] Split Xapi_periodic_scheduler into two parts

To: xen-api <xen-api@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-API] [PATCH] Split Xapi_periodic_scheduler into two parts
From: Rob Hoes <rob.hoes@xxxxxxxxxx>
Date: Tue, 8 Dec 2009 14:24:36 +0000
Delivery-date: Tue, 08 Dec 2009 06:24:36 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Rob Hoes <rob.hoes@xxxxxxxxxx>
Split Xapi_periodic_scheduler into two parts

...to resolve cyclic dependencies. Placed the register function into a separate 
module, as this function depends on various other modules.
Also added ocamldoc comments.

Signed-off-by: Rob Hoes <rob.hoes@xxxxxxxxxx>

diff -r f0f5f84ef6d9 ocaml/xapi/OMakefile
--- a/ocaml/xapi/OMakefile      Mon Dec 07 15:17:02 2009 +0000
+++ b/ocaml/xapi/OMakefile      Tue Dec 08 10:04:59 2009 +0000
@@ -176,6 +176,7 @@
        cli_printer \
        ipq \
        xapi_periodic_scheduler \
+       xapi_periodic_scheduler_init \
        dbsync \
        dbsync_slave \
        dbsync_master \
diff -r f0f5f84ef6d9 ocaml/xapi/xapi.ml
--- a/ocaml/xapi/xapi.ml        Mon Dec 07 15:17:02 2009 +0000
+++ b/ocaml/xapi/xapi.ml        Tue Dec 08 10:04:59 2009 +0000
@@ -829,7 +829,7 @@
       "touching ready file", [], (fun () -> Helpers.touch_file 
!Xapi_globs.ready_file);
        (* -- CRITICAL: this check must be performed before touching shared 
storage *)
       "Performing no-other-masters check", [ Startup.OnlyMaster ], 
check_no_other_masters;
-      "Registering periodic functions", [], Xapi_periodic_scheduler.register;
+      "Registering periodic functions", [], 
Xapi_periodic_scheduler_init.register;
       "executing startup scripts", [ Startup.NoExnRaising], startup_script;
 
       "considering executing on-master-start script", [],
diff -r f0f5f84ef6d9 ocaml/xapi/xapi_periodic_scheduler.ml
--- a/ocaml/xapi/xapi_periodic_scheduler.ml     Mon Dec 07 15:17:02 2009 +0000
+++ b/ocaml/xapi/xapi_periodic_scheduler.ml     Tue Dec 08 10:04:59 2009 +0000
@@ -11,7 +11,6 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU Lesser General Public License for more details.
  *)
-(* Periodic scheduler - for background tasks *)
 
 module D = Debug.Debugger(struct let name="backgroundscheduler" end)
 open D
@@ -63,85 +62,4 @@
       with _ -> ()
     done
 
-let register () =
-  debug "Registering periodic calls";
 
-  let master = Pool_role.is_master () in
-  
-  (* blob/message/rrd file syncing - sync once a day *)
-  let sync_timer = 
-    if Xapi_fist.reduce_blob_sync_interval then 60.0 *. 5.0 else 60.0 *. 60.0 
*. 24.0 in
-  let sync_func () =
-    Xapi_sync.do_sync () in
-  let sync_delay =
-  (* 10 mins if fist point there - to ensure rrd sync happens first *)
-    if Xapi_fist.reduce_blob_sync_interval then 60.0 *. 10.0 else 7200.0 in
-
-  (* Logrotate - poll the amount of data written out by the logger, *)
-  (* and call logrotate when it exceeds the threshold *) 
-  let logrotate_timer = 60.0 *. 5.0 in
-  let logrotate_func () =
-    let dorotate = Mutex.execute Log.mutex 
-      (fun () ->
-       if !Log.filesize > !Xapi_globs.logrot_max then
-         (Log.filesize := 0; true)
-       else 
-         false)
-    in
-    if dorotate 
-    then 
-      try
-       info "xapi about to invoke logrotate";
-       let stdout, stderr = Forkhelpers.execute_command_get_output 
Xapi_globs.logrot_cmd Xapi_globs.logrot_arg in
-       info "Logrotate executed: stdout='%s' stderr='%s'" stdout stderr
-      with Forkhelpers.Spawn_internal_error(log,output,err) ->
-       error "Logrotate executed with error code: stdout='%s' stderr='%s'" 
output log;
-       ()      
-  in
-  
-  (* Network bridge GC *)
-  let networkgc_timer = 60.0 *. 60.0 *. 1.5 in (* hour and a half *)
-  let networkgc_func () = Xapi_network.network_gc_func () in
-
-  (* Heartbeat to show the queue is still running - will be more useful when 
there's less logging! *)
-  let hb_timer = 3600.0 in (* one hour *)
-  let hb_func () = debug "Periodic scheduler heartbeat" in
-
-  (* Periodic backup of RRDs *)
-  let rrdbackup_timer = 
-    if Xapi_fist.reduce_rrd_backup_interval then 60.0 *. 5.0 else 3600.0 *. 
24.0 in
-  let rrdbackup_func () =
-    Server_helpers.exec_with_new_task "rrdbackup_func"
-      (fun __context ->
-       let hosts = Db.Host.get_all ~__context in
-       Helpers.call_api_functions ~__context 
-         (fun rpc session_id -> 
-           ignore(List.fold_left (fun delay host -> 
Client.Client.Host.backup_rrds rpc session_id host delay; (delay +. 60.0)) 0.0 
hosts)))
-  in
-  let rrdbackup_delay = 
-    if Xapi_fist.reduce_rrd_backup_interval then 60.0 *. 6.0 else 3600.0 in
-
-  (* CP-703: Periodic revalidation of externally-authenticated sessions *)
-  let session_revalidation_timer = 60.0 *. 5.0 in (* every 5 minutes *)
-  let session_revalidation_func () =
-    Server_helpers.exec_with_new_task "session_revalidation_func"
-      (fun __context -> Xapi_session.revalidate_all_sessions ~__context) in
-  let session_revalidation_delay = 60.0 *. 5.0 in (* initial delay = 5 minutes 
*)
-
-  (* CP-820: other-config field in subjects should be periodically refreshed *)
-  let update_all_subjects_timer = 60.0 *. 15.0 in (* every 15 minutes *)
-  let update_all_subjects_func () =
-    Server_helpers.exec_with_new_task "update_all_subjects_func"
-      (fun __context -> Xapi_subject.update_all_subjects ~__context) in
-  let update_all_subjects_delay = 60.0 *. 15.0 in (* initial delay = 15 
minutes *)
-
-  if master then add_to_queue "Synchronising RRDs/messages" (Periodic 
sync_timer) sync_delay sync_func;
-  if master then add_to_queue "Backing up RRDs" (Periodic rrdbackup_timer) 
rrdbackup_delay rrdbackup_func;
-  if master then add_to_queue "Revalidating externally-authenticated sessions" 
-    (Periodic session_revalidation_timer) session_revalidation_delay 
session_revalidation_func;
-  if master then add_to_queue "Trying to update subjects' info using external 
directory service (if any)" 
-    (Periodic update_all_subjects_timer) update_all_subjects_delay 
update_all_subjects_func;
-  add_to_queue "Logrotate" (Periodic logrotate_timer) 120.0 logrotate_func;
-  add_to_queue "Network bridge GC" (Periodic networkgc_timer) networkgc_timer 
networkgc_func;
-  add_to_queue "Periodic scheduler heartbeat" (Periodic hb_timer) 240.0 
hb_func;
-
diff -r f0f5f84ef6d9 ocaml/xapi/xapi_periodic_scheduler.mli
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/ocaml/xapi/xapi_periodic_scheduler.mli    Tue Dec 08 10:04:59 2009 +0000
@@ -0,0 +1,27 @@
+(*
+ * Copyright (C) 2006-2009 Citrix Systems Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *)
+(** Periodic scheduler for background tasks. *)
+
+(** Timer type. *)
+type func_ty =
+| OneShot                              (** Fire just once *)
+| Periodic of float            (** Fire periodically with a given period in 
seconds *)
+
+(** Start a new timer. *)
+val add_to_queue :
+  ?signal:bool -> string -> func_ty -> float -> (unit -> unit) -> unit
+
+(** The scheduler's main loop, started by {!Xapi} on start-up. *)
+val loop : unit -> unit
+
diff -r f0f5f84ef6d9 ocaml/xapi/xapi_periodic_scheduler_init.mli
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/ocaml/xapi/xapi_periodic_scheduler_init.mli       Tue Dec 08 10:04:59 
2009 +0000
@@ -0,0 +1,17 @@
+(*
+ * Copyright (C) 2006-2009 Citrix Systems Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *)
+(** Schedule common background tasks. *)
+
+(** Register periodic calls, done by {!Xapi} on start-up. *)
+val register : unit -> unit

Attachment: periodic-scheduler
Description: Text document

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-API] [PATCH] Split Xapi_periodic_scheduler into two parts, Rob Hoes <=