note description: "Aranea profiling application receiver node" author: "Comerge AG, DR" date: "$Date$" revision: "$Revision$" class RECEIVER_NODE inherit AP_PROFILING_NODE redefine register_message_handlers, node_name, make_profiling_node, clean_results end A_GENERAL_CONSTANTS PROFILING_CONSTANTS AP_PROFILING_CONSTANTS PROFILING_UTILS AP_PROFILING_RESULTS_REQUEST_MESSAGE_HANDLER create make_profiling_node feature -- Creation make_profiling_node -- prepare the profiling node do print("starting receiver%N") Precursor end feature -- Handler registration register_message_handlers -- do Precursor register_message_handler (general_namespace, general_string_type, agent handle_profiling_msg) register_message_handler (profiling_namespace, profiling_results_request_type, agent results_request_message_handler_register) end feature {NONE} -- Implementation handle_profiling_msg (a_msg: A_MESSAGE) -- measure time and send the reply back -- TODO use the handler class here instead of casting the message type local l_msg: A_GENERAL_STRING_MESSAGE l_reply: A_GENERAL_STRING_MESSAGE l_timestamp: INTEGER_64 do l_timestamp := compute_timestamp_now print("receiver: handling request...%N") l_msg ?= a_msg -- measure time and send back reply app_timestamps.force_last (l_timestamp) -- simulate work (create {EXECUTION_ENVIRONMENT}).sleep (sleep_time) -- send back response create l_reply.make_from_string (l_msg.string.value) l_timestamp := compute_timestamp_now app_timestamps.force_last (l_timestamp) send_message_reply (l_reply, a_msg) end handle_results_request (a_request: AP_PROFILING_RESULTS_REQUEST_MESSAGE) -- send back the time measurements local l_reply: AP_PROFILING_RESULTS_REPLY_MESSAGE do print("DEBUG: receiver app stamps raw: ") print_list (app_timestamps) clean_results create l_reply.make (serialize_timestamp_list (app_timestamps), serialize_timestamp_list (ems_timestamps)) send_message_reply (l_reply, a_request) -- clear the timestamps create app_timestamps.make_default create ems_timestamps.make_default end clean_results -- cleanup operations before the results are sent back do -- remove unwanted ems timestamp (added by the receipt of the AP_PROFILING_RESULTS_REQUEST_MESSAGE) ems_timestamps.remove_last end feature -- Access node_name: STRING -- node name used internally do Result := "ECHO" end end