Skip to content

Commit 9c78090

Browse files
authored
Merge master to feature/host-network-device-ordering (#6479)
2 parents ce4de83 + 76929ca commit 9c78090

File tree

119 files changed

+2988
-834
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+2988
-834
lines changed

ocaml/database/block_device_io.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(* this file is empty on purpose: this is an executable file *)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
(*
2+
* Copyright (C) Cloud Software Group
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published
6+
* by the Free Software Foundation; version 2.1 only. with the special
7+
* exception on linking described in file LICENSE.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*)
14+
15+
val timeout_error_msg : string
16+
17+
val not_enough_space_error_msg : string
18+
19+
val not_initialised_error_msg : string

ocaml/database/database_server_main.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ let remote_database_access_handler_v2 req bio =
3333
flush stdout ;
3434
raise e
3535

36+
open Xapi_database
3637
module Local_tests =
37-
Xapi_database.Database_test.Tests (Xapi_database.Db_cache_impl)
38+
Database_test.Tests (Db_interface_compat.OfCached (Db_cache_impl))
3839

3940
let schema = Test_schemas.schema
4041

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(* this file is empty on purpose: this is an executable file *)

ocaml/database/database_test.ml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,13 @@ functor
205205
let db =
206206
db
207207
|> add_row "bar" "bar:1"
208-
(Row.add 0L Db_names.ref (String "bar:1")
208+
(Row.add 0L Db_names.ref
209+
(Schema.Value.string "bar:1")
209210
(Row.add 0L "foos" (Set []) Row.empty)
210211
)
211212
|> add_row "foo" "foo:1"
212-
(Row.add 0L Db_names.ref (String "foo:1")
213+
(Row.add 0L Db_names.ref
214+
(Schema.Value.string "foo:1")
213215
(Row.add 0L "bars" (Set []) Row.empty)
214216
)
215217
|> set_field "foo" "foo:1" "bars" (add_to_set "bar:1" (Set []))
@@ -219,7 +221,7 @@ functor
219221
Table.find "bar:1" (TableSet.find "bar" (Database.tableset db))
220222
in
221223
let bar_foos = Row.find "foos" bar_1 in
222-
if bar_foos <> Set ["foo:1"] then
224+
if bar_foos <> Schema.Value.set ["foo:1"] then
223225
failwith_fmt
224226
"check_many_to_many: bar(bar:1).foos expected ('foo:1') got %s"
225227
(Schema.Value.marshal bar_foos) ;
@@ -235,13 +237,13 @@ functor
235237
failwith_fmt "check_many_to_many: bar(bar:1).foos expected () got %s"
236238
(Schema.Value.marshal bar_foos) ;
237239
(* add 'bar' to foo.bars *)
238-
let db = set_field "foo" "foo:1" "bars" (Set ["bar:1"]) db in
240+
let db = set_field "foo" "foo:1" "bars" (Schema.Value.set ["bar:1"]) db in
239241
(* check that 'bar.foos' includes 'foo' *)
240242
let bar_1 =
241243
Table.find "bar:1" (TableSet.find "bar" (Database.tableset db))
242244
in
243245
let bar_foos = Row.find "foos" bar_1 in
244-
if bar_foos <> Set ["foo:1"] then
246+
if bar_foos <> Schema.Value.set ["foo:1"] then
245247
failwith_fmt
246248
"check_many_to_many: bar(bar:1).foos expected ('foo:1') got %s - 2"
247249
(Schema.Value.marshal bar_foos) ;
@@ -269,9 +271,9 @@ functor
269271
let row = Db_cache_types.Table.find r table in
270272
let s =
271273
Db_cache_types.Row.fold_over_recent g
272-
(fun k _ v acc ->
274+
(fun k _ cached acc ->
273275
Printf.sprintf "%s %s=%s" acc k
274-
(Schema.Value.marshal v)
276+
(Schema.CachedValue.string_of cached)
275277
)
276278
row ""
277279
in

ocaml/database/db_action_helper.ml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,5 @@ let __callback :
2020

2121
let events_register f = __callback := Some f
2222

23-
let events_unregister () = __callback := None
24-
2523
let events_notify ?snapshot ty op ref =
2624
match !__callback with None -> () | Some f -> f ?snapshot ty op ref
27-
28-
(*
29-
exception Db_set_or_map_parse_fail of string
30-
31-
let parse_sexpr s : SExpr.t list =
32-
match SExpr_TS.of_string s with
33-
| SExpr.Node xs -> xs
34-
| _ -> raise (Db_set_or_map_parse_fail s)
35-
*)

ocaml/database/db_action_helper.mli

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
(*
2+
* Copyright (C) Cloud Software Group
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published
6+
* by the Free Software Foundation; version 2.1 only. with the special
7+
* exception on linking described in file LICENSE.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*)
14+
15+
val events_register :
16+
(?snapshot:Rpc.t -> string -> string -> string -> unit) -> unit
17+
18+
val events_notify : ?snapshot:Rpc.t -> string -> string -> string -> unit

ocaml/database/db_backend.ml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ let db_FLUSH_TIMER = 2.0
2121

2222
(* --------------------- Util functions on db datastructures *)
2323

24-
let master_database = ref (Db_cache_types.Database.make Schema.empty)
24+
let master_database = Atomic.make (Db_cache_types.Database.make Schema.empty)
2525

26-
let __test_set_master_database db = master_database := db
26+
let __test_set_master_database db = Atomic.set master_database db
2727

28-
let make () = Db_ref.in_memory (ref master_database)
28+
let make () = Db_ref.in_memory master_database
2929

3030
(* !!! Right now this is called at cache population time. It would probably be preferable to call it on flush time instead, so we
3131
don't waste writes storing non-persistent field values on disk.. At the moment there's not much to worry about, since there are
@@ -43,7 +43,10 @@ let blow_away_non_persistent_fields (schema : Schema.t) db =
4343
let col = Schema.Table.find name schema in
4444
let empty = col.Schema.Column.empty in
4545
let v', modified' =
46-
if col.Schema.Column.persistent then (v, modified) else (empty, g)
46+
if col.Schema.Column.persistent then
47+
(Schema.CachedValue.value_of v, modified)
48+
else
49+
(empty, g)
4750
in
4851
( Row.update modified' name empty
4952
(fun _ -> v')

ocaml/database/db_cache.ml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,32 @@ module D = Debug.Make (struct let name = "db_cache" end)
1919
open D
2020

2121
(** Masters will use this to modify the in-memory cache directly *)
22-
module Local_db : DB_ACCESS = Db_cache_impl
22+
module Local_db : DB_ACCESS2 = Db_cache_impl
2323

2424
(** Slaves will use this to call the master by XMLRPC *)
25-
module Remote_db : DB_ACCESS = Db_rpc_client_v1.Make (struct
25+
module Remote_db : DB_ACCESS2 =
26+
Db_interface_compat.OfCompat (Db_rpc_client_v1.Make (struct
2627
let initialise () =
2728
ignore (Master_connection.start_master_connection_watchdog ()) ;
2829
ignore (Master_connection.open_secure_connection ())
2930

3031
let rpc request = Master_connection.execute_remote_fn request
31-
end)
32+
end))
3233

3334
let get = function
3435
| Db_ref.In_memory _ ->
35-
(module Local_db : DB_ACCESS)
36+
(module Local_db : DB_ACCESS2)
3637
| Db_ref.Remote ->
37-
(module Remote_db : DB_ACCESS)
38+
(module Remote_db : DB_ACCESS2)
3839

3940
let lifecycle_state_of ~obj fld =
4041
let open Datamodel in
4142
let {fld_states; _} = StringMap.find obj all_lifecycles in
4243
StringMap.find fld fld_states
4344

45+
module DB = Db_interface_compat.OfCached (Local_db)
46+
4447
let apply_delta_to_cache entry db_ref =
45-
let module DB : DB_ACCESS = Local_db in
4648
match entry with
4749
| Redo_log.CreateRow (tblname, objref, kvs) ->
4850
debug "Redoing create_row %s (%s)" tblname objref ;

ocaml/database/db_cache.mli

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
(*
2+
* Copyright (C) Cloud Software Group
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published
6+
* by the Free Software Foundation; version 2.1 only. with the special
7+
* exception on linking described in file LICENSE.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*)
14+
15+
val get : Db_ref.t -> (module Db_interface.DB_ACCESS2)
16+
17+
val apply_delta_to_cache : Redo_log.t -> Db_ref.t -> unit

0 commit comments

Comments
 (0)