diff options
author | wolff1 <wolff1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2008-11-11 23:01:38 +0000 |
---|---|---|
committer | wolff1 <wolff1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2008-11-11 23:01:38 +0000 |
commit | 6b7475b1d9e1b61333d4dc6674faac93e4533c97 (patch) | |
tree | d104fc17eb620562a9e84d5e06fbd7ba72b54bfe | |
parent | 5053083f3c1c052191966b104ed6681dc98d79e4 (diff) | |
download | ATCD-6b7475b1d9e1b61333d4dc6674faac93e4533c97.tar.gz |
added registration calls and properties to component executor
5 files changed, 140 insertions, 55 deletions
diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolerance-Deployments/Components/SimpleFT.idl b/CIAO/DAnCE/tests/CIAO/FaultTolerance-Deployments/Components/SimpleFT.idl index fe9dda8b34e..ced46cf9224 100644 --- a/CIAO/DAnCE/tests/CIAO/FaultTolerance-Deployments/Components/SimpleFT.idl +++ b/CIAO/DAnCE/tests/CIAO/FaultTolerance-Deployments/Components/SimpleFT.idl @@ -7,7 +7,9 @@ module Simple { component SimpleFT supports test { - attribute string app_name; + attribute string object_id; + attribute double load; + attribute short role; }; home SimpleFTHome manages SimpleFT diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolerance-Deployments/Components/SimpleFT.mpc b/CIAO/DAnCE/tests/CIAO/FaultTolerance-Deployments/Components/SimpleFT.mpc index 55325aadd50..cff45f0b366 100644 --- a/CIAO/DAnCE/tests/CIAO/FaultTolerance-Deployments/Components/SimpleFT.mpc +++ b/CIAO/DAnCE/tests/CIAO/FaultTolerance-Deployments/Components/SimpleFT.mpc @@ -129,5 +129,3 @@ project(SimpleFT_svnt) : ciao_servant { SimpleFTS.inl } } - - diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolerance-Deployments/Components/SimpleFT_exec.cpp b/CIAO/DAnCE/tests/CIAO/FaultTolerance-Deployments/Components/SimpleFT_exec.cpp index 90d154edfb1..c5d29e4adda 100644 --- a/CIAO/DAnCE/tests/CIAO/FaultTolerance-Deployments/Components/SimpleFT_exec.cpp +++ b/CIAO/DAnCE/tests/CIAO/FaultTolerance-Deployments/Components/SimpleFT_exec.cpp @@ -19,13 +19,16 @@ // http://www.dre.vanderbilt.edu/CIAO #include "SimpleFT_exec.h" + +#include <sstream> #include <ace/Env_Value_T.h> #include <ace/Throughput_Stats.h> #include <orbsvcs/CosNamingC.h> #include "ciao/CIAO_common.h" -#include "ciao/Containers/Container_Base.h" -#include "ciao/Contexts/Context_Impl_Base.h" #include "ciao/FTComponentServer/Name_Helper_T.h" +#include "ciao/FTComponentServer/CommonIDL/ReplicationManagerC.h" +#include "ciao/Containers/Container_Base.h" +#include "SimpleFT_svnt.h" namespace CIDL_SimpleFT_Impl { @@ -34,7 +37,9 @@ namespace CIDL_SimpleFT_Impl //================================================================== SimpleFT_exec_i::SimpleFT_exec_i (void) - : app_name_ ("APPLICATION_NAME"), + : app_name_ ("SimpleFT_Application"), + load_ (0.4), + primary_ (true), orb_ (CORBA::ORB::_nil ()), agent_ (StateSynchronizationAgent::_nil ()), history_ (50), @@ -42,28 +47,6 @@ namespace CIDL_SimpleFT_Impl { CIAO_TRACE ("SimpleFT_exec_i::SimpleFT_exec_i (void)"); CIAO_DEBUG ((LM_EMERGENCY, "SimpleFT - Test - Lifecycle event - SimpleFT_exec_i::SimpleFT_exec_i (void)\n")); - - CIAO::Context_Impl_Base * base_context = dynamic_cast <CIAO::Context_Impl_Base*> (context_.in ()); - - if (base_context == 0) - { - CIAO_ERROR ((LM_ERROR, "could not cast to Context_Impl_Base\n")); - } - else - { - CIAO::Container_var container = base_context->_ciao_the_Container (); - - CIAO::Container_i * container_i = dynamic_cast <CIAO::Container_i*> (container.in ()); - - if (container_i == 0) - { - CIAO_ERROR ((LM_ERROR, "could not cast to Container_i\n")); - } - else - { - orb_ = container_i->the_ORB (); - } - } } SimpleFT_exec_i::~SimpleFT_exec_i (void) @@ -93,6 +76,27 @@ namespace CIDL_SimpleFT_Impl { throw ::CORBA::INTERNAL (); } + + CIDL_SimpleFT_Impl::SimpleFT_Context * ft_context = + CIDL_SimpleFT_Impl::SimpleFT_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 @@ -108,25 +112,35 @@ namespace CIDL_SimpleFT_Impl { CIAO_TRACE ("SimpleFT_exec_i::ccm_activate"); CIAO_DEBUG ((LM_EMERGENCY, "SimpleFT - Test - Lifecycle event - SimpleFT_exec_i::ccm_activate\n")); - - Name_Helper_T <StateSynchronizationAgent> nh (orb_.in (), true); - - CIAO_DEBUG ((LM_DEBUG, "resolving the StateSynchronizationAgent in the NamingService.\n")); - try + try { - agent_ = nh.resolve ("FLARe/" + - this->get_hostname () + - "/StateSynchronizationAgent"); + if (CORBA::is_nil (orb_.in ())) + { + CIAO_ERROR ((LM_WARNING, "SimpleFT_exec_i::ccm_activate - orb_ member is nil.\n")); + return; + } + + // register application with StateSynchronizationAgent + Name_Helper_T <StateSynchronizationAgent> nh (orb_.in (), true); + + 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, "SimpleFT_exec_i::ccm_activate - could not find agent.\n")); return; } - + CIAO_DEBUG ((LM_DEBUG, "registering the application with the agent.\n")); - + ReplicatedApplication_var myself = ReplicatedApplication::_narrow (this); if (CORBA::is_nil (myself.in ())) @@ -136,10 +150,37 @@ namespace CIDL_SimpleFT_Impl } agent_->register_application (app_name_.c_str (), myself.in ()); + + // register application with ReplicationManager + + CIAO_DEBUG ((LM_DEBUG, "resolving the ReplicationManager in the NamingService.\n")); + + Name_Helper_T <ReplicationManager> rmh (orb_.in (), true); + + ReplicationManager_var rm = rmh.resolve ("FLARe/ReplicationManager"); + + std::string hn = this->get_hostname (); + std::string pid = this->get_process_id (); + + CORBA::Object_var self_obj = CORBA::Object::_narrow (this); + + rm->register_application (app_name_.c_str (), + load_, + hn.c_str (), + pid.c_str (), + (primary_ ? 1 : 2), + self_obj.in ()); + } + catch (Name_Helper_Exception & ex) + { + CIAO_ERROR ((LM_ERROR, + "SimpleFT_exec_i::ccm_activate - " + "caught Name_Helper_Exception: %s", + ex.what ())); } catch (CORBA::Exception &ex) { - CIAO_ERROR ((LM_ERROR, "SimpleFT_exec_i::ccm_activate - cuaght: %s", ex._info ().c_str ())); + CIAO_ERROR ((LM_ERROR, "SimpleFT_exec_i::ccm_activate - caught: %s", ex._info ().c_str ())); } } @@ -178,7 +219,7 @@ namespace CIDL_SimpleFT_Impl // Attribute operations char * - SimpleFT_exec_i::app_name (void) + SimpleFT_exec_i::object_id (void) { char * name = new char[app_name_.length ()]; ACE_OS::strcpy (name, app_name_.c_str ()); @@ -187,9 +228,36 @@ namespace CIDL_SimpleFT_Impl } void - SimpleFT_exec_i::app_name (const char * app_name) + SimpleFT_exec_i::object_id (const char * object_id) + { + app_name_ = object_id; + } + + CORBA::Double + SimpleFT_exec_i::load () { - app_name_ = app_name; + return load_; + } + + void + SimpleFT_exec_i::load (CORBA::Double load) + { + load_ = load; + } + + CORBA::Short + SimpleFT_exec_i::role () + { + if (primary_) + return 1; + else + return 2; + } + + void + SimpleFT_exec_i::role (CORBA::Short role) + { + primary_ = (role == 1); } // Supported or inherited operations. @@ -292,6 +360,16 @@ namespace CIDL_SimpleFT_Impl } + std::string + SimpleFT_exec_i::get_process_id () + { + pid_t pid = ACE_OS::getpid (); + std::stringstream ss; + ss << pid; + + return ss.str (); + } + // Home operations. // Factory and finder operations. diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolerance-Deployments/Components/SimpleFT_exec.h b/CIAO/DAnCE/tests/CIAO/FaultTolerance-Deployments/Components/SimpleFT_exec.h index e47e3b8ad00..b66ea665b4d 100644 --- a/CIAO/DAnCE/tests/CIAO/FaultTolerance-Deployments/Components/SimpleFT_exec.h +++ b/CIAO/DAnCE/tests/CIAO/FaultTolerance-Deployments/Components/SimpleFT_exec.h @@ -60,9 +60,17 @@ namespace CIDL_SimpleFT_Impl // Attribute operations. - virtual char * app_name (void); + virtual char * object_id (void); - virtual void app_name (const char * app_name); + virtual void object_id (const char * object_id); + + virtual CORBA::Double load (); + + virtual void load (CORBA::Double load); + + virtual CORBA::Short role (); + + virtual void role (CORBA::Short role); // Port operations. @@ -83,10 +91,20 @@ namespace CIDL_SimpleFT_Impl private: std::string get_hostname (); + std::string get_process_id (); + ::Simple::CCM_SimpleFT_Context_var context_; + // members representing config properties + std::string app_name_; + CORBA::Double load_; + + bool primary_; + + // members needed for component functionality + CORBA::ORB_var orb_; StateSynchronizationAgent_var agent_; diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolerance-Deployments/SimpleComponentExplicitHome.cdp b/CIAO/DAnCE/tests/CIAO/FaultTolerance-Deployments/SimpleComponentExplicitHome.cdp index 31474b4865a..e894997c52a 100644 --- a/CIAO/DAnCE/tests/CIAO/FaultTolerance-Deployments/SimpleComponentExplicitHome.cdp +++ b/CIAO/DAnCE/tests/CIAO/FaultTolerance-Deployments/SimpleComponentExplicitHome.cdp @@ -60,17 +60,6 @@ </value> </value> </execParameter> - <execParameter> - <name>edu.vanderbilt.dre.CIAO.ServerTimeout</name> - <value> - <type> - <kind>tk_ulong</kind> - </type> - <value> - <string>10</string> - </value> - </value> - </execParameter> </implementation> <implementation xmi:id="SimpleFTComponentImplementation"> |