indexing description: "Query system status use case." author: "Patrick Ruckstuhl " date: "$Date$" revision: "$Revision$" class SYSTEM_STATUS inherit AUTH_USE_CASE O_SYSTEM_CONSTANTS THREAD_CONTROL create make feature -- Access namespace: STRING is -- Namespace of this use case. once Result := system_namespace end type: STRING is -- Message type of this use case. once Result := system_status_type end feature -- Basic operation start (a_msg: O_MESSAGE) is -- Start the use case by a_msg. local l_msg: O_SESSION_MESSAGE do l_msg ?= a_msg check session_message: l_msg /= Void end -- check if the user is authorized and act accordingly is_authorized_for_project (l_msg, "system_status", 0, auth_node) end feature {NONE} -- Implementation handle_auth_success (a_msg: O_MESSAGE) is -- a_msg has been authorized, execute it. local l_nodes: LIST [STRING] l_result: STRING l_req: O_SYSTEM_STATUS_MESSAGE l_rep: O_GENERAL_STRING_MESSAGE l_result_mutex: MUTEX do create l_result_mutex.make create l_result.make_empty l_result.append ("===========================%N") l_nodes := node.peer_module.node_list -- TODO: if we have semaphores with negative count -- TODO: create a semaphore with count -(count-1) -- TODO: after each reply we receive we call post so the semaphore is increase, so after count calls the semaphore is 1 and therefore lets us through from l_nodes.start until l_nodes.after loop -- send a message to each node to retrieve the status from it and aggregate this in l_result create l_req.make ("DUMMY") l_req.set_reply_handler (agent (aa_msg: O_MESSAGE; al_result: STRING; al_result_mutex: MUTEX) local ll_msg: O_GENERAL_STRING_MESSAGE do ll_msg ?= aa_msg check string_message: ll_msg /= Void end al_result_mutex.lock al_result.append (ll_msg.string) al_result.append ("===========================%N") al_result_mutex.unlock end (?, l_result, l_result_mutex)) node.send_message_node (l_req, l_nodes.item) l_nodes.forth end -- TODO: this can be removed if we can do the solution with semaphores, for now just sleep for 5 seconds after which all results should be here. -- 3s sleep (3000000000) -- generate reply create l_rep.make (l_result) node.send_message_reply (l_rep, a_msg) end end