Commit ee10b8e4 authored by Fardale's avatar Fardale

more info with jobq

parent 23e858d6
......@@ -8,57 +8,88 @@ let cmd id delete addr port pass () =
Lwt_io.write_line oc
(Serialization_j.string_of_query (pass, `JOBQ (id, delete)))
>>= fun () ->
Lwt_io.read_line ic
>>= fun json ->
Lwt_io.read_line ic >>= fun json ->
match
CCResult.guard (fun () -> Serialization_j.answer_of_string json)
with
| Ok answer -> (
match answer with
| `Ok ->
Logs_lwt.info (fun m -> m "Jobq query successfully sent.")
>>= fun () ->
if not delete then
Lwt_io.read_line ic
>>= fun json ->
let open PrintBox in
match
CCResult.guard (fun () ->
Serialization_j.query_data_of_string json)
with
| Ok (`JOBS jobs) ->
Array.of_list jobs
|> fun jobs ->
Array.init
(Array.length jobs + 1)
(fun i ->
if i = 0 then
[| text "ID"
; text "Name"
; text "Iteration(current)"
; text "ARG" |]
else
[| sprintf "%i" jobs.(i - 1).id
; text jobs.(i - 1).name
; sprintf "%i(%i)" jobs.(i - 1).iteration
jobs.(i - 1).current
; text (String.concat " " jobs.(i - 1).args) |])
|> grid |> frame
|> PrintBox_text.output stdout ;
Format.printf "@." ;
Lwt.return_unit
| Ok q ->
Logs_lwt.err (fun m ->
m "Error received the wrong answer: %s"
(Serialization_j.string_of_query_data q))
| Error e ->
Logs_lwt.err (fun m ->
m "Error during the reception of the answer: %s"
(Printexc.to_string e))
else Lwt.return_unit
| `Error s ->
Logs_lwt.err (fun m ->
m "Error during the reception of the jobq query: %s" s) )
match answer with
| `Ok ->
Logs_lwt.info (fun m -> m "Jobq query successfully sent.")
>>= fun () ->
if not delete then
Lwt_io.read_line ic >>= fun json ->
let open PrintBox in
match
CCResult.guard (fun () ->
Serialization_j.query_data_of_string json)
with
| Ok (`JOBS (jobs, running)) ->
let b_jobs =
Array.of_list jobs |> fun jobs ->
Array.init
(Array.length jobs + 1)
(fun i ->
if i = 0 then
[|
text "ID";
text "Name";
text "Iteration(current)";
text "ARG";
|]
else
[|
sprintf "%i" jobs.(i - 1).id;
text jobs.(i - 1).name;
sprintf "%i(%i)" jobs.(i - 1).iteration
jobs.(i - 1).current;
text (String.concat " " jobs.(i - 1).args);
|])
|> grid |> frame
in
let b_running =
Array.of_list running |> fun running ->
Array.init
(Array.length running + 1)
(fun i ->
if i = 0 then [| text "Server"; text "Computations" |]
else
let ip, computations = running.(i - 1) in
[|
sprintf "%s" ip;
( Array.of_list computations |> fun computations ->
Array.init
(Array.length computations + 1)
(fun i ->
if i = 0 then [| text "ID"; text "ARG" |]
else
[|
sprintf "%i, %i"
(fst computations.(i - 1).id)
(snd computations.(i - 1).id);
text
(String.concat " "
computations.(i - 1).args);
|])
|> grid );
|])
|> grid |> frame
in
Format.printf "Jobq:@,%a@.@.Running:@,%a@." PrintBox_text.pp
b_jobs PrintBox_text.pp b_running;
Lwt.return_unit
| Ok q ->
Logs_lwt.err (fun m ->
m "Error received the wrong answer: %s"
(Serialization_j.string_of_query_data q))
| Error e ->
Logs_lwt.err (fun m ->
m "Error during the reception of the answer: %s"
(Printexc.to_string e))
else Lwt.return_unit
| `Error s ->
Logs_lwt.err (fun m ->
m "Error during the reception of the jobq query: %s" s) )
| Error e ->
Logs_lwt.err (fun m ->
m "Error during the reception of the answer: %s"
......
......@@ -235,8 +235,22 @@ let server_handler pass port sockaddr (ic, oc) =
CCDeque.(
filter (fun (j : job) -> j.id = id) jobs |> to_list)
in
let running_list =
SHashtbl.to_list nodes
|>
match id with
| None ->
List.map (fun (ip, (_, computations)) -> (ip, computations))
| Some id ->
List.map (fun (ip, (_, computations)) ->
( ip,
List.filter_map
(fun c -> if fst c.id = id then Some c else None)
computations ))
in
Lwt_io.write_line oc
(Serialization_j.string_of_query_data (`JOBS jobs_list))
(Serialization_j.string_of_query_data
(`JOBS (jobs_list, running_list)))
>>= fun () -> Lwt_io.flush oc
| _ ->
Lwt_io.write_line oc
......
......@@ -16,7 +16,8 @@ type result =
{id: (int * int); stdout: string; stderr: string; ret_code: ret_code}
type query_data = [ COMPUTATION of computation | JOBQ of (int option * bool)
| RESULT of result | JOB of submission | JOBS of (job list)
| RESULT of result | JOB of submission
| JOBS of (job list * (string * computation list) list)
| STAT ]
type stat = (int * int)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment