note description: "Statistics node" author: "Patrick Ruckstuhl " date: "$Date$" revision: "$Revision$" class NODE_STATISTICS inherit A_NODE_CLIENT redefine listen_queues, register_message_handlers end O_NODE O_STATISTICS_CONSTANTS create make feature -- Access name: STRING = "Origo statistics node" version: STRING = "$Revision$" feature {NONE} -- Implementation of message handlers statistics: DS_ARRAYED_LIST [STATISTIC] -- Registered statistics. listen_queues: DS_LIST [STRING] -- Listen queues. once Result := Precursor Result.put_last (origo_statistics_queue) end register_message_handlers -- Register message handlers. do Precursor create statistics.make (10) statistics.put_last (create {WORKITEM_STATISTIC}.make (Current)) statistics.put_last (create {ISSUE_STATISTIC}.make (Current)) statistics.put_last (create {WEB_STATISTIC}.make (Current)) register_main_loop_message_handler (statistics_namespace, statistics_create_type, agent create_statistics) register_main_loop_message_handler (statistics_namespace, statistics_update_type, agent retrieve_projects_to_update) end retrieve_projects_to_update (a_msg: A_MESSAGE) -- Retrieve projects to update and then invoke update_statistics with the project list reply. require a_msg_ok: a_msg /= Void local l_req: O_PROJECT_LIST_PARTIAL_INTERNAL_MESSAGE do create l_req.make ( create {A_BOOLEAN_VALUE}.make (True), create {A_INTEGER_VALUE}.make (0), create {A_INTEGER_VALUE}.make ({INTEGER}.max_value), create {A_STRING_VALUE}.make ("name"), create {A_STRING_VALUE}.make ("asc")) l_req.set_reply_handler (agent update_statistics) send_message (l_req, origo_storage_queue) end update_statistics (a_msg: A_MESSAGE) -- Update the statistics. require a_msg_ok: a_msg /= Void local l_cursor: DS_LIST_CURSOR [STATISTIC] l_rep: O_PROJECT_LIST_MESSAGE l_project_map: DS_HASH_TABLE[O_PROJECT_PROJECT_MESSAGE, A_STRING_VALUE] l_projects: DS_ARRAYED_LIST [STRING] i: INTEGER do -- build the project list from the message l_rep ?= a_msg check valid_message: l_rep /= Void end l_project_map := l_rep.project_list.map create l_projects.make (l_project_map.count) from i := 0 until i >= l_project_map.count loop l_projects.put_last (l_project_map.item (create {A_STRING_VALUE}.make (i.out)).name.value) i := i + 1 end l_cursor := statistics.new_cursor from l_cursor.start until l_cursor.after loop l_cursor.item.update_statistic (l_projects) l_cursor.forth end end create_statistics (a_msg: A_MESSAGE) -- Create statistics files fro a project. require a_msg_ok: a_msg /= Void local l_msg: O_STATISTICS_CREATE_MESSAGE l_cursor: DS_LIST_CURSOR [STATISTIC] do l_msg ?= a_msg check valid_msg: l_msg /= Void end l_cursor := statistics.new_cursor from l_cursor.start until l_cursor.after loop l_cursor.item.create_statistic (l_msg.project_name.value) l_cursor.forth end end end