summaryrefslogtreecommitdiff
path: root/TAO/utils/logWalker/Thread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/utils/logWalker/Thread.cpp')
-rw-r--r--TAO/utils/logWalker/Thread.cpp136
1 files changed, 120 insertions, 16 deletions
diff --git a/TAO/utils/logWalker/Thread.cpp b/TAO/utils/logWalker/Thread.cpp
index 57345a22447..3635358006d 100644
--- a/TAO/utils/logWalker/Thread.cpp
+++ b/TAO/utils/logWalker/Thread.cpp
@@ -3,21 +3,25 @@
#include "Thread.h"
#include "Invocation.h"
#include "PeerProcess.h"
+#include "GIOP_Buffer.h"
#include "ace/OS_NS_stdio.h"
-
#include <stack>
-Thread::Thread (long tid, const char *alias)
+Thread::Thread (long tid, const char *alias, size_t offset)
: id_(tid),
alias_ (alias),
max_depth_ (0),
- encounters_ (0),
+ client_encounters_ (0),
+ server_encounters_ (0),
nested_ (0),
pending_(),
incoming_(0),
new_connection_(0),
giop_target_(0),
- active_handle_ (0)
+ target_dup_(0),
+ current_invocation_ (),
+ active_handle_ (0),
+ first_line_ (offset)
{
}
@@ -34,9 +38,21 @@ Thread::pending_peer (void) const
}
void
+Thread::pending_local_addr (const ACE_CString &addr)
+{
+ this->pending_local_addr_ = addr;
+}
+
+const ACE_CString &
+Thread::pending_local_addr (void) const
+{
+ return this->pending_local_addr_;
+}
+
+void
Thread::handle_request (void)
{
- this->encounters_++;
+ this->server_encounters_++;
if (this->pending_.size() > 1)
this->nested_++;
}
@@ -45,7 +61,7 @@ void
Thread::enter_wait (PeerProcess *pp)
{
this->pending_.push (pp);
- this->encounters_++;
+ this->client_encounters_++;
if (this->pending_.size() > this->max_depth_)
this->max_depth_ = this->pending_.size();
if (this->pending_.size() > 1)
@@ -76,12 +92,6 @@ Thread::max_depth (void) const
}
long
-Thread::encounters (void) const
-{
- return this->encounters_;
-}
-
-long
Thread::id (void) const
{
return this->id_;
@@ -117,16 +127,61 @@ Thread::active_handle (void) const
return this->active_handle_;
}
-Invocation::GIOP_Buffer *
+void
+Thread::set_dup (Thread *other, bool set_other)
+{
+ this->target_dup_ = other;
+ if (set_other)
+ {
+ other->set_dup (this, false);
+ }
+}
+
+void
+Thread::clear_dup (void)
+{
+ this->target_dup_ = 0;
+}
+
+bool
+Thread::has_dup (void)
+{
+ return this->target_dup_ != 0;
+}
+
+void
+Thread::swap_target (void)
+{
+ if (target_dup_ != 0 && target_dup_->giop_target() != 0)
+ {
+ this->giop_target_->swap (target_dup_->giop_target());
+ this->target_dup_->clear_dup ();
+ this->target_dup_ = 0;
+ }
+ else
+ {
+ if (target_dup_ == 0)
+ ACE_ERROR ((LM_ERROR, "Thread::swap_target, target_dup_ == 0\n"));
+ else
+ ACE_ERROR ((LM_ERROR, "Thread::swap_target, target_dup_.id = %d, giop_target == 0\n", target_dup_->id()));
+ }
+}
+
+GIOP_Buffer *
Thread::giop_target (void)
{
return this->giop_target_;
}
void
-Thread::set_giop_target (Invocation::GIOP_Buffer *buffer)
+Thread::set_giop_target (GIOP_Buffer *buffer)
{
this->giop_target_ = buffer;
+ if (this->target_dup_ != 0)
+ {
+ this->target_dup_->clear_dup();
+ this->target_dup_ = 0;
+ }
}
void
@@ -136,10 +191,34 @@ Thread::add_invocation (Invocation *inv)
}
void
-Thread::dump_detail (ostream &strm)
+Thread::push_invocation (Invocation *inv)
+{
+ this->current_invocation_.push(inv);
+}
+
+void
+Thread::pop_invocation (void)
+{
+ Invocation *inv;
+ this->current_invocation_.pop (inv);
+}
+
+Invocation *
+Thread::current_invocation (void) const
+{
+ Invocation *inv = 0;
+ if (this->current_invocation_.size() > 0)
+ this->current_invocation_.top(inv);
+ return inv;
+}
+
+void
+Thread::dump_detail (ostream &strm) const
{
strm << " " << this->alias_ << " tid = " << this->id_
- << "\t" << this->encounters_ << " encounters";
+ << "\tfirst line " << this->first_line_ << "\t"
+ << this->server_encounters_ << " requests sent "
+ << this->client_encounters_ << " requests received";
if (nested_ > 0)
strm <<", with " << this->nested_ << " nested upcalls, max depth "
<< this->max_depth_;
@@ -147,8 +226,31 @@ Thread::dump_detail (ostream &strm)
}
void
+Thread::get_summary (long &sent_reqs, long &recv_reqs, size_t &sent_size, size_t &recv_size)
+{
+ for (ACE_DLList_Iterator <Invocation> i(this->invocations_);
+ !i.done();
+ i.advance())
+ {
+ Invocation *inv;
+ i.next(inv);
+ if (inv->sent_request())
+ {
+ ++sent_reqs;
+ sent_size += inv->request_bytes();
+ }
+ else
+ {
+ ++recv_reqs;
+ recv_size += inv->request_bytes();
+ }
+ }
+}
+
+void
Thread::dump_invocations (ostream &strm)
{
+ unsigned long total_request_bytes = 0;
strm << " " << this->alias_ << " handled " << this->invocations_.size() << " invocations" << endl;
std::stack<Invocation *> nested;
@@ -171,5 +273,7 @@ Thread::dump_invocations (ostream &strm)
nested.push(inv);
inv->dump_detail (strm, level, Invocation::Dump_Proc, false);
+ total_request_bytes += inv->request_bytes();
}
+ strm << "total request octet count: " << total_request_bytes;
}