From 09c937b5280aae0dea3c55773dece14346cc8a2c Mon Sep 17 00:00:00 2001 From: Razvan Deaconescu Date: Thu, 25 Aug 2011 12:54:14 +0300 Subject: [PATCH] ppf/new: Add top level functions and scripts design proposal. --- ppf/new/top-design-proposal.txt | 94 +++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 ppf/new/top-design-proposal.txt diff --git a/ppf/new/top-design-proposal.txt b/ppf/new/top-design-proposal.txt new file mode 100644 index 0000000..a1db8e8 --- /dev/null +++ b/ppf/new/top-design-proposal.txt @@ -0,0 +1,94 @@ +== top.py == + +parse_store_session(SwarmWriter sw, LogParser p, int session_id) +{ + while True: + msg = parser.get_next_message() + # In case of no more messages, exit loop. + if msg == None: + break + + msg.set_client_session_id(session_id) + sw.add_message(msg) +} + +enhance_swarm_description(SwarmDescription sd, SwarmWriter sw) +{ + sw.add_swarm(sd.get_swarm()) + + for section in sd.get_section_list() + session = get_session_from_section(section) + session_id = sw.add_session(session) + sd.update_section_with_session_id(section, session_id) +} + +# se is a sesssion section in swarm description file. +retrieve_log(SessionEntry se) +{ + rsync, scp, whatever + uncompress + + return log_location +} + +parse_session_log(SessionEntry se, SwarmWriter sw) +{ + location = retrieve_logs(se) + + p = LogParser.create_parser_by_type(se.get_client_type(), location) + sid = se.get_session_id() + + parse_store_session(sw, p, sid) +} + +parse_swarm_log(SwarmDescription sd, SwarmWriter sw) +{ + for section in sd.get_section_list() + se = SwarmDescription.get_session_entry(section) + parse_session_log(se, sw) +} + += "Executable" Scripts (use main()) = + +== enhance_swarm_description.py == + +main() +{ + # arguments are swarm_description_file and access_config_file + sd = SwarmDescription.load(swarm_description_file) + ac = AccessConfig.load(access_config_file) + sw = get_swarm_writer(ac) + + top.enhance_swarm_description(sd, sw) + + sd.store(swarm_description_file) +} + +== parse_session_log.py == + +main() +{ + # arguments are swarm_description_file, access_config_file and section + sd = SwarmDescription.load(swarm_description_file) + ac = AccessConfig.load(access_config_file) + sw = get_swarm_writer(ac) + + se = SwarmDescription.get_session_entry(section) + top.parse_session_log(se, ac) +} + +== parse_swarm_log.py == + +main() +{ + # arguments are swarm_description_file and access_config_file + sd = SwarmDescription.load(swarm_description_file) + ac = AccessConfig.load(access_config_file) + sw = get_swarm_writer(ac) + + # Enhance swarm description with session id. Store enhanced file. + top.enhance_swarm_description(sd, sw) + sd.store(swarm_description_file) + + top.parse_swarm(sd, sw) +} -- 2.20.1