5 #ifndef LOG_WALKER_HOST_PROCESS_H
6 #define LOG_WALKER_HOST_PROCESS_H
7 #include "ace/SString.h"
9 #include "ace/Containers.h"
10 #include "ace/Hash_Map_Manager.h"
11 #include "ace/RB_Tree.h"
12 #include "ace/Functor.h"
13 #include "Invocation.h"
14 #include "PeerProcess.h"
21 * Peer node is an element of the connection list which associates peer
22 * processes to the host process by handle. The peer node does not own
23 * the reference to the peer process, and the specific peer process may
28 PeerNode (long h
, PeerProcess
*p
);
33 typedef ACE_DLList
<Thread
> ThreadList
;
34 typedef ACE_DLList
<PeerNode
> PeerArray
;
35 typedef ACE_DLList
<Endpoint
> AddrList
;
36 typedef ACE_RB_Tree
<Endpoint
, PeerProcess
*, ACE_Less_Than
<Endpoint
>, ACE_Null_Mutex
> PeerProcs
;
39 * HostProcess encapsulates the state related a specific process instance
40 * described by a log file. There may be more than one HostProcess in a
47 HostProcess (const ACE_CString
&src
, long pid
);
50 // set/get the name of the process. This is only provided by
51 // an alias supplied to the logWalker command line or manifest file.
52 void proc_name (const ACE_CString
&name
);
53 const ACE_CString
&proc_name () const;
55 // Returns a thread instance based on thread id. Will create an instance
57 Thread
* find_thread (long tid
, size_t offset
);
59 // Returns a thread that has a pending peer with the supplied address
60 Thread
* find_thread_for_peer (const ACE_CString
& addr
);
62 // Returns a thread that had previously worked with handle h. May return
64 Thread
* find_thread_for_handle (long h
);
66 // Returns the process id.
69 const ACE_Time_Value
&start_time () const;
70 void start_time (const ACE_Time_Value
&);
72 // Return true if the supplied endpoint has been visited before. This
73 // may be either a listen endpoint or a client endpoint used to connect
75 bool has_endpoint (const Endpoint
& addr
, bool listen
);
77 // adds a new endpoint to the list of listen endpoints. Client endpoints
78 // are added as part of the process to add a new peer process
79 void add_client_endpoint (const Endpoint
& addr
);
81 // adds a new endpoint to the list of listen endpoints. Client endpoints
82 // are added as part of the process to add a new peer process
83 void add_listen_endpoint (const Endpoint
& addr
);
85 // add a peer to the connection list. If the peer is not in the
86 // by_addr_ table, it will be added there too.
87 void add_peer (long handle
, PeerProcess
*peer
);
89 // locate a peer process by handle or address
90 PeerProcess
*find_peer (const ACE_CString
& addr
);
91 PeerProcess
*find_peer (long handle
);
93 void remove_peer (long handle
);
95 // remove a peer by handle, noting the line.
96 void close_peer (long handle
, size_t offset
);
98 // various output methods
99 void dump_ident (ostream
&strm
, const char *extra
);
100 void dump_summary (ostream
&strm
);
101 void dump_thread_summary (ostream
&strm
);
102 void split_thread_invocations (Session
*session
, const ACE_Time_Value
& start
);
103 void dump_thread_invocations (ostream
&strm
, const ACE_Time_Value
& start
);
104 void dump_peer_summary (ostream
&strm
);
105 void dump_object_detail (ostream
&strm
);
106 void split_peer_invocations (Session
*session
);
107 void dump_invocation_detail (ostream
&strm
);
109 // reconcile_peers gives an opportunity to resolve peer process names
110 // by matching the peer processes to other host processes in the session.
111 void reconcile_peers (Session
*session
);
114 void iterate_peers (int group
,
117 Session
* session
= 0);
120 ACE_CString logfile_name_
;
121 ACE_CString proc_name_
;
122 AddrList client_endpoints_
;
123 AddrList listen_endpoints_
;
127 PeerArray by_handle_
;
128 ACE_Time_Value start_time_
;
131 #endif // LOG_WALKER_HOST_PROCESS_H