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 01 of 11] CA-35165: Clean up xapi startup log messages,

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH 01 of 11] CA-35165: Clean up xapi startup log messages, particularly those to do with the 'localdb'
From: David Scott <dave.scott@xxxxxxxxxxxxx>
Date: Mon, 30 Nov 2009 15:40:53 +0000
Delivery-date: Mon, 30 Nov 2009 07:40:01 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1259595652@xxxxxxxxxxxxxxxxxxxx>
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 David Scott <dave.scott@xxxxxxxxxxxxx>
# Date 1259595420 0
# Node ID 019aa574738a5b334ae20c313c2a640570162569
# Parent  a64d476f8d96662d660837a81435d142cbdc9a6a
CA-35165: Clean up xapi startup log messages, particularly those to do with the 
'localdb'.

Add a Localdb.get_with_default [key] [default] function as an alternative to 
the exception-throwing Localdb.get.

Signed-off-by: David Scott <dave.scott@xxxxxxxxxxxxx>

diff -r a64d476f8d96 -r 019aa574738a ocaml/xapi/localdb.ml
--- a/ocaml/xapi/localdb.ml     Mon Nov 30 15:36:58 2009 +0000
+++ b/ocaml/xapi/localdb.ml     Mon Nov 30 15:37:00 2009 +0000
@@ -37,7 +37,7 @@
       finally 
        (fun () -> of_db (Xmlm.make_input (`Channel ic)); loaded := true)
        (fun () -> close_in ic);
-      Hashtbl.iter (fun k v -> debug "loaded %s -> %s" k v) db
+      Hashtbl.iter (fun k v -> debug "%s = %s" k v) db
     with 
       | Unix.Unix_error (Unix.ENOENT, _, _) ->
          debug "Local database %s doesn't currently exist. Continuing." 
Xapi_globs.local_database
@@ -61,6 +61,11 @@
         Hashtbl.find db key
        with Not_found -> raise (Missing_key key)
     )
+
+let get_with_default (key: string) (default: string) = 
+  try
+       get key
+  with Missing_key _ -> default
 
 (* Returns true if a change was made and should be flushed *)
 let put_one (key: string) (v: string) = 
diff -r a64d476f8d96 -r 019aa574738a ocaml/xapi/localdb.mli
--- a/ocaml/xapi/localdb.mli    Mon Nov 30 15:36:58 2009 +0000
+++ b/ocaml/xapi/localdb.mli    Mon Nov 30 15:37:00 2009 +0000
@@ -21,6 +21,10 @@
 (** Retrieves a value *)
 val get: string -> string
 
+(** [get_with_default key default] returns the value associated with [key], 
+       or [default] if the key is missing. *)
+val get_with_default: string -> string -> string
+
 (** Inserts a value into the database, only returns when the insertion has
     been persisted. *)
 val put: string -> string -> unit
diff -r a64d476f8d96 -r 019aa574738a ocaml/xapi/xapi.ml
--- a/ocaml/xapi/xapi.ml        Mon Nov 30 15:36:58 2009 +0000
+++ b/ocaml/xapi/xapi.ml        Mon Nov 30 15:37:00 2009 +0000
@@ -322,11 +322,11 @@
 (* Make sure the local database can be read *)
 let init_local_database () =
   (try
-     let enabled = Localdb.get Constants.ha_armed in
-     debug "%s = %s" Constants.ha_armed enabled;
+     let (_: string) = Localdb.get Constants.ha_armed in
+        ()
    with Localdb.Missing_key _ ->
      Localdb.put Constants.ha_armed "false";
-     debug "Missing %s key, assuming 'false'" Constants.ha_armed);
+     debug "%s = 'false' (by default)" Constants.ha_armed);
   (* Add the local session check hook *)
   Session_check.check_local_session_hook := Some 
(Xapi_local_session.local_session_hook);
   (* Resynchronise the master_scripts flag if this is the first start since 
system boot *)
@@ -420,7 +420,7 @@
 let start_redo_log () =
   try
     if Pool_role.is_master () &&
-               bool_of_string (Localdb.get Constants.redo_log_enabled) && 
+               bool_of_string (Localdb.get_with_default 
Constants.redo_log_enabled "false") && 
          not (bool_of_string (Localdb.get Constants.ha_armed)) then
     begin
       debug "Redo log was enabled when shutting down, so restarting it";
3 files changed, 14 insertions(+), 5 deletions(-)
ocaml/xapi/localdb.ml  |    7 ++++++-
ocaml/xapi/localdb.mli |    4 ++++
ocaml/xapi/xapi.ml     |    8 ++++----


Attachment: xen-api.hg-11.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>