From 9624c7e4b0ff329274eb79a82f08a31dedb2aecc Mon Sep 17 00:00:00 2001 From: GuyPerets106 Date: Tue, 23 Jan 2024 13:17:47 +0000 Subject: [PATCH] Comments on formats --- src_erl/NerlnetApp/src/Client/clientStatem.erl | 3 ++- src_erl/NerlnetApp/src/Stats/stats.erl | 5 +++-- src_py/apiServer/decoderHttpMainServer.py | 6 ++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src_erl/NerlnetApp/src/Client/clientStatem.erl b/src_erl/NerlnetApp/src/Client/clientStatem.erl index 78df7f44..4a383ba4 100644 --- a/src_erl/NerlnetApp/src/Client/clientStatem.erl +++ b/src_erl/NerlnetApp/src/Client/clientStatem.erl @@ -169,7 +169,7 @@ idle(cast, _In = {statistics}, State = #client_statem_state{ myName = MyName, et ClientStatsEncStr = stats:encode_ets_to_http_bin_str(ClientStatsEts), ClientStatsToSend = atom_to_list(MyName) ++ ?API_SERVER_WITHIN_ENTITY_SEPERATOR ++ ClientStatsEncStr ++ ?API_SERVER_ENTITY_SEPERATOR, stats:increment_messages_received(ClientStatsEts), - ListStatsEts = ets:tab2list(EtsStats) -- [{MyName , ClientStatsEts}], + ListStatsEts = ets:tab2list(EtsStats) -- [{MyName , ClientStatsEts}], WorkersStatsEncStr = create_encoded_stats_str(ListStatsEts), StatsBody = {MyName , ClientStatsToSend ++ WorkersStatsEncStr}, {RouterHost,RouterPort} = ets:lookup_element(EtsRef, my_router, ?DATA_IDX), @@ -409,6 +409,7 @@ cast_message_to_workers(EtsRef, Msg) -> create_encoded_stats_str(ListStatsEts) -> Func = fun({WorkerName , StatsEts}) -> WorkerEncStatsStr = stats:encode_ets_to_http_bin_str(StatsEts), + %% w1&bytes_sent:6.0:float#bad_messages:0:int....| WorkerName ++ ?API_SERVER_WITHIN_ENTITY_SEPERATOR ++ WorkerEncStatsStr ++ ?API_SERVER_ENTITY_SEPERATOR end, lists:flatten(lists:map(Func , ListStatsEts)). \ No newline at end of file diff --git a/src_erl/NerlnetApp/src/Stats/stats.erl b/src_erl/NerlnetApp/src/Stats/stats.erl index d5c09969..0aa462ca 100644 --- a/src_erl/NerlnetApp/src/Stats/stats.erl +++ b/src_erl/NerlnetApp/src/Stats/stats.erl @@ -28,6 +28,7 @@ encode_ets_to_http_bin_str(StatsEts) -> KeyStr = lists:flatten(io_lib:format("~p" , [Key])), ValueStr = lists:flatten(io_lib:format("~p" , [Value])), TypeStr = lists:flatten(io_lib:format("~p" , [Type])), + %% StatsKey:StatsValue:StatsType#StatsKey:StatsValue:StatsType#... KeyStr ++ ?SEPERATOR_WITHIN_TRIPLET ++ ValueStr ++ ?SEPERATOR_WITHIN_TRIPLET ++ TypeStr ++ ?SEPERATOR_TRIPLETS end, lists:flatten(lists:map(Func , StatsList)). @@ -49,7 +50,7 @@ decode_http_bin_str_to_ets(EncodedStr) -> ReturnedEts. -generate_stats_ets() -> +generate_stats_ets() -> %% clients , routers , mainserver... StatsEts = ets:new(stats_ets , [set]), ets:insert(StatsEts, {messages_received , 0}), ets:insert(StatsEts, {messages_sent , 0}), @@ -62,7 +63,7 @@ generate_stats_ets() -> ets:insert(StatsEts, {batches_sent , 0}), % related with source StatsEts. -generate_workers_stats_ets() -> +generate_workers_stats_ets() -> %% workers.. WorkersStatsEts = ets:new(workers_ets , [set, public]), ets:insert(WorkersStatsEts, {bytes_received , 0}), ets:insert(WorkersStatsEts, {bytes_sent , 0}), diff --git a/src_py/apiServer/decoderHttpMainServer.py b/src_py/apiServer/decoderHttpMainServer.py index ee9f1170..e1b01c1e 100644 --- a/src_py/apiServer/decoderHttpMainServer.py +++ b/src_py/apiServer/decoderHttpMainServer.py @@ -1,6 +1,12 @@ from decoderHttpMainServerDefs import * +# ? Example: "name:mainServer:string#bytes_sent:0.5:float#....|name:c1:string#bytes_sent:0.5:float#....#w1&average_time_training:10.5:float#...|w2&...|name:c2:string#...#w3&...|" +# | seperates entities +# & start worker stats under his client +# # seperates stat_name-stat_value-type triplets +# : seperates stat_name , stat_value and type + def decode_main_server_ets_str(string_to_convert: str): result_list = [] # [(entity_name, ets_dict), ...)]