Skip to content

Commit

Permalink
CP-51693: feat(use-xmlrpc): [perf] use JSONRPC instead of XMLRPC for …
Browse files Browse the repository at this point in the history
…internal communication

Feature flag: use-xmlrpc

Signed-off-by: Edwin Török <[email protected]>
  • Loading branch information
edwintorok committed Nov 18, 2024
1 parent 3b3756f commit 8e92942
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ocaml/tests/common/mock_rpc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let rpc __context call =
Rpc.
{
success= true
; contents= contents |> Xmlrpc.to_string |> Xmlrpc.of_string
; contents= contents |> Jsonrpc.to_string |> Jsonrpc.of_string
; is_notification= false
}
| "VM.update_allowed_operations", [session_id_rpc; self_rpc] ->
Expand Down
10 changes: 8 additions & 2 deletions ocaml/xapi/helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,13 @@ let make_rpc ~__context rpc : Rpc.response =
let subtask_of = Ref.string_of (Context.get_task_id __context) in
let open Xmlrpc_client in
let tracing = Context.set_client_span __context in
let http = xmlrpc ~subtask_of ~version:"1.1" "/" ~tracing in
let dorpc, path =
if !Xapi_globs.use_xmlrpc then
(XMLRPC_protocol.rpc, "/")
else
(JSONRPC_protocol.rpc, "/jsonrpc")
in
let http = xmlrpc ~subtask_of ~version:"1.1" path ~tracing in
let transport =
if Pool_role.is_master () then
Unix Xapi_globs.unix_domain_socket
Expand All @@ -407,7 +413,7 @@ let make_rpc ~__context rpc : Rpc.response =
, !Constants.https_port
)
in
XMLRPC_protocol.rpc ~srcstr:"xapi" ~dststr:"xapi" ~transport ~http rpc
dorpc ~srcstr:"xapi" ~dststr:"xapi" ~transport ~http rpc

let make_timeboxed_rpc ~__context timeout rpc : Rpc.response =
let subtask_of = Ref.string_of (Context.get_task_id __context) in
Expand Down
7 changes: 7 additions & 0 deletions ocaml/xapi/xapi_globs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,8 @@ let max_spans = ref 10000

let max_traces = ref 10000

let use_xmlrpc = ref true

let compress_tracing_files = ref true

let prefer_nbd_attach = ref false
Expand Down Expand Up @@ -1436,6 +1438,11 @@ let other_options =
, (fun () -> string_of_bool !allow_host_sched_gran_modification)
, "Allows to modify the host's scheduler granularity"
)
; ( "use-xmlrpc"
, Arg.Set use_xmlrpc
, (fun () -> string_of_bool !use_xmlrpc)
, "Use XMLRPC (deprecated) for internal communication or JSONRPC"
)
; ( "extauth_ad_backend"
, Arg.Set_string extauth_ad_backend
, (fun () -> !extauth_ad_backend)
Expand Down

0 comments on commit 8e92942

Please sign in to comment.