Skip to content

Commit

Permalink
Comments on formats
Browse files Browse the repository at this point in the history
  • Loading branch information
GuyPerets106 committed Jan 23, 2024
1 parent acbaf7a commit 9624c7e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src_erl/NerlnetApp/src/Client/clientStatem.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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)).
5 changes: 3 additions & 2 deletions src_erl/NerlnetApp/src/Stats/stats.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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)).
Expand All @@ -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}),
Expand All @@ -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}),
Expand Down
6 changes: 6 additions & 0 deletions src_py/apiServer/decoderHttpMainServer.py
Original file line number Diff line number Diff line change
@@ -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), ...)]

Expand Down

0 comments on commit 9624c7e

Please sign in to comment.