diff options
author | wolff1 <wolff1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-03-12 03:49:17 +0000 |
---|---|---|
committer | wolff1 <wolff1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-03-12 03:49:17 +0000 |
commit | ca6a15f2d3e5674e3798cf9c6e2e167a11592581 (patch) | |
tree | 93046ebc1c72d403b668fb233742953908457ea6 | |
parent | ed7cba9b35ea16b1d92be4118f24fc424f2402d1 (diff) | |
download | ATCD-ca6a15f2d3e5674e3798cf9c6e2e167a11592581.tar.gz |
ChangeLogTag: Thu Mar 12 03:48:16 UTC 2009 Friedhelm Wolf <fwolf@dre.vanderbilt.edu>
7 files changed, 115 insertions, 35 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index c1590dced1c..a84d6a01180 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,18 @@ +Thu Mar 12 03:48:16 UTC 2009 Friedhelm Wolf <fwolf@dre.vanderbilt.edu> + + * orbsvcs/examples/FaultTolerance/FLARe/Worker/server.cpp + * orbsvcs/examples/FaultTolerance/FLARe/Worker/Worker_i.cpp + * orbsvcs/examples/FaultTolerance/FLARe/Worker/Worker_i.h: + + Added task for failure that can be triggered based on the + invocation count. + + * orbsvcs/examples/FaultTolerance/FLARe/Worker/client.cpp + * orbsvcs/examples/FaultTolerance/FLARe/Worker/Client_Timer_Handler.h + * orbsvcs/examples/FaultTolerance/FLARe/Worker/Client_Timer_Handler.cpp: + + Changed measurement and shutdown behavior. + Tue Mar 10 20:19:22 UTC 2009 Friedhelm Wolf <fwolf@dre.vanderbilt.edu> * orbsvcs/orbsvcs/LWFT/HostMonitorImpl.cpp: diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Client_Timer_Handler.cpp b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Client_Timer_Handler.cpp index ce8a1a41b14..9d77302c1cc 100644 --- a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Client_Timer_Handler.cpp +++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Client_Timer_Handler.cpp @@ -8,30 +8,31 @@ extern double execution_time; Client_Timer_Handler::Client_Timer_Handler (long iterations, - const std::string & filename, - const ACE_Time_Value & period, - bool logging) + const std::string & filename, + const ACE_Time_Value & period, + bool logging) : period_ (period), invocations_ (0), + logfile_ (filename), max_iterations_ (iterations), logging_ (logging) { - if (logging_) - out_.open (filename.c_str ()); } Client_Timer_Handler::~Client_Timer_Handler () { if (logging_) { + std::ofstream out (logfile_.c_str ()); + for (TimingList::iterator it = history_.begin (); it != history_.end (); ++it) { - out_ << it->first << " " << it->second << std::endl; + out << *it << std::endl; } - out_.close (); + out.close (); } } @@ -51,9 +52,6 @@ int Client_Timer_Handler::handle_timeout (const ACE_Time_Value &, const void *) { - if ((max_iterations_ > 0) && (invocations_++ > max_iterations_)) - orb_->shutdown (); - try { timer_.start (); @@ -68,9 +66,7 @@ Client_Timer_Handler::handle_timeout (const ACE_Time_Value &, timer_.elapsed_time (rt); if (logging_) - history_.push_back ( - TimingResult (rt.msec (), - ACE_Time_Value (period_ - rt).msec ())); + history_.push_back (rt.msec ()); } catch (CORBA::SystemException & ex) { @@ -83,6 +79,13 @@ Client_Timer_Handler::handle_timeout (const ACE_Time_Value &, return 1; } + if ((max_iterations_ > 0) && (++invocations_ > max_iterations_)) + { + worker_->stop (); + + orb_->shutdown (); + } + return 0; } diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Client_Timer_Handler.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Client_Timer_Handler.h index 2dda15be846..57340347440 100644 --- a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Client_Timer_Handler.h +++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Client_Timer_Handler.h @@ -40,15 +40,15 @@ class Client_Timer_Handler : public ACE_Event_Handler long invocations_; + std::string logfile_; + long max_iterations_; std::ofstream out_; bool logging_; - typedef std::pair <CORBA::ULong, CORBA::ULong> TimingResult; - - typedef std::list<TimingResult> TimingList; + typedef std::list<CORBA::ULong> TimingList; TimingList history_; }; diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Worker_i.cpp b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Worker_i.cpp index 33ea9875bfb..25895d53048 100644 --- a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Worker_i.cpp +++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Worker_i.cpp @@ -1,5 +1,44 @@ #include "Worker_i.h" +Failure_Task::Failure_Task (CORBA::ORB_ptr orb, + long limit, + long & count) + : condition_ (lock_), + orb_ (CORBA::ORB::_duplicate (orb)), + limit_ (limit), + count_ (count), + stop_ (false) +{ +} + +int +Failure_Task::svc (void) +{ + ACE_Guard <ACE_Thread_Mutex> guard (lock_); + + while (((limit_ == 0) || (count_ < limit_)) && !stop_) + { + condition_.wait (); + } + + orb_->shutdown (); + + return 0; +} + +void +Failure_Task::signal (void) +{ + condition_.signal (); +} + +void +Failure_Task::stop (void) +{ + stop_ = true; + condition_.signal (); +} + Worker_i::Worker_i (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, const std::string & object_id, @@ -10,8 +49,10 @@ Worker_i::Worker_i (CORBA::ORB_ptr orb, object_id_ (object_id), agent_ (StateSynchronizationAgent::_duplicate (agent)), state_ (0), - suicidal_count_ (invocations) + suicidal_count_ (invocations), + task_ (orb_.in (), suicidal_count_, state_) { + task_.activate (); } void @@ -22,11 +63,14 @@ Worker_i::run_task (CORBA::Double execution_time) ++state_; agent_->state_changed (object_id_.c_str ()); + + task_.signal (); } void Worker_i::stop () { - this->orb_->shutdown (0); + task_.stop (); + this->orb_->shutdown (); } void @@ -86,4 +130,3 @@ Worker_i::object_id (const char * object_id) { object_id_ = object_id; } - diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Worker_i.h b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Worker_i.h index 09c767e43a2..f5529ab7efe 100644 --- a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Worker_i.h +++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/Worker_i.h @@ -3,8 +3,32 @@ #include "WorkerS.h" #include "CPU/CPU_Worker.h" +#include "ace/Task.h" +#include "ace/Condition_T.h" #include "orbsvcs/orbsvcs/LWFT/StateSynchronizationAgentC.h" +class Failure_Task : public ACE_Task_Base +{ + public: + Failure_Task (CORBA::ORB_ptr orb, + long limit, + long & count); + + int svc (void); + + void signal (void); + + void stop (void); + + private: + ACE_Thread_Mutex lock_; + ACE_Condition <ACE_Thread_Mutex> condition_; + CORBA::ORB_var orb_; + long limit_; + long & count_; + bool stop_; +}; + class Worker_i : public POA_DeCoRAM::Worker { public: @@ -46,6 +70,8 @@ class Worker_i : public POA_DeCoRAM::Worker long state_; long suicidal_count_; + + Failure_Task task_; }; #endif /* WORKER_I_H_ */ diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/client.cpp b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/client.cpp index 2972dd0a8b5..cfa6eb7badf 100644 --- a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/client.cpp +++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/client.cpp @@ -99,9 +99,9 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) // PriorityModelPolicy, and get their server priorities. Client_Timer_Handler timeout_handler (iterations, - server_id + "-client.txt", - period, - logging); + server_id + "-client.txt", + period, + logging); timeout_handler.set_orb (orb.in ()); timeout_handler.set_worker (server1.in ()); @@ -116,21 +116,9 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) ACE_Time_Value::zero, period); - if (kill_me) - { - std::ostringstream os; - os << "kill-" << ACE_OS::getpid (); - std::ofstream file (os.str ().c_str ()); - file << 0; - file.close (); - } - orb->run (); orb->orb_core ()->reactor ()->cancel_timer (&timeout_handler); - - // DeCoRAM::Workering over. Shut down Server ORB. - server1->stop (); } catch (const CORBA::Exception& ex) { diff --git a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/server.cpp b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/server.cpp index e49dfd48a05..c880359304c 100644 --- a/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/server.cpp +++ b/TAO/orbsvcs/examples/FaultTolerance/FLARe/Worker/server.cpp @@ -119,7 +119,7 @@ Task::Task (ACE_Thread_Manager &thread_manager, : ACE_Task_Base (&thread_manager), orb_ (CORBA::ORB::_duplicate (orb)), rm_ (ReplicationManager::_duplicate (rm)), - agent_ (agent) + agent_ (StateSynchronizationAgent::_duplicate (agent)) { } @@ -183,6 +183,11 @@ Task::svc (void) AppOptions::instance ()->role (), obj.in ()); + ReplicatedApplication_var app = ReplicatedApplication::_narrow (obj.in ()); + + agent_->register_application (AppOptions::instance ()->app_id ().c_str (), + app.in ()); + // Start ORB event loop. this->orb_->run (); |