Commit e8d750e4 authored by Fardale's avatar Fardale

use write_line and read_line to send and receive data

By doing this node and server will be able to acknowledge the good
reception of the data and if not communication can be repeat.
parent 2fdfa7d3
......@@ -6,4 +6,4 @@ let cmd cpu ram time iteration port script_file pass addr =
Lwt_io.with_connection
(Lwt_unix.ADDR_INET (Unix.inet_addr_of_string addr, port))
(fun (_ic, oc) ->
Lwt_io.write oc (Serialization_j.string_of_query (`JOB submission)) )
Lwt_io.write_line oc (Serialization_j.string_of_query (`JOB submission)) )
......@@ -60,7 +60,7 @@ let rec launch_job () =
n.port )
>>= fun () ->
Lwt_io.with_connection sockaddr (fun (_ic, oc) ->
Lwt_io.write oc (Serialization_j.string_of_query (`COMPUTATION j))
Lwt_io.write_line oc (Serialization_j.string_of_query (`COMPUTATION j))
)
(* TODO: check return value *)
>>= Lwt.pause
......@@ -68,7 +68,7 @@ let rec launch_job () =
else Logs_lwt.debug (fun m -> m "No compuatiton")
let server_handler pass port sockaddr (ic, _oc) =
Lwt_io.read ic
Lwt_io.read_line ic
>>= fun json ->
match CCResult.guard (fun () -> Serialization_j.query_of_string json) with
| Result.Ok query -> (
......
......@@ -13,7 +13,7 @@ let process_status_to_ret_code = function
let run_computation (computation : computation) =
Lwt_io.with_temp_file ~prefix:"ocluster" ~perm:0o700 (fun (name, oc) ->
Lwt_io.write oc computation.script
Lwt_io.write_line oc computation.script
>>= fun () ->
Lwt_io.close oc
>>= fun () ->
......@@ -52,16 +52,16 @@ let handle_computation sockaddr computation () =
s
in
Lwt_io.with_connection sockaddr (fun (_ic, oc) ->
Lwt_io.write oc (Serialization_j.string_of_query (`RESULT result)) )
Lwt_io.write_line oc (Serialization_j.string_of_query (`RESULT result)) )
(* TODO: rendre ça résistant au crash du serveur *)
>>= fun () ->
Logs_lwt.debug (fun m ->
m "End computation %i,%i" (fst computation.id) (snd computation.id) )
let stat oc = Lwt_io.write_value oc `OK
let stat oc = Lwt_io.write_line oc (Serialization_j.string_of_stat `OK)
let server_handler pass sockaddr (ic, oc) =
Lwt_io.read ic
Lwt_io.read_line ic
>>= fun json ->
( match CCResult.guard (fun () -> Serialization_j.query_of_string json) with
| Result.Ok query -> (
......
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