diff options
author | wolff1 <wolff1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-03-13 02:34:20 +0000 |
---|---|---|
committer | wolff1 <wolff1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-03-13 02:34:20 +0000 |
commit | ee46e8cc8433815360b1b7cc78c83f1f4def14cc (patch) | |
tree | 0df1d67428c6b66844232c3ec9cf8f6c2676bda3 | |
parent | d2c4044a6a1494ee5a1ccb09533ef27adfde37f3 (diff) | |
download | ATCD-ee46e8cc8433815360b1b7cc78c83f1f4def14cc.tar.gz |
ChangeLogTag: Fri Mar 13 02:33:32 UTC 2009 Friedhelm Wolf <fwolf@dre.vanderbilt.edu>
-rw-r--r-- | CIAO/ChangeLog | 15 | ||||
-rw-r--r-- | CIAO/DAnCE/tests/CIAO/FTComponents/FTClient.idl | 4 | ||||
-rw-r--r-- | CIAO/DAnCE/tests/CIAO/FTComponents/FTClient_Timer_Handler.cpp | 92 | ||||
-rw-r--r-- | CIAO/DAnCE/tests/CIAO/FTComponents/FTClient_Timer_Handler.h | 22 | ||||
-rw-r--r-- | CIAO/DAnCE/tests/CIAO/FTComponents/FTClient_exec.cpp | 24 | ||||
-rw-r--r-- | CIAO/DAnCE/tests/CIAO/FTComponents/FTClient_exec.h | 19 | ||||
-rw-r--r-- | CIAO/DAnCE/tests/CIAO/FTComponents/FTTask.idl | 1 | ||||
-rw-r--r-- | CIAO/DAnCE/tests/CIAO/FTComponents/FTTask_exec.cpp | 43 | ||||
-rw-r--r-- | CIAO/DAnCE/tests/CIAO/FTComponents/FTTask_exec.h | 11 | ||||
-rw-r--r-- | CIAO/DAnCE/tests/CIAO/FTComponents/Failure_Task.cpp | 16 | ||||
-rw-r--r-- | CIAO/DAnCE/tests/CIAO/FTComponents/Failure_Task.h | 8 |
11 files changed, 199 insertions, 56 deletions
diff --git a/CIAO/ChangeLog b/CIAO/ChangeLog index 4788e90666d..3ac2cfaf4b9 100644 --- a/CIAO/ChangeLog +++ b/CIAO/ChangeLog @@ -1,3 +1,18 @@ +Fri Mar 13 02:33:32 UTC 2009 Friedhelm Wolf <fwolf@dre.vanderbilt.edu> + + * DAnCE/tests/CIAO/FTComponents/FTClient.idl + * DAnCE/tests/CIAO/FTComponents/FTTask_exec.cpp + * DAnCE/tests/CIAO/FTComponents/FTTask_exec.h + * DAnCE/tests/CIAO/FTComponents/FTClient_Timer_Handler.cpp + * DAnCE/tests/CIAO/FTComponents/Failure_Task.cpp + * DAnCE/tests/CIAO/FTComponents/FTClient_Timer_Handler.h + * DAnCE/tests/CIAO/FTComponents/FTClient_exec.cpp + * DAnCE/tests/CIAO/FTComponents/Failure_Task.h + * DAnCE/tests/CIAO/FTComponents/FTClient_exec.h + * DAnCE/tests/CIAO/FTComponents/FTTask.idl: + + Changed client and server behavior for automated test cases. + Thu Mar 12 15:57:15 UTC 2009 Friedhelm Wolf <fwolf@dre.vanderbilt.edu> * DAnCE/tests/CIAO/FTComponents/Worker.idl diff --git a/CIAO/DAnCE/tests/CIAO/FTComponents/FTClient.idl b/CIAO/DAnCE/tests/CIAO/FTComponents/FTClient.idl index 0ad5bbe7494..13c5498e9f4 100644 --- a/CIAO/DAnCE/tests/CIAO/FTComponents/FTClient.idl +++ b/CIAO/DAnCE/tests/CIAO/FTComponents/FTClient.idl @@ -8,9 +8,9 @@ module DeCoRAM { attribute double period; attribute double execution_time; - attribute unsigned long priority; + attribute unsigned long iterations; attribute string server_ior; - }; + }; home FTClientHome manages FTClient { diff --git a/CIAO/DAnCE/tests/CIAO/FTComponents/FTClient_Timer_Handler.cpp b/CIAO/DAnCE/tests/CIAO/FTComponents/FTClient_Timer_Handler.cpp index a0f4ec9683b..33bd6a4e541 100644 --- a/CIAO/DAnCE/tests/CIAO/FTComponents/FTClient_Timer_Handler.cpp +++ b/CIAO/DAnCE/tests/CIAO/FTComponents/FTClient_Timer_Handler.cpp @@ -4,15 +4,17 @@ //#include <tao/RTCORBA/RTCORBA.h> #include "FTClient_Timer_Handler.h" #include "ciao/CIAO_common.h" -#include "WorkerC.h" #include "FTClient_exec.h" namespace CIDL_FTClient_Impl { FTClient_Timer_Handler::FTClient_Timer_Handler ( - CIDL_FTClient_Impl::FTClient_exec_i * client_executor) - : client_executor_ (client_executor) + CIDL_FTClient_Impl::FTClient_exec_i * client_executor, + bool logging) + : client_executor_ (client_executor), + logging_ (logging), + count_ (0) { } @@ -22,6 +24,12 @@ namespace CIDL_FTClient_Impl orb_ = CORBA::ORB::_duplicate (orb); } + void + FTClient_Timer_Handler::set_server (DeCoRAM::Worker_ptr server) + { + server_ = DeCoRAM::Worker::_duplicate (server); + } + int FTClient_Timer_Handler::handle_timeout (const ACE_Time_Value &, const void *) @@ -35,24 +43,33 @@ namespace CIDL_FTClient_Impl rt_current->the_priority (client_executor_->priority ()); */ - DeCoRAM::Worker_var server = client_executor_->server (); + CIAO_DEBUG ((LM_TRACE, "s(%d) ", + count_)); - if (CORBA::is_nil (server.in ())) - return 0; + if (CORBA::is_nil (server_.in ())) + { + // try to get a recent object reference first + server_ = DeCoRAM::Worker::_duplicate (client_executor_->server ()); - ACE_hrtime_t start, end; - start = ACE_OS::gethrtime (); + if (CORBA::is_nil (server_.in ())) + { + return 0; + } + } + + timer_.start (); // we have to do some profiling first to see how we can achieve // the correct execution time. - server->run_task (client_executor_->execution_time ()); - - end = ACE_OS::gethrtime (); - - CIAO_DEBUG ((LM_DEBUG, - "response time for %f was %d.\n", - client_executor_->execution_time (), - end - start)); + server_->run_task (client_executor_->execution_time ()); + + timer_.stop (); + + ACE_Time_Value rt; + timer_.elapsed_time (rt); + + if (logging_) + history_.push_back (rt.msec ()); } catch (CORBA::Exception & ex) { @@ -61,7 +78,48 @@ namespace CIDL_FTClient_Impl "caught: %s", ex._info ().c_str ())); } + try + { + // this code makes sure the client component stops execution + if ((client_executor_->iterations () > 0) && + (++count_ > client_executor_->iterations ())) + { + server_->stop (); + + client_executor_->ccm_passivate (); + + orb_->shutdown (); + } + } + catch (CORBA::Exception & ex) + { + CIAO_DEBUG ((LM_WARNING, + "FTClient_Timer_Handler::handle_timeout () after run_task - " + "caught: %s", ex._info ().c_str ())); + } + + return 0; } - + + void + FTClient_Timer_Handler::dump (void) + { + if (logging_) + { + std::string logfile = client_executor_->name (); + logfile += "client.txt"; + std::ofstream out (logfile.c_str ()); + + for (TimingList::iterator it = history_.begin (); + it != history_.end (); + ++it) + { + out << *it << std::endl; + } + + out.close (); + } + } + } // end namespace CIDL_FTClient_Impl diff --git a/CIAO/DAnCE/tests/CIAO/FTComponents/FTClient_Timer_Handler.h b/CIAO/DAnCE/tests/CIAO/FTComponents/FTClient_Timer_Handler.h index a22592b0398..d76d7639062 100644 --- a/CIAO/DAnCE/tests/CIAO/FTComponents/FTClient_Timer_Handler.h +++ b/CIAO/DAnCE/tests/CIAO/FTComponents/FTClient_Timer_Handler.h @@ -3,8 +3,11 @@ #ifndef FTCLIENT_TIMER_HANDLER_H_ #define FTCLIENT_TIMER_HANDLER_H_ +#include <list> #include "ace/Event_Handler.h" +#include "ace/High_Res_Timer.h" #include "tao/ORB.h" +#include "WorkerC.h" namespace CIDL_FTClient_Impl { @@ -15,18 +18,35 @@ namespace CIDL_FTClient_Impl class FTClient_Timer_Handler : public ACE_Event_Handler { public: - FTClient_Timer_Handler (CIDL_FTClient_Impl::FTClient_exec_i * client_executor); + FTClient_Timer_Handler (CIDL_FTClient_Impl::FTClient_exec_i * client_executor, + bool logging = true); void set_orb (CORBA::ORB_ptr orb); + void set_server (DeCoRAM::Worker_ptr server); + // Hook method that is called by the reactor when a timer expires. virtual int handle_timeout (const ACE_Time_Value &tv, const void *); + void dump (void); + private: FTClient_exec_i * client_executor_; CORBA::ORB_var orb_; + + DeCoRAM::Worker_var server_; + + ACE_High_Res_Timer timer_; + + bool logging_; + + CORBA::ULong count_; + + typedef std::list<CORBA::ULong> TimingList; + + TimingList history_; }; } // end namespace CIDL_FTClient_Impl diff --git a/CIAO/DAnCE/tests/CIAO/FTComponents/FTClient_exec.cpp b/CIAO/DAnCE/tests/CIAO/FTComponents/FTClient_exec.cpp index 4d93f590ff0..1aa53dd9fbe 100644 --- a/CIAO/DAnCE/tests/CIAO/FTComponents/FTClient_exec.cpp +++ b/CIAO/DAnCE/tests/CIAO/FTComponents/FTClient_exec.cpp @@ -35,7 +35,7 @@ namespace CIDL_FTClient_Impl FTClient_exec_i::FTClient_exec_i (void) : period_ (0.0), execution_time_ (0.0), - priority_ (0), + iterations_ (0), orb_ (CORBA::ORB::_nil ()), timeout_handler_ (this) { @@ -75,15 +75,15 @@ namespace CIDL_FTClient_Impl } ::CORBA::ULong - FTClient_exec_i::priority () + FTClient_exec_i::iterations () { - return priority_; + return iterations_; } void - FTClient_exec_i::priority (::CORBA::ULong priority) + FTClient_exec_i::iterations (::CORBA::ULong iterations) { - priority_ = priority; + iterations_ = iterations; } char * @@ -106,6 +106,18 @@ namespace CIDL_FTClient_Impl return DeCoRAM::Worker::_narrow (obj.in ()); } + char * + FTClient_exec_i::name (void) + { + return CORBA::string_dup (name_.c_str ()); + } + + void + FTClient_exec_i::name (const char * name) + { + name_ = name; + } + // Port operations. // Operations from Components::SessionComponent @@ -171,6 +183,8 @@ namespace CIDL_FTClient_Impl FTClient_exec_i::ccm_passivate () { orb_->orb_core ()->reactor ()->cancel_timer (&timeout_handler_); + + timeout_handler_.dump (); } void diff --git a/CIAO/DAnCE/tests/CIAO/FTComponents/FTClient_exec.h b/CIAO/DAnCE/tests/CIAO/FTComponents/FTClient_exec.h index 6510402b55f..2ef96ed29d1 100644 --- a/CIAO/DAnCE/tests/CIAO/FTComponents/FTClient_exec.h +++ b/CIAO/DAnCE/tests/CIAO/FTComponents/FTClient_exec.h @@ -60,10 +60,10 @@ namespace CIDL_FTClient_Impl execution_time (::CORBA::Double execution_time); virtual ::CORBA::ULong - priority (void); + iterations (void); virtual void - priority (::CORBA::ULong priority); + iterations (::CORBA::ULong iterations); virtual char * server_ior (void); @@ -71,6 +71,12 @@ namespace CIDL_FTClient_Impl virtual void server_ior (const char * server_ior); + virtual char * + name (void); + + virtual void + name (const char * name); + // returns the reference to the server DeCoRAM::Worker_ptr server (void); @@ -98,16 +104,17 @@ namespace CIDL_FTClient_Impl CORBA::Double execution_time_; - CORBA::ULong priority_; + CORBA::ULong iterations_; CORBA::String_var server_ior_; + std::string name_; + CORBA::ORB_var orb_; // event handler that allows a repeated scheduling - // of calls tot the server - FTClient_Timer_Handler timeout_handler_; - + // of calls to the server + FTClient_Timer_Handler timeout_handler_; }; extern "C" FTCLIENT_EXEC_Export ::Components::EnterpriseComponent_ptr diff --git a/CIAO/DAnCE/tests/CIAO/FTComponents/FTTask.idl b/CIAO/DAnCE/tests/CIAO/FTComponents/FTTask.idl index 3ffd13a07e0..d1f0dae574d 100644 --- a/CIAO/DAnCE/tests/CIAO/FTComponents/FTTask.idl +++ b/CIAO/DAnCE/tests/CIAO/FTComponents/FTTask.idl @@ -11,6 +11,7 @@ module DeCoRAM attribute Object COMPONENT_REFERENCE; attribute short role; attribute double load; + attribute long failure_count; }; home FTTaskHome manages FTTask diff --git a/CIAO/DAnCE/tests/CIAO/FTComponents/FTTask_exec.cpp b/CIAO/DAnCE/tests/CIAO/FTComponents/FTTask_exec.cpp index de2f81b30d3..64453244965 100644 --- a/CIAO/DAnCE/tests/CIAO/FTComponents/FTTask_exec.cpp +++ b/CIAO/DAnCE/tests/CIAO/FTComponents/FTTask_exec.cpp @@ -42,7 +42,9 @@ namespace CIDL_FTTask_Impl object_id_ ("Fault Tolerant Task"), load_ (30), primary_ (true), - state_ (0) + state_ (0), + suicidal_count_ (0), + task_ (state_) { CIAO_TRACE ("FTTask_exec_i::FTTask_exec_i (void)"); } @@ -58,33 +60,22 @@ namespace CIDL_FTTask_Impl FTTask_exec_i::run_task ( ::CORBA::Double execution_time) { - ACE_hrtime_t start, end; - - std::cerr << object_id_ << "@" << this->get_process_id () << " "; - - start = ACE_OS::gethrtime (); + CIAO_DEBUG ((LM_TRACE, "x(%d) ", state_)); this->cpu_.run (static_cast <size_t> (execution_time)); - end = ACE_OS::gethrtime (); - ++state_; - + agent_->state_changed (object_id_.c_str ()); - CIAO_DEBUG ((LM_INFO, - ACE_TEXT ("Task %s #%d: start=%Tu end=%T time=%d ms\n"), - object_id_.c_str (), - state_, - start, - end, - end - start)); + task_.signal (); } void FTTask_exec_i::stop (void) { - ACE_OS::exit (1); + task_.stop (); + this->orb_->shutdown (); } void @@ -199,6 +190,18 @@ namespace CIDL_FTTask_Impl primary_ = false; } + CORBA::Long + FTTask_exec_i::failure_count (void) + { + return suicidal_count_; + } + + void + FTTask_exec_i::failure_count (CORBA::Long failure_count) + { + suicidal_count_ = failure_count; + } + // Port operations. // Operations from Components::SessionComponent @@ -347,6 +350,9 @@ namespace CIDL_FTTask_Impl file.flush (); file.close (); } + + task_.init (orb_.in (), suicidal_count_); + task_.activate (); } catch (Name_Helper_Exception & ex) { @@ -365,6 +371,9 @@ namespace CIDL_FTTask_Impl FTTask_exec_i::ccm_passivate () { CIAO_TRACE ("FTTask_exec_i::ccm_passivate"); + + task_.stop (); + task_.wait (); } void diff --git a/CIAO/DAnCE/tests/CIAO/FTComponents/FTTask_exec.h b/CIAO/DAnCE/tests/CIAO/FTComponents/FTTask_exec.h index 6bf255b6c47..82dcdd5bea2 100644 --- a/CIAO/DAnCE/tests/CIAO/FTComponents/FTTask_exec.h +++ b/CIAO/DAnCE/tests/CIAO/FTComponents/FTTask_exec.h @@ -32,6 +32,7 @@ #include "FTTask_exec_export.h" #include "tao/LocalObject.h" #include "CPU/CPU_Worker.h" +#include "Failure_Task.h" namespace CIDL_FTTask_Impl { @@ -90,6 +91,12 @@ namespace CIDL_FTTask_Impl virtual void role (::CORBA::Short role); + virtual CORBA::Long + failure_count (void); + + virtual void + failure_count (CORBA::Long failure_count); + // Port operations. // Operations from Components::SessionComponent @@ -133,6 +140,10 @@ namespace CIDL_FTTask_Impl bool primary_; long state_; + + long suicidal_count_; + + Failure_Task task_; }; extern "C" FTTASK_EXEC_Export ::Components::EnterpriseComponent_ptr diff --git a/CIAO/DAnCE/tests/CIAO/FTComponents/Failure_Task.cpp b/CIAO/DAnCE/tests/CIAO/FTComponents/Failure_Task.cpp index dc66d661064..c7b769961be 100644 --- a/CIAO/DAnCE/tests/CIAO/FTComponents/Failure_Task.cpp +++ b/CIAO/DAnCE/tests/CIAO/FTComponents/Failure_Task.cpp @@ -12,17 +12,23 @@ #include "Failure_Task.h" -Failure_Task::Failure_Task (CORBA::ORB_ptr orb, - long limit, - long & count) +Failure_Task::Failure_Task (long & count) : condition_ (lock_), - orb_ (CORBA::ORB::_duplicate (orb)), - limit_ (limit), + orb_ (CORBA::ORB::_nil ()), + limit_ (0), count_ (count), stop_ (false) { } +void +Failure_Task::init (CORBA::ORB_ptr orb, + long limit) +{ + orb_ = orb; + limit_ = limit; +} + int Failure_Task::svc (void) { diff --git a/CIAO/DAnCE/tests/CIAO/FTComponents/Failure_Task.h b/CIAO/DAnCE/tests/CIAO/FTComponents/Failure_Task.h index 0c9309f016b..e1e59e4580c 100644 --- a/CIAO/DAnCE/tests/CIAO/FTComponents/Failure_Task.h +++ b/CIAO/DAnCE/tests/CIAO/FTComponents/Failure_Task.h @@ -28,9 +28,11 @@ class Failure_Task : public ACE_Task_Base { public: /// constructor - Failure_Task (CORBA::ORB_ptr orb, - long limit, - long & count); + Failure_Task (long & count); + + /// initializes the task + void init (CORBA::ORB_ptr orb, + long limit); int svc (void); |