diff options
author | aky <aky@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2011-07-06 21:49:28 +0000 |
---|---|---|
committer | aky <aky@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2011-07-06 21:49:28 +0000 |
commit | 06184073a6569f50143e664048122dbd16632faf (patch) | |
tree | 2580fd62e5a1417cd722b2e4f1b50c22f4a881ec | |
parent | 2bca8d156a6e6584071bdb118d13065c88cc4f63 (diff) | |
download | ATCD-06184073a6569f50143e664048122dbd16632faf.tar.gz |
Added CORFU Tests
30 files changed, 2725 insertions, 0 deletions
diff --git a/DAnCE/ChangeLog b/DAnCE/ChangeLog index 207c3b23f76..e24fcd5775e 100644 --- a/DAnCE/ChangeLog +++ b/DAnCE/ChangeLog @@ -1,3 +1,42 @@ +Wed Jul 6 21:48:20 UTC 2011 Akshay V. Dabholkar <aky@dre.vanderbilt.edu> + + * tests/FTComponents: + + * tests/FTComponents/FTClient.cidl: + * tests/FTComponents/FTClient.idl: + * tests/FTComponents/FTClient_Task.h: + * tests/FTComponents/FTClient_Task.cpp: + * tests/FTComponents/FTClient_Timer_Handler.h: + * tests/FTComponents/FTClient_Timer_Handler.cpp: + * tests/FTComponents/FTClient_exec.h: + * tests/FTComponents/FTClient_exec.cpp: + * tests/FTComponents/FTClient_exec_export.h: + * tests/FTComponents/FTClient_stub_export.h: + * tests/FTComponents/FTClient_svnt_export.h: + * tests/FTComponents/FTComponents.mpc: + * tests/FTComponents/FTTask.cidl: + * tests/FTComponents/FTTask.idl: + * tests/FTComponents/FTTask_exec.h: + * tests/FTComponents/FTTask_exec.cpp: + * tests/FTComponents/FTTask_exec_export.h: + * tests/FTComponents/FTTask_stub_export.h: + * tests/FTComponents/FTTask_svnt_export.h: + * tests/FTComponents/FTTrigger_export.h: + * tests/FTComponents/FTWorker_export.h: + * tests/FTComponents/Failure_Task.h: + * tests/FTComponents/Failure_Task.cpp: + * tests/FTComponents/Trigger.idl: + * tests/FTComponents/Worker.idl: + * tests/FTComponents/client_trigger.cpp: + * tests/FTComponents/killtask.cpp: + + * tests/FaultCorrelation: + + * tests/FaultCorrelation/proc_failure.mpc: + * tests/FaultCorrelation/proc_failure.cpp: + + Added CORFU Tests + Tue Jun 7 21:18:05 UTC 2011 William R. Otte <wotte@dre.vanderbilt.edu> * dance/Plan_Launcher/Plan_Launcher.cpp: diff --git a/DAnCE/tests/FTComponents/FTClient.cidl b/DAnCE/tests/FTComponents/FTClient.cidl new file mode 100644 index 00000000000..13e6a51d947 --- /dev/null +++ b/DAnCE/tests/FTComponents/FTClient.cidl @@ -0,0 +1,12 @@ +// $Id$ + +#include "FTClient.idl" + +composition session FTClient_Impl +{ + home executor FTClientHome_Exec + { + implements DeCoRAM::FTClientHome; + manages SimpleProvider_Exec; + }; +}; diff --git a/DAnCE/tests/FTComponents/FTClient.idl b/DAnCE/tests/FTComponents/FTClient.idl new file mode 100644 index 00000000000..9d34148944b --- /dev/null +++ b/DAnCE/tests/FTComponents/FTClient.idl @@ -0,0 +1,23 @@ + +// $Id$ + +#include <Components.idl> +#include "Trigger.idl" + +module DeCoRAM +{ + component FTClient supports Trigger + { + attribute Object COMPONENT_REFERENCE; + attribute double period; + attribute double execution_time; + attribute unsigned long iterations; + attribute unsigned long logstart; + attribute string server_ior; + attribute string name; + }; + + home FTClientHome manages FTClient + { + }; +}; diff --git a/DAnCE/tests/FTComponents/FTClient_Task.cpp b/DAnCE/tests/FTComponents/FTClient_Task.cpp new file mode 100644 index 00000000000..21c393f0e37 --- /dev/null +++ b/DAnCE/tests/FTComponents/FTClient_Task.cpp @@ -0,0 +1,78 @@ +// $Id$ + +#include <ace/High_Res_Timer.h> +//#include <tao/RTCORBA/RTCORBA.h> +#include <ciao/CIAO_common.h> +#include "FTClient_Task.h" +#include "WorkerC.h" +#include "FTClient_exec.h" + +namespace CIDL_FTClient_Impl +{ + + FTClient_Task::FTClient_Task ( + CIDL_FTClient_Impl::FTClient_exec_i * client_executor) + : client_executor_ (client_executor), + stop_ (false) + { + } + + void + FTClient_Task::set_orb (CORBA::ORB_ptr orb) + { + orb_ = CORBA::ORB::_duplicate (orb); + } + + void + FTClient_Task::stop () + { + stop_ = true; + } + + int + FTClient_Task::svc (void) + { + DeCoRAM::Worker_var server = client_executor_->server (); + + // CORBA::Object_var obj = orb_->resolve_initial_references ("RTCurrent"); + // RTCORBA::Current_var rt_current = RTCORBA::Current::_narrow (obj); + // rt_current->the_priority (client_executor_->priority ()); + + while (!stop_) + { + try + { + CIAO_DEBUG ((LM_DEBUG, ACE_TEXT ("FT_Client_Task::svc : before run_task.\n"))); + + ACE_hrtime_t start, end; + start = ACE_OS::gethrtime (); + + // 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, ACE_TEXT ("FT_Client_Task::svc : after run_task.\n"))); + + /* + CIAO_DEBUG ((LM_DEBUG, + ACE_TEXT ("response time for %f was %d.\n"), + client_executor_->execution_time (), + end - start)); + */ + } + catch (CORBA::SystemException & ex) + { + CIAO_DEBUG ((LM_WARNING, + ACE_TEXT ("FTClient_Task::svc () - " + "caught: %s"), ex._info ().c_str ())); + } + + sleep (2); + } + + return 0; + } + +} // end namespace CIDL_FTClient_Impl diff --git a/DAnCE/tests/FTComponents/FTClient_Task.h b/DAnCE/tests/FTComponents/FTClient_Task.h new file mode 100644 index 00000000000..777a6c6c385 --- /dev/null +++ b/DAnCE/tests/FTComponents/FTClient_Task.h @@ -0,0 +1,37 @@ +// $Id$ + +#ifndef FTCLIENT_TASK_H_ +#define FTCLIENT_TASK_H_ + +#include "ace/Task.h" +#include "tao/ORB.h" + +namespace CIDL_FTClient_Impl +{ + + // forward declaration + class FTClient_exec_i; + + class FTClient_Task : public ACE_Task_Base + { + public: + FTClient_Task (CIDL_FTClient_Impl::FTClient_exec_i * client_executor); + + // Hook method that is called by the reactor when a timer expires. + virtual int svc (void); + + void stop (void); + + void set_orb (CORBA::ORB_ptr orb); + + private: + FTClient_exec_i * client_executor_; + + CORBA::ORB_var orb_; + + bool stop_; + }; + +} // end namespace CIDL_FTClient_Impl + +#endif /* FTCLIENT_TASK_H_ */ diff --git a/DAnCE/tests/FTComponents/FTClient_Timer_Handler.cpp b/DAnCE/tests/FTComponents/FTClient_Timer_Handler.cpp new file mode 100644 index 00000000000..2d77006a6c7 --- /dev/null +++ b/DAnCE/tests/FTComponents/FTClient_Timer_Handler.cpp @@ -0,0 +1,141 @@ +// $Id$ + +#include <ace/High_Res_Timer.h> +#include <ace/Env_Value_T.h> +//#include <tao/RTCORBA/RTCORBA.h> +#include "FTClient_Timer_Handler.h" +#include "ciao/CIAO_common.h" +#include "FTClient_exec.h" + +const char * CORFU_TEXT_ENVIRONMENT_VARIABLE = "CORFU_TEST"; + +namespace CIDL_FTClient_Impl +{ + + FTClient_Timer_Handler::FTClient_Timer_Handler ( + CIDL_FTClient_Impl::FTClient_exec_i * client_executor, + bool logging) + : client_executor_ (client_executor), + logging_ (logging), + count_ (0) + { + timer_.calibrate (); + } + + void + FTClient_Timer_Handler::set_orb (CORBA::ORB_ptr orb) + { + orb_ = CORBA::ORB::_duplicate (orb); + } + + void + FTClient_Timer_Handler::set_server (DeCoRAM::Worker_ptr server) + { + server_ = DeCoRAM::Worker::_duplicate (server); + } + + void + FTClient_Timer_Handler::set_prefix (const char * prefix) + { + prefix_ = prefix; + } + + int + FTClient_Timer_Handler::handle_timeout (const ACE_Time_Value &, + const void *) + { + try + { + /* + CORBA::Object_var obj = orb_->resolve_initial_references ("RTCurrent"); + RTCORBA::Current_var rt_current = RTCORBA::Current::_narrow (obj); + + rt_current->the_priority (client_executor_->priority ()); + */ + + CIAO_DEBUG ((LM_EMERGENCY, "s(%s) ", + client_executor_->name ())); + + if (CORBA::is_nil (server_.in ())) + { + // try to get a recent object reference first + server_ = DeCoRAM::Worker::_duplicate (client_executor_->server ()); + + if (CORBA::is_nil (server_.in ())) + { + return 0; + } + } + + ACE_Time_Value server_processing_time; + + timer_.start (); + + server_processing_time.msec ( + server_->run_task (client_executor_->execution_time ())); + + timer_.stop (); + + ACE_Time_Value rt; + timer_.elapsed_time (rt); + + if (logging_ && (count_ >= client_executor_->logstart ())) + { + ResponseTimeMeasurement m = {server_processing_time, rt}; + history_.push_back (m); + } + } + catch (CORBA::Exception & ex) + { + CIAO_DEBUG ((LM_WARNING, + "FTClient_Timer_Handler::handle_timeout () - " + "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; + logfile += prefix_; + 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->server_time.msec () << " " << it->client_time.msec () << std::endl; + } + + out.close (); + } + } + +} // end namespace CIDL_FTClient_Impl diff --git a/DAnCE/tests/FTComponents/FTClient_Timer_Handler.h b/DAnCE/tests/FTComponents/FTClient_Timer_Handler.h new file mode 100644 index 00000000000..5bc689df815 --- /dev/null +++ b/DAnCE/tests/FTComponents/FTClient_Timer_Handler.h @@ -0,0 +1,63 @@ +// $Id$ + +#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 +{ + + // forward declaration + class FTClient_exec_i; + + class FTClient_Timer_Handler : public ACE_Event_Handler + { + public: + 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); + + void set_prefix (const char * prefix); + + // 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_; + + struct ResponseTimeMeasurement { + ACE_Time_Value server_time; + ACE_Time_Value client_time; + }; + + typedef std::list<ResponseTimeMeasurement> TimingList; + + TimingList history_; + + std::string prefix_; + }; + +} // end namespace CIDL_FTClient_Impl + +#endif /* FTCLIENT_TIMER_HANDLER_H_ */ diff --git a/DAnCE/tests/FTComponents/FTClient_exec.cpp b/DAnCE/tests/FTComponents/FTClient_exec.cpp new file mode 100644 index 00000000000..69866151ab4 --- /dev/null +++ b/DAnCE/tests/FTComponents/FTClient_exec.cpp @@ -0,0 +1,317 @@ +// $Id$ +// +// **** Code generated by the **** +// **** Component Integrated ACE ORB (CIAO) CIDL Compiler **** +// CIAO has been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// CIDL Compiler has been developed by: +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about CIAO is available at: +// http://www.dre.vanderbilt.edu/CIAO + +#include "FTClient_exec.h" +#include "FTClient_svnt.h" +#include "ace/Reactor.h" +#include "tao/ORB_Core.h" +#include "ciao/CIAO_common.h" +#include "ciao/Containers/Container_Base.h" +#include "FTClient_Timer_Handler.h" +#include "ciao/FTComponentServer/Name_Helper_T.h" + +namespace CIDL_FTClient_Impl +{ + //================================================================== + // Component Executor Implementation Class: FTClient_exec_i + //================================================================== + + FTClient_exec_i::FTClient_exec_i (void) + : period_ (0.0), + execution_time_ (0.0), + iterations_ (0), + name_ ("?"), + started_ (false), + orb_ (CORBA::ORB::_nil ()), + timeout_handler_ (this) + { + } + + FTClient_exec_i::~FTClient_exec_i (void) + { + } + + // Supported or inherited operations. + + void + FTClient_exec_i::start (const char * prefix) + { + CIAO_TRACE ("FTClient_exec_i::start ()"); + + if (!started_) + { + timeout_handler_.set_prefix (prefix); + + // register the timer handler with the ORB reactor + ACE_Time_Value period; + period.msec (static_cast<long> (period_)); + + orb_->orb_core ()->reactor ()->schedule_timer (&timeout_handler_, + 0, + ACE_Time_Value::zero, + period); + + started_ = true; + } + } + + // Attribute operations. + + ::CORBA::Double + FTClient_exec_i::period () + { + // Your code here. + return period_; + } + + void + FTClient_exec_i::period (::CORBA::Double period) + { + period_ = period; + } + + ::CORBA::Double + FTClient_exec_i::execution_time () + { + return execution_time_; + } + + void + FTClient_exec_i::execution_time (::CORBA::Double execution_time) + { + execution_time_ = execution_time; + } + + ::CORBA::ULong + FTClient_exec_i::iterations () + { + return iterations_; + } + + void + FTClient_exec_i::iterations (::CORBA::ULong iterations) + { + iterations_ = iterations; + } + + + CORBA::ULong + FTClient_exec_i::logstart (void) + { + return logstart_; + } + + void + FTClient_exec_i::logstart (CORBA::ULong logstart) + { + logstart_ = logstart; + } + + char * + FTClient_exec_i::server_ior () + { + return CORBA::string_dup (server_ior_.in ()); + } + + void + FTClient_exec_i::server_ior (const char * server_ior) + { + server_ior_ = server_ior; + } + + DeCoRAM::Worker_ptr + FTClient_exec_i::server (void) + { + CORBA::Object_var obj = orb_->string_to_object (server_ior_); + + 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; + } + + ::CORBA::Object_ptr + FTClient_exec_i::COMPONENT_REFERENCE () + { + CIAO_TRACE ("FTClient_exec_i::COMPONENT_REFERENCE () getter"); + return CORBA::Object::_duplicate (myself_.in ()); + } + + void + FTClient_exec_i::COMPONENT_REFERENCE (::CORBA::Object_ptr COMPONENT_REFERENCE) + { + CIAO_TRACE ("FTClient_exec_i::COMPONENT_REFERENCE () setter"); + myself_ = CORBA::Object::_duplicate (COMPONENT_REFERENCE); + } + + // Port operations. + + // Operations from Components::SessionComponent + + void + FTClient_exec_i::set_session_context ( + ::Components::SessionContext_ptr ctx) + { + this->context_ = + DeCoRAM::CCM_FTClient_Context::_narrow (ctx); + + if (CORBA::is_nil (this->context_.in ())) + { + throw ::CORBA::INTERNAL (); + } + + CIDL_FTClient_Impl::FTClient_Context * ft_context = + CIDL_FTClient_Impl::FTClient_Context::_narrow (context_.in ()); + + if (0 == ft_context) + { + CIAO_ERROR ((LM_ERROR, "could not narrow to SimpleFT_Context\n")); + return; + } + + CIAO::Container_var container = ft_context->_ciao_the_Container (); + + CIAO::Container_i * ci = dynamic_cast <CIAO::Container_i*> (container.in ()); + + if (ci == 0) + { + CIAO_ERROR ((LM_WARNING, "could not cast to Container_i\n")); + return; + } + + orb_ = ci->the_ORB (); + + timeout_handler_.set_orb (orb_.in ()); + } + + void + FTClient_exec_i::configuration_complete () + { + // Your code here. + } + + void + FTClient_exec_i::ccm_activate () + { + CIAO_TRACE ("FTClient_exec_i::ccm_activate ()"); + + // publish application in NameService for the client + + Name_Helper_T <Trigger> tnh (orb_.in ()); + + Trigger_var ref = Trigger::_narrow (myself_.in ()); + + tnh.bind ("FLARE_TESTAPPLICATION/" + name_ + "Client", + ref.in ()); + + // and write it to a file + std::string iorfilename = name_ + "Client.ior"; + std::ofstream file (iorfilename.c_str ()); + file << orb_->object_to_string (ref.in ()); + file.flush (); + file.close (); + } + + void + FTClient_exec_i::ccm_passivate () + { + orb_->orb_core ()->reactor ()->cancel_timer (&timeout_handler_); + + timeout_handler_.dump (); + } + + void + FTClient_exec_i::ccm_remove () + { + // Your code here. + } + + extern "C" FTCLIENT_EXEC_Export ::Components::EnterpriseComponent_ptr + create_DeCoRAM_FTClient_Impl (void) + { + ::Components::EnterpriseComponent_ptr retval = + ::Components::EnterpriseComponent::_nil (); + + ACE_NEW_RETURN (retval, + FTClient_exec_i, + ::Components::EnterpriseComponent::_nil ()); + + return retval; + } + + //================================================================== + // Home Executor Implementation Class: FTClientHome_exec_i + //================================================================== + + FTClientHome_exec_i::FTClientHome_exec_i (void) + { + } + + FTClientHome_exec_i::~FTClientHome_exec_i (void) + { + } + + // Supported or inherited operations. + + // Home operations. + + // Factory and finder operations. + + // Attribute operations. + + // Implicit operations. + + ::Components::EnterpriseComponent_ptr + FTClientHome_exec_i::create () + { + ::Components::EnterpriseComponent_ptr retval = + ::Components::EnterpriseComponent::_nil (); + + ACE_NEW_THROW_EX ( + retval, + FTClient_exec_i, + ::CORBA::NO_MEMORY ()); + + return retval; + } + + extern "C" FTCLIENT_EXEC_Export ::Components::HomeExecutorBase_ptr + create_DeCoRAM_FTClientHome_Impl (void) + { + ::Components::HomeExecutorBase_ptr retval = + ::Components::HomeExecutorBase::_nil (); + + ACE_NEW_RETURN ( + retval, + FTClientHome_exec_i, + ::Components::HomeExecutorBase::_nil ()); + + return retval; + } +} diff --git a/DAnCE/tests/FTComponents/FTClient_exec.h b/DAnCE/tests/FTComponents/FTClient_exec.h new file mode 100644 index 00000000000..89e6f7dfb0c --- /dev/null +++ b/DAnCE/tests/FTComponents/FTClient_exec.h @@ -0,0 +1,171 @@ +// $Id$ +// +// **** Code generated by the **** +// **** Component Integrated ACE ORB (CIAO) CIDL Compiler **** +// CIAO has been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// CIDL Compiler has been developed by: +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about CIAO is available at: +// http://www.dre.vanderbilt.edu/CIAO + +#ifndef CIAO_FTCLIENT_EXEC_H +#define CIAO_FTCLIENT_EXEC_H + +#include /**/ "ace/pre.h" + +#include "FTClientEC.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "FTClient_exec_export.h" +#include "tao/LocalObject.h" +#include "FTClient_Timer_Handler.h" +#include "WorkerC.h" + +namespace CIDL_FTClient_Impl +{ + class FTCLIENT_EXEC_Export FTClient_exec_i + : public virtual SimpleProvider_Exec, + public virtual ::CORBA::LocalObject + { + public: + FTClient_exec_i (void); + virtual ~FTClient_exec_i (void); + + // Supported or inherited operations. + + virtual void start (const char * prefix); + + // Attribute operations. + virtual ::CORBA::Double + period (void); + + virtual void + period (::CORBA::Double period); + + virtual ::CORBA::Double + execution_time (void); + + virtual void + execution_time (::CORBA::Double execution_time); + + virtual CORBA::ULong + iterations (void); + + virtual void + iterations (CORBA::ULong iterations); + + virtual CORBA::ULong + logstart (void); + + virtual void + logstart (CORBA::ULong logstart); + + virtual char * + server_ior (void); + + virtual void + server_ior (const char * server_ior); + + virtual char * + name (void); + + virtual void + name (const char * name); + + virtual ::CORBA::Object_ptr + COMPONENT_REFERENCE (); + + virtual void + COMPONENT_REFERENCE (::CORBA::Object_ptr COMPONENT_REFERENCE); + + // returns the reference to the server + DeCoRAM::Worker_ptr server (void); + + // Port operations. + + // Operations from Components::SessionComponent + + virtual void + set_session_context ( + ::Components::SessionContext_ptr ctx); + + virtual void configuration_complete (void); + + virtual void ccm_activate (void); + + virtual void ccm_passivate (void); + + virtual void ccm_remove (void); + + private: + DeCoRAM::CCM_FTClient_Context_var context_; + + // members for attribute implementation + CORBA::Double period_; + + CORBA::Double execution_time_; + + CORBA::ULong iterations_; + + CORBA::ULong logstart_; + + CORBA::String_var server_ior_; + + std::string name_; + + bool started_; + + CORBA::ORB_var orb_; + + CORBA::Object_var myself_; + + // event handler that allows a repeated scheduling + // of calls to the server + FTClient_Timer_Handler timeout_handler_; + }; + + extern "C" FTCLIENT_EXEC_Export ::Components::EnterpriseComponent_ptr + create_DeCoRAM_FTClient_Impl (void); + + class FTCLIENT_EXEC_Export FTClientHome_exec_i + : public virtual FTClientHome_Exec, + public virtual ::CORBA::LocalObject + { + public: + FTClientHome_exec_i (void); + virtual ~FTClientHome_exec_i (void); + + // Supported or inherited operations. + + // Home operations. + + // Factory and finder operations. + + // Attribute operations. + + // Implicit operations. + + virtual ::Components::EnterpriseComponent_ptr + create (void); + }; + + extern "C" FTCLIENT_EXEC_Export ::Components::HomeExecutorBase_ptr + create_DeCoRAM_FTClientHome_Impl (void); +}; + +#include /**/ "ace/post.h" + +#endif /* CIAO_FTCLIENT_EXEC_H */ diff --git a/DAnCE/tests/FTComponents/FTClient_exec_export.h b/DAnCE/tests/FTComponents/FTClient_exec_export.h new file mode 100644 index 00000000000..3874ee3958a --- /dev/null +++ b/DAnCE/tests/FTComponents/FTClient_exec_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl FTCLIENT_EXEC +// ------------------------------ +#ifndef FTCLIENT_EXEC_EXPORT_H +#define FTCLIENT_EXEC_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (FTCLIENT_EXEC_HAS_DLL) +# define FTCLIENT_EXEC_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && FTCLIENT_EXEC_HAS_DLL */ + +#if !defined (FTCLIENT_EXEC_HAS_DLL) +# define FTCLIENT_EXEC_HAS_DLL 1 +#endif /* ! FTCLIENT_EXEC_HAS_DLL */ + +#if defined (FTCLIENT_EXEC_HAS_DLL) && (FTCLIENT_EXEC_HAS_DLL == 1) +# if defined (FTCLIENT_EXEC_BUILD_DLL) +# define FTCLIENT_EXEC_Export ACE_Proper_Export_Flag +# define FTCLIENT_EXEC_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define FTCLIENT_EXEC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* FTCLIENT_EXEC_BUILD_DLL */ +# define FTCLIENT_EXEC_Export ACE_Proper_Import_Flag +# define FTCLIENT_EXEC_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define FTCLIENT_EXEC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* FTCLIENT_EXEC_BUILD_DLL */ +#else /* FTCLIENT_EXEC_HAS_DLL == 1 */ +# define FTCLIENT_EXEC_Export +# define FTCLIENT_EXEC_SINGLETON_DECLARATION(T) +# define FTCLIENT_EXEC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* FTCLIENT_EXEC_HAS_DLL == 1 */ + +// Set FTCLIENT_EXEC_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (FTCLIENT_EXEC_NTRACE) +# if (ACE_NTRACE == 1) +# define FTCLIENT_EXEC_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define FTCLIENT_EXEC_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !FTCLIENT_EXEC_NTRACE */ + +#if (FTCLIENT_EXEC_NTRACE == 1) +# define FTCLIENT_EXEC_TRACE(X) +#else /* (FTCLIENT_EXEC_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define FTCLIENT_EXEC_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (FTCLIENT_EXEC_NTRACE == 1) */ + +#endif /* FTCLIENT_EXEC_EXPORT_H */ + +// End of auto generated file. diff --git a/DAnCE/tests/FTComponents/FTClient_stub_export.h b/DAnCE/tests/FTComponents/FTClient_stub_export.h new file mode 100644 index 00000000000..0e508c30d80 --- /dev/null +++ b/DAnCE/tests/FTComponents/FTClient_stub_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl FTCLIENT_STUB +// ------------------------------ +#ifndef FTCLIENT_STUB_EXPORT_H +#define FTCLIENT_STUB_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (FTCLIENT_STUB_HAS_DLL) +# define FTCLIENT_STUB_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && FTCLIENT_STUB_HAS_DLL */ + +#if !defined (FTCLIENT_STUB_HAS_DLL) +# define FTCLIENT_STUB_HAS_DLL 1 +#endif /* ! FTCLIENT_STUB_HAS_DLL */ + +#if defined (FTCLIENT_STUB_HAS_DLL) && (FTCLIENT_STUB_HAS_DLL == 1) +# if defined (FTCLIENT_STUB_BUILD_DLL) +# define FTCLIENT_STUB_Export ACE_Proper_Export_Flag +# define FTCLIENT_STUB_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define FTCLIENT_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* FTCLIENT_STUB_BUILD_DLL */ +# define FTCLIENT_STUB_Export ACE_Proper_Import_Flag +# define FTCLIENT_STUB_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define FTCLIENT_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* FTCLIENT_STUB_BUILD_DLL */ +#else /* FTCLIENT_STUB_HAS_DLL == 1 */ +# define FTCLIENT_STUB_Export +# define FTCLIENT_STUB_SINGLETON_DECLARATION(T) +# define FTCLIENT_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* FTCLIENT_STUB_HAS_DLL == 1 */ + +// Set FTCLIENT_STUB_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (FTCLIENT_STUB_NTRACE) +# if (ACE_NTRACE == 1) +# define FTCLIENT_STUB_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define FTCLIENT_STUB_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !FTCLIENT_STUB_NTRACE */ + +#if (FTCLIENT_STUB_NTRACE == 1) +# define FTCLIENT_STUB_TRACE(X) +#else /* (FTCLIENT_STUB_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define FTCLIENT_STUB_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (FTCLIENT_STUB_NTRACE == 1) */ + +#endif /* FTCLIENT_STUB_EXPORT_H */ + +// End of auto generated file. diff --git a/DAnCE/tests/FTComponents/FTClient_svnt_export.h b/DAnCE/tests/FTComponents/FTClient_svnt_export.h new file mode 100644 index 00000000000..6e628fd8084 --- /dev/null +++ b/DAnCE/tests/FTComponents/FTClient_svnt_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl FTCLIENT_SVNT +// ------------------------------ +#ifndef FTCLIENT_SVNT_EXPORT_H +#define FTCLIENT_SVNT_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (FTCLIENT_SVNT_HAS_DLL) +# define FTCLIENT_SVNT_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && FTCLIENT_SVNT_HAS_DLL */ + +#if !defined (FTCLIENT_SVNT_HAS_DLL) +# define FTCLIENT_SVNT_HAS_DLL 1 +#endif /* ! FTCLIENT_SVNT_HAS_DLL */ + +#if defined (FTCLIENT_SVNT_HAS_DLL) && (FTCLIENT_SVNT_HAS_DLL == 1) +# if defined (FTCLIENT_SVNT_BUILD_DLL) +# define FTCLIENT_SVNT_Export ACE_Proper_Export_Flag +# define FTCLIENT_SVNT_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define FTCLIENT_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* FTCLIENT_SVNT_BUILD_DLL */ +# define FTCLIENT_SVNT_Export ACE_Proper_Import_Flag +# define FTCLIENT_SVNT_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define FTCLIENT_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* FTCLIENT_SVNT_BUILD_DLL */ +#else /* FTCLIENT_SVNT_HAS_DLL == 1 */ +# define FTCLIENT_SVNT_Export +# define FTCLIENT_SVNT_SINGLETON_DECLARATION(T) +# define FTCLIENT_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* FTCLIENT_SVNT_HAS_DLL == 1 */ + +// Set FTCLIENT_SVNT_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (FTCLIENT_SVNT_NTRACE) +# if (ACE_NTRACE == 1) +# define FTCLIENT_SVNT_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define FTCLIENT_SVNT_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !FTCLIENT_SVNT_NTRACE */ + +#if (FTCLIENT_SVNT_NTRACE == 1) +# define FTCLIENT_SVNT_TRACE(X) +#else /* (FTCLIENT_SVNT_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define FTCLIENT_SVNT_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (FTCLIENT_SVNT_NTRACE == 1) */ + +#endif /* FTCLIENT_SVNT_EXPORT_H */ + +// End of auto generated file. diff --git a/DAnCE/tests/FTComponents/FTComponents.mpc b/DAnCE/tests/FTComponents/FTComponents.mpc new file mode 100644 index 00000000000..d1bfc6bdb61 --- /dev/null +++ b/DAnCE/tests/FTComponents/FTComponents.mpc @@ -0,0 +1,317 @@ +// $Id$ + +project(Worker) : ciaoidldefaults, anytypecode, ciao_lib, portableserver { + idlflags += -Wb,stub_export_macro=FTWORKER_Export \ + -Wb,stub_export_include=FTWorker_export.h \ + -Wb,skel_export_macro=FTWORKER_Export \ + -Wb,skel_export_include=FTWorker_export.h + + verbatim(gnuace, macros) { + override no_hidden_visibility = 1 + } + + macros += FTWORKER_BUILD_DLL + + IDL_Files { + Worker.idl + } + Source_Files{ + WorkerC.cpp + WorkerS.cpp + } +} + +project(Trigger) : ciaoidldefaults, anytypecode, ciao_lib, portableserver { + idlflags += -Wb,stub_export_macro=FTTRIGGER_Export \ + -Wb,stub_export_include=FTTrigger_export.h \ + -Wb,skel_export_macro=FTTRIGGER_Export \ + -Wb,skel_export_include=FTTrigger_export.h + + verbatim(gnuace, macros) { + override no_hidden_visibility = 1 + } + + macros += FTTRIGGER_BUILD_DLL + + IDL_Files { + Trigger.idl + } + Source_Files{ + TriggerC.cpp + TriggerS.cpp + } +} + +project(FTClient_idl_gen) : ciaoidldefaults, anytypecode { + avoids += ace_for_tao + custom_only = 1 + idlflags += -Wb,stub_export_macro=FTCLIENT_STUB_Export \ + -Wb,stub_export_include=FTClient_stub_export.h \ + -Wb,skel_export_macro=FTCLIENT_SVNT_Export \ + -Wb,skel_export_include=FTClient_svnt_export.h + idlflags += -I$(TAO_ROOT)/orbsvcs/orbsvcs/LWFT + + IDL_Files { + FTClient.idl + } +} + +project(FTClient_cidl_gen) : ciaocidldefaults, ciaoidldefaults { + avoids += ace_for_tao + custom_only = 1 + cidlflags += --svnt-export-macro FTCLIENT_SVNT_Export \ + --svnt-export-include FTClient_svnt_export.h + idlflags += -Wb,export_macro=FTCLIENT_EXEC_Export \ + -Wb,export_include=FTClient_exec_export.h \ + -SS + + idlflags += -I$(TAO_ROOT)/orbsvcs/orbsvcs/LWFT + cidlflags += -I$(TAO_ROOT)/orbsvcs/orbsvcs/LWFT + + CIDL_Files { + FTClient.cidl + } + + IDL_Files { + FTClientE.idl + } +} + +project(FTClient_stub) : ccm_stub, ciao_lib { + avoids += ace_for_tao + after += FTClient_idl_gen Worker Trigger + libs += Worker Trigger + + sharedname = FTClient_stub + dynamicflags = FTCLIENT_STUB_BUILD_DLL + + IDL_Files { + } + + Source_Files { + FTClientC.cpp + } + + Header_Files { + FTClientC.h + FTClient_stub_export.h + } + + Inline_Files { + FTClientC.inl + } +} + +project(FTClient_exec) : ciao_executor, ciao_container_base_stub, naming, orbsvcslib, ciao_lib { + avoids += ace_for_tao + after += FTClient_cidl_gen FTClient_stub + sharedname = FTClient_exec + libs += FTClient_stub + includes += $(TAO_ROOT)/orbsvcs/orbsvcs/LWFT + dynamicflags = FTCLIENT_EXEC_BUILD_DLL + + IDL_Files { + } + + Source_Files { + FTClientEC.cpp + FTClient_exec.cpp + FTClient_Timer_Handler.cpp + } + + Header_Files { + FTClientEC.h + FTClient_exec.h + FTClient_exec_export.h + FTClient_Timer_Handler.h + } + + Inline_Files { + FTClientEC.inl + } +} + + +project(FTClient_svnt) : ciao_servant, naming, ciao_lib { + avoids += ace_for_tao + after += FTClient_exec + sharedname = FTClient_svnt + libs += FTClient_exec \ + FTClient_stub + + includes += $(TAO_ROOT)/orbsvcs/orbsvcs/LWFT + dynamicflags = FTCLIENT_SVNT_BUILD_DLL + + CIDL_Files { + } + + IDL_Files { + } + + Source_Files { + FTClientS.cpp + FTClient_svnt.cpp + } + + Header_Files { + FTClientS.h + FTClient_svnt.h + FTClient_svnt_export.h + } + + Inline_Files { + FTClientS.inl + } +} + +project(FTTask_idl_gen) : ciaoidldefaults, anytypecode { + avoids += ace_for_tao + custom_only = 1 + idlflags += -Wb,stub_export_macro=FTTASK_STUB_Export \ + -Wb,stub_export_include=FTTask_stub_export.h \ + -Wb,skel_export_macro=FTTASK_SVNT_Export \ + -Wb,skel_export_include=FTTask_svnt_export.h + idlflags += -I$(TAO_ROOT)/orbsvcs/orbsvcs/LWFT + + IDL_Files { + FTTask.idl + } +} + +project(FTTask_cidl_gen) : ciaocidldefaults, ciaoidldefaults { + avoids += ace_for_tao + custom_only = 1 + cidlflags += --svnt-export-macro FTTASK_SVNT_Export \ + --svnt-export-include FTTask_svnt_export.h + idlflags += -Wb,export_macro=FTTASK_EXEC_Export \ + -Wb,export_include=FTTask_exec_export.h \ + -SS + + idlflags += -I$(TAO_ROOT)/orbsvcs/orbsvcs/LWFT + cidlflags += -I$(TAO_ROOT)/orbsvcs/orbsvcs/LWFT + + CIDL_Files { + FTTask.cidl + } + + IDL_Files { + FTTaskE.idl + } +} + +project(FTTask_stub) : ccm_stub, ciao_lib { + avoids += ace_for_tao + after += FTTask_idl_gen Worker + libs += Worker + + includes += $(TAO_ROOT)/orbsvcs/orbsvcs/LWFT + + sharedname = FTTask_stub + dynamicflags = FTTASK_STUB_BUILD_DLL + libs += LWFT_StateSyncAgent + + IDL_Files { + } + + Source_Files { + FTTaskC.cpp + } + + Header_Files { + FTTaskC.h + FTTask_stub_export.h + } + + Inline_Files { + FTTaskC.inl + } +} + +project(FTTask_exec) : ciao_executor, ciao_container_base_stub, naming, orbsvcslib, ciao_lib { + avoids += ace_for_tao + after += FTTask_cidl_gen FTTask_stub + sharedname = FTTask_exec + libs += FTTask_stub CUTS CUTS_CPU_Worker Worker + libpaths += $(CUTS_ROOT)/lib + includes += $(TAO_ROOT)/orbsvcs/orbsvcs/LWFT $(CUTS_ROOT) $(CUTS_ROOT)/cuts/workers + dynamicflags = FTTASK_EXEC_BUILD_DLL + + IDL_Files { + } + + Source_Files { + FTTaskEC.cpp + FTTask_exec.cpp + Failure_Task.cpp + } + + Header_Files { + FTTaskEC.h + FTTask_exec.h + Failure_Task.h + FTTask_exec_export.h + } + + Inline_Files { + FTTaskEC.inl + } +} + + +project(FTTask_svnt) : ciao_servant, naming, ciao_lib { + avoids += ace_for_tao + after += FTTask_exec + sharedname = FTTask_svnt + libs += FTTask_exec \ + FTTask_stub + + includes += $(TAO_ROOT)/orbsvcs/orbsvcs/LWFT + dynamicflags = FTTASK_SVNT_BUILD_DLL + + CIDL_Files { + } + + IDL_Files { + } + + Source_Files { + FTTaskS.cpp + FTTask_svnt.cpp + } + + Header_Files { + FTTaskS.h + FTTask_svnt.h + FTTask_svnt_export.h + } + + Inline_Files { + FTTaskS.inl + } +} + +project(killtask) : naming, ciao { + + after += Worker + libs += Worker + + IDL_Files { + } + + Source_Files { + killtask.cpp + } +} + +project(client_trigger) : naming, ciao { + + after += Trigger + libs += Trigger + + IDL_Files { + } + + Source_Files { + client_trigger.cpp + } +} diff --git a/DAnCE/tests/FTComponents/FTTask.cidl b/DAnCE/tests/FTComponents/FTTask.cidl new file mode 100644 index 00000000000..6a7b56b08db --- /dev/null +++ b/DAnCE/tests/FTComponents/FTTask.cidl @@ -0,0 +1,12 @@ +// $Id$ + +#include "FTTask.idl" + +composition session FTTask_Impl +{ + home executor FTTaskHome_Exec + { + implements DeCoRAM::FTTaskHome; + manages DeCoRAMProvider_Exec; + }; +}; diff --git a/DAnCE/tests/FTComponents/FTTask.idl b/DAnCE/tests/FTComponents/FTTask.idl new file mode 100644 index 00000000000..d1f0dae574d --- /dev/null +++ b/DAnCE/tests/FTComponents/FTTask.idl @@ -0,0 +1,20 @@ +// $Id$ + +#include <Components.idl> +#include <ReplicatedApplication.idl> +#include "Worker.idl" + +module DeCoRAM +{ + component FTTask supports Worker, ReplicatedApplication + { + attribute Object COMPONENT_REFERENCE; + attribute short role; + attribute double load; + attribute long failure_count; + }; + + home FTTaskHome manages FTTask + { + }; +}; diff --git a/DAnCE/tests/FTComponents/FTTask_exec.cpp b/DAnCE/tests/FTComponents/FTTask_exec.cpp new file mode 100644 index 00000000000..2f75d0050da --- /dev/null +++ b/DAnCE/tests/FTComponents/FTTask_exec.cpp @@ -0,0 +1,483 @@ +// $Id$ +// +// **** Code generated by the **** +// **** Component Integrated ACE ORB (CIAO) CIDL Compiler **** +// CIAO has been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// CIDL Compiler has been developed by: +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about CIAO is available at: +// http://www.dre.vanderbilt.edu/CIAO + +#include <sstream> +#include <ace/High_Res_Timer.h> +#include "FTTask_exec.h" +#include "FTTask_svnt.h" +#include "ciao/CIAO_common.h" +#include "ciao/Containers/Container_Base.h" +#include "ciao/FTComponentServer/Name_Helper_T.h" +#include "orbsvcs/orbsvcs/LWFT/StateSynchronizationAgentC.h" +#include "orbsvcs/orbsvcs/LWFT/ReplicationManagerC.h" + +namespace CIDL_FTTask_Impl +{ + //================================================================== + // Component Executor Implementation Class: FTTask_exec_i + //================================================================== + + FTTask_exec_i::FTTask_exec_i (void) + : orb_ (CORBA::ORB::_nil ()), + agent_ (StateSynchronizationAgent::_nil ()), + context_ (DeCoRAM::CCM_FTTask_Context::_nil ()), + myself_ (CORBA::Object::_nil ()), + object_id_ ("Fault Tolerant Task"), + load_ (30), + primary_ (true), + state_ (0), + suicidal_count_ (0), + task_ (state_) + { + CIAO_TRACE ("FTTask_exec_i::FTTask_exec_i (void)"); + + timer_.calibrate (); + } + + FTTask_exec_i::~FTTask_exec_i (void) + { + CIAO_TRACE ("FTTask_exec_i::~FTTask_exec_i (void)"); + } + + // Supported or inherited operations. + + CORBA::Long + FTTask_exec_i::run_task ( + ::CORBA::Double execution_time) + { + CIAO_DEBUG ((LM_EMERGENCY, "x(%s) ", object_id_.c_str ())); + + timer_.start (); + + this->cpu_.run (static_cast <size_t> (execution_time)); + + ++state_; + + agent_->state_changed (object_id_.c_str ()); + + timer_.stop (); + + timer_.elapsed_time (last_execution_time_); + + task_.signal (); + + return last_execution_time_.msec (); + } + + void + FTTask_exec_i::stop (void) + { + task_.stop (); + } + + void + FTTask_exec_i::set_state ( + const ::CORBA::Any & state_value) + { + // extract value to an intermediate long variable since it's not possible + // to extract to a long & directly + CORBA::Long value; + + if (state_value >>= value) + state_ = value; + else + CIAO_DEBUG ((LM_WARNING, + "FTTask_exec_i::set_state () " + "could not extract state value from Any.")); + + CIAO_DEBUG ((LM_TRACE, "FTTask_exec_i::set_state (%d) called.\n", value)); + } + + ::CORBA::Any * + FTTask_exec_i::get_state () + { + // create new any object + CORBA::Any_var state (new CORBA::Any); + + // create intermediate object with the value + CORBA::Long value = state_; + + ACE_DEBUG ((LM_INFO, "FTTask_exec_i::get_state returns %d.\n", value)); + + // insert value into the any object + *state <<= value; + + return state._retn (); + } + + ::StateSynchronizationAgent_ptr + FTTask_exec_i::agent () + { + CIAO_TRACE ("FTTask_exec_i::agent () getter"); + return StateSynchronizationAgent::_duplicate (agent_.in ()); + } + + void + FTTask_exec_i::agent (::StateSynchronizationAgent_ptr agent) + { + CIAO_TRACE ("FTTask_exec_i::agent () setter"); + agent_ = agent; + } + + char * + FTTask_exec_i::object_id (void) + { + CIAO_TRACE ("FTTask_exec_i::object_id () getter"); + return CORBA::string_dup (object_id_.c_str ()); + } + + void + FTTask_exec_i::object_id (const char * object_id) + { + CIAO_TRACE ("FTTask_exec_i::object_id () setter"); + object_id_ = object_id; + } + + // Attribute operations. + + ::CORBA::Object_ptr + FTTask_exec_i::COMPONENT_REFERENCE () + { + CIAO_TRACE ("FTTask_exec_i::COMPONENT_REFERENCE () getter"); + return CORBA::Object::_duplicate (myself_.in ()); + } + + void + FTTask_exec_i::COMPONENT_REFERENCE (::CORBA::Object_ptr COMPONENT_REFERENCE) + { + CIAO_TRACE ("FTTask_exec_i::COMPONENT_REFERENCE () setter"); + myself_ = CORBA::Object::_duplicate (COMPONENT_REFERENCE); + } + + CORBA::Double + FTTask_exec_i::load () + { + return load_; + } + + void + FTTask_exec_i::load (CORBA::Double load) + { + CIAO_DEBUG ((LM_DEBUG, "FTTask_exec_i::load (%d)\n", load)); + load_ = load; + } + + ::CORBA::Short + FTTask_exec_i::role () + { + CIAO_DEBUG ((LM_DEBUG, "FTTask_exec_i::role () getter\n")); + if (primary_) + return 1; + else + return 2; + } + + void + FTTask_exec_i::role (::CORBA::Short role) + { + CIAO_DEBUG ((LM_DEBUG, "FTTask_exec_i::role (%d)\n", role)); + if (role == 1) + primary_ = true; + else + 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 + + void + FTTask_exec_i::set_session_context ( + ::Components::SessionContext_ptr ctx) + { + this->context_ = + ::DeCoRAM::CCM_FTTask_Context::_narrow (ctx); + + if (CORBA::is_nil (this->context_.in ())) + { + throw ::CORBA::INTERNAL (); + } + + CIDL_FTTask_Impl::FTTask_Context * ft_context = + CIDL_FTTask_Impl::FTTask_Context::_narrow (context_.in ()); + + if (0 == ft_context) + { + CIAO_ERROR ((LM_ERROR, "could not narrow to SimpleFT_Context\n")); + return; + } + + CIAO::Container_var container = ft_context->_ciao_the_Container (); + + CIAO::Container_i * ci = dynamic_cast <CIAO::Container_i*> (container.in ()); + + if (ci == 0) + { + CIAO_ERROR ((LM_WARNING, "could not cast to Container_i\n")); + return; + } + + orb_ = ci->the_ORB (); + } + + void + FTTask_exec_i::configuration_complete () + { + CIAO_TRACE ("FTTask_exec_i::configuration_complete (void)"); + + try + { + if (CORBA::is_nil (orb_.in ())) + { + CIAO_ERROR ((LM_WARNING, "FTTask_exec_i::configuration_complete - orb_ member is nil.\n")); + return; + } + + // register application with StateSynchronizationAgent + Name_Helper_T <StateSynchronizationAgent> nh (orb_.in ()); + + CIAO_DEBUG ((LM_DEBUG, "resolving the StateSynchronizationAgent in the NamingService.\n")); + + std::string ssa_path = "FLARe/" + nh.escape_dots (this->get_hostname ()) + "/" + + this->get_process_id () + "/StateSynchronizationAgent"; + + CIAO_DEBUG ((LM_DEBUG, "\tpath = %s\n", ssa_path.c_str ())); + + agent_ = nh.resolve (ssa_path); + + if (CORBA::is_nil (agent_.in ())) + { + CIAO_ERROR ((LM_WARNING, "FTTask_exec_i::configuration_complete - could not find agent.\n")); + return; + } + + CIAO_DEBUG ((LM_DEBUG, "FTTask_exec_i::configuration_complete - registering the application with the agent.\n")); + + if (CORBA::is_nil (myself_.in ())) + { + CIAO_ERROR ((LM_ERROR, "FTTask_exec_i::configuration_complete - Could not resolve my own reference!\n")); + return; + } + + ReplicatedApplication_var myself = ReplicatedApplication::_narrow (myself_.in ()); + + if (CORBA::is_nil (myself.in ())) + { + CIAO_ERROR ((LM_WARNING, "FTTask_exec_i::configuration_complete - could not get reference to itself.\n")); + return; + } + + agent_->register_application (object_id_.c_str (), myself.in ()); + } + catch (Name_Helper_Exception & ex) + { + CIAO_ERROR ((LM_ERROR, + "FTTask_exec_i::configuration_complete - " + "caught Name_Helper_Exception: %s", + ex.what ())); + } + catch (CORBA::Exception &ex) + { + CIAO_ERROR ((LM_ERROR, "FTTask_exec_i::configuration_complete - caught: %s", ex._info ().c_str ())); + } + } + + void + FTTask_exec_i::ccm_activate () + { + CIAO_TRACE ("FTTask_exec_i::ccm_activate"); + + try + { + if (CORBA::is_nil (orb_.in ())) + { + CIAO_ERROR ((LM_WARNING, "FTTask_exec_i::ccm_activate - orb_ member is nil.\n")); + return; + } + + // register application with ReplicationManager + + CIAO_DEBUG ((LM_DEBUG, "resolving the ReplicationManager in the NamingService.\n")); + + Name_Helper_T <ReplicationManager> rmh (orb_.in ()); + + ReplicationManager_var rm = rmh.resolve ("ReplicationManager"); + + std::string hn = this->get_hostname (); + std::string pid = this->get_process_id (); + + rm->register_application (object_id_.c_str (), + load_, + hn.c_str (), + pid.c_str (), + (primary_ ? 1 : 2), + myself_.in ()); + + DeCoRAM::Worker_var ref = DeCoRAM::Worker::_narrow (myself_.in ()); + + // publish application in NameService for the client + if (primary_) + { + Name_Helper_T <Worker> tnh (orb_.in ()); + + tnh.bind ("FLARE_TESTAPPLICATION/" + object_id_, + ref.in ()); + } + + // and write it to a file + std::string iorfilename; + if (!primary_) + iorfilename = object_id_ + "-b.ior"; + else + iorfilename = object_id_ + ".ior"; + + std::ofstream file (iorfilename.c_str ()); + file << orb_->object_to_string (ref.in ()); + file.flush (); + file.close (); + + task_.init (orb_.in (), suicidal_count_); + task_.activate (); + } + catch (Name_Helper_Exception & ex) + { + CIAO_ERROR ((LM_ERROR, + "FTTask_exec_i::ccm_activate - " + "caught Name_Helper_Exception: %s", + ex.what ())); + } + catch (CORBA::Exception &ex) + { + CIAO_ERROR ((LM_ERROR, "FTTask_exec_i::ccm_activate - caught: %s", ex._info ().c_str ())); + } + } + + void + FTTask_exec_i::ccm_passivate () + { + CIAO_TRACE ("FTTask_exec_i::ccm_passivate"); + + task_.stop (); + task_.wait (); + } + + void + FTTask_exec_i::ccm_remove () + { + CIAO_TRACE ("FTTask_exec_i::ccm_remove"); + } + + std::string + FTTask_exec_i::get_hostname () + { + char hn_str [100]; + gethostname (hn_str, sizeof (hn_str)); + + return std::string (hn_str); + } + + + std::string + FTTask_exec_i::get_process_id () + { + pid_t pid = ACE_OS::getpid (); + std::stringstream ss; + ss << pid; + + return ss.str (); + } + + + extern "C" FTTASK_EXEC_Export ::Components::EnterpriseComponent_ptr + create_DeCoRAM_FTTask_Impl (void) + { + ::Components::EnterpriseComponent_ptr retval = + ::Components::EnterpriseComponent::_nil (); + + ACE_NEW_RETURN (retval, + FTTask_exec_i, + ::Components::EnterpriseComponent::_nil ()); + + return retval; + } + + + //================================================================== + // Home Executor Implementation Class: FTTaskHome_exec_i + //================================================================== + + FTTaskHome_exec_i::FTTaskHome_exec_i (void) + { + } + + FTTaskHome_exec_i::~FTTaskHome_exec_i (void) + { + } + + // Supported or inherited operations. + + // Home operations. + + // Factory and finder operations. + + // Attribute operations. + + // Implicit operations. + + ::Components::EnterpriseComponent_ptr + FTTaskHome_exec_i::create () + { + ::Components::EnterpriseComponent_ptr retval = + ::Components::EnterpriseComponent::_nil (); + + ACE_NEW_THROW_EX ( + retval, + FTTask_exec_i, + ::CORBA::NO_MEMORY ()); + + return retval; + } + + extern "C" FTTASK_EXEC_Export ::Components::HomeExecutorBase_ptr + create_DeCoRAM_FTTaskHome_Impl (void) + { + ::Components::HomeExecutorBase_ptr retval = + ::Components::HomeExecutorBase::_nil (); + + ACE_NEW_RETURN ( + retval, + FTTaskHome_exec_i, + ::Components::HomeExecutorBase::_nil ()); + + return retval; + } +} diff --git a/DAnCE/tests/FTComponents/FTTask_exec.h b/DAnCE/tests/FTComponents/FTTask_exec.h new file mode 100644 index 00000000000..ab5df8df465 --- /dev/null +++ b/DAnCE/tests/FTComponents/FTTask_exec.h @@ -0,0 +1,186 @@ +// $Id$ +// +// **** Code generated by the **** +// **** Component Integrated ACE ORB (CIAO) CIDL Compiler **** +// CIAO has been developed by: +// Center for Distributed Object Computing +// Washington University +// St. Louis, MO +// USA +// http://www.cs.wustl.edu/~schmidt/doc-center.html +// CIDL Compiler has been developed by: +// Institute for Software Integrated Systems +// Vanderbilt University +// Nashville, TN +// USA +// http://www.isis.vanderbilt.edu/ +// +// Information about CIAO is available at: +// http://www.dre.vanderbilt.edu/CIAO + +#ifndef CIAO_FTTASK_EXEC_H +#define CIAO_FTTASK_EXEC_H + +#include /**/ "ace/pre.h" + +#include "FTTaskEC.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "FTTask_exec_export.h" +#include "tao/LocalObject.h" +#include "CPU/CPU_Worker.h" +#include "Failure_Task.h" +#include "ace/High_Res_Timer.h" + +namespace CIDL_FTTask_Impl +{ + class FTTASK_EXEC_Export FTTask_exec_i + : public virtual DeCoRAMProvider_Exec, + public virtual ::CORBA::LocalObject + { + public: + FTTask_exec_i (void); + virtual ~FTTask_exec_i (void); + + // Supported or inherited operations. + + virtual CORBA::Long + run_task ( + ::CORBA::Double execution_time); + + virtual void stop (void); + + virtual void + set_state ( + const ::CORBA::Any & state_value); + + virtual ::CORBA::Any * + get_state (); + + virtual ::StateSynchronizationAgent_ptr + agent (); + + virtual void + agent (::StateSynchronizationAgent_ptr agent); + + virtual char * + object_id (); + + virtual void + object_id (const char * object_id); + + // Attribute operations. + + virtual ::CORBA::Object_ptr + COMPONENT_REFERENCE (); + + virtual void + COMPONENT_REFERENCE (::CORBA::Object_ptr COMPONENT_REFERENCE); + + virtual CORBA::Double + load (); + + virtual void + load (CORBA::Double load); + + virtual ::CORBA::Short + role (); + + 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 + + virtual void + set_session_context ( + ::Components::SessionContext_ptr ctx); + + virtual void configuration_complete (); + + virtual void ccm_activate (); + + virtual void ccm_passivate (); + + virtual void ccm_remove (); + + private: + /// helper function to find out about the hostname + std::string get_hostname (); + + /// helper function to find out about the process id of the + /// application + std::string get_process_id (); + + // member variables + + CORBA::ORB_var orb_; + + StateSynchronizationAgent_var agent_; + + DeCoRAM::CCM_FTTask_Context_var context_; + + CORBA::Object_var myself_; + + CUTS_CPU_Worker cpu_; + + std::string object_id_; + + CORBA::Double load_; + + bool primary_; + + long state_; + + long suicidal_count_; + + Failure_Task task_; + + ACE_High_Res_Timer timer_; + + ACE_Time_Value last_execution_time_; + }; + + extern "C" FTTASK_EXEC_Export ::Components::EnterpriseComponent_ptr + create_DeCoRAM_FTTask_Impl (void); + + class FTTASK_EXEC_Export FTTaskHome_exec_i + : public virtual FTTaskHome_Exec, + public virtual ::CORBA::LocalObject + { + public: + FTTaskHome_exec_i (void); + virtual ~FTTaskHome_exec_i (void); + + // Supported or inherited operations. + + // Home operations. + + // Factory and finder operations. + + // Attribute operations. + + // Implicit operations. + + virtual ::Components::EnterpriseComponent_ptr + create (); + }; + + extern "C" FTTASK_EXEC_Export ::Components::HomeExecutorBase_ptr + create_DeCoRAM_FTTaskHome_Impl (void); +} + +#include /**/ "ace/post.h" + +#endif /* CIAO_FTTASK_EXEC_H */ + diff --git a/DAnCE/tests/FTComponents/FTTask_exec_export.h b/DAnCE/tests/FTComponents/FTTask_exec_export.h new file mode 100644 index 00000000000..d82ac9f148c --- /dev/null +++ b/DAnCE/tests/FTComponents/FTTask_exec_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl FTTASK_EXEC +// ------------------------------ +#ifndef FTTASK_EXEC_EXPORT_H +#define FTTASK_EXEC_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (FTTASK_EXEC_HAS_DLL) +# define FTTASK_EXEC_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && FTTASK_EXEC_HAS_DLL */ + +#if !defined (FTTASK_EXEC_HAS_DLL) +# define FTTASK_EXEC_HAS_DLL 1 +#endif /* ! FTTASK_EXEC_HAS_DLL */ + +#if defined (FTTASK_EXEC_HAS_DLL) && (FTTASK_EXEC_HAS_DLL == 1) +# if defined (FTTASK_EXEC_BUILD_DLL) +# define FTTASK_EXEC_Export ACE_Proper_Export_Flag +# define FTTASK_EXEC_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define FTTASK_EXEC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* FTTASK_EXEC_BUILD_DLL */ +# define FTTASK_EXEC_Export ACE_Proper_Import_Flag +# define FTTASK_EXEC_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define FTTASK_EXEC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* FTTASK_EXEC_BUILD_DLL */ +#else /* FTTASK_EXEC_HAS_DLL == 1 */ +# define FTTASK_EXEC_Export +# define FTTASK_EXEC_SINGLETON_DECLARATION(T) +# define FTTASK_EXEC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* FTTASK_EXEC_HAS_DLL == 1 */ + +// Set FTTASK_EXEC_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (FTTASK_EXEC_NTRACE) +# if (ACE_NTRACE == 1) +# define FTTASK_EXEC_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define FTTASK_EXEC_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !FTTASK_EXEC_NTRACE */ + +#if (FTTASK_EXEC_NTRACE == 1) +# define FTTASK_EXEC_TRACE(X) +#else /* (FTTASK_EXEC_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define FTTASK_EXEC_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (FTTASK_EXEC_NTRACE == 1) */ + +#endif /* FTTASK_EXEC_EXPORT_H */ + +// End of auto generated file. diff --git a/DAnCE/tests/FTComponents/FTTask_stub_export.h b/DAnCE/tests/FTComponents/FTTask_stub_export.h new file mode 100644 index 00000000000..1e5ba908c2e --- /dev/null +++ b/DAnCE/tests/FTComponents/FTTask_stub_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl FTTASK_STUB +// ------------------------------ +#ifndef FTTASK_STUB_EXPORT_H +#define FTTASK_STUB_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (FTTASK_STUB_HAS_DLL) +# define FTTASK_STUB_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && FTTASK_STUB_HAS_DLL */ + +#if !defined (FTTASK_STUB_HAS_DLL) +# define FTTASK_STUB_HAS_DLL 1 +#endif /* ! FTTASK_STUB_HAS_DLL */ + +#if defined (FTTASK_STUB_HAS_DLL) && (FTTASK_STUB_HAS_DLL == 1) +# if defined (FTTASK_STUB_BUILD_DLL) +# define FTTASK_STUB_Export ACE_Proper_Export_Flag +# define FTTASK_STUB_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define FTTASK_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* FTTASK_STUB_BUILD_DLL */ +# define FTTASK_STUB_Export ACE_Proper_Import_Flag +# define FTTASK_STUB_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define FTTASK_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* FTTASK_STUB_BUILD_DLL */ +#else /* FTTASK_STUB_HAS_DLL == 1 */ +# define FTTASK_STUB_Export +# define FTTASK_STUB_SINGLETON_DECLARATION(T) +# define FTTASK_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* FTTASK_STUB_HAS_DLL == 1 */ + +// Set FTTASK_STUB_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (FTTASK_STUB_NTRACE) +# if (ACE_NTRACE == 1) +# define FTTASK_STUB_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define FTTASK_STUB_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !FTTASK_STUB_NTRACE */ + +#if (FTTASK_STUB_NTRACE == 1) +# define FTTASK_STUB_TRACE(X) +#else /* (FTTASK_STUB_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define FTTASK_STUB_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (FTTASK_STUB_NTRACE == 1) */ + +#endif /* FTTASK_STUB_EXPORT_H */ + +// End of auto generated file. diff --git a/DAnCE/tests/FTComponents/FTTask_svnt_export.h b/DAnCE/tests/FTComponents/FTTask_svnt_export.h new file mode 100644 index 00000000000..319f37af3d4 --- /dev/null +++ b/DAnCE/tests/FTComponents/FTTask_svnt_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl FTTASK_SVNT +// ------------------------------ +#ifndef FTTASK_SVNT_EXPORT_H +#define FTTASK_SVNT_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (FTTASK_SVNT_HAS_DLL) +# define FTTASK_SVNT_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && FTTASK_SVNT_HAS_DLL */ + +#if !defined (FTTASK_SVNT_HAS_DLL) +# define FTTASK_SVNT_HAS_DLL 1 +#endif /* ! FTTASK_SVNT_HAS_DLL */ + +#if defined (FTTASK_SVNT_HAS_DLL) && (FTTASK_SVNT_HAS_DLL == 1) +# if defined (FTTASK_SVNT_BUILD_DLL) +# define FTTASK_SVNT_Export ACE_Proper_Export_Flag +# define FTTASK_SVNT_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define FTTASK_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* FTTASK_SVNT_BUILD_DLL */ +# define FTTASK_SVNT_Export ACE_Proper_Import_Flag +# define FTTASK_SVNT_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define FTTASK_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* FTTASK_SVNT_BUILD_DLL */ +#else /* FTTASK_SVNT_HAS_DLL == 1 */ +# define FTTASK_SVNT_Export +# define FTTASK_SVNT_SINGLETON_DECLARATION(T) +# define FTTASK_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* FTTASK_SVNT_HAS_DLL == 1 */ + +// Set FTTASK_SVNT_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (FTTASK_SVNT_NTRACE) +# if (ACE_NTRACE == 1) +# define FTTASK_SVNT_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define FTTASK_SVNT_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !FTTASK_SVNT_NTRACE */ + +#if (FTTASK_SVNT_NTRACE == 1) +# define FTTASK_SVNT_TRACE(X) +#else /* (FTTASK_SVNT_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define FTTASK_SVNT_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (FTTASK_SVNT_NTRACE == 1) */ + +#endif /* FTTASK_SVNT_EXPORT_H */ + +// End of auto generated file. diff --git a/DAnCE/tests/FTComponents/FTTrigger_export.h b/DAnCE/tests/FTComponents/FTTrigger_export.h new file mode 100644 index 00000000000..c521927a98f --- /dev/null +++ b/DAnCE/tests/FTComponents/FTTrigger_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl FTTRIGGER +// ------------------------------ +#ifndef FTTRIGGER_EXPORT_H +#define FTTRIGGER_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (FTTRIGGER_HAS_DLL) +# define FTTRIGGER_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && FTTRIGGER_HAS_DLL */ + +#if !defined (FTTRIGGER_HAS_DLL) +# define FTTRIGGER_HAS_DLL 1 +#endif /* ! FTTRIGGER_HAS_DLL */ + +#if defined (FTTRIGGER_HAS_DLL) && (FTTRIGGER_HAS_DLL == 1) +# if defined (FTTRIGGER_BUILD_DLL) +# define FTTRIGGER_Export ACE_Proper_Export_Flag +# define FTTRIGGER_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define FTTRIGGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* FTTRIGGER_BUILD_DLL */ +# define FTTRIGGER_Export ACE_Proper_Import_Flag +# define FTTRIGGER_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define FTTRIGGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* FTTRIGGER_BUILD_DLL */ +#else /* FTTRIGGER_HAS_DLL == 1 */ +# define FTTRIGGER_Export +# define FTTRIGGER_SINGLETON_DECLARATION(T) +# define FTTRIGGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* FTTRIGGER_HAS_DLL == 1 */ + +// Set FTTRIGGER_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (FTTRIGGER_NTRACE) +# if (ACE_NTRACE == 1) +# define FTTRIGGER_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define FTTRIGGER_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !FTTRIGGER_NTRACE */ + +#if (FTTRIGGER_NTRACE == 1) +# define FTTRIGGER_TRACE(X) +#else /* (FTTRIGGER_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define FTTRIGGER_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (FTTRIGGER_NTRACE == 1) */ + +#endif /* FTTRIGGER_EXPORT_H */ + +// End of auto generated file. diff --git a/DAnCE/tests/FTComponents/FTWorker_export.h b/DAnCE/tests/FTComponents/FTWorker_export.h new file mode 100644 index 00000000000..00f48094c86 --- /dev/null +++ b/DAnCE/tests/FTComponents/FTWorker_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl FTWORKER +// ------------------------------ +#ifndef FTWORKER_EXPORT_H +#define FTWORKER_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (FTWORKER_HAS_DLL) +# define FTWORKER_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && FTWORKER_HAS_DLL */ + +#if !defined (FTWORKER_HAS_DLL) +# define FTWORKER_HAS_DLL 1 +#endif /* ! FTWORKER_HAS_DLL */ + +#if defined (FTWORKER_HAS_DLL) && (FTWORKER_HAS_DLL == 1) +# if defined (FTWORKER_BUILD_DLL) +# define FTWORKER_Export ACE_Proper_Export_Flag +# define FTWORKER_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define FTWORKER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* FTWORKER_BUILD_DLL */ +# define FTWORKER_Export ACE_Proper_Import_Flag +# define FTWORKER_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define FTWORKER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* FTWORKER_BUILD_DLL */ +#else /* FTWORKER_HAS_DLL == 1 */ +# define FTWORKER_Export +# define FTWORKER_SINGLETON_DECLARATION(T) +# define FTWORKER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* FTWORKER_HAS_DLL == 1 */ + +// Set FTWORKER_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (FTWORKER_NTRACE) +# if (ACE_NTRACE == 1) +# define FTWORKER_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define FTWORKER_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !FTWORKER_NTRACE */ + +#if (FTWORKER_NTRACE == 1) +# define FTWORKER_TRACE(X) +#else /* (FTWORKER_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define FTWORKER_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (FTWORKER_NTRACE == 1) */ + +#endif /* FTWORKER_EXPORT_H */ + +// End of auto generated file. diff --git a/DAnCE/tests/FTComponents/Failure_Task.cpp b/DAnCE/tests/FTComponents/Failure_Task.cpp new file mode 100644 index 00000000000..51677bfeb51 --- /dev/null +++ b/DAnCE/tests/FTComponents/Failure_Task.cpp @@ -0,0 +1,59 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Failure_Task.cpp + * + * $Id$ + * + * @author Friedhelm Wolf <fwolf@dre.vanderbilt.edu> + */ +//============================================================================= + +#include "Failure_Task.h" + +Failure_Task::Failure_Task (long & count) + : condition_ (lock_), + 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) +{ + ACE_Guard <ACE_Thread_Mutex> guard (lock_); + + while (((limit_ == 0) || (count_ < limit_)) && !stop_) + { + condition_.wait (); + } + + // don't call shutdown on regular stop + orb_->shutdown (true); + + return 0; +} + +void +Failure_Task::signal (void) +{ + condition_.signal (); +} + +void +Failure_Task::stop (void) +{ + stop_ = true; + condition_.signal (); +} diff --git a/DAnCE/tests/FTComponents/Failure_Task.h b/DAnCE/tests/FTComponents/Failure_Task.h new file mode 100644 index 00000000000..e1e59e4580c --- /dev/null +++ b/DAnCE/tests/FTComponents/Failure_Task.h @@ -0,0 +1,67 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Failure_Task.h + * + * $Id$ + * + * @author Friedhelm Wolf <fwolf@dre.vanderbilt.edu> + */ +//============================================================================= + +#ifndef FAILURE_TASK_H_ +#define FAILURE_TASK_H_ + +#include "ace/Condition_T.h" +#include "ace/Task.h" +#include "tao/ORB.h" + +/** + * @class Failure_Task + * + * @brief Active object that can be notified to simulate an + * application crash by shutting down the ORB. + */ + +class Failure_Task : public ACE_Task_Base +{ + public: + /// constructor + Failure_Task (long & count); + + /// initializes the task + void init (CORBA::ORB_ptr orb, + long limit); + + int svc (void); + + /// signals the internal condition + void signal (void); + + /// stops the thread by signaling the condition + void stop (void); + + private: + /// lock for condition variable + ACE_Thread_Mutex lock_; + + /// This condition variable is used for signalling changes of the + /// count + ACE_Condition <ACE_Thread_Mutex> condition_; + + /// ORB reference + CORBA::ORB_var orb_; + + /// limit that the count has to reach to provoke a failure + /// Zero means there is no limit and no failure will occure + long limit_; + + /// invocation count + long & count_; + + /// flag that indicates that the thread should be shut down + bool stop_; +}; + +#endif /* FAILURE_TASK_H_ */ diff --git a/DAnCE/tests/FTComponents/Trigger.idl b/DAnCE/tests/FTComponents/Trigger.idl new file mode 100644 index 00000000000..03e6de9d37d --- /dev/null +++ b/DAnCE/tests/FTComponents/Trigger.idl @@ -0,0 +1,9 @@ +#ifndef TRIGGER_IDL_ +#define TRIGGER_IDL_ + +interface Trigger +{ + void start (in string prefix); +}; + +#endif /* TRIGGER_IDL_ */ diff --git a/DAnCE/tests/FTComponents/Worker.idl b/DAnCE/tests/FTComponents/Worker.idl new file mode 100644 index 00000000000..2628afcbbfe --- /dev/null +++ b/DAnCE/tests/FTComponents/Worker.idl @@ -0,0 +1,13 @@ +module DeCoRAM +{ + interface Worker + { + /** + * @param execution_time indicates how long the method will run in + * ms. + * @return time in ms that has elapsed since the method started. + */ + long run_task (in double execution_time); + void stop (); + }; +}; diff --git a/DAnCE/tests/FTComponents/client_trigger.cpp b/DAnCE/tests/FTComponents/client_trigger.cpp new file mode 100644 index 00000000000..eba2316170e --- /dev/null +++ b/DAnCE/tests/FTComponents/client_trigger.cpp @@ -0,0 +1,78 @@ +// $Id$ + +#include <string> +#include <vector> +#include "TriggerC.h" +#include "ace/Get_Opt.h" + +const ACE_TCHAR *prefix = ACE_TEXT (""); +std::vector <std::string> applications; + +int +parse_args (int argc, ACE_TCHAR *argv[]) +{ + if (argc > 1) + prefix = argv[1]; + + if (argc > 2) + { + for (int i = 2; i < argc; ++i) + { + applications.push_back (argv[i]); + } + } + else + return -1; + + // Indicates sucessful parsing of the command line + return 0; +} + +int +ACE_TMAIN(int argc, ACE_TCHAR *argv[]) +{ + try + { + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); + + if (parse_args (argc, argv) != 0) + return 1; + + std::vector <Trigger_var> triggers; + + for (std::vector<std::string>::iterator it = applications.begin (); + it != applications.end (); + ++it) + { + CORBA::Object_var tmp = orb->string_to_object(it->c_str ()); + + Trigger_var trigger = Trigger::_narrow(tmp.in ()); + + if (CORBA::is_nil (trigger.in ())) + { + ACE_ERROR_RETURN ((LM_DEBUG, + "Nil Trigger reference <%s>\n", + it->c_str ()), + 1); + } + + triggers.push_back (trigger); + } + + for (std::vector<Trigger_var>::iterator it2 = triggers.begin (); + it2 != triggers.end (); + ++it2) + { + (*it2)->start (CORBA::string_dup (prefix)); + } + + orb->destroy (); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + return 1; + } + + return 0; +} diff --git a/DAnCE/tests/FTComponents/killtask.cpp b/DAnCE/tests/FTComponents/killtask.cpp new file mode 100644 index 00000000000..4aba79e20ed --- /dev/null +++ b/DAnCE/tests/FTComponents/killtask.cpp @@ -0,0 +1,66 @@ +// $Id$ + +#include "WorkerC.h" +#include "ace/Get_Opt.h" + +const ACE_TCHAR *first_ior = ACE_TEXT ("file://first.ior"); + +int +parse_args (int argc, ACE_TCHAR *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:")); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'k': + first_ior = get_opts.opt_arg (); + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s" + "-k <ior> " + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + +int +ACE_TMAIN(int argc, ACE_TCHAR *argv[]) +{ + try + { + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); + + if (parse_args (argc, argv) != 0) + return 1; + + CORBA::Object_var tmp = orb->string_to_object(first_ior); + + DeCoRAM::Worker_var worker = DeCoRAM::Worker::_narrow(tmp.in ()); + + if (CORBA::is_nil (worker.in ())) + { + ACE_ERROR_RETURN ((LM_DEBUG, + "Nil Worker reference <%s>\n", + first_ior), + 1); + } + + worker->stop (); + + orb->destroy (); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + return 1; + } + + return 0; +} diff --git a/DAnCE/tests/FaultCorrelation/proc_failure.cpp b/DAnCE/tests/FaultCorrelation/proc_failure.cpp new file mode 100644 index 00000000000..f0bf902eb21 --- /dev/null +++ b/DAnCE/tests/FaultCorrelation/proc_failure.cpp @@ -0,0 +1,62 @@ +/** + * @file proc_failure.cpp + * @author Friedhelm Wolf <fwolf@dre.vanderbilt.edu> + * $Id$ + * Triggers a proc_failure () call on the FaultCorrelationManager + * interface + */ + +#include "Interfaces/FaultCorrelationManagerC.h" + +int usage () +{ + ACE_ERROR ((LM_ERROR, "proc_failure <fcm_url> <object_id> <node_id>\n")); + return -1; +} + +#include <iostream> + +int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) +{ + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); + + if (argc != 4) + return usage (); + + try + { + ACE_DEBUG ((LM_DEBUG, "resolving FCM reference %C\n", argv[1])); + + CORBA::Object_var obj = orb->string_to_object (argv[1]); + + DAnCE::FaultCorrelationManager_var fcm = + DAnCE::FaultCorrelationManager::_narrow (obj.in ()); + + if (CORBA::is_nil (fcm.in ())) + { + ACE_DEBUG ((LM_ERROR, "FCM reference is nil.\n")); + return -1; + } + + ACE_DEBUG ((LM_DEBUG, + "calling proc_failure (%C, %C)\n", + argv[2], + argv[3])); + + fcm->proc_failure (argv[2], argv[3]); + } + catch (CORBA::Exception &ex) + { + ACE_ERROR ((LM_ERROR, "*** Caught CORBA exception: %s\n", + ex._info ().c_str ())); + return -1; + + } + catch (...) + { + orb->destroy (); + ACE_ERROR ((LM_ERROR, "*** Caugn unknown exception\n")); + return -1; + } + return 0; +} diff --git a/DAnCE/tests/FaultCorrelation/proc_failure.mpc b/DAnCE/tests/FaultCorrelation/proc_failure.mpc new file mode 100644 index 00000000000..08cfc42dadd --- /dev/null +++ b/DAnCE/tests/FaultCorrelation/proc_failure.mpc @@ -0,0 +1,8 @@ +// $Id$ +project(proc_failure) : dance_deployment_stub { + libs += DAnCE_FaultCorrelationManager_stub DAnCE_ExecutionManager_stub + + Source_Files { + proc_failure.cpp + } +}
\ No newline at end of file |