diff options
author | wolff1 <wolff1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2008-11-06 22:37:00 +0000 |
---|---|---|
committer | wolff1 <wolff1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2008-11-06 22:37:00 +0000 |
commit | d2b1bf694b1df6a35d75d5b87fc4e03a57e473ec (patch) | |
tree | a007cbc46abd87bc6a6542c40affc175e36ba08f | |
parent | 46e0fab39bbc9992e9e2e9c814d54c6cc29703aa (diff) | |
download | ATCD-d2b1bf694b1df6a35d75d5b87fc4e03a57e473ec.tar.gz |
add ft component server
99 files changed, 8547 insertions, 4 deletions
diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/.depend.simple_nm_launcher b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/.depend.simple_nm_launcher new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/.depend.simple_nm_launcher diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT.cidl b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT.cidl new file mode 100644 index 00000000000..c923063eacd --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT.cidl @@ -0,0 +1,12 @@ +// $Id$ + +#include "SimpleFT.idl" + +composition session SimpleFT_Impl +{ + home executor SimpleFTHome_Exec + { + implements Simple::SimpleFTHome; + manages SimpleProvider_Exec; + }; +}; diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT.idl b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT.idl new file mode 100644 index 00000000000..2671922ef42 --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT.idl @@ -0,0 +1,15 @@ +// $Id$ + +#include <Components.idl> +#include "Test.idl" + +module Simple +{ + component SimpleFT supports test + { + }; + + home SimpleFTHome manages SimpleFT + { + }; +}; diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT.mpc b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT.mpc new file mode 100644 index 00000000000..55325aadd50 --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT.mpc @@ -0,0 +1,133 @@ +// $Id$ +// This file is generated with "generate_component_mpc.pl SimpleFT" + +project(SimpleFT_idl_gen) : taoidldefaults, anytypecode { + avoids += ace_for_tao + custom_only = 1 + idlflags += -Wb,stub_export_macro=SIMPLEFT_STUB_Export \ + -Wb,stub_export_include=SimpleFT_stub_export.h \ + -Wb,skel_export_macro=SIMPLEFT_SVNT_Export \ + -Wb,skel_export_include=SimpleFT_svnt_export.h + idlflags += -I$(CIAO_ROOT)/ccm + idlflags += -I$(CIAO_ROOT)/ciao/FTComponentServer/CommonIDL + + IDL_Files { + SimpleFT.idl + Test.idl + } +} + +project(SimpleFT_cidl_gen) : ciaocidldefaults, taoidldefaults { + avoids += ace_for_tao + custom_only = 1 + cidlflags += --svnt-export-macro SIMPLEFT_SVNT_Export \ + --svnt-export-include SimpleFT_svnt_export.h + idlflags += -Wb,export_macro=SIMPLEFT_EXEC_Export \ + -Wb,export_include=SimpleFT_exec_export.h \ + -SS + idlflags += -I$(CIAO_ROOT)/ccm + + cidlflags += -I$(CIAO_ROOT)/ciao/FTComponentServer/CommonIDL + idlflags += -I$(CIAO_ROOT)/ciao/FTComponentServer/CommonIDL + + CIDL_Files { + SimpleFT.cidl + } + + IDL_Files { + SimpleFTE.idl + } +} + +project(SimpleFT_stub) : ccm_stub { + avoids += ace_for_tao + after += SimpleFT_idl_gen + libs += FTCommonIdl + + includes += $(CIAO_ROOT)/ciao/FTComponentServer/CommonIDL + + sharedname = SimpleFT_stub + dynamicflags = SIMPLEFT_STUB_BUILD_DLL + + IDL_Files { + } + + Source_Files { + SimpleFTC.cpp + TestC.cpp + } + + Header_Files { + SimpleFTC.h + SimpleFT_stub_export.h + } + + Inline_Files { + SimpleFTC.inl + } +} + +project(SimpleFT_exec) : ciao_executor, orbsvcslib { + avoids += ace_for_tao + after += SimpleFT_cidl_gen SimpleFT_stub + sharedname = SimpleFT_exec + libs += SimpleFT_stub + + includes += $(CIAO_ROOT)/ciao/FTComponentServer/CommonIDL + + dynamicflags = SIMPLEFT_EXEC_BUILD_DLL + + IDL_Files { + } + + Source_Files { + SimpleFTEC.cpp + SimpleFT_exec.cpp + } + + Header_Files { + SimpleFTEC.h + SimpleFT_exec.h + SimpleFT_exec_export.h + } + + Inline_Files { + SimpleFTEC.inl + } +} + + +project(SimpleFT_svnt) : ciao_servant { + avoids += ace_for_tao + after += SimpleFT_exec + sharedname = SimpleFT_svnt + libs += SimpleFT_exec \ + SimpleFT_stub + includes += $(CIAO_ROOT)/ciao/FTComponentServer/CommonIDL + + dynamicflags = SIMPLEFT_SVNT_BUILD_DLL + + CIDL_Files { + } + + IDL_Files { + } + + Source_Files { + SimpleFTS.cpp + SimpleFT_svnt.cpp + TestS.cpp + } + + Header_Files { + SimpleFTS.h + SimpleFT_svnt.h + SimpleFT_svnt_export.h + } + + Inline_Files { + SimpleFTS.inl + } +} + + diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT_exec.cpp b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT_exec.cpp new file mode 100644 index 00000000000..7661c1e7205 --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT_exec.cpp @@ -0,0 +1,275 @@ +// $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 "SimpleFT_exec.h" +#include <ace/Env_Value_T.h> +#include <orbsvcs/CosNamingC.h> +#include "ciao/CIAO_common.h" +#include "ciao/Containers/Container_Base.h" +#include "ciao/Contexts/Context_Impl_Base.h" + + +namespace CIDL_SimpleFT_Impl +{ + //================================================================== + // Component Executor Implementation Class: SimpleFT_exec_i + //================================================================== + + SimpleFT_exec_i::SimpleFT_exec_i (void) + { + 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")); + } + + SimpleFT_exec_i::~SimpleFT_exec_i (void) + { + CIAO_TRACE ("SimpleFT_exec_i::~SimpleFT_exec_i"); + CIAO_DEBUG ((LM_EMERGENCY, "SimpleFT - Test - Lifecycle event - SimpleFT_exec_i::~SimpleFT_exec_i\n")); + } + + // Supported or inherited operations. + + // Attribute operations. + + // Port operations. + + // Operations from Components::SessionComponent + + void + SimpleFT_exec_i::set_session_context ( + ::Components::SessionContext_ptr ctx) + { + CIAO_TRACE ("SimpleFT_exec_i::set_session_context"); + CIAO_DEBUG ((LM_EMERGENCY, "SimpleFT - Test - Lifecycle event - SimpleFT_exec_i::set_session_context\n")); + this->context_ = + ::Simple::CCM_SimpleFT_Context::_narrow (ctx); + + if (CORBA::is_nil (this->context_.in ())) + { + throw ::CORBA::INTERNAL (); + } + } + + void + SimpleFT_exec_i::configuration_complete () + { + CIAO_TRACE ("SimpleFT_exec_i::configuration_complete\n"); + CIAO_DEBUG ((LM_EMERGENCY, "SimpleFT - Test - Lifecycle event - SimpleFT_exec_i::configuration_complete\n")); + // Your code here. + } + + void + SimpleFT_exec_i::ccm_activate () + { + CIAO_TRACE ("SimpleFT_exec_i::ccm_activate"); + CIAO_DEBUG ((LM_EMERGENCY, "SimpleFT - Test - Lifecycle event - SimpleFT_exec_i::ccm_activate\n")); + + CIAO_DEBUG ((LM_DEBUG, "resolving name service reference\n")); +#ifdef RESOLVE_INITIAL_REFERENCE_IS_IMPLEMENTED + CORBA::Object_var ns_obj = context_->resolve_service_reference ("NameService"); +#else + std::string ns_ior = ACE_Env_Value <std::string> ("NameServiceIOR", std::string ()); + + if (ns_ior.empty ()) + { + CIAO_ERROR ((LM_WARNING, "SimpleFT_exec_i::ccm_activate - could find NameServiceIOR env variable.\n")); + return; + } +#endif +#if 0 + CIAO::Context_Impl_Base * base_context = + dynamic_cast <CIAO::Context_Impl_Base*> (context_.in ()); + CORBA::Object_var ns_obj = base_context->_ciao_the_Container ()->the_ORB ()->string_to_object (ns_ior.c_str ()); + + CIAO_DEBUG ((LM_DEBUG, "narrowing name servic\n")); + CosNaming::NamingContextExt_var ns = CosNaming::NamingContextExt::_narrow (ns_obj.in ()); +#endif + } + + void + SimpleFT_exec_i::ccm_passivate () + { + CIAO_TRACE ("SimpleFT_exec_i::ccm_passivate"); + CIAO_DEBUG ((LM_EMERGENCY, "SimpleFT - Test - Lifecycle event - SimpleFT_exec_i::ccm_passivate\n")); + // Your code here. + } + + void + SimpleFT_exec_i::ccm_remove () + { + CIAO_TRACE ("SimpleFT_exec_i::ccm_remove"); + CIAO_DEBUG ((LM_EMERGENCY, "SimpleFT - Test - Lifecycle event - SimpleFT_exec_i::ccm_remove\n")); + // Your code here. + } + + //================================================================== + // Home Executor Implementation Class: SimpleFTHome_exec_i + //================================================================== + + SimpleFTHome_exec_i::SimpleFTHome_exec_i (void) + { + CIAO_TRACE ("SimpleFTHome_exec_i::SimpleFTHome_exec_i"); + CIAO_DEBUG ((LM_EMERGENCY, "SimpleFT - Test - Lifecycle event - SimpleFTHome_exec_i::SimpleFTHome_exec_i\n")); + } + + SimpleFTHome_exec_i::~SimpleFTHome_exec_i (void) + { + CIAO_TRACE ("SimpleFTHome_exec_i::~SimpleFTHome_exec_i"); + CIAO_DEBUG ((LM_EMERGENCY, "SimpleFT - Test - Lifecycle event - SimpleFTHome_exec_i::~SimpleFTHome_exec_i\n")); + } + + // Supported or inherited operations. + + void + SimpleFT_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, + "ReplicatedApplication_i::set_state () " + "could not extract satet value from Any.")); + + CIAO_DEBUG ((LM_TRACE, "test_i::set_state (%d) called.\n", value)); + + } + + CORBA::Any * + SimpleFT_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_DEBUG, "test_i::get_state returns %d.\n", value)); + + // insert value into the any object + *state <<= value; + + return state._retn (); + } + + void + SimpleFT_exec_i::method (CORBA::ULong test_start, CORBA::ULong test_end, + CORBA::ULong work, + CORBA::ULong prime_number, + CORBA::ULong kill) + { +#ifdef JUST_COPIED + static int i = 0; + ACE_DEBUG ((LM_DEBUG, "%d\n",i++)); + + if (kill && stop_) + ACE_OS::exit (1); + if (test_start == 1) + { + this->start_ = ACE_OS::gethrtime (); + } + ACE_hrtime_t start = ACE_OS::gethrtime (); + + for (; work != 0; work--) + ACE::is_prime (prime_number, + 2, + prime_number / 2); + ACE_hrtime_t end = ACE_OS::gethrtime (); + + ++state_; + + if (!CORBA::is_nil (agent_.in ())) + agent_->state_changed (object_id_.c_str ()); + + // ACE_DEBUG ((LM_DEBUG, "Time taken = %d\n", end - start)); + this->history_.sample (end - start); + if (test_end == 1) + { + this->end_ = ACE_OS::gethrtime (); + } +#endif + } + + void + SimpleFT_exec_i::dump (void) + { +#ifdef JUST_COPIED + ACE_UINT32 gsf = ACE_High_Res_Timer::global_scale_factor (); + ACE_Basic_Stats stats; + this->history_.collect_basic_stats (stats); + stats.dump_results ("Total", gsf); + ACE_Throughput_Stats::dump_throughput ("Total", gsf, + this->end_ - this->start_, + stats.samples_count ()); +#endif + } + + void + SimpleFT_exec_i::shutdown (void) + { +#ifdef JUST_COPIED + this->orb_->shutdown (0); +#endif + } + + // Home operations. + + // Factory and finder operations. + + // Attribute operations. + + // Implicit operations. + + ::Components::EnterpriseComponent_ptr + SimpleFTHome_exec_i::create () + { + CIAO_TRACE ("SimpleFTHome_exec_i::create"); + CIAO_DEBUG ((LM_EMERGENCY, "SimpleFT - Test - Lifecycle event - SimpleFTHome_exec_i::create\n")); + ::Components::EnterpriseComponent_ptr retval = + ::Components::EnterpriseComponent::_nil (); + + ACE_NEW_THROW_EX ( + retval, + SimpleFT_exec_i, + ::CORBA::NO_MEMORY ()); + + return retval; + } + + extern "C" SIMPLEFT_EXEC_Export ::Components::HomeExecutorBase_ptr + create_Simple_SimpleFTHome_Impl (void) + { + CIAO_TRACE ("create_Simple_SimpleFTHome_Impl"); + CIAO_DEBUG ((LM_EMERGENCY, "SimpleFT - Test - Lifecycle event - create_Simple_SimpleFTHome_Impl\n")); + ::Components::HomeExecutorBase_ptr retval = + ::Components::HomeExecutorBase::_nil (); + + ACE_NEW_RETURN ( + retval, + SimpleFTHome_exec_i, + ::Components::HomeExecutorBase::_nil ()); + + return retval; + } +} + diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT_exec.h b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT_exec.h new file mode 100644 index 00000000000..d431d336172 --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT_exec.h @@ -0,0 +1,114 @@ +// $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_SIMPLEFT_EXEC_H +#define CIAO_SIMPLEFT_EXEC_H + +#include /**/ "ace/pre.h" + +#include "SimpleFTEC.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "SimpleFT_exec_export.h" +#include "tao/LocalObject.h" +#include "StateSynchronizationAgentC.h" + +namespace CIDL_SimpleFT_Impl +{ + class SIMPLEFT_EXEC_Export SimpleFT_exec_i + : public virtual SimpleProvider_Exec, + public virtual ::CORBA::LocalObject + { + public: + SimpleFT_exec_i (void); + virtual ~SimpleFT_exec_i (void); + + // Supported or inherited operations. + + virtual void set_state (const CORBA::Any & state_value); + + virtual CORBA::Any * get_state (); + + virtual void method (CORBA::ULong start, CORBA::ULong end, CORBA::ULong work, + CORBA::ULong prime_number, CORBA::ULong kill); + + virtual void shutdown (void); + + virtual void dump (void); + + // Attribute operations. + + // 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: + ::Simple::CCM_SimpleFT_Context_var context_; + + StateSynchronizationAgent_var agent_; + + long state_; + }; + + class SIMPLEFT_EXEC_Export SimpleFTHome_exec_i + : public virtual SimpleFTHome_Exec, + public virtual ::CORBA::LocalObject + { + public: + SimpleFTHome_exec_i (void); + virtual ~SimpleFTHome_exec_i (void); + + // Supported or inherited operations. + + // Home operations. + + // Factory and finder operations. + + // Attribute operations. + + // Implicit operations. + + virtual ::Components::EnterpriseComponent_ptr + create (); + }; + + extern "C" SIMPLEFT_EXEC_Export ::Components::HomeExecutorBase_ptr + create_Simple_SimpleFTHome_Impl (void); +} + +#include /**/ "ace/post.h" + +#endif /* CIAO_SIMPLEFT_EXEC_H */ + diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT_exec_export.h b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT_exec_export.h new file mode 100644 index 00000000000..d9998cd3fb3 --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT_exec_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl SIMPLEFT_EXEC +// ------------------------------ +#ifndef SIMPLEFT_EXEC_EXPORT_H +#define SIMPLEFT_EXEC_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (SIMPLEFT_EXEC_HAS_DLL) +# define SIMPLEFT_EXEC_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && SIMPLEFT_EXEC_HAS_DLL */ + +#if !defined (SIMPLEFT_EXEC_HAS_DLL) +# define SIMPLEFT_EXEC_HAS_DLL 1 +#endif /* ! SIMPLEFT_EXEC_HAS_DLL */ + +#if defined (SIMPLEFT_EXEC_HAS_DLL) && (SIMPLEFT_EXEC_HAS_DLL == 1) +# if defined (SIMPLEFT_EXEC_BUILD_DLL) +# define SIMPLEFT_EXEC_Export ACE_Proper_Export_Flag +# define SIMPLEFT_EXEC_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define SIMPLEFT_EXEC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* SIMPLEFT_EXEC_BUILD_DLL */ +# define SIMPLEFT_EXEC_Export ACE_Proper_Import_Flag +# define SIMPLEFT_EXEC_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define SIMPLEFT_EXEC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* SIMPLEFT_EXEC_BUILD_DLL */ +#else /* SIMPLEFT_EXEC_HAS_DLL == 1 */ +# define SIMPLEFT_EXEC_Export +# define SIMPLEFT_EXEC_SINGLETON_DECLARATION(T) +# define SIMPLEFT_EXEC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* SIMPLEFT_EXEC_HAS_DLL == 1 */ + +// Set SIMPLEFT_EXEC_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (SIMPLEFT_EXEC_NTRACE) +# if (ACE_NTRACE == 1) +# define SIMPLEFT_EXEC_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define SIMPLEFT_EXEC_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !SIMPLEFT_EXEC_NTRACE */ + +#if (SIMPLEFT_EXEC_NTRACE == 1) +# define SIMPLEFT_EXEC_TRACE(X) +#else /* (SIMPLEFT_EXEC_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define SIMPLEFT_EXEC_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (SIMPLEFT_EXEC_NTRACE == 1) */ + +#endif /* SIMPLEFT_EXEC_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT_stub_export.h b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT_stub_export.h new file mode 100644 index 00000000000..9f00b3d51b7 --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT_stub_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl SIMPLEFT_STUB +// ------------------------------ +#ifndef SIMPLEFT_STUB_EXPORT_H +#define SIMPLEFT_STUB_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (SIMPLEFT_STUB_HAS_DLL) +# define SIMPLEFT_STUB_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && SIMPLEFT_STUB_HAS_DLL */ + +#if !defined (SIMPLEFT_STUB_HAS_DLL) +# define SIMPLEFT_STUB_HAS_DLL 1 +#endif /* ! SIMPLEFT_STUB_HAS_DLL */ + +#if defined (SIMPLEFT_STUB_HAS_DLL) && (SIMPLEFT_STUB_HAS_DLL == 1) +# if defined (SIMPLEFT_STUB_BUILD_DLL) +# define SIMPLEFT_STUB_Export ACE_Proper_Export_Flag +# define SIMPLEFT_STUB_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define SIMPLEFT_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* SIMPLEFT_STUB_BUILD_DLL */ +# define SIMPLEFT_STUB_Export ACE_Proper_Import_Flag +# define SIMPLEFT_STUB_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define SIMPLEFT_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* SIMPLEFT_STUB_BUILD_DLL */ +#else /* SIMPLEFT_STUB_HAS_DLL == 1 */ +# define SIMPLEFT_STUB_Export +# define SIMPLEFT_STUB_SINGLETON_DECLARATION(T) +# define SIMPLEFT_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* SIMPLEFT_STUB_HAS_DLL == 1 */ + +// Set SIMPLEFT_STUB_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (SIMPLEFT_STUB_NTRACE) +# if (ACE_NTRACE == 1) +# define SIMPLEFT_STUB_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define SIMPLEFT_STUB_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !SIMPLEFT_STUB_NTRACE */ + +#if (SIMPLEFT_STUB_NTRACE == 1) +# define SIMPLEFT_STUB_TRACE(X) +#else /* (SIMPLEFT_STUB_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define SIMPLEFT_STUB_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (SIMPLEFT_STUB_NTRACE == 1) */ + +#endif /* SIMPLEFT_STUB_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT_svnt_export.h b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT_svnt_export.h new file mode 100644 index 00000000000..5b5bda97c49 --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/SimpleFT_svnt_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl SIMPLEFT_SVNT +// ------------------------------ +#ifndef SIMPLEFT_SVNT_EXPORT_H +#define SIMPLEFT_SVNT_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (SIMPLEFT_SVNT_HAS_DLL) +# define SIMPLEFT_SVNT_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && SIMPLEFT_SVNT_HAS_DLL */ + +#if !defined (SIMPLEFT_SVNT_HAS_DLL) +# define SIMPLEFT_SVNT_HAS_DLL 1 +#endif /* ! SIMPLEFT_SVNT_HAS_DLL */ + +#if defined (SIMPLEFT_SVNT_HAS_DLL) && (SIMPLEFT_SVNT_HAS_DLL == 1) +# if defined (SIMPLEFT_SVNT_BUILD_DLL) +# define SIMPLEFT_SVNT_Export ACE_Proper_Export_Flag +# define SIMPLEFT_SVNT_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define SIMPLEFT_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* SIMPLEFT_SVNT_BUILD_DLL */ +# define SIMPLEFT_SVNT_Export ACE_Proper_Import_Flag +# define SIMPLEFT_SVNT_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define SIMPLEFT_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* SIMPLEFT_SVNT_BUILD_DLL */ +#else /* SIMPLEFT_SVNT_HAS_DLL == 1 */ +# define SIMPLEFT_SVNT_Export +# define SIMPLEFT_SVNT_SINGLETON_DECLARATION(T) +# define SIMPLEFT_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* SIMPLEFT_SVNT_HAS_DLL == 1 */ + +// Set SIMPLEFT_SVNT_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (SIMPLEFT_SVNT_NTRACE) +# if (ACE_NTRACE == 1) +# define SIMPLEFT_SVNT_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define SIMPLEFT_SVNT_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !SIMPLEFT_SVNT_NTRACE */ + +#if (SIMPLEFT_SVNT_NTRACE == 1) +# define SIMPLEFT_SVNT_TRACE(X) +#else /* (SIMPLEFT_SVNT_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define SIMPLEFT_SVNT_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (SIMPLEFT_SVNT_NTRACE == 1) */ + +#endif /* SIMPLEFT_SVNT_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/Test.idl b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/Test.idl new file mode 100644 index 00000000000..4fee003011c --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/Components/Test.idl @@ -0,0 +1,13 @@ +#include <ReplicatedApplication.idl> + +interface test : ReplicatedApplication +{ + void method (in unsigned long test_start, + in unsigned long test_end, + in unsigned long work, + in unsigned long prime_number, + in unsigned long end); + + void shutdown (); + void dump (); +}; diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/FTComponentExplicitHome.cdp b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/FTComponentExplicitHome.cdp new file mode 100644 index 00000000000..31474b4865a --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/FTComponentExplicitHome.cdp @@ -0,0 +1,124 @@ +<Deployment:DeploymentPlan + xmlns:Deployment="http://www.omg.org/Deployment" + xmlns:xmi="http://www.omg.org/XMI" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.omg.org/Deployment Deployment.xsd"> + <label>SimpleComponent_Home</label> + <UUID>SimpleComponent_Home</UUID> + + <!-- Implementations declarations --> + + <!-- Server Dance implementation--> + <!-- Home implementation --> + <implementation xmi:id="SimpleFTHomeImplementation"> + <name>SimpleFTHomeImplementation</name> + <source/> + <artifact xmi:idref="SimpleFT_ExecArtifact" /> + <artifact xmi:idref="SimpleFT_SvntArtifact" /> + <execParameter> + <!-- entrypoint as exec parameter (see §10.6.1) --> + <name>home factory</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>create_Simple_SimpleFTHome_Impl</string> + </value> + </value> + </execParameter> + <execParameter> + <name>edu.vanderbilt.dre.CIAO.ServantEntrypoint</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>create_Simple_SimpleFTHome_Servant</string> + </value> + </value> + </execParameter> + <execParameter> + <name>edu.vanderbilt.dre.CIAO.ServantArtifact</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>SimpleFT_svnt</string> + </value> + </value> + </execParameter> + <execParameter> + <name>edu.vanderbilt.dre.CIAO.ExecutorArtifact</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>SimpleFT_exec</string> + </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"> + <name>SimpleFTComponentImplementation</name> + <source/> + <artifact xmi:idref="SimpleFT_ExecArtifact" /> + <artifact xmi:idref="SimpleFT_SvntArtifact" /> + </implementation> + + <instance xmi:id="SimpleFTHomeInstance"> + <name>SimpleFTHome</name> + <node>Node</node> + <!-- hostname --> + <source/> + <implementation xmi:idref="SimpleFTHomeImplementation" /> + </instance> + + <instance xmi:id="SimpleFTComponentInstance"> + <name>SimpleFTComponent</name> + <node>Node</node> + <!-- hostname --> + <source/> + <implementation xmi:idref="SimpleFTComponentImplementation" /> + <configProperty> + <name>edu.vanderbilt.dre.DAnCE.ExplicitHome</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>SimpleFTHome</string> + </value> + </value> + </configProperty> + </instance> + + <!-- Artifacts declarations --> + <artifact xmi:id="SimpleFT_ExecArtifact"> + <name>SimpleFT_exec</name> + <source/> + <node/> + <location>SimpleFT_exec</location> + </artifact> + <artifact xmi:id="SimpleFT_SvntArtifact"> + <name>SimpleFT_svnt</name> + <source/> + <node/> + <location>SimpleFT_svnt</location> + </artifact> + + </Deployment:DeploymentPlan> diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/SimpleComponentExplicitHome.cdp b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/SimpleComponentExplicitHome.cdp new file mode 100644 index 00000000000..31474b4865a --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/SimpleComponentExplicitHome.cdp @@ -0,0 +1,124 @@ +<Deployment:DeploymentPlan + xmlns:Deployment="http://www.omg.org/Deployment" + xmlns:xmi="http://www.omg.org/XMI" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.omg.org/Deployment Deployment.xsd"> + <label>SimpleComponent_Home</label> + <UUID>SimpleComponent_Home</UUID> + + <!-- Implementations declarations --> + + <!-- Server Dance implementation--> + <!-- Home implementation --> + <implementation xmi:id="SimpleFTHomeImplementation"> + <name>SimpleFTHomeImplementation</name> + <source/> + <artifact xmi:idref="SimpleFT_ExecArtifact" /> + <artifact xmi:idref="SimpleFT_SvntArtifact" /> + <execParameter> + <!-- entrypoint as exec parameter (see §10.6.1) --> + <name>home factory</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>create_Simple_SimpleFTHome_Impl</string> + </value> + </value> + </execParameter> + <execParameter> + <name>edu.vanderbilt.dre.CIAO.ServantEntrypoint</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>create_Simple_SimpleFTHome_Servant</string> + </value> + </value> + </execParameter> + <execParameter> + <name>edu.vanderbilt.dre.CIAO.ServantArtifact</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>SimpleFT_svnt</string> + </value> + </value> + </execParameter> + <execParameter> + <name>edu.vanderbilt.dre.CIAO.ExecutorArtifact</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>SimpleFT_exec</string> + </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"> + <name>SimpleFTComponentImplementation</name> + <source/> + <artifact xmi:idref="SimpleFT_ExecArtifact" /> + <artifact xmi:idref="SimpleFT_SvntArtifact" /> + </implementation> + + <instance xmi:id="SimpleFTHomeInstance"> + <name>SimpleFTHome</name> + <node>Node</node> + <!-- hostname --> + <source/> + <implementation xmi:idref="SimpleFTHomeImplementation" /> + </instance> + + <instance xmi:id="SimpleFTComponentInstance"> + <name>SimpleFTComponent</name> + <node>Node</node> + <!-- hostname --> + <source/> + <implementation xmi:idref="SimpleFTComponentImplementation" /> + <configProperty> + <name>edu.vanderbilt.dre.DAnCE.ExplicitHome</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>SimpleFTHome</string> + </value> + </value> + </configProperty> + </instance> + + <!-- Artifacts declarations --> + <artifact xmi:id="SimpleFT_ExecArtifact"> + <name>SimpleFT_exec</name> + <source/> + <node/> + <location>SimpleFT_exec</location> + </artifact> + <artifact xmi:id="SimpleFT_SvntArtifact"> + <name>SimpleFT_svnt</name> + <source/> + <node/> + <location>SimpleFT_svnt</location> + </artifact> + + </Deployment:DeploymentPlan> diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/SimpleHome.cdp b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/SimpleHome.cdp new file mode 100644 index 00000000000..a63da21f0f6 --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/SimpleHome.cdp @@ -0,0 +1,90 @@ +<Deployment:DeploymentPlan + xmlns:Deployment="http://www.omg.org/Deployment" + xmlns:xmi="http://www.omg.org/XMI" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.omg.org/Deployment Deployment.xsd"> + <label>SimpleComponent_Home</label> + <UUID>SimpleComponent_Home</UUID> + + <!-- Implementations declarations --> + + <!-- Server Dance implementation--> + <!-- Home implementation --> + <implementation xmi:id="SimpleNullHomeImplementation"> + <name>SimpleNullHomeImplementation</name> + <source/> + <artifact xmi:idref="SimpleNull_ExecArtifact" /> + <artifact xmi:idref="SimpleNull_SvntArtifact" /> + <execParameter> + <!-- entrypoint as exec parameter (see §10.6.1) --> + <name>home factory</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>create_Simple_SimpleNullHome_Impl</string> + </value> + </value> + </execParameter> + <execParameter> + <name>edu.vanderbilt.dre.CIAO.ServantEntrypoint</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>create_Simple_SimpleNullHome_Servant</string> + </value> + </value> + </execParameter> + <execParameter> + <name>edu.vanderbilt.dre.CIAO.ServantArtifact</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>SimpleNull_svnt</string> + </value> + </value> + </execParameter> + <execParameter> + <name>edu.vanderbilt.dre.CIAO.ExecutorArtifact</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>SimpleNull_exec</string> + </value> + </value> + </execParameter> + </implementation> + + <!-- Instances declarations --> + + <!-- Server Dance instances--> + <instance xmi:id="SimpleNullHomeInstance"> + <name>SimpleNullHome</name> + <node>Node</node> + <!-- hostname --> + <source/> + <implementation xmi:idref="SimpleNullHomeImplementation" /> + </instance> + + <!-- Artifacts declarations --> + <artifact xmi:id="SimpleNull_ExecArtifact"> + <name>SimpleNull_exec</name> + <source/> + <node/> + <location>SimpleNull_exec</location> + </artifact> + <artifact xmi:id="SimpleNull_SvntArtifact"> + <name>SimpleNull_svnt</name> + <source/> + <node/> + <location>SimpleNull_svnt</location> + </artifact> + + </Deployment:DeploymentPlan> diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/lns.sh b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/lns.sh new file mode 100755 index 00000000000..f51b97ea03b --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/lns.sh @@ -0,0 +1,3 @@ +tao_nslist --ns $NameServiceIOR + + diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/nm_launcher.mpc b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/nm_launcher.mpc new file mode 100644 index 00000000000..0e960e72d68 --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/nm_launcher.mpc @@ -0,0 +1,6 @@ +project(simple_ft_nm_launcher) : ciao_config_handlers, dance_nodemanager_stub { + libs += CIAO_Logger + Source_Files { + simple_nm_launcher.cpp + } +}
\ No newline at end of file diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/run_componentserver.sh b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/run_componentserver.sh new file mode 100755 index 00000000000..04562e2651e --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/run_componentserver.sh @@ -0,0 +1 @@ +$CIAO_ROOT/bin/ciao_ft_componentserver -ORBInitRef NameService=file://./ns.ior -u Upsi
\ No newline at end of file diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/run_launcher.sh b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/run_launcher.sh new file mode 100755 index 00000000000..30c480c38de --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/run_launcher.sh @@ -0,0 +1 @@ +./simple_nm_launcher file://./nm.ior FTComponentExplicitHome.cdp
\ No newline at end of file diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/run_test.sh b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/run_test.sh new file mode 100755 index 00000000000..9d2a7d851f0 --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/run_test.sh @@ -0,0 +1,4 @@ +. start_ns.sh +./start_rm.sh +./start_nm.sh +./run_launcher.sh diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/simple_nm_launcher.cpp b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/simple_nm_launcher.cpp new file mode 100644 index 00000000000..67dfbbcd6c9 --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/simple_nm_launcher.cpp @@ -0,0 +1,136 @@ +/** + * @file simple_nm_launcher.cpp + * @author William R. Otte <wotte@dre.vanderbilt.edu> + * + * Launches then immediately tears down a plan. + */ + +#include "ace/Log_Msg.h" +#include "tao/ORB.h" +#include "ciao/Logger/Logger_Service.h" +#include "ciao/Logger/Log_Macros.h" +#include "Deployment/Deployment_NodeApplicationC.h" +#include "Deployment/Deployment_NodeManagerC.h" +#include "Deployment/Deployment_DeploymentPlanC.h" +#include "tools/Config_Handlers/XML_File_Intf.h" + +int usage () +{ + ACE_ERROR ((LM_ERROR, "simple_nm_launcher <nm_url> <plan>\n")); + return -1; +} + +#include <iostream> + +int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) +{ + std::cerr << "1\n"; + + CIAO_DISABLE_TRACE (); + + std::cerr << "1\n"; + + auto_ptr<CIAO::Logger_Service> logger; + + std::cerr << "1\n"; + + CIAO::Logger_Service + * dlf = ACE_Dynamic_Service<CIAO::Logger_Service>::instance ("CIAO_Logger_Backend_Factory"); + + std::cerr << "1\n"; + + if (!dlf) + dlf = new CIAO::Logger_Service; + + logger.reset (dlf); + logger->init (argc, argv); + std::cerr << "2\n"; + + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); + + if (argc != 3) + return usage (); + + try + { + ACE_DEBUG ((LM_DEBUG, "*** simple_nm_launcher: parsing XML\n")); + // Parse plan + CIAO::Config_Handlers::XML_File_Intf xml (argv[2]); + xml.add_search_path ("CIAO_ROOT", "/docs/schema/"); + + auto_ptr< ::Deployment::DeploymentPlan> plan (xml.release_plan ()); + + if (plan.get () == 0) + { + ACE_ERROR ((LM_ERROR, "*** error parsing XML document\n")); + throw 1; + } + + + ACE_DEBUG ((LM_DEBUG, "*** simple_nm_launcher: resoling node manager reference.\n")); + CORBA::Object_var obj = orb->string_to_object (argv[1]); + Deployment::NodeManager_var nm = Deployment::NodeManager::_narrow (obj.in ()); + + if (CORBA::is_nil (nm.in ())) + { + ACE_ERROR ((LM_ERROR, "*** simple_nm_launcher: NodeManager reference is nil.")); + throw 1; + } + + ACE_DEBUG ((LM_DEBUG, "*** simple_nm_launcher: calling prepareplan.\n")); + Deployment::NodeApplicationManager_var nam = nm->preparePlan (*plan, + Deployment::ResourceCommitmentManager::_nil ()); + + ACE_DEBUG ((LM_DEBUG, "*** simple_nm_launcher: calling startLaunch\n")); + Deployment::Connections_var conns; + Deployment::Properties props; + Deployment::Application_var app = nam->startLaunch (props, conns.out ()); + Deployment::NodeApplication_var na = Deployment::NodeApplication::_narrow (app.in ()); + + ACE_DEBUG ((LM_DEBUG, "*** simple_nm_launcher: calling finishLaunch\n")); + na->finishLaunch (conns.in (), false); + + ACE_DEBUG ((LM_DEBUG, "*** simple_nm_launcher: calling start\n")); + na->start (); + + ACE_DEBUG ((LM_DEBUG, "*** simple_nm_launcher: start finished, sleeping 20 seconds.\n")); + ACE_OS::sleep (20); + ACE_DEBUG ((LM_DEBUG, "*** simple_nm_launcher: waking up from sleep, calling destroyApplication\n")); + + nam->destroyApplication (na.in ()); + + ACE_DEBUG ((LM_DEBUG, "*** simple_nm_launcher: calling destroyManager\n")); + + nm->destroyManager (nam.in ()); + + ACE_DEBUG ((LM_DEBUG, "*** simple_nm_launcher: destroyManager completed.\n")); + + orb->destroy (); + } + catch (Deployment::StopError &ex) + { + ACE_ERROR ((LM_ERROR, "*** Caught StopError exception with name %s and reason %s\n", + ex.name.in (), ex.reason.in ())); + return -1; + } + catch (Deployment::StartError &ex) + { + ACE_ERROR ((LM_ERROR, "*** Caught StartError exception with name %s and reason %s\n", + ex.name.in (), ex.reason.in ())); + return -1; + } + 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/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/start_nm.sh b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/start_nm.sh new file mode 100755 index 00000000000..2531da0129e --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/start_nm.sh @@ -0,0 +1,2 @@ +$CIAO_ROOT/DAnCE/bin/dance_node_manager -n FTNode=nm.ior -s $CIAO_ROOT/bin/ciao_ft_componentserver --server-args -ORBInitRef NameService=file://./ns.ior & + diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/start_ns.sh b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/start_ns.sh new file mode 100755 index 00000000000..425bc28dfff --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/start_ns.sh @@ -0,0 +1,4 @@ +$TAO_ROOT/orbsvcs/Naming_Service/Naming_Service -o ns.ior & +sleep 2 +export NameServiceIOR=`cat ns.ior` + diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/start_rm.sh b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/start_rm.sh new file mode 100755 index 00000000000..d8008655463 --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/start_rm.sh @@ -0,0 +1,3 @@ +$TAO_ROOT/orbsvcs/examples/FaultTolerance/FLARe/no-RT/ReplicationManager & +sleep 1 +tao_nsadd --ns file://./ns.ior --name ReplicationManager --ior file://./rm.ior diff --git a/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/stop.sh b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/stop.sh new file mode 100644 index 00000000000..dbb064f0cff --- /dev/null +++ b/CIAO/DAnCE/tests/CIAO/FaultTolernace-Deployments/stop.sh @@ -0,0 +1,3 @@ +./stop_nm.sh +./stop_rm.sh +./stop_ns.sh diff --git a/CIAO/DAnCE/tests/CIAO/NodeManager-Deployments/Components/SimpleConsumer.mpc b/CIAO/DAnCE/tests/CIAO/NodeManager-Deployments/Components/SimpleConsumer.mpc index bece676d798..5b4445933b5 100644 --- a/CIAO/DAnCE/tests/CIAO/NodeManager-Deployments/Components/SimpleConsumer.mpc +++ b/CIAO/DAnCE/tests/CIAO/NodeManager-Deployments/Components/SimpleConsumer.mpc @@ -8,6 +8,7 @@ project(SimpleCommon_SimpleConsumer_idl_gen) : taoidldefaults, anytypecode { -Wb,stub_export_include=SimpleConsumer_stub_export.h \ -Wb,skel_export_macro=SIMPLECONSUMER_SVNT_Export \ -Wb,skel_export_include=SimpleConsumer_svnt_export.h + idlflags += -I$(CIAO_ROOT)/ccm IDL_Files { SimpleConsumer.idl diff --git a/CIAO/ciao/Containers/Swapping/Dynamic_Component_Activator.h b/CIAO/ciao/Containers/Swapping/Dynamic_Component_Activator.h index 1ca97160ebe..ec3b49cd4a5 100644 --- a/CIAO/ciao/Containers/Swapping/Dynamic_Component_Activator.h +++ b/CIAO/ciao/Containers/Swapping/Dynamic_Component_Activator.h @@ -27,7 +27,7 @@ #include "tao/PortableServer/Key_Adapters.h" #include "tao/LocalObject.h" #include "tao/PortableServer/ServantActivatorC.h" - +#include "ciao/CIAO_common.h" #include "ace/Hash_Map_Manager_T.h" #if defined(_MSC_VER) diff --git a/CIAO/ciao/FTComponentServer/CIAO_CS_Client.idl b/CIAO/ciao/FTComponentServer/CIAO_CS_Client.idl new file mode 100644 index 00000000000..0250cf48817 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_CS_Client.idl @@ -0,0 +1,35 @@ +/** + * @file CIAO_CS_Client.idl + * @author William R. Otte <wotte@dre.vanderbilt.edu> + * + * A couple CIAO-specific extensions to the component server client + * interfaces. + */ + +#ifndef CIAO_COMPONENTSERVER_IDL_ +#define CIAO_COMPONENTSERVER_IDL_ + +#include <ccm/ComponentServer/ComponentServer_Client.idl> + +module CIAO +{ + module Deployment + { + interface ServerActivator : ::Components::Deployment::ServerActivator + { + /// Used by spawned component servers to notify the server + /// activator of their object reference and retrieve + /// configuration information. + void component_server_callback (in ::Components::Deployment::ComponentServer serverref, + in string server_UUID, + out ::Components::ConfigValues config); + + void configuration_complete (in string server_UUID); + }; + }; +}; + + +#endif + + diff --git a/CIAO/ciao/FTComponentServer/CIAO_CS_Client_svnt_export.h b/CIAO/ciao/FTComponentServer/CIAO_CS_Client_svnt_export.h new file mode 100644 index 00000000000..32a2ea33fd5 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_CS_Client_svnt_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl CIAO_CS_Client_svnt +// ------------------------------ +#ifndef CIAO_CS_CLIENT_SVNT_EXPORT_H +#define CIAO_CS_CLIENT_SVNT_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (CIAO_CS_CLIENT_SVNT_HAS_DLL) +# define CIAO_CS_CLIENT_SVNT_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && CIAO_CS_CLIENT_SVNT_HAS_DLL */ + +#if !defined (CIAO_CS_CLIENT_SVNT_HAS_DLL) +# define CIAO_CS_CLIENT_SVNT_HAS_DLL 1 +#endif /* ! CIAO_CS_CLIENT_SVNT_HAS_DLL */ + +#if defined (CIAO_CS_CLIENT_SVNT_HAS_DLL) && (CIAO_CS_CLIENT_SVNT_HAS_DLL == 1) +# if defined (CIAO_CS_CLIENT_SVNT_BUILD_DLL) +# define CIAO_CS_Client_svnt_Export ACE_Proper_Export_Flag +# define CIAO_CS_CLIENT_SVNT_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define CIAO_CS_CLIENT_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* CIAO_CS_CLIENT_SVNT_BUILD_DLL */ +# define CIAO_CS_Client_svnt_Export ACE_Proper_Import_Flag +# define CIAO_CS_CLIENT_SVNT_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define CIAO_CS_CLIENT_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* CIAO_CS_CLIENT_SVNT_BUILD_DLL */ +#else /* CIAO_CS_CLIENT_SVNT_HAS_DLL == 1 */ +# define CIAO_CS_Client_svnt_Export +# define CIAO_CS_CLIENT_SVNT_SINGLETON_DECLARATION(T) +# define CIAO_CS_CLIENT_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* CIAO_CS_CLIENT_SVNT_HAS_DLL == 1 */ + +// Set CIAO_CS_CLIENT_SVNT_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (CIAO_CS_CLIENT_SVNT_NTRACE) +# if (ACE_NTRACE == 1) +# define CIAO_CS_CLIENT_SVNT_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define CIAO_CS_CLIENT_SVNT_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !CIAO_CS_CLIENT_SVNT_NTRACE */ + +#if (CIAO_CS_CLIENT_SVNT_NTRACE == 1) +# define CIAO_CS_CLIENT_SVNT_TRACE(X) +#else /* (CIAO_CS_CLIENT_SVNT_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define CIAO_CS_CLIENT_SVNT_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (CIAO_CS_CLIENT_SVNT_NTRACE == 1) */ + +#endif /* CIAO_CS_CLIENT_SVNT_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/CIAO_ComponentServer.idl b/CIAO/ciao/FTComponentServer/CIAO_ComponentServer.idl new file mode 100644 index 00000000000..19e633a9cd2 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_ComponentServer.idl @@ -0,0 +1,69 @@ +/** + * @file CIAO_ComponentServer.idl + * @author William R. Otte <wotte@dre.vanderbilt.edu> + * + * A couple CIAO-specific extensions to the component server + * interfaces. + */ + +#ifndef CIAO_COMPONENTSERVER_IDL_ +#define CIAO_COMPONENTSERVER_IDL_ + +#include <ccm/CCM_Object.idl> +#include <ccm/ComponentServer/ComponentServer.idl> + +module CIAO +{ + module Deployment + { + interface ComponentServer : ::Components::Deployment::ComponentServer + { + oneway void shutdown (); + }; + + typedef sequence< ::Components::CCMObject> CCMObjects; + + exception InvalidComponent + { + }; + + /** + * @interface CIAO_Container + * @brief CIAO specific extensions to the component server interface. + */ + interface Container : Components::Deployment::Container + { + /// Instruct the container to install a component without + /// an explicit home. + ::Components::CCMObject install_component (in ::Components::Deployment::UUID id, + in string entrypt, + in ::Components::ConfigValues config) + raises (::Components::Deployment::UnknownImplId, + ::Components::Deployment::ImplEntryPointNotFound, + ::Components::Deployment::InstallationFailure, + ::Components::Deployment::InvalidConfiguration); + + + /// Activate component with specified ID, if no ID provided, + /// activates all components. + void activate_component (in ::Components::CCMObject comp) + raises (InvalidComponent); + + /// Passivate component with specified ID, if no ID provided, + /// passivates all components. + void passivate_component (in ::Components::CCMObject comp) + raises (InvalidComponent); + + /// Instruct the container to remove a component installed + /// without an explicit home. If the component was installed + /// with an explicit home, this operation will fail. + void remove_component (in ::Components::CCMObject cref) + raises (::Components::RemoveFailure); + + /// Returns a sequence of all homeless components. + CCMObjects get_components (); + }; + }; +}; + +#endif /* CIAO_COMPONENTSERVER_IDL_ */ diff --git a/CIAO/ciao/FTComponentServer/CIAO_ComponentServer.mpc b/CIAO/ciao/FTComponentServer/CIAO_ComponentServer.mpc new file mode 100644 index 00000000000..a12dfad1924 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_ComponentServer.mpc @@ -0,0 +1,90 @@ +project(CIAO_FTComponentServer_IDL) : taoidldefaults, anytypecode { + idlflags += -Wb,stub_export_macro=CIAO_FTComponentServer_stub_Export + idlflags += -Wb,stub_export_include=CIAO_FTComponentServer_stub_export.h + idlflags += -Wb,skel_export_macro=CIAO_FTComponentServer_svnt_Export + idlflags += -Wb,skel_export_include=CIAO_FTComponentServer_svnt_export.h + + custom_only=1 + + IDL_Files { + CIAO_ComponentServer.idl + CIAO_ServerResources.idl + } +} + +project(CIAO_FTCS_Client_IDL) : taoidldefaults, anytypecode { + idlflags += -Wb,stub_export_macro=CIAO_FTComponentServer_stub_Export + idlflags += -Wb,stub_export_include=CIAO_FTComponentServer_stub_export.h + idlflags += -Wb,skel_export_macro=CIAO_CS_Client_svnt_Export + idlflags += -Wb,skel_export_include=CIAO_CS_Client_svnt_export.h + + custom_only=1 + + IDL_Files { + CIAO_CS_Client.idl + CIAO_Properties.idl + } +} + +project(CIAO_FTComponentServer_stub) : ccm_componentserver_stub, taolib_with_idl, tao_output, \ + messaging, anytypecode, ciao_lib { + after += CIAO_FTComponentServer_IDL CIAO_FTCS_Client_IDL + dynamicflags = CIAO_FTCOMPONENTSERVER_STUB_BUILD_DLL + + IDL_Files { + } + + Source_Files { + CIAO_ComponentServerC.cpp + CIAO_CS_ClientC.cpp + CIAO_ServerResourcesC.cpp + CIAO_PropertiesC.cpp + } +} + +project(CIAO_FTCS_Client_svnt) : ccm_svnt, ccm_componentserver_svnt, ciao_ft_componentserver_stub, portableserver, \ + ciao_client, ciao_lib { + dynamicflags = CIAO_CS_CLIENT_SVNT_BUILD_DLL + after += CIAO_FTCS_Client_IDL CIAO_FTComponentServer_stub + + IDL_Files { + } + + Source_Files { + CIAO_ServerActivator_Impl.cpp + CIAO_CS_ClientS.cpp + } + Header_Files { + CIAO_ServerActivator_Impl.h + CIAO_CS_ClientS.h + } +} + +project(CIAO_FTComponentServer_svnt) : ccm_componentserver_svnt, ciao_ft_componentserver_stub, portableserver, ciao_ft_componentserver_configurator, ciao_session_container, naming, ciao_server { + + dynamicflags = CIAO_FTCOMPONENTSERVER_SVNT_BUILD_DLL + + IDL_Files { + } + Source_Files { + CIAO_FTComponentServer_Impl.cpp + CIAO_ComponentServerS.cpp + CIAO_ServerResourcesS.cpp + CIAO_Container_Impl.cpp + Configurator_Factory.cpp + } +} + +project(CIAO_FTComponentServer_exe) : ccm_componentserver_svnt, portableserver, ciao_ft_componentserver_svnt, messaging, anytypecode, ciao_server, ciaoexe, ciao_session_container, ciao_ft_componentserver_configurator { + exename = ciao_ft_componentserver + libs += CIAO_Logger SSA_Agent ServerInterceptor + after += SSA_Agent + macros += CIAO_BUILD_COMPONENTSERVER_EXE + includes += CommonIDL + + Source_Files { + CIAO_FTComponentServer.cpp + } + IDL_Files { + } +} diff --git a/CIAO/ciao/FTComponentServer/CIAO_Container_Impl.cpp b/CIAO/ciao/FTComponentServer/CIAO_Container_Impl.cpp new file mode 100644 index 00000000000..4d2b4e760eb --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_Container_Impl.cpp @@ -0,0 +1,361 @@ +#include "CIAO_Container_Impl.h" + +#include "ace/Log_Msg.h" +#include "ccm/CCM_HomeC.h" +#include "ciao/CIAO_common.h" +#include "ciao/Server_init.h" +#include "ciao/Client_init.h" +#include "CIAO_PropertiesC.h" + +namespace CIAO +{ + namespace Deployment + { + namespace + { + const char *register_naming = "edu.dre.vanderbilt.RegisterNaming"; + } + // Constructor + CIAO_Container_i::CIAO_Container_i (const Components::ConfigValues &config, + const Static_Config_EntryPoints_Maps *static_entrypts, + const char *name, + const CORBA::PolicyList *policies, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa) + : orb_ (CORBA::ORB::_duplicate (orb)), + poa_ (PortableServer::POA::_duplicate (poa)), + config_ (config.length ()), + static_entrypts_maps_ (static_entrypts) + { + CIAO_TRACE("CIAO_Container_i::CIAO_Container_i"); + + for (CORBA::ULong i = 0; i < config.length (); ++i) + { + this->config_[i] = config[i]; + } + + try + { + if (this->static_entrypts_maps_ == 0) + { + CIAO_DEBUG((LM_DEBUG, CLINFO "CIAO_Container_i: creating Session container with dynamic linkage\n")); + this->container_ = new CIAO::Session_Container (this->orb_.in (), this, false, + 0, name, policies); + } + else + { + CIAO_DEBUG((LM_DEBUG, CLINFO "CIAO_Container_i: creating Session container with static linkage\n")); + this->container_ = new CIAO::Session_Container (this->orb_.in (), this, true, + this->static_entrypts_maps_, + name, policies); + } + } + catch (...) + { + CIAO_ERROR((LM_ERROR, CLINFO "CIAO_Container_i::CIAO_Container_i - " + "Caught exception while allocating container implementation\n")); + throw; + } + } + + + // Destructor + CIAO_Container_i::~CIAO_Container_i (void) + { + CIAO_TRACE("CIAO_Container_i::~CIAO_Container_i"); + } + + ::Components::CCMObject_ptr + CIAO_Container_i::install_component (const char * /*id*/, + const char * /*entrypt*/, + const ::Components::ConfigValues & /*config*/) + { + CIAO_TRACE("CIAO_Container_i::install_component"); + throw CORBA::NO_IMPLEMENT (); + return 0; + } + + void + CIAO_Container_i::remove_component (::Components::CCMObject_ptr /*cref*/) + { + CIAO_TRACE("CIAO_Container_i::remove_component"); + throw CORBA::NO_IMPLEMENT (); + } + + ::CIAO::Deployment::CCMObjects * + CIAO_Container_i::get_components (void) + { + CIAO_TRACE("CIAO_Container_i::get_components"); + throw CORBA::NO_IMPLEMENT (); + return 0; + } + + ::Components::ConfigValues * + CIAO_Container_i::configuration (void) + { + CIAO_TRACE("CIAO_Container_i::configuration"); + throw CORBA::NO_IMPLEMENT (); + return 0; + } + + ::Components::Deployment::ComponentServer_ptr + CIAO_Container_i::get_component_server (void) + { + CIAO_TRACE("CIAO_Container_i::get_component_server"); + throw CORBA::NO_IMPLEMENT (); + return 0; + } + + ::Components::CCMHome_ptr + CIAO_Container_i::install_home (const char * id, + const char * entrypt, + const ::Components::ConfigValues & config) + { + CIAO_TRACE("CIAO_Container_i::install_home"); + + if (id == 0) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_Container_i::install_home - " + "No home ID provided\n")); + throw ::Components::Deployment::InvalidConfiguration (); + } + + Components::CCMHome_var home; + + if (this->home_map_.find (id, home) == 0) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_Container_i::install_home - " + "Home with id %s already installed, aborting\n", + id)); + throw Components::CreateFailure (); + } + + if (entrypt == 0) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_Container_i::install_home - " + "No executor entrypoint found.\n")); + throw ::Components::Deployment::InvalidConfiguration (); + } + + CIAO_DEBUG ((LM_INFO, CLINFO "CIAO_Container_i::install_home - " + "Attempting to install home with id [%s]\n", + id)); + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_Container_i::install_home - " + "Extracting ConfigValues from sequence of length [%u]\n", + config.length ())); + + CIAO::Utility::CONFIGVALUE_MAP cm; + CIAO::Utility::build_config_values_map (cm, config); + CORBA::Any val; + + const char *tmp; + CORBA::String_var exec_art, svnt_art, svnt_entry; + if (cm.find (SVNT_ENTRYPT, val) == 0) + { + val >>= tmp; + svnt_entry = tmp; + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_Container_i::install_home - " + "Found Servant entrypoint %s\n", svnt_entry.in ())); + } + else + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_Container_i::install_home - " + "Error: No Servant entrypoint porovided, aborting installation\n")); + throw Components::InvalidConfiguration (); + } + + if (cm.find (SVNT_ARTIFACT, val) == 0) + { + val >>= tmp; + svnt_art = tmp; + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_Container_i::install_home - " + "Found Servant artifact %s\n", svnt_art.in ())); + } + else + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_Container_i::install_home - " + "Error: No Servant artifact porovided, aborting installation\n")); + throw Components::InvalidConfiguration (); + } + + + if (cm.find (EXEC_ARTIFACT, val) == 0) + { + val >>= tmp; + exec_art = tmp; + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_Container_i::install_home - " + "Found executor artifact: %s\n", exec_art.in ())); + } + else + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_Container_i::install_home - " + "Error: No Executor artifact porovided, aborting installation\n")); + } + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_Container_i::install_home - " + "Extraction resulted in map of [%u] values", cm.current_size ())); + + + // extract config values here... + + //CIAO_DEBUG ((LM_DEBUG, CLINFO "CIAO_Container_i::install_home - ", + //"Executor entrypoint [%s], servant entrypoint [%s], servant library [%s]\n", + //entrypt, svnt_entrypt.in (), svnt_library.in ())); + + home = this->container_->install_home (exec_art, + entrypt, + svnt_art, + svnt_entry, + id); + + if (this->home_map_.bind (id, + Components::CCMHome::_duplicate (home.in ())) == -1) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_Container_i::install_home - " + "Unable to bind home into home map\n")); + } + + if (cm.find (REGISTER_NAMING, val) == 0) + { + const char *str_val; + + if (val >>= str_val) + { + CIAO_ERROR ((LM_WARNING, CLINFO + "CIAO_Container_i::install_home - " + "Naming service registration not yet supported\n")); + + //CIAO_DEBUG ((LM_NOTICE, CLINFO + // "CIAO_Container_i::install_home - " + // "Home with ID [%s] registered in naming service with name [%s]\n", + // id, str_val)); + } + else + CIAO_ERROR ((LM_WARNING, CLINFO + "CIAO_Container_i::install_home - " + "Warning: Extraction of Naming Service value failed!\n")); + } + + return home._retn (); + } + + void + CIAO_Container_i::remove_home (::Components::CCMHome_ptr href) + { + CIAO_TRACE("CIAO_Container_i::remove_home"); + + ::Components::CCMHome_var home (href); + + Home_Iterator i = this->home_map_.begin (); + while (!i.done ()) + { + if (i->item ()->_is_equivalent (home.in ())) + { + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_Container_i::remove_home - " + "Successfully found matching home\n")); + break; + } + i.advance (); + } + + if (i.done ()) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_Container_i::remove_home - " + "Unable to find matching home managed by this container, throwing RemoveFailure\n")); + throw Components::RemoveFailure (); + } + + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_Container_i::remove_home - " + "Invoking remove on the container impl for home %s.\n", + i->key ().c_str ())); + this->container_->uninstall_home (home.in ()); + CIAO_DEBUG ((LM_INFO, CLINFO "CIAO_Container_i::remove_home - " + "Successfully removed home %s\n", + i->key ().c_str ())); + + if (this->home_map_.unbind (i->key ()) != 0) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_Container_i::remove_home - " + "Unable to unbind removed home with id %s from home map\n", + i->key ().c_str ())); + } + } + + ::Components::CCMHomes * + CIAO_Container_i::get_homes (void) + { + CIAO_TRACE("CIAO_Container_i::get_homes"); + + ::Components::CCMHomes * tmp_homes; + + ACE_NEW_THROW_EX (tmp_homes, + ::Components::CCMHomes (this->home_map_.current_size ()), + CORBA::NO_MEMORY ()); + + ::Components::CCMHomes_var retval (tmp_homes); + retval->length (this->home_map_.current_size ()); + Home_Iterator i = this->home_map_.begin (); + CORBA::ULong pos = 0; + while (!i.done ()) + { + retval[pos++] = ::Components::CCMHome::_duplicate (i->item ().in ()); + i.advance (); + } + + return retval._retn (); + } + + void + CIAO_Container_i::remove (void) + { + CIAO_TRACE("CIAO_Container_i::remove"); + + if (this->home_map_.current_size () != 0 || + this->component_map_.current_size () != 0) + { + CIAO_ERROR ((LM_WARNING, CLINFO "CIAO_Container_i::remove - " + "Attempting to remove container that still has %u homes and %u components installed\n", + this->home_map_.current_size (), + this->component_map_.current_size ())); + + } + + //this->container_->_remove_ref (); + } + + void + CIAO_Container_i::activate_component (::Components::CCMObject_ptr comp) + { + CIAO_TRACE ("CIAO_Container_i::activate_component"); + + this->container_->activate_component (comp); + } + + + void + CIAO_Container_i::passivate_component (::Components::CCMObject_ptr comp) + { + CIAO_TRACE ("CIAO_Container_i::passivate_component"); + + this->container_->passivate_component (comp); + } + + + PortableServer::POA_ptr + CIAO_Container_i::_default_POA (void) + { + CIAO_TRACE ("CIAO_Container_i::_default_POA"); + return PortableServer::POA::_duplicate (this->poa_.in ()); + } + } +} diff --git a/CIAO/ciao/FTComponentServer/CIAO_Container_Impl.h b/CIAO/ciao/FTComponentServer/CIAO_Container_Impl.h new file mode 100644 index 00000000000..5811c5992f9 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_Container_Impl.h @@ -0,0 +1,119 @@ +/** + * @file CIAO_Container.h + * @author William R. Otte <wotte@dre.vanderbilt.edu> + */ + +#ifndef CIAO_CONTAINER_H_ +#define CIAO_CONTAINER_H_ + +#include "CIAO_ComponentServerS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ciao/Containers/Session/Session_Container.h" + +#include "CIAO_FTComponentServer_svnt_export.h" + +namespace CIAO +{ + namespace Deployment + { + /** + * @class CIAO_Container + * @brief Implements external interface for CIAO container. + */ + class CIAO_FTComponentServer_svnt_Export CIAO_Container_i + : public virtual POA_CIAO::Deployment::Container + { + public: + // Constructor + CIAO_Container_i (const Components::ConfigValues &config, + const Static_Config_EntryPoints_Maps *, + const char *, + const CORBA::PolicyList *, + CORBA::ORB_ptr, + PortableServer::POA_ptr); + // Destructor + virtual ~CIAO_Container_i (void); + + virtual + ::Components::CCMObject_ptr install_component (const char * id, + const char * entrypt, + const ::Components::ConfigValues & config); + + virtual + void remove_component (::Components::CCMObject_ptr cref); + + virtual + ::CIAO::Deployment::CCMObjects * get_components (void); + + virtual + ::Components::ConfigValues * configuration (void); + + virtual + ::Components::Deployment::ComponentServer_ptr get_component_server (void); + + virtual + ::Components::CCMHome_ptr install_home (const char * id, + const char * entrypt, + const ::Components::ConfigValues & config); + + virtual + void remove_home (::Components::CCMHome_ptr href); + + virtual + ::Components::CCMHomes * get_homes (void); + + virtual + void remove (void); + + virtual void activate_component (::Components::CCMObject_ptr comp); + + virtual void passivate_component (::Components::CCMObject_ptr comp); + + virtual PortableServer::POA_ptr _default_POA (void); + + private: + /// Keep a pointer to the managing ORB serving this servant. + CORBA::ORB_var orb_; + + PortableServer::POA_var poa_; + + CIAO::Container_var container_; + + Components::ConfigValues config_; + + const Static_Config_EntryPoints_Maps* static_entrypts_maps_; + + /// To store all created CCMHome object + typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + Components::CCMHome_var, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> CCMHome_Map; + typedef CCMHome_Map::iterator Home_Iterator; + CCMHome_Map home_map_; + + /// To store all created Component object. + // @@Gan, see how this caching is duplicated.. + typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + Components::CCMObject_var, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> CCMComponent_Map; + typedef CCMComponent_Map::iterator Component_Iterator; + CCMComponent_Map component_map_; + + typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + ACE_CString, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> CCMNaming_Map; + CCMNaming_Map naming_map_; + + }; + } +} +#endif /* CIAO_CONTAINER_H_ */ diff --git a/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.cpp b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.cpp new file mode 100644 index 00000000000..cd650ca0dff --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.cpp @@ -0,0 +1,689 @@ +/** + * @file CIAO_ComponentServer.cpp + * @author William R. Otte + * + * Implementation and main for CIAO_ComponentServer. + */ + +#include "CIAO_FTComponentServer.h" + +#include <sstream> +#include "ace/OS_NS_string.h" +#include "ace/Log_Msg.h" +#include "ace/Get_Opt.h" +#include "ace/Sched_Params.h" +#include "ace/Trace.h" +#include "ace/Env_Value_T.h" +#include "tao/ORB.h" +#include "tao/Object.h" +#include "tao/CORBA_methods.h" +#include "tao/PortableServer/PortableServer.h" +#include "tao/ORB_Core.h" +#include "tao/ORBInitializer_Registry.h" +#include "ciao/CIAO_common.h" +#include "ciao/Logger/Logger_Service.h" +#include "ciao/Logger/Log_Macros.h" +#include "ciao/Server_init.h" + + +#include "CIAO_FTComponentServer_Impl.h" +#include "CIAO_CS_ClientC.h" +#include "Configurator_Factory.h" +#include "Configurators/Server_Configurator.h" +#include "StateSynchronizationAgent/StateSynchronizationAgent_i.h" +#include "ServerInterceptor/ServerORBInitializer.h" + +#ifdef CIAO_BUILD_COMPONENTSERVER_EXE + +int ACE_TMAIN (int argc, ACE_TCHAR **argv) +{ + // Tracing disabled by default + CIAO_DISABLE_TRACE (); + + CIAO_TRACE ("CIAO_ComponentServer::ACE_TMAIN"); + + try + { + CIAO::Deployment::ComponentServer_Task cs (argc, argv); + cs.run (); + return 0; + } + catch (CIAO::Deployment::ComponentServer_Task::Error &e) + { + CIAO_DEBUG ((LM_ALERT, CLINFO "CIAO_ComponentServer main: Caught ComponentServer exception: %s\n", + e.err_.c_str ())); + } + catch (...) + { + CIAO_DEBUG ((LM_ALERT, CLINFO "CIAO_ComponentServer main: Caught unknown exception.\n")); + } + + return -1; +} + +#endif /* CIAO_BUILD_COMPONENTSERVER_EXE */ + +bool +write_IOR (const char * ior_file_name, const char* ior) +{ + FILE* ior_output_file_ = + ACE_OS::fopen (ior_file_name, "w"); + + if (ior_output_file_) + { + ACE_OS::fprintf (ior_output_file_, + "%s", + ior); + ACE_OS::fclose (ior_output_file_); + return true; + } + return false; +} + +namespace CIAO +{ + namespace Deployment + { + ComponentServer_Task::ComponentServer_Task (int argc, ACE_TCHAR **argv) + : orb_ (0), + uuid_ (""), + callback_ior_str_ ("") + { + CIAO_TRACE ("CIAO_ComponentServer_Task::CIAO_ComponentServer_Task ()"); + + Logger_Service + *clf = ACE_Dynamic_Service<Logger_Service>::instance ("CIAO_Logger_Backend_Factory"); + + if (!clf) + clf = new Logger_Service; + + this->logger_.reset (clf); + + this->logger_->init (argc, argv); + + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_ComponentServer_Task::CIAO_ComponentServer_Task - " + "Creating server object\n")); + Configurator_Factory cf; + this->configurator_.reset (cf (argc, argv)); + + if (!this->configurator_->create_config_managers ()) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "ComponentServer_Task::ComponentServer_Task - " + "Error configuring ComponentServer configurator, exiting.\n")); + throw Error ("Unable to load ComponentServer configurator."); + } + + this->configurator_->pre_orb_initialize (); + + // register FT ORB Initializer + PortableInterceptor::ORBInitializer_ptr tmp; + + ACE_NEW_NORETURN (tmp, + ServerORBInitializer); // No CORBA exceptions yet! + + PortableInterceptor::ORBInitializer_var orb_initializer = tmp; + + PortableInterceptor::register_orb_initializer (orb_initializer.in ()); + + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_ComponentServer_Task::CIAO_ComponentServer_Task - " + "Creating ORB\n")); + this->orb_ = CORBA::ORB_init (argc, argv); + + this->configurator_->post_orb_initialize (this->orb_.in ()); + + this->parse_args (argc, argv); + this->configure_logging_backend (); + + CIAO::Server_init (this->orb_.in ()); + + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_ComponentServer_Task::CIAO_ComponentServer_Task - " + "CIAO_ComponentServer object created.\n")); + } + + int + ComponentServer_Task::svc (void) + { + try + { + CIAO_TRACE ("ComponentServer_Task::svc"); + + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "Activating the root POA\n")); + + CORBA::Object_var object = + this->orb_->resolve_initial_references ("RootPOA"); + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (object.in ()); + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (); + + poa_manager->activate (); + + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "Creating state synchronization servant\n")); + + // start up SSA + StateSynchronizationAgent_i* ssa_servant = 0; + ACE_NEW_NORETURN (ssa_servant, StateSynchronizationAgent_i ( + orb_.in (), + this->get_hostname (), // this has to be replaced by the + this->get_process_id ())); // real hostname and process id + + if (ssa_servant == 0) + { + CIAO_ERROR ((LM_CRITICAL, "ComponentServer_Task::run - " + "Out of memory error while allocating ssa servant.")); + throw Error ("Out of memory whilst allocating ssa servant."); + } + + PortableServer::ServantBase_var safe_ssa (ssa_servant); + + // activate servant here + StateSynchronizationAgent_var ssa (ssa_servant->_this ()); + + this->bind_obj ("StateSynchronizationAgent", ssa.in ()); + + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "Creating server implementation object\n")); + CIAO::Deployment::CIAO_ComponentServer_i *ci_srv = 0; + ACE_NEW_NORETURN (ci_srv, CIAO_ComponentServer_i (this->uuid_, this->orb_.in (), root_poa.in ())); + + if (ci_srv == 0) + { + CIAO_ERROR ((LM_CRITICAL, "ComponentServer_Task::run - " + "Out of memory error while allocating servant.")); + throw Error ("Out of memory whilst allocating servant."); + } + + PortableServer::ServantBase_var safe (ci_srv); + + ComponentServer_var cs (ci_srv->_this ()); + + if (this->output_file_ != "") + { + CORBA::String_var ior = this->orb_->object_to_string (cs.in ()); + write_IOR (this->output_file_.c_str (), ior.in ()); + } + + if (this->callback_ior_str_ != "") + { + CIAO_DEBUG ((LM_TRACE, CLINFO " resolving callback IOR\n")); + CORBA::Object_ptr obj = this->orb_->string_to_object (this->callback_ior_str_.c_str ()); + ServerActivator_var sa (ServerActivator::_narrow (obj)); + + if (CORBA::is_nil (sa.in ())) + { + CIAO_DEBUG ((LM_ERROR, CLINFO "ComponentServer_Task::svc - " + "Failed to narrow callback IOR\n")); + throw Error ("Faled to narrow callback IOR"); + } + + Components::ConfigValues_var config; + { + Components::ConfigValues *cf; + ACE_NEW_NORETURN (cf, Components::ConfigValues (0)); + + if (cf == 0) + { + CIAO_ERROR ((LM_CRITICAL, "ComponentServer_Task::run - " + "Out of memory error while allocating config values.")); + } + else config = cf; + } + + // Make callback. + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "Making callback on my ServerActivator\n")); + + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "Calling back to ServerActivator\n")); + + try + { + // Callback to NodeApplication to get configuration + sa->component_server_callback (cs.in (), + this->uuid_.c_str (), + config.out ()); + + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "Configuration received\n")); + // @@WO: Probably need to do something with these config values. + + ci_srv->init (sa.in (), config._retn ()); + + CIAO_DEBUG ((LM_NOTICE, CLINFO "ComponentServer_Task::svc - " + "Configuration complete for component server %s\n", + this->uuid_.c_str ())); + + sa->configuration_complete (this->uuid_.c_str ()); + } + catch (CORBA::BAD_PARAM &) + { + CIAO_ERROR ((LM_ERROR, CLINFO "ComponentServer_Task::svc - " + "The Callback IOR provided pointed to the wrong ServerActivator\n")); + throw Error ("Bad callback IOR"); + } + catch (...) + { + CIAO_ERROR ((LM_ERROR, CLINFO "ComponentServer_Task::svc - " + "Caught exception while calling back\n")); + throw Error ("Caught exception while calling back"); + } + } + else + { + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "Initializing ComponentServer without ServantActivator callback\n")); + ci_srv->init (0, 0); + } + + this->orb_->run (); + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::svc - " + "ORB Event loop completed.\n")); + + + + root_poa->destroy (1, 1); + + this->orb_->destroy (); + return 0; + } + catch (CORBA::Exception & ex) + { + CIAO_ERROR ((LM_ERROR, CLINFO "ComponentServer_Task::svc - " + "caught: %s.\n", ex._info ().c_str ())); + } + return -1; + } + + void + ComponentServer_Task::run (void) + { + CIAO_TRACE ("ComponentServer_Task::run"); + + if (this->configurator_->rt_support ()) + { + CIAO_DEBUG ((LM_DEBUG, CLINFO "ComponentServer_Task::run - Starting ORB with RT support\n")); + + this->check_supported_priorities (); + + // spawn a thread + // Task activation flags. + long flags = + THR_NEW_LWP | + THR_JOINABLE | + this->orb_->orb_core ()->orb_params ()->thread_creation_flags (); + + // Activate task. + int result = + this->activate (flags); + if (result == -1) + { + if (errno == EPERM) + { + CIAO_ERROR ((LM_EMERGENCY, CLINFO + "ComponentServer_Task::run - Cannot create thread with scheduling policy %s\n" + "because the user does not have the appropriate privileges, terminating program. " + "Check svc.conf options and/or run as root\n", + sched_policy_name (this->orb_->orb_core ()->orb_params ()->ace_sched_policy ()))); + throw Error ("Unable to start RT support due to permissions problem."); + } + else + throw Error ("Unknown error while spawning ORB thread."); + } + + // Wait for task to exit. + result = + this->wait (); + + if (result != -1) + throw Error ("Unknown error waiting for ORB thread to complete"); + + CIAO_DEBUG ((LM_INFO, CLINFO "ComponentServer_Task::run - ORB thread completed, terminating ComponentServer %s\n", + this->uuid_.c_str ())); + } + else + { + CIAO_DEBUG ((LM_DEBUG, CLINFO "ComponentServer_Task::run - Starting ORB without RT support\n")); + this->svc (); + CIAO_DEBUG ((LM_INFO, CLINFO "ComponentServer_Task::run - ORB has shutdown, terminating ComponentServer \n")); + } + } + + void + ComponentServer_Task::parse_args (int argc, ACE_TCHAR **argv) + { + CIAO_TRACE ("ComponentServer_Task::parse_args"); + + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::parse_args - parsing arguments...\n")); + + ACE_Get_Opt opts (argc, argv, "hu:c:", 1, 0, + ACE_Get_Opt::RETURN_IN_ORDER); + opts.long_option ("uuid", 'u', ACE_Get_Opt::ARG_REQUIRED); + opts.long_option ("callback-ior", 'c', ACE_Get_Opt::ARG_REQUIRED); + opts.long_option ("help", 'h'); + opts.long_option ("log-level",'l', ACE_Get_Opt::ARG_REQUIRED); + opts.long_option ("trace",'t', ACE_Get_Opt::NO_ARG); + opts.long_option ("output-ior",'o', ACE_Get_Opt::ARG_REQUIRED); + + //int j; + char c; + ACE_CString s; + + while ((c = opts ()) != -1) + { + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::parse_args - " + "Found option: \"%s\" with argument \"%s\"\n", + opts.last_option (), opts.opt_arg ())); + + switch (c) + { + case 'u': + CIAO_DEBUG ((LM_DEBUG, CLINFO "ComponentServer_Task::parse_args - " + "uuid is %s\n", + opts.opt_arg ())); + this->uuid_ = opts.opt_arg (); + break; + + case 'c': + CIAO_DEBUG ((LM_DEBUG, CLINFO "ComponentServer_Task::parse_args - " + "callback ior is %s\n", + opts.opt_arg ())); + this->callback_ior_str_ = opts.opt_arg (); + break; + + case 'l': + { + continue; // no-op, already taken care of + } + + case 't': + continue; // already taken care of + + case 'o': + CIAO_DEBUG ((LM_DEBUG, CLINFO "ComponentServer_Task::parse_args - " + "IOR Output file: %s\n", + opts.opt_arg ())); + this->output_file_ = opts.opt_arg (); + break; + + case 'h': + this->usage (); + throw Error ("Command line help requested, bailing out...."); + + default: + CIAO_ERROR ((LM_ERROR, CLINFO " Unknown option: %s\n", + opts.last_option ())); + this->usage (); + ACE_CString err ("Unknown option "); + err += opts.last_option (); + throw Error (err); + } + } + + // check required options. + if (this->uuid_ == "") + throw Error ("Option required: -u|--uuid"); + if (this->callback_ior_str_ == "") + CIAO_ERROR ((LM_WARNING, CLINFO + "ComponentServer_Task::parse_args - Starting ComponentServer without a callback IOR\n")); + } + + void + ComponentServer_Task::usage (void) + { + CIAO_TRACE ("ComponentServer_Task::usage"); + // Shouldn't be subject to CIAO's logging policy + ACE_ERROR ((LM_EMERGENCY, "Usage: CIAO_ComponentServer <options>\n" + "Options: \n" + "\t-h|--help\t\t\t\tShow help\n" + "\t-l|--log-level <level>\t\t\tSets log level (default 5). 1 - most detailed.\n" + "\t-u|--uuid <uuid> \t\t\tSets UUID of spawned component server (required)\n" + "\t-c|--callback-ior <string ior>\t\tSets callback url for the spawning ServerActivator.\n" + "\t-o|--output-ior <filename>\t\tOutputs the IOR of the component server object to file\n" + )); + + } + + const char * + ComponentServer_Task::sched_policy_name (int sched_policy) + { + const char *name = 0; + + switch (sched_policy) + { + case ACE_SCHED_OTHER: + name = "SCHED_OTHER"; + break; + case ACE_SCHED_RR: + name = "SCHED_RR"; + break; + case ACE_SCHED_FIFO: + name = "SCHED_FIFO"; + break; + } + + return name; + } + + /// The following check is taken from $(TAO_ROOT)/tests/RTCORBA/ + void + ComponentServer_Task::check_supported_priorities (void) + { + CIAO_TRACE ("ComponentServer_Task::check_supported_priorities"); + + int const sched_policy = + this->orb_->orb_core ()->orb_params ()->ace_sched_policy (); + + // Check that we have sufficient priority range to run, + // i.e., more than 1 priority level. + int const max_priority = + ACE_Sched_Params::priority_max (sched_policy); + int const min_priority = + ACE_Sched_Params::priority_min (sched_policy); + + if (max_priority == min_priority) + { + CIAO_DEBUG ((LM_DEBUG, CLINFO "ComponentServer_Task::check_supported_priorities - " + " Not enough priority levels with the %s scheduling policy\n" + "on this platform to run, terminating ....\n" + "Check svc.conf options\n", + sched_policy_name (sched_policy))); + + throw Error ("Bad scheduling policy."); + } + } + + void + ComponentServer_Task::configure_logging_backend (void) + { + Logger_Service + *clf = ACE_Dynamic_Service<Logger_Service>::instance ("CIAO_Logger_Backend_Factory"); + if (clf) + { + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Task::configure_logging_backend - " + "Replacing logger backend\n")); + ACE_Log_Msg_Backend * backend = clf->get_logger_backend(this->orb_); + backend->open(0); + ACE_Log_Msg::msg_backend (backend); + ACE_Log_Msg * ace = ACE_Log_Msg::instance(); + ace->clr_flags(ace->flags()); + ace->set_flags(ACE_Log_Msg::CUSTOM); + } + } + + std::string + ComponentServer_Task::get_hostname () + { + char hostname [100]; + gethostname (hostname, sizeof (hostname)); + + return std::string (hostname);; + } + + std::string + ComponentServer_Task::get_process_id () + { + pid_t pid = ACE_OS::getpid (); + std::stringstream ss; + ss << pid; + + return ss.str (); + } + + std::string + ComponentServer_Task::get_obj_path () + { + std::string path; + path += ("FLARe/"); + std::string hostname = this->get_hostname (); + + // replace all dots in the hostname with escaped dots for + //to_name conversion. + for (size_t pos = hostname.find ('.', 0); + pos < hostname.length (); + pos = hostname.find ('.', pos)) + { + hostname.replace (pos, 1, "\\."); + pos += 2; + } + + path += hostname; + path += "/"; + path += this->get_process_id (); + + return path; + } + + void + ComponentServer_Task::bind_obj (std::string obj_name, CORBA::Object_ptr obj) + { + CIAO_TRACE ("ComponentServer_Task::bind_obj ()"); + +#ifdef DOES_NOT_WORK_SINCE_NO_PARAMETERS_CAN_BE_PASSED_TO_COMPONENTSERVER + // register StateSynchronization Agent in the NameService + CORBA::Object_var ns_obj = orb_->resolve_initial_references ("NameService"); +#else + std::string ns_ior = ACE_Env_Value<std::string> ("NameServiceIOR", + std::string ()); + + if (ns_ior.empty ()) + { + CIAO_ERROR ((LM_WARNING, "Could not find environment variable " + "NameServiceIOR. FTComponentServer is not able to" + "bind the StateSynchronziationAgent entry\n")); + return; + } + + CORBA::Object_var ns_obj = orb_->string_to_object (ns_ior.c_str ()); +#endif + + if (CORBA::is_nil (ns_obj.in ())) + { + CIAO_ERROR ((LM_WARNING, "ComponentServer_Task::svc - " + "Could not resolve NameService\n")); + } + else + { + CosNaming::NamingContextExt_var ns = + CosNaming::NamingContextExt::_narrow (ns_obj.in ()); + + if (CORBA::is_nil (ns.in ())) + { + CIAO_ERROR ((LM_ERROR, "ComponentServer_Task::svc - " + "Narrowing NameService failed.\n")); + throw Error ("Narrowing NameService failed."); + } + + std::string path = get_obj_path (); + + CosNaming::NamingContext_var nc = + CosNaming::NamingContext::_narrow (ns.in ()); + CosNaming::Name_var name = ns->to_name (path.c_str ()); + CosNaming::Name entry; + entry.length (1); + + for (size_t i = 0; + i < name->length (); + ++i) + { + entry[0] = CosNaming::NameComponent (name[i]); + try + { + nc = nc->bind_new_context (entry); + } + catch (CosNaming::NamingContext::AlreadyBound & ex) + { + // if the entry is already there just go on + nc = CosNaming::NamingContext::_narrow (nc->resolve (entry)); + } + } + + name = ns->to_name (obj_name.c_str ()); + nc->bind (name, obj); + } + } + + void + ComponentServer_Task::unbind_obj (std::string obj_name) + { + CIAO_TRACE ("ComponentServer_Task::unbind_obj ()"); + +#ifdef DOES_NOT_WORK_SINCE_NO_PARAMETERS_CAN_BE_PASSED_TO_COMPONENTSERVER + // register StateSynchronization Agent in the NameService + CORBA::Object_var ns_obj = orb_->resolve_initial_references ("NameService"); +#else + std::string ns_ior = ACE_Env_Value<std::string> ("NameServiceIOR", + std::string ()); + if (ns_ior.empty ()) + { + CIAO_ERROR ((LM_WARNING, "Could not find environment variable " + "NameServiceIOR. FTComponentServer is not able to" + "bind the StateSynchronziationAgent entry\n")); + return; + } + + CORBA::Object_var ns_obj = orb_->string_to_object (ns_ior.c_str ()); +#endif + + if (CORBA::is_nil (ns_obj.in ())) + { + CIAO_ERROR ((LM_WARNING, "ComponentServer_Task::svc - " + "Could not resolve NameService\n")); + } + else + { + CosNaming::NamingContextExt_var ns = + CosNaming::NamingContextExt::_narrow (ns_obj.in ()); + + if (CORBA::is_nil (ns.in ())) + { + CIAO_ERROR ((LM_ERROR, "ComponentServer_Task::svc - " + "Narrowing NameService failed.\n")); + throw Error ("Narrowing NameService failed."); + } + + std::string path = get_obj_path (); + + std::string obj_path = path + obj_name; + CosNaming::Name_var path_name = ns->to_name (path.c_str ()); + CosNaming::Name_var name = ns->to_name (obj_path.c_str ()); + + try + { + ns->unbind (name); + ns->unbind (path_name); + } + catch (CosNaming::NamingContext::AlreadyBound & ex) + { + } + } + } + + } +} + + diff --git a/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.h b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.h new file mode 100644 index 00000000000..54bcea068ce --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer.h @@ -0,0 +1,78 @@ +/** + * @file CIAO_ComponentServer.h + * @author William R. Otte + * + * Defines interface for the bootstrap element of the CIAO Component + * Server. + */ + +#ifndef CIAO_COMPONENTSERVER_H_ +#define CIAO_COMPONENTSERVER_H_ + +#include "ace/String_Base.h" +#include "ace/Task.h" +#include "tao/ORB.h" +#include "ciao/Logger/Logger_Service.h" + +namespace CIAO +{ + namespace Deployment + { + class ComponentServer_Configurator; + + + class ComponentServer_Task : ACE_Task_Base + { + public: + ComponentServer_Task (int argc, ACE_TCHAR **argv); + + int svc (void); + + struct Error + { + Error (const ACE_CString &err) : err_(err) {} + + ACE_CString err_; + }; + + void run (void); + + private: + void parse_args (int argc, ACE_TCHAR **argv); + + void get_log_level (int argc, ACE_TCHAR **argv); + + void set_log_level (void); + + void configure_logging_backend (void); + + void usage (void); + + const char * sched_policy_name (int sched_policy); + + void check_supported_priorities (void); + + std::string get_hostname (); + + std::string get_process_id (); + + std::string get_obj_path (); + + void bind_obj (std::string obj_name, CORBA::Object_ptr obj); + + void unbind_obj (std::string obj_name); + + CORBA::ORB_var orb_; + + auto_ptr<CIAO::Logger_Service> logger_; + + ACE_CString uuid_; + ACE_CString callback_ior_str_; + ACE_CString output_file_; + auto_ptr<ComponentServer_Configurator> configurator_; + + }; + } +} + +#endif diff --git a/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_Impl.cpp b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_Impl.cpp new file mode 100644 index 00000000000..8f1827c6035 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_Impl.cpp @@ -0,0 +1,250 @@ +#include "CIAO_FTComponentServer_Impl.h" + +#include "ciao/CIAO_common.h" + +#include "CIAO_CS_ClientC.h" +#include "CIAO_Container_Impl.h" + +namespace CIAO +{ + namespace Deployment + { + CIAO_ComponentServer_i::CIAO_ComponentServer_i (const ACE_CString &uuid, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa) + : uuid_ (uuid), + orb_ (CORBA::ORB::_duplicate (orb)), + poa_ (PortableServer::POA::_duplicate (poa)), + containers_ () + { + CIAO_TRACE("CIAO_ComponentServer_i::CIAO_ComponentServer_i"); + } + + // Destructor + CIAO_ComponentServer_i::~CIAO_ComponentServer_i (void) + { + CIAO_TRACE("CIAO_ComponentServer_i::~CIAO_ComponentServer_i"); + } + + + void + CIAO_ComponentServer_i::shutdown (void) + { + CIAO_TRACE("CIAO_ComponentServer_i::shutdown"); + + CIAO_DEBUG ((LM_DEBUG, CLINFO "CIAO_ComponentServer_i::shutdown - ORB shutdown request received at %s.\n", + this->uuid_.c_str ())); + + if (!this->containers_.is_empty ()) + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_ComponentServer_i::shutdown - ComponentServer %s still containers!\n", + this->uuid_.c_str ())); + + this->orb_->shutdown (); + } + + + ::Components::ConfigValues * + CIAO_ComponentServer_i::configuration (void) + { + CIAO_TRACE("CIAO_ComponentServer_i::configuration"); + return this->config_values_.out (); + } + + + ::Components::Deployment::ServerActivator_ptr + CIAO_ComponentServer_i::get_server_activator (void) + { + CIAO_TRACE("CIAO_ComponentServer_i::get_server_activator"); + return this->serv_act_.in (); + } + + + ::Components::Deployment::Container_ptr + CIAO_ComponentServer_i::create_container (const ::Components::ConfigValues & config) + { + CIAO_TRACE("CIAO_ComponentServer_i::create_container"); + + try + { + CIAO_DEBUG ((LM_INFO, CLINFO "CIAO_ComponentServer_i::create_container - Request received with %u config values\n", + config.length ())); + + CORBA::PolicyList policies; + const char *name = 0; + + CIAO_Container_i *cont = 0; + ACE_NEW_THROW_EX (cont, + CIAO_Container_i (config, 0, name, &policies, this->orb_.in (), this->poa_.in ()), + CORBA::NO_MEMORY ()); + + CIAO_DEBUG ((LM_DEBUG, CLINFO "CIAO_ComponentServer_i::create_container - " + "Container servant successfully allocated.\n")); + + PortableServer::ServantBase_var safe_config = cont; + CIAO::Deployment::Container_var cont_var = cont->_this (); + + this->containers_.insert (CIAO::Deployment::Container::_duplicate(cont_var.in ())); + + CIAO_DEBUG ((LM_INFO, CLINFO "CIAO_ComponentServer_i::create_container - Container successfully activated and stored," + "now manage %u containers\n", + this->containers_.size ())); + + return cont_var._retn (); + } + catch (CORBA::NO_MEMORY &) + { + CIAO_ERROR ((LM_CRITICAL, CLINFO "CIAO_ComponentServer_Impl: Out of memory exception whilst creating container.\n")); + throw; + } + catch (...) + { + CIAO_ERROR ((LM_ERROR, "CIAO_ComponentServer_Impl: Caught unknown exception\n")); + } + + throw Components::CreateFailure (); + } + + + + void + CIAO_ComponentServer_i::remove_container (::Components::Deployment::Container_ptr cref) + { + CIAO_TRACE("CIAO_ComponentServer_i::remove_container"); + + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_ComponentServer_i::remove_container - remove request received.\n")); + + if (CORBA::is_nil (cref)) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ComponentServer_i::remove_container - " + "Error: Received nil container reference\n")); + throw Components::RemoveFailure (); + } + + + if (this->containers_.is_empty ()) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ComponentServer_i::remove_container - " + "Error: I don't manage any containers!\n")); + throw Components::RemoveFailure (); + } + + + try + { + CONTAINERS::ITERATOR i (this->containers_.begin ()); + + // @@ TODO: artifact from when this was a sequence, should probably use .find, + // which will work properly with the new parameterized set class. + for (CONTAINERS::iterator i = this->containers_.begin (); + i.done () != 1; i.advance ()) + { + if (CORBA::is_nil (*i)) + { + ACE_ERROR ((LM_WARNING, CLINFO + "CIAO_ComponentServer_i::remove_container - " + "Managed container reference is nil, skipping.\n")); + continue; + } + + if ((*i)->_is_equivalent (cref)) + { + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_ComponentServer_i::remove_container - Found container, invoking remove....\n")); + cref->remove (); + if (this->containers_.remove (*i) != 0) + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ComponentServer_i::remove_container - Unable to remove " + "container reference from internal structure....\n")); + CIAO_DEBUG ((LM_TRACE, CLINFO "CIAO_ComponentServer_i::remove_container - Remove completed, destroying object, " + "now manage %u containers\n", this->containers_.size ())); + return; + } + } + } + catch (CORBA::Exception &ex) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_ComponentServer_i::remove_container - " + "Caught CORBA exception whilst removing container: %s\n", + ex._info ().c_str ())); + } + + catch (...) + { + CIAO_ERROR ((LM_ERROR, CLINFO "CIAO_ComponentServer_i::remove_container - Error: Unknown exception caught while removing a container.\n")); + } + throw Components::RemoveFailure (); + } + + + ::Components::Deployment::Containers * + CIAO_ComponentServer_i::get_containers (void) + { + CIAO_TRACE("CIAO_ComponentServer_i::get_containers"); + + ::Components::Deployment::Containers *tmp(0); + // tmp = new ::Components::Deployment::Containers (); + ACE_NEW_THROW_EX (tmp, + ::Components::Deployment::Containers (this->containers_.size ()), + CORBA::NO_MEMORY ()); + + ::Components::Deployment::Containers_var retval (tmp); + CORBA::ULong pos (0); + retval->length (this->containers_.size ()); + + for (CONTAINERS::iterator i = this->containers_.begin (); + i.done () != 1; i.advance ()) + { + retval[pos++] = ::CIAO::Deployment::Container::_duplicate (*i); + } + + return retval._retn (); + } + + + void + CIAO_ComponentServer_i::remove (void) + { + CIAO_TRACE("CIAO_ComponentServer_i::remove"); + + bool successful = true; + + for (CONTAINERS::iterator i = this->containers_.begin (); + i.done () != 1; i.advance ()) + { + try + { + (*i)->remove (); + } + catch (CORBA::Exception &ex) + { + successful = false; + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ComponentServer_i::remove - " + "Intercepted CORBA exception while trying to remove a container:%s\n", + ex._info ().c_str ())); + } + catch (...) + { + successful = false; + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ComponentServer_i::remove - " + "Intercepted exception while trying to remove a container\n")); + } + } + + this->containers_.reset (); + + if (!successful) + throw ::Components::RemoveFailure (); + } + + void + CIAO_ComponentServer_i::init (::Components::Deployment::ServerActivator_ptr sa, + Components::ConfigValues *cvs) + { + this->serv_act_ = ::Components::Deployment::ServerActivator::_duplicate(sa); + this->config_values_ = cvs; + } + } +} diff --git a/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_Impl.h b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_Impl.h new file mode 100644 index 00000000000..63ed835a644 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_Impl.h @@ -0,0 +1,78 @@ +/** + * @file CIAO_ComponentServer.h + * @author William R. Otte <wotte@dre.vanderbilt.edu> + */ + +#ifndef CIAO_COMPONENTSERVER_IMPL_H_ +#define CIAO_COMPONENTSERVER_IMPL_H_ + +#include "ciao/ComponentServer/CIAO_ComponentServerS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/String_Base.h" +#include "ace/Unbounded_Set_Ex.h" + +namespace CIAO +{ + namespace Deployment + { + class CIAO_ComponentServer_svnt_Export CIAO_ComponentServer_i + : public virtual POA_CIAO::Deployment::ComponentServer + { + public: + // Constructor + CIAO_ComponentServer_i (const ACE_CString &uuid, CORBA::ORB_ptr orb, PortableServer::POA_ptr poa); + + // Destructor + virtual ~CIAO_ComponentServer_i (void); + + virtual void shutdown (void); + + virtual ::Components::ConfigValues * configuration (void); + + virtual + ::Components::Deployment::ServerActivator_ptr get_server_activator (void); + + virtual + ::Components::Deployment::Container_ptr create_container (const ::Components::ConfigValues & config); + + virtual + void remove_container (::Components::Deployment::Container_ptr cref); + + virtual + ::Components::Deployment::Containers * get_containers (void); + + virtual + void remove (void); + + void init (::Components::Deployment::ServerActivator_ptr sa, + Components::ConfigValues *cvs); + + private: + ACE_CString uuid_; + CORBA::ORB_var orb_; + PortableServer::POA_var poa_; + ::Components::Deployment::ServerActivator_var serv_act_; + Components::ConfigValues_var config_values_; + + template<typename T> + struct _is_equivalent + { + bool operator() (const T &a, const T &b) const + { + return a->_is_equivalent (const_cast <T&> (b)); + } + }; + + typedef ACE_Unbounded_Set_Ex <Container_var, + _is_equivalent<Container_var> > CONTAINERS; + + CONTAINERS containers_; + }; + } +} + +#endif diff --git a/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_stub_export.h b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_stub_export.h new file mode 100644 index 00000000000..8f5dddc8c9e --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_stub_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl CIAO_FTComponentServer_stub +// ------------------------------ +#ifndef CIAO_FTCOMPONENTSERVER_STUB_EXPORT_H +#define CIAO_FTCOMPONENTSERVER_STUB_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (CIAO_FTCOMPONENTSERVER_STUB_HAS_DLL) +# define CIAO_FTCOMPONENTSERVER_STUB_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && CIAO_FTCOMPONENTSERVER_STUB_HAS_DLL */ + +#if !defined (CIAO_FTCOMPONENTSERVER_STUB_HAS_DLL) +# define CIAO_FTCOMPONENTSERVER_STUB_HAS_DLL 1 +#endif /* ! CIAO_FTCOMPONENTSERVER_STUB_HAS_DLL */ + +#if defined (CIAO_FTCOMPONENTSERVER_STUB_HAS_DLL) && (CIAO_FTCOMPONENTSERVER_STUB_HAS_DLL == 1) +# if defined (CIAO_FTCOMPONENTSERVER_STUB_BUILD_DLL) +# define CIAO_FTComponentServer_stub_Export ACE_Proper_Export_Flag +# define CIAO_FTCOMPONENTSERVER_STUB_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define CIAO_FTCOMPONENTSERVER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* CIAO_FTCOMPONENTSERVER_STUB_BUILD_DLL */ +# define CIAO_FTComponentServer_stub_Export ACE_Proper_Import_Flag +# define CIAO_FTCOMPONENTSERVER_STUB_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define CIAO_FTCOMPONENTSERVER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* CIAO_FTCOMPONENTSERVER_STUB_BUILD_DLL */ +#else /* CIAO_FTCOMPONENTSERVER_STUB_HAS_DLL == 1 */ +# define CIAO_FTComponentServer_stub_Export +# define CIAO_FTCOMPONENTSERVER_STUB_SINGLETON_DECLARATION(T) +# define CIAO_FTCOMPONENTSERVER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* CIAO_FTCOMPONENTSERVER_STUB_HAS_DLL == 1 */ + +// Set CIAO_FTCOMPONENTSERVER_STUB_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (CIAO_FTCOMPONENTSERVER_STUB_NTRACE) +# if (ACE_NTRACE == 1) +# define CIAO_FTCOMPONENTSERVER_STUB_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define CIAO_FTCOMPONENTSERVER_STUB_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !CIAO_FTCOMPONENTSERVER_STUB_NTRACE */ + +#if (CIAO_FTCOMPONENTSERVER_STUB_NTRACE == 1) +# define CIAO_FTCOMPONENTSERVER_STUB_TRACE(X) +#else /* (CIAO_FTCOMPONENTSERVER_STUB_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define CIAO_FTCOMPONENTSERVER_STUB_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (CIAO_FTCOMPONENTSERVER_STUB_NTRACE == 1) */ + +#endif /* CIAO_FTCOMPONENTSERVER_STUB_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_svnt_export.h b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_svnt_export.h new file mode 100644 index 00000000000..ecd2a4ba8e4 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_FTComponentServer_svnt_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl CIAO_FTComponentServer_svnt +// ------------------------------ +#ifndef CIAO_FTCOMPONENTSERVER_SVNT_EXPORT_H +#define CIAO_FTCOMPONENTSERVER_SVNT_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (CIAO_FTCOMPONENTSERVER_SVNT_HAS_DLL) +# define CIAO_FTCOMPONENTSERVER_SVNT_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && CIAO_FTCOMPONENTSERVER_SVNT_HAS_DLL */ + +#if !defined (CIAO_FTCOMPONENTSERVER_SVNT_HAS_DLL) +# define CIAO_FTCOMPONENTSERVER_SVNT_HAS_DLL 1 +#endif /* ! CIAO_FTCOMPONENTSERVER_SVNT_HAS_DLL */ + +#if defined (CIAO_FTCOMPONENTSERVER_SVNT_HAS_DLL) && (CIAO_FTCOMPONENTSERVER_SVNT_HAS_DLL == 1) +# if defined (CIAO_FTCOMPONENTSERVER_SVNT_BUILD_DLL) +# define CIAO_FTComponentServer_svnt_Export ACE_Proper_Export_Flag +# define CIAO_FTCOMPONENTSERVER_SVNT_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define CIAO_FTCOMPONENTSERVER_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* CIAO_FTCOMPONENTSERVER_SVNT_BUILD_DLL */ +# define CIAO_FTComponentServer_svnt_Export ACE_Proper_Import_Flag +# define CIAO_FTCOMPONENTSERVER_SVNT_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define CIAO_FTCOMPONENTSERVER_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* CIAO_FTCOMPONENTSERVER_SVNT_BUILD_DLL */ +#else /* CIAO_FTCOMPONENTSERVER_SVNT_HAS_DLL == 1 */ +# define CIAO_FTComponentServer_svnt_Export +# define CIAO_FTCOMPONENTSERVER_SVNT_SINGLETON_DECLARATION(T) +# define CIAO_FTCOMPONENTSERVER_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* CIAO_FTCOMPONENTSERVER_SVNT_HAS_DLL == 1 */ + +// Set CIAO_FTCOMPONENTSERVER_SVNT_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (CIAO_FTCOMPONENTSERVER_SVNT_NTRACE) +# if (ACE_NTRACE == 1) +# define CIAO_FTCOMPONENTSERVER_SVNT_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define CIAO_FTCOMPONENTSERVER_SVNT_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !CIAO_FTCOMPONENTSERVER_SVNT_NTRACE */ + +#if (CIAO_FTCOMPONENTSERVER_SVNT_NTRACE == 1) +# define CIAO_FTCOMPONENTSERVER_SVNT_TRACE(X) +#else /* (CIAO_FTCOMPONENTSERVER_SVNT_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define CIAO_FTCOMPONENTSERVER_SVNT_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (CIAO_FTCOMPONENTSERVER_SVNT_NTRACE == 1) */ + +#endif /* CIAO_FTCOMPONENTSERVER_SVNT_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/CIAO_Properties.idl b/CIAO/ciao/FTComponentServer/CIAO_Properties.idl new file mode 100644 index 00000000000..d77b5c8b09b --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_Properties.idl @@ -0,0 +1,28 @@ +/** + * @file CIAO_Properties.idl + * @author William R. Otte + * + * Standardizes names of configvalues used by CIAO. + */ + +#ifndef CIAO_PROPERTIES_IDL +#define CIAO_PROPERTIES_IDL + +module CIAO +{ + module Deployment + { + const string SVNT_ENTRYPT = "edu.vanderbilt.dre.CIAO.ServantEntrypoint"; + const string SVNT_ARTIFACT = "edu.vanderbilt.dre.CIAO.ServantArtifact"; + const string EXEC_ARTIFACT = "edu.vanderbilt.dre.CIAO.ExecutorArtifact"; + const string SERVER_RESOURCES = "edu.vanderbilt.dre.CIAO.ServerResources"; + const string SERVER_UUID = "edu.vanderbilt.dre.CIAO.ServerUUID"; + const string SERVER_EXECUTABLE = "edu.vanderbilt.dre.CIAO.ComponentServerExecutable"; + const string SERVER_ARGUMENTS = "edu.vanderbilt.dre.CIAO.ComponentServerArgs"; + const string SERVER_TIMEOUT = "edu.vanderbilt.dre.CIAO.ServerTimeout"; + const string SERVER_MULTITHREAD = "edu.vanderbilt.dre.CIAO.Multithreaded"; + const string REGISTER_NAMING = "edu.vanderbilt.dre.CIAO.RegisterNaming"; + + }; +}; +#endif /* CIAO_PROPERTIES_IDL */
\ No newline at end of file diff --git a/CIAO/ciao/FTComponentServer/CIAO_ServerActivator_Impl.cpp b/CIAO/ciao/FTComponentServer/CIAO_ServerActivator_Impl.cpp new file mode 100644 index 00000000000..a1ae89404f0 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_ServerActivator_Impl.cpp @@ -0,0 +1,528 @@ +#include "CIAO_ServerActivator_Impl.h" + +#include "ace/Log_Msg.h" +#include "ace/UUID.h" +#include "ciao/CIAO_common.h" +#include "ciao/Client_init.h" +#include "ciao/CIAO_FailureReasonsC.h" + +#include "CIAO_ServerResourcesC.h" +#include "CIAO_ComponentServerC.h" +#include "CIAO_PropertiesC.h" + +namespace CIAO +{ + namespace Deployment + { + CIAO_ServerActivator_i::CIAO_ServerActivator_i (CORBA::ULong def_spawn_delay, + const char * default_cs_path, + const char * cs_args, + bool multithreaded, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa) + : spawn_delay_ (def_spawn_delay), + multithreaded_ (multithreaded), + orb_ (CORBA::ORB::_duplicate (orb)), + poa_ (PortableServer::POA::_duplicate (poa)), + cs_path_ (default_cs_path), + cs_args_ (cs_args), + mutex_ (), + condition_ (mutex_) + { + CIAO_TRACE (CLINFO "CIAO_ServerActivator_i::CIAO_ServerActivator_i"); + } + + CIAO_ServerActivator_i::~CIAO_ServerActivator_i(void) + { + } + + void + CIAO_ServerActivator_i::component_server_callback (::Components::Deployment::ComponentServer_ptr serverref, + const char * server_UUID, + ::Components::ConfigValues_out config) + { + CIAO_TRACE(CLINFO "CIAO_ServerActivator_i::component_server_callback"); + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Received callback from ComponentServer %s\n", + server_UUID)); + + if (this->server_infos_.is_empty ()) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Received callback from ComponentServer %s, but I don't manage any.\n", + server_UUID)); + throw CORBA::BAD_PARAM (); + } + + //SERVER_INFOS::iterator i (this->server_infos_.begin ()); + //i.first (); + Server_Info *info = 0; + + for (SERVER_INFOS::iterator i (this->server_infos_.begin ()); + !i.done (); ++i) + { + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Comparing %s with %s\n", (*i)->uuid_.c_str (), server_UUID)); + if ((*i)->uuid_ == server_UUID) + { + info = (*i).get (); + } + } + + if (info == 0) + { CIAO_ERROR ((LM_WARNING, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Received callback from ComponentServer %s, which doesn't belong to me.\n", + server_UUID)); + throw CORBA::BAD_PARAM (); + } + + if (info->activated_) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Received callback from ComponentServer %s, which has already been configured.\n", + server_UUID)); + throw CORBA::BAD_INV_ORDER (); + } + + if (!CORBA::is_nil (info->ref_)) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Received callback from ComponentServer %s, which has already called back.\n", + server_UUID)); + throw CORBA::BAD_INV_ORDER (); + } + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Received callback from ComponentServer %s\n", + server_UUID)); + + info->ref_ = ::Components::Deployment::ComponentServer::_duplicate (serverref); + + this->create_component_server_config_values (*info, config); + + // @@TODO: May want to print out configvalues here. + CIAO_DEBUG ((LM_DEBUG, CLINFO + "CIAO_ServerActivator_i::component_server_callback - " + "Generated %u ConfigValues for ComponentServer %s\n", + config->length (), server_UUID)); + } + + void + CIAO_ServerActivator_i::configuration_complete (const char *server_UUID) + { + CIAO_TRACE (CLINFO "CIAO_ServerActivator_i::configuration_complete"); + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::configuration_complete - " + "Received configuration_complete from ComponentServer %s\n", + server_UUID)); + + try + { + if (this->server_infos_.is_empty ()) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::configuration_complete - " + "Received callback from ComponentServer %s, but I don't manage any.\n", + server_UUID)); + throw CORBA::BAD_PARAM (); + } + + Server_Info *info = 0; + + for (SERVER_INFOS::ITERATOR j (this->server_infos_); + !j.done (); ++j) + { + if ((*j)->uuid_ == server_UUID) + { + info = (*j).get (); + } + } + + if (info == 0) + { + CIAO_ERROR ((LM_WARNING, CLINFO + "CIAO_ServerActivator_i::configuration_complete - " + "Received configuration_complete from ComponentServer %s, which doesn't belong to me.\n", + server_UUID)); + throw CORBA::BAD_PARAM (); + } + + if (info->activated_) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::configuration_complete - " + "Received configuration_complete from ComponentServer %s, which has already been completed.\n", + server_UUID)); + throw CORBA::BAD_INV_ORDER (); + } + + if (CORBA::is_nil (info->ref_.in ())) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::configuration_complete - " + "Received configuration_complete from ComponentServer %s, which has not called back.\n", + server_UUID)); + throw CORBA::BAD_INV_ORDER (); + } + + info->activated_ = true; + } + catch (...) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::configuration_complete - " + "Caught unknown exception while processing configuration_complete\n")); + throw; + } + } + + ::Components::Deployment::ComponentServer_ptr + CIAO_ServerActivator_i::create_component_server (const ::Components::ConfigValues & config) + { + CIAO_TRACE(CLINFO "CIAO_ServerActivator_i::create_component_server"); + + Safe_Server_Info server (new Server_Info (config.length () + 1)); + + CIAO::Utility::build_config_values_map (*server->cmap_, config); + + ACE_CString cmd_options = this->construct_command_line (*server); + + CIAO_DEBUG ((LM_DEBUG, CLINFO + "CIAO_ServerActivator_i::create_component_server - ComponentServer arguments: %C\n", + cmd_options.c_str ())); + + server_infos_.insert_tail (server); + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::create_component_server - " + "Attempting to spawn ComponentServer with UUID %s\n", + server->uuid_.c_str ())); + // Now we need to get a copy of the one that was inserted... + pid_t pid = this->spawn_component_server (*server, cmd_options); + + ACE_Time_Value timeout (this->spawn_delay_); + + CORBA::Any val; + + if (server->cmap_->find (SERVER_TIMEOUT, val) == 0) + { + CORBA::ULong t; + if (val >>= t) + { + CIAO_DEBUG ((LM_DEBUG, CLINFO "CIAO_ServerActivator_i::create_component_server - " + "Using provided non-default server timeout of %u\n", t)); + timeout = ACE_Time_Value (t); + } + else + { + CIAO_ERROR ((LM_WARNING, CLINFO "CIAO_ServerActivator_i::create_component_server - " + "Failed to extract provided non-default server timeout from property '%s', " + "falling back to default timeout of %u\n", + this->spawn_delay_)); + } + } + + if (this->multithreaded_) + this->multi_threaded_wait_for_callback (*server, timeout/*, pid*/); + else + this->single_threaded_wait_for_callback (*server, timeout/*, pid*/); + + CIAO_DEBUG ((LM_DEBUG, CLINFO + "CIAO_ServerActivator_i::create_component_server - " + "ComponentServer %s successfully spawned and configured!\n", + server->uuid_.c_str ())); + + return ::Components::Deployment::ComponentServer::_duplicate (server->ref_.in ()); + } + + ACE_CString + CIAO_ServerActivator_i::construct_command_line (Server_Info &server) + { + CIAO_TRACE (CLINFO "CIAO_ServerActivator_i::construct_command_line"); + // Build our command line to launch the compoent server + ACE_CString cmd_options (this->cs_args_); + + CORBA::Any val; + + if (server.cmap_->find (SERVER_UUID, val) == 0) + { + // Nodeapplication has requested a custom uuid + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::construct_command_line - Using provided UUID\n")); + const char *uuid = 0; + val >>= uuid; + server.uuid_ = uuid; + } + else + { + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::construct_command_line - Using generated UUID\n")); + ACE_Utils::UUID uuid; + ACE_Utils::UUID_GENERATOR::instance ()->generate_UUID (uuid); + server.uuid_ = *uuid.to_string (); + } + + CIAO_DEBUG ((LM_DEBUG, CLINFO + "CIAO_ServerActivator_i::construct_command_line - Creating component server " + " with UUID %s\n", server.uuid_.c_str ())); + + cmd_options += " -u "; + cmd_options += server.uuid_; + + if (server.cmap_->find (SERVER_RESOURCES, val) == 0) + { + // There may be command line arguments specified in the plan + ServerResource_var sr; + val >>= sr; + + // If command line options are specified through RTCCM descriptors, + // then we should honor these command line options as well. + for (CORBA::ULong arg_i = 0; + arg_i < sr->args.length (); + ++arg_i) + { + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::construct_command_line - Adding argument %s from ServerResource\n ", + sr->args[arg_i].in ())); + cmd_options += " "; // space between command line args + cmd_options += sr->args[arg_i]; + } + + // If service configuration file is specified through RTCCM + // descriptors, then we should honor it as well. + if (ACE_OS::strcmp (sr->svcconf.in (), + "") != 0) + { + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::construct_command_line - Using SvcConf file %s\n ", + sr->svcconf.in ())); + cmd_options += " -ORBSvcConf "; + cmd_options += sr->svcconf; + } + } + + return cmd_options; + } + + pid_t + CIAO_ServerActivator_i::spawn_component_server (const Server_Info &si, + const ACE_CString &cmd_line) + { + CIAO_TRACE ("CIAO_ServerActivator_i::spawn_component_server"); + + ACE_Process_Options options; + + // Get my object reference + CORBA::Object_var obj = this->poa_->servant_to_reference (this); + CORBA::String_var ior = this->orb_->object_to_string (obj.in ()); + CORBA::Any val; + + const char *path = this->cs_path_.c_str (); + + if (si.cmap_->find (SERVER_EXECUTABLE, val) == 0) + { + val >>= path; + CIAO_DEBUG ((LM_DEBUG, CLINFO "CIAO_ServerActivator_i::spawn_component_server - " + "Using provided component server executable:%s\n", path)); + } + else CIAO_DEBUG ((LM_DEBUG, CLINFO "CIAO_ServerActivator_i::spawn_component_server - " + "Using default component server execuable\n")); + + options.command_line ("%s %s -c %s", + path, + cmd_line.c_str (), + ior.in ()); + + options.avoid_zombies (0); + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::spawn_component_server - Spawning process, command line is %s\n", + options.command_line_buf ())); + + pid_t pid = this->process_manager_.spawn (options, + &this->child_handler_); + + if (pid == ACE_INVALID_PID) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "Failed to spawn a ComponentServer process\n")); + throw Components::CreateFailure (CIAO::SERVER_SPAWN_FAILURE); + } + + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::spawn_component_server - Process successfully spawned with pid %u\n", + pid)); + return pid; + } + + void + CIAO_ServerActivator_i:: + single_threaded_wait_for_callback (const Server_Info &si, + ACE_Time_Value &timeout) + { + CIAO_TRACE (CLINFO "CIAO_ServerActivator_i::single_threaded_wait_for_callback"); + // Below code is broken for thread-per-connection concurrency model, + // since the main thread is running ORB event loop and will spawn + // a different thread to handle the call <register_node_application>, + // the <perform_work> operation will not be invoked and finally + // a timeout will occur. For a similar reason, it won't work + // for thread-pool concurrency model. + while (true) + { + this->orb_->perform_work (timeout); + + if (timeout == ACE_Time_Value::zero) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::single_threaded_wait_for_callback - " + "Timed out while waiting for ComponentServer %s to call back.\n", + si.uuid_.c_str ())); + throw ::Components::CreateFailure (CIAO::CALLBACK_TIMEOUT_EXCEEDED); + } + + if (si.activated_) + { + break; + } + } + } + + void + CIAO_ServerActivator_i:: + multi_threaded_wait_for_callback (const Server_Info &si, + ACE_Time_Value &timeout) + { + CIAO_TRACE (CLINFO "CIAO_ServerActivator_i::multi_threaded_wait_for_callback"); + + // Wait for a conditional variable + ACE_GUARD_THROW_EX ( ACE_Thread_Mutex, + guard, + this->mutex_, + CORBA::NO_RESOURCES ()); + + while (! si.activated_ ) + if (this->condition_.wait (&timeout) == -1) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::multi_threaded_wait_for_callback - " + "Timed out while waiting for ComponentServer %s to call back.\n", + si.uuid_.c_str ())); + throw Components::CreateFailure (CIAO::CALLBACK_TIMEOUT_EXCEEDED); + } + } + + void + CIAO_ServerActivator_i::remove_component_server (::Components::Deployment::ComponentServer_ptr server) + { + CIAO_TRACE(CLINFO "CIAO_ServerActivator_i::remove_component_server"); + + if (this->server_infos_.is_empty ()) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::remove_component_server - " + "I don't manage any ComponentServers.\n")); + throw CORBA::BAD_PARAM (); + } + + Server_Info *info = 0; + + for (SERVER_INFOS::ITERATOR i (this->server_infos_); + !i.done (); ++i) + { + if ((*i)->ref_->_is_equivalent (server)) + { + info = (*i).get (); + } + } + + if (info == 0) + { + CIAO_ERROR ((LM_ERROR, CLINFO + "CIAO_ServerActivator_i::remove_component_server - " + "Failed to find equivalent ComponentServer under my management.\n")); + throw ::Components::RemoveFailure (); + } + + try + { + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::remove_component_server - " + "Calling remove () on ComponentServer %s\n", + info->uuid_.c_str ())); + server->remove (); + } + catch (::Components::RemoveFailure &) + { + CIAO_ERROR ((LM_WARNING, CLINFO + "CIAO_ServerActivator_i::remove_component_server - " + "Received RemoveFailure exception from ComponentServer %s\n", + info->uuid_.c_str ())); + } + + // If this is a CIAO component server, call shutdown + CIAO::Deployment::ComponentServer_var ccs = + CIAO::Deployment::ComponentServer::_narrow (server); + if (!CORBA::is_nil (ccs)) + { + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::remove_component_server - " + "Calling shutdown () on ComponentServer %s\n", + info->uuid_.c_str ())); + ccs->shutdown (); + } + else + CIAO_DEBUG ((LM_TRACE, CLINFO + "CIAO_ServerActivator_i::remove_component_server - " + "ComponentServer %s is not a CIAO_ComponentServer, not calling shutdown.\n", + info->uuid_.c_str ())); + + CIAO_DEBUG ((LM_INFO, CLINFO + "CIAO_ServerActivator_i::remove_component_server - " + "ComponentServer %s successfully shut down.\n", + info->uuid_.c_str ())); + } + + ::Components::Deployment::ComponentServers * + CIAO_ServerActivator_i::get_component_servers (void) + { + CIAO_TRACE(CLINFO "CIAO_ServerActivator_i::get_component_servers"); + + ::Components::Deployment::ComponentServers_var retval = new + Components::Deployment::ComponentServers (this->server_infos_.size ()); + + if (retval->length () == 0) + return retval; + + + CORBA::ULong pos = 0; + + for (SERVER_INFOS::ITERATOR i (this->server_infos_); + !i.done (); ++i) + { + retval[pos++] = ::Components::Deployment::ComponentServer::_duplicate ((*i)->ref_); + } + + return retval._retn (); + } + + void + CIAO_ServerActivator_i::create_component_server_config_values (const Server_Info &, + Components::ConfigValues_out &config) + { + ACE_NEW_THROW_EX (config, + Components::ConfigValues (0), + CORBA::NO_MEMORY ()); + } + + } +} + diff --git a/CIAO/ciao/FTComponentServer/CIAO_ServerActivator_Impl.h b/CIAO/ciao/FTComponentServer/CIAO_ServerActivator_Impl.h new file mode 100644 index 00000000000..455f043aab7 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_ServerActivator_Impl.h @@ -0,0 +1,193 @@ +/** + * @file CIAO_ServerActivator.h + * @author William R. Otte + */ + +#ifndef CIAO_SERVERACTIVATOR_H_ +#define CIAO_SERVERACTIVATOR_H_ + +#include "ace/Process_Manager.h" +#include "ace/Event_Handler.h" +#include "ace/Condition_T.h" +#include "ace/OS_NS_sys_wait.h" +#include "ace/Refcounted_Auto_Ptr.h" +#include "ace/Unbounded_Set_Ex.h" +#include "tao/PortableServer/PortableServer.h" +#include "ciao/Client_init.h" +#include "ciao/FTComponentServer/CIAO_CS_ClientS.h" +#include "ciao/FTComponentServer/CIAO_ComponentServerC.h" +#include "ciao/FTComponentServer/CIAO_CS_Client_svnt_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +namespace CIAO +{ + namespace Deployment + { + namespace + { + /** + * @class Child_Handler + * @brief The signal handler class for the SIGCHLD + * handling to avoid zombies + * + */ + class Child_Handler : public virtual ACE_Event_Handler + { + public: + virtual int handle_signal (int sig, + siginfo_t *, + ucontext_t *) + { + ACE_UNUSED_ARG (sig); + + // @@ Note that this code is not portable to all OS platforms + // since it uses print statements within signal handler context. + ACE_exitcode status; + // makes a claal to the underlying os system call + // -1 to wait for any child process + // and WNOHANG so that it retuurns immediately + ACE_OS::waitpid (-1 ,&status, WNOHANG, 0); + + return 0; + } + }; + } + + + /** + * @class CIAO_ServerActivator_i + * @author William R. Otte <wotte@dre.vanderbilt.edu> + * @brief Default server activator for CIAO component servers. + * + * Implements the default component server activation strategy + * which is to spawn new processes. This is not thread-safe, + * nor is it intended to be. Containers are reated serially, + * so there will be only one actor *modifying* data at a particular + * point in time. + */ + class CIAO_CS_Client_svnt_Export CIAO_ServerActivator_i + : public virtual POA_CIAO::Deployment::ServerActivator + { + public: + // Constructor + CIAO_ServerActivator_i (CORBA::ULong def_spawn_delay, + const char * default_cs_path, + const char * cs_args, + bool multithreaded, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa_); + + + // Destructor + virtual ~CIAO_ServerActivator_i (void); + + virtual + void component_server_callback (::Components::Deployment::ComponentServer_ptr serverref, + const char * server_UUID, + ::Components::ConfigValues_out config); + + virtual void configuration_complete (const char *server_UUID); + + virtual + ::Components::Deployment::ComponentServer_ptr + create_component_server (const ::Components::ConfigValues & config); + + virtual + void remove_component_server (::Components::Deployment::ComponentServer_ptr server); + + virtual + ::Components::Deployment::ComponentServers * get_component_servers (void); + + private: + struct Server_Info; + + /// Builds command line options based on configuration information. + /// May modify the uuid of the component server. + ACE_CString construct_command_line (Server_Info &si); + + /// Spawns the component server process, but does not wait for it + /// to call back. + pid_t spawn_component_server (const Server_Info &si, + const ACE_CString &cmd_line); + + /// This method is only applicable when our program is configured as + /// singled threaded . Internally it uses a <perform_work> blocking + /// call to wait for NA object to call back + void single_threaded_wait_for_callback (const Server_Info &si, + ACE_Time_Value &timeout); + + /// This method is only applicable when our program is configured as + /// multiple threaded. Internally it waits on a conditional variable + /// that could be modified by the callback servant which runs in + /// another thread + void multi_threaded_wait_for_callback (const Server_Info &si, + ACE_Time_Value &timeout); + + void create_component_server_config_values (const Server_Info &info, + Components::ConfigValues_out &config); + + struct Server_Info + { + Server_Info (size_t cmap_size_hint = 128) + : cmap_ (new CIAO::Utility::CONFIGVALUE_MAP (cmap_size_hint)), + ref_ (Components::Deployment::ComponentServer::_nil ()), + pid_ (ACE_INVALID_PID), + activated_ (false) {} + + typedef ACE_Refcounted_Auto_Ptr <CIAO::Utility::CONFIGVALUE_MAP, + ACE_Null_Mutex> CONFIGVALUE_MAP_PTR; + + ACE_CString uuid_; + CONFIGVALUE_MAP_PTR cmap_; + Components::Deployment::ComponentServer_var ref_; + pid_t pid_; + bool activated_; + }; + + typedef ACE_Refcounted_Auto_Ptr<Server_Info, ACE_Null_Mutex> Safe_Server_Info; + + struct _server_info + { + bool operator() (const Safe_Server_Info &a, const Safe_Server_Info &b) const + { + return a->uuid_ == b->uuid_; + } + }; + + // Presumably, there won't be too many component servers per node application + typedef ACE_Unbounded_Set_Ex <Safe_Server_Info, _server_info> SERVER_INFOS; + + /// Default args to pass to all componentservers. + ACE_CString default_args_; + + SERVER_INFOS server_infos_; + + ACE_Process_Manager process_manager_; + + Child_Handler child_handler_; + + CORBA::ULong spawn_delay_; + + /////*******NEW + bool multithreaded_; + + CORBA::ORB_var orb_; + + PortableServer::POA_var poa_; + + ACE_CString cs_path_; + + ACE_CString cs_args_; + + ACE_Thread_Mutex mutex_; + + ACE_Condition<ACE_Thread_Mutex> condition_; + }; + + + } +} +#endif /* CIAO_SERVERACTIVATOR_H_ */ diff --git a/CIAO/ciao/FTComponentServer/CIAO_ServerResources.idl b/CIAO/ciao/FTComponentServer/CIAO_ServerResources.idl new file mode 100644 index 00000000000..8516c3fd1ec --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CIAO_ServerResources.idl @@ -0,0 +1,268 @@ +// $Id$ + +/** + * @file CIAO_ServerResources.idl + * + * @brief A collection of IDL data types for + * + * @author Nanbor Wang + */ + +#if !defined (CIAO_SERVERRESOURCES_IDL) +#define CIAO_SERVERRESOURCES_IDL + +#include <orb.idl> + +module CIAO +{ + module Deployment + { + /** + * @brief A single command line argument corresponds to a string as + * in the case of "argv". + */ + typedef string CommandlineArg; + /** + * @brief A list of command line arguments which a + * NodeApplicationManager will use to start up the NodeApplication + * this list is associated to. The command line arguments will be + * appended to the command line in order. + */ + typedef sequence<CommandlineArg> CommandlineArgs; + + /** + * @brief A string containing the filename of the svc.conf file the + * NodeApplication uses. The current approach of specifying + * svc.conf filename directly some harder problems such as + * distribution of svc.conf files and the relative/absolute path to + * the svc.conf file (the ServerResrouces xml document will have to + * assume the svc.conf file will be available at specific location.) + */ + typedef string SvcconfURI; + + /** + * @brief enumeration of ORB Resource Types (ORT) supported in RT + * extension. + */ + enum ORBResourceType + { + ORT_THREADPOOL, + ORT_THREADPOOLWITHLANES, + ORT_CONNECTIONBANDS + }; + + typedef short Priority; + + /** + * @brief Define a threadpool resource that an ORB must provide + */ + struct ORS_Threadpool + { + string Id; + unsigned long stacksize; + unsigned long static_threads; + unsigned long dynamic_threads; + Priority default_priority; + boolean allow_request_buffering; + unsigned long max_buffered_requests; + unsigned long max_request_buffer_size; + }; + + typedef sequence<ORS_Threadpool> ORS_ThreadpoolSeq; + + /** + * @brief Defines the configuration of a threadpool lane. We need + * to redefine it here to avoid dependency to RTCORBA library. + */ + struct ORS_ThreadpoolLane + { + Priority lane_priority; + unsigned long static_threads; + unsigned long dynamic_threads; + }; + + /** + * @brief Defines a set of threadpool lanes. We need + * to redefine it here to avoid dependency to RTCORBA library. + */ + typedef sequence<ORS_ThreadpoolLane> ORS_ThreadpoolLanes; + + /** + * @brief Defines a Threadpool with Lanes resource that an ORB + * must provide. + */ + struct ORS_ThreadpoolWithLanes + { + string Id; + unsigned long stacksize; + ORS_ThreadpoolLanes threadpool_lanes; + boolean allow_borrowing; + boolean allow_request_buffering; + unsigned long max_buffered_requests; + unsigned long max_request_buffer_size; + }; + + typedef sequence<ORS_ThreadpoolWithLanes> ORS_ThreadpoolWithLanesSeq; + + /** + * @brief Define a priority band for BandedConnection policies. + */ + struct ORS_PriorityBand + { + Priority low; + Priority high; + }; + /** + * @brief Define a list of priority bands for BandedConnection + * policies. + */ + typedef sequence<ORS_PriorityBand> ORS_PriorityBands; + + /** + * @brief Define the information needed to create a + * BandedConnection policy. This info can be referred to via its + * name (Id). + */ + struct ORS_ConnectionBands + { + string Id; + ORS_PriorityBands bands; + }; + + typedef sequence<ORS_ConnectionBands> ORS_ConnectionBandsSeq; + + /** + * @brief Collection of resources managed by the NodeApplication + * ORB. + */ + struct ORBResource + { + ORS_ThreadpoolSeq threadpool_list; + + ORS_ThreadpoolWithLanesSeq threadpool_with_lanes_list; + + ORS_ConnectionBandsSeq connection_bands_list; + }; + + typedef sequence<ORBResource, 1> ORBResources; + + // ================================================================= + + /** + * @brief PolicyType supported by DAnCE extension. Again, we are + * redefining these value to avoid dependencies to various ORB + * modules such as RTCORBA and DiffServ policy libraries. + * @JW This is a bad thing to redefine. Maybe we have to make a seperate + * IDL lib for these libraries, but redefinition is really a bad thing + */ + const CORBA::PolicyType PRIORITY_MODEL_POLICY_TYPE = 40; + const CORBA::PolicyType THREADPOOL_POLICY_TYPE = 41; + const CORBA::PolicyType PRIORITY_BANDED_CONNECTION_POLICY_TYPE = 45; + const CORBA::PolicyType CLIENT_NETWORK_PRIORITY_TYPE = 86; + const CORBA::PolicyType NETWORK_PRIORITY_TYPE = 87; + + enum PriorityModel + { + CLIENT_PROPAGATED, + SERVER_DECLARED + }; + + enum NWPriorityModel + { + CLIENT_PROPAGATED_NWPRIORITY, + SERVER_DECLARED_NWPRIORITY + }; + + /** + * @brief Defines data required for creating a PriorityModel Policy + */ + struct PriorityModelPolicyDef + { + PriorityModel priority_model; + Priority server_priority; + }; + + /** + * @brief Defines data required for creating a server side DiffServ policy + */ + struct NWPriorityModelPolicyDef + { + NWPriorityModel nw_priority_model; + long request_dscp; + long reply_dscp; + }; + + /** + * @brief Defines data required for creating a client side DiffServ policy + */ + struct CNWPriorityModelPolicyDef + { + long request_dscp; + long reply_dscp; + }; + + /** + * @brief Define data required for creating a Threadpool policy + */ + struct ThreadpoolPolicyDef + { + string Id; // Threadpool name defined in + // ORBResource + }; + + /** + * @brief Define data required for creating a PriorityBandedConnection + * policy + */ + struct PriorityBandedConnectionPolicyDef + { + string Id; // PriorityBands name defined in + // ORBResource + }; + + union PolicyDef switch (CORBA::PolicyType) + { + case PRIORITY_MODEL_POLICY_TYPE: PriorityModelPolicyDef PriorityModelDef; + case THREADPOOL_POLICY_TYPE: ThreadpoolPolicyDef ThreadpoolDef; + case PRIORITY_BANDED_CONNECTION_POLICY_TYPE: PriorityBandedConnectionPolicyDef PriorityBandedConnectionDef; + case CLIENT_NETWORK_PRIORITY_TYPE: CNWPriorityModelPolicyDef CNWPriorityModelDef; + case NETWORK_PRIORITY_TYPE: NWPriorityModelPolicyDef NWPriorityModelDef; + }; + + /** + * @brief Define a set of policy definitions. + */ + typedef sequence<PolicyDef> PolicyDefs; + + /** + * @brief A policy set is named. + */ + struct PolicySet + { + string Id; // Name of this policy set + PolicyDefs policies; + }; + + /** + * @brief A list of all policy sets. + */ + typedef sequence<PolicySet> PolicySets; + + struct ORBConfigs + { + ORBResources orb_resources; + PolicySets policy_set; + }; + + struct ServerResource + { + string Id; + + CommandlineArgs args; + SvcconfURI svcconf; + ORBConfigs orb_config; + }; + }; +}; + +#endif /* CIAO_SERVERRESOURCES_IDL */ diff --git a/CIAO/ciao/FTComponentServer/ClientInterceptor/Agent.cpp b/CIAO/ciao/FTComponentServer/ClientInterceptor/Agent.cpp new file mode 100644 index 00000000000..65cdfcbaee7 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/ClientInterceptor/Agent.cpp @@ -0,0 +1,215 @@ +// cvs-id : $Id$ + +#include "Agent.h" + +Agent_i::Agent_i (bool proactive) + : //failover_map_ (100), + //secondary_map_ (100), + //failure_map_ (100), + proactive_(proactive), + update_count_ (0) +{ +} + +Agent_i::~Agent_i (void) +{ +} + +void Agent_i::proactive(bool v) +{ + proactive_ = v; +} + +CORBA::Object_ptr +Agent_i::next_member (const char *ior_string) +{ + ACE_DEBUG ((LM_DEBUG, "NEXT MEMBER CALLED for ior_string = %s.\n",ior_string)); + //sleep (3); + //if (! proactive_) + // { +// CORBA::Object_var object = RM_var_->get_next(ior_string); + //return CORBA::Object::_duplicate(object.in()); +// } + + ACE_Guard <ACE_Thread_Mutex> guard (ior_map_mutex_); + AGENT_RANKED_IOR_LIST ranked_ior_list; + if (this->objectid_rankedior_map_.find(ACE_CString(ior_string), + ranked_ior_list) == 0) + { + CORBA::Object_var ior (ranked_ior_list.ior_list.front()); + ranked_ior_list.ior_list.pop_front(); + this->objectid_rankedior_map_.rebind(ACE_CString(ior_string),ranked_ior_list); + return CORBA::Object::_duplicate(ior.in()); + } + else + { + ACE_DEBUG((LM_ERROR,"No ior list for tag=%s!!!\n",ior_string)); + return 0; + } + +/* // this->RM_var_->next_member (ior_string); + CORBA::Object_var replica_ior; + CORBA::ULong failure_count = 0; + if (this->failure_map_.find (ACE_CString(ior_string), failure_count) == 0) + { + ACE_DEBUG ((LM_DEBUG, "FAILURE COUNT IS %d\n", failure_count)); + if (failure_count == 1) + { + if (this->failover_map_.find (ior_string, replica_ior) == 0) + { + this->failure_map_.rebind (ior_string, 2); + return CORBA::Object::_duplicate (replica_ior.in ()); + } + } + else if (failure_count == 2) + { + if (this->secondary_map_.find (ior_string, replica_ior) == 0) + { + return CORBA::Object::_duplicate (replica_ior.in ()); + } + } + } + else + { + for (FAILURE_MAP::iterator it = this->failure_map_.begin (); + it != this->failure_map_.end (); ++it) + { + ACE_CString object_id = (*it).ext_id_; + ACE_DEBUG((LM_DEBUG,"object_id in the failure_map_ is %s.\n",object_id.c_str())); + } + } + return 0; +*/ +} + +void Agent_i:: +update_rank_list (const RankList & rank_list) +{ +/* if (update_count_ > 80) + { + ACE_DEBUG((LM_DEBUG,"not updated.\n")); + return; + } + update_count_++; +*/ + ACE_Guard <ACE_Thread_Mutex> guard (ior_map_mutex_); + objectid_rankedior_map_.close(); + objectid_rankedior_map_.open(); + + // ACE_DEBUG((LM_DEBUG,"Received rank_list length = %d.\n", rank_list.length())); + for (size_t i = 0;i < rank_list.length();++i) + { + AGENT_RANKED_IOR_LIST ranked_ior_list; + ranked_ior_list.now = rank_list[i].now; + for (size_t j = 0; j < rank_list[i].ior_list.length(); ++j) + { + ranked_ior_list.ior_list.push_back( + CORBA::Object::_duplicate(rank_list[i].ior_list[j])); + } + ACE_CString oid (rank_list[i].object_id); + objectid_rankedior_map_.bind(oid,ranked_ior_list); + //ACE_DEBUG((LM_DEBUG,"object_id=%s. ior_list_size=%d.\n", + // oid.c_str(), ranked_ior_list.ior_list.size())); + } +} + +void Agent_i:: +initialize (CORBA::Object_ptr rm_ior) +{ + this->RM_var_ = ReplicationManager::_narrow (rm_ior); + Agent_var temp = this->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + + ACE_DEBUG ((LM_DEBUG, "calling register agent\n")); + RankList *rank_list = this->RM_var_->register_agent (temp.in ()); + update_rank_list (*rank_list); + +/* + CORBA::String_var ior_string = + this->orb_->object_to_string (temp.in ()); + + FILE *output_file= ACE_OS::fopen (ior_file, "w"); + if (output_file == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file <%s> for writing " + "IOR: %s", + ior_string.in ()), + 1); + } + + ACE_OS::fprintf (output_file, "%s", ior_string.in ()); + ACE_OS::fclose (output_file); +*/ + +} + +/* +void +Agent_i::update_reference (const char *ior_string) +{ + this->forward_str_ = CORBA::string_dup (ior_string); +} + +void +Agent_i::update_failover_list (const FailoverList &failover_list) +{ + ACE_DEBUG ((LM_DEBUG, "failure map updates\n")); + CORBA::ULong failover_list_length = failover_list.length (); + for (CORBA::ULong i = 0; i < failover_list_length; ++i) + { + const char *object_id = failover_list[i]; + ACE_DEBUG ((LM_DEBUG, "OBJECT ID is %s\n", object_id)); + this->failure_map_.rebind (object_id, 2); + } +} + +void +Agent_i::update_failover (const char * object_id, + CORBA::Object_ptr next_member) +{ + ACE_DEBUG ((LM_DEBUG, "calling update next member\n")); + this->failover_map_.rebind (object_id, + CORBA::Object::_duplicate (next_member)); +} + +void +Agent_i::update_secondary (const char * object_id, + CORBA::Object_ptr next_member) +{ + ACE_DEBUG ((LM_DEBUG, "calling update next members\n")); + this->secondary_map_.rebind (object_id, + CORBA::Object::_duplicate (next_member)); +} + +void +Agent_i::initialize_agent (const ReplicaList & replica_list, + const ReplicasList & replicas_list) +{ + ACE_DEBUG ((LM_DEBUG, "calling initialize agent\n")); + + CORBA::ULong replica_list_length = replica_list.length (); + for (CORBA::ULong i = 0; i < replica_list_length; ++i) + { + const char *object_id = replica_list[i].object_id; + CORBA::Object_var replica_ior = replica_list[i].next_member; + + if (this->failover_map_.bind (object_id, replica_ior) != 0) + ACE_DEBUG((LM_DEBUG,"failover_map_ did not bind %s.\n", object_id)); + + if (this->failure_map_.bind (object_id, 1) != 0) + ACE_DEBUG((LM_DEBUG,"failure_map_ did not bind %s.\n", object_id)); + + ACE_DEBUG((LM_DEBUG,"object_id added to failover map = %s:\n",object_id)); + } + + CORBA::ULong replicas_list_length = replicas_list.length (); + for (CORBA::ULong i = 0; i < replicas_list_length; ++i) + { + const char *object_id = replicas_list[i].object_id; + CORBA::Object_var replicas_ior = replicas_list[i].next_members; + this->secondary_map_.bind (object_id, replicas_ior); + ACE_DEBUG((LM_DEBUG,"object_id added to secondary map = %s:\n",object_id)); + } +} + +*/ diff --git a/CIAO/ciao/FTComponentServer/ClientInterceptor/Agent.h b/CIAO/ciao/FTComponentServer/ClientInterceptor/Agent.h new file mode 100644 index 00000000000..299e8ff05ec --- /dev/null +++ b/CIAO/ciao/FTComponentServer/ClientInterceptor/Agent.h @@ -0,0 +1,84 @@ +// cvs-id : $Id$ + +#ifndef AGENT_H +#define AGENT_H + +#include "ace/Hash_Map_Manager_T.h" +#include "ace/Unbounded_Queue.h" +#include "AgentS.h" +#include "ReplicationManagerC.h" + +#include <list> + +struct AGENT_RANKED_IOR_LIST +{ + bool now; + std::list<CORBA::Object_var> ior_list; +}; + + +class Agent_i : public virtual POA_Agent +{ +public: + Agent_i (bool proactive = true); + + ~Agent_i (void); + + virtual CORBA::Object_ptr next_member (const char * m); + + virtual void update_rank_list (const RankList & rank_list); + + void initialize (CORBA::Object_ptr); + void proactive (bool v); + +/* + virtual void update_reference (const char * m); + + virtual void update_failover (const char * object_id, + CORBA::Object_ptr next_object); + + virtual void update_secondary (const char * object_id, + CORBA::Object_ptr next_member); + + + virtual void initialize_agent (const ReplicaList & replica_list, + const ReplicasList & replicas_list)); + + + virtual void update_failover_list (const FailoverList &failover_list); + + typedef ACE_Hash_Map_Manager_Ex< + ACE_CString, + CORBA::Object_var, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> REPLICA_MAP; + + typedef ACE_Hash_Map_Manager_Ex< + ACE_CString, + CORBA::ULong, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> FAILURE_MAP; +*/ + typedef ACE_Hash_Map_Manager_Ex< + ACE_CString, + AGENT_RANKED_IOR_LIST, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> OBJECTID_RANKED_IOR_MAP; + + +private: + //CORBA::String_var forward_str_; + //REPLICA_MAP failover_map_; + //REPLICA_MAP secondary_map_; + //FAILURE_MAP failure_map_; + ReplicationManager_var RM_var_; + OBJECTID_RANKED_IOR_MAP objectid_rankedior_map_; + ACE_Thread_Mutex ior_map_mutex_; + bool proactive_; + size_t update_count_; +}; + +#endif /* AGENT_H */ diff --git a/CIAO/ciao/FTComponentServer/ClientInterceptor/ClientInterceptor.mpc b/CIAO/ciao/FTComponentServer/ClientInterceptor/ClientInterceptor.mpc new file mode 100644 index 00000000000..00988928a6a --- /dev/null +++ b/CIAO/ciao/FTComponentServer/ClientInterceptor/ClientInterceptor.mpc @@ -0,0 +1,16 @@ +project(*) : pi_server, interceptors, ciao_lib { + dynamicflags = CI_BUILD_DLL + idlflags += -Wb,export_macro=CI_Export -Wb,export_include=ci_export.h + idlflags += -I../CommonIDL + includes += ../CommonIDL + libs += FTCommonIdl + + IDL_Files { + } + + Source_Files { + Agent.cpp + Client_ORBInitializer.cpp + Client_Request_Interceptor.cpp + } +} diff --git a/CIAO/ciao/FTComponentServer/ClientInterceptor/Client_ORBInitializer.cpp b/CIAO/ciao/FTComponentServer/ClientInterceptor/Client_ORBInitializer.cpp new file mode 100644 index 00000000000..592fc06f663 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/ClientInterceptor/Client_ORBInitializer.cpp @@ -0,0 +1,58 @@ +// -*- C++ -*- + +#include "Client_ORBInitializer.h" + +ACE_RCSID (Hello, + Client_ORBInitializer, + "$Id$") + +#if TAO_HAS_INTERCEPTORS == 1 + +#include "Client_Request_Interceptor.h" + +#include "tao/StringSeqC.h" +#include "tao/ORB_Constants.h" +#include "ace/OS_NS_string.h" + +Client_ORBInitializer::Client_ORBInitializer (Agent_i *agent) + : agent_ (agent) +{ +} + +Client_ORBInitializer::~Client_ORBInitializer (void) +{ +} + + +void +Client_ORBInitializer::pre_init ( + PortableInterceptor::ORBInitInfo_ptr) +{ +} + +void +Client_ORBInitializer::post_init ( + PortableInterceptor::ORBInitInfo_ptr info) +{ + CORBA::String_var orb_id = info->orb_id (); + + PortableInterceptor::ClientRequestInterceptor_ptr interceptor = + PortableInterceptor::ClientRequestInterceptor::_nil (); + + // Install the client request interceptor. + ACE_NEW_THROW_EX (interceptor, + Client_Request_Interceptor (orb_id.in (), agent_), + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + + PortableInterceptor::ClientRequestInterceptor_var + client_interceptor = interceptor; + + info->add_client_request_interceptor (client_interceptor.in ()); + +} + +#endif /* TAO_HAS_INTERCEPTORS == 1 */ diff --git a/CIAO/ciao/FTComponentServer/ClientInterceptor/Client_ORBInitializer.h b/CIAO/ciao/FTComponentServer/ClientInterceptor/Client_ORBInitializer.h new file mode 100644 index 00000000000..f78de24fcea --- /dev/null +++ b/CIAO/ciao/FTComponentServer/ClientInterceptor/Client_ORBInitializer.h @@ -0,0 +1,54 @@ +// -*- C++ -*- + +#ifndef TAO_CLIENT_ORB_INITIALIZER_H +#define TAO_CLIENT_ORB_INITIALIZER_H + +#include /**/ "ace/pre.h" + +#include "tao/PI/PI.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if TAO_HAS_INTERCEPTORS == 1 + +#include "tao/LocalObject.h" + +// This is to remove "inherits via dominance" warnings from MSVC. +// MSVC is being a little too paranoid. +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +class Agent_i; + +/// Client side ORB initializer. +class Client_ORBInitializer : + public virtual PortableInterceptor::ORBInitializer, + public virtual TAO_Local_RefCounted_Object +{ +public: + + Client_ORBInitializer (Agent_i *agent); + + ~Client_ORBInitializer (void); + + virtual void pre_init (PortableInterceptor::ORBInitInfo_ptr info); + + virtual void post_init (PortableInterceptor::ORBInitInfo_ptr info); + +private: + Agent_i *agent_; +}; + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + +#include /**/ "ace/post.h" + +#endif /* TAO_CLIENT_ORB_INITIALIZER_H */ diff --git a/CIAO/ciao/FTComponentServer/ClientInterceptor/Client_Request_Interceptor.cpp b/CIAO/ciao/FTComponentServer/ClientInterceptor/Client_Request_Interceptor.cpp new file mode 100644 index 00000000000..cc0c41468fb --- /dev/null +++ b/CIAO/ciao/FTComponentServer/ClientInterceptor/Client_Request_Interceptor.cpp @@ -0,0 +1,74 @@ +// -*- C++ -*- + +#include "Client_Request_Interceptor.h" +#include "ace/Log_Msg.h" +#include "Agent.h" + +ACE_RCSID (Hello, + Client_Request_Interceptor, + "$Id$") + +Client_Request_Interceptor::Client_Request_Interceptor ( + const char *orb_id, Agent_i *agent) + : orb_id_ (CORBA::string_dup (orb_id)), + orb_ (), + request_count_ (0), + agent_ (agent) +{ +} + +char * +Client_Request_Interceptor::name () +{ + return CORBA::string_dup ("Client_Request_Interceptor"); +} + +void +Client_Request_Interceptor::destroy (void) +{ +} + +void +Client_Request_Interceptor::send_request ( + PortableInterceptor::ClientRequestInfo_ptr) +{ +} + +void +Client_Request_Interceptor::send_poll ( + PortableInterceptor::ClientRequestInfo_ptr) +{ +} + +void +Client_Request_Interceptor::receive_reply ( + PortableInterceptor::ClientRequestInfo_ptr) +{ +} + +void +Client_Request_Interceptor::receive_exception ( + PortableInterceptor::ClientRequestInfo_ptr ri) +{ + ACE_DEBUG ((LM_DEBUG, "Catching exception\n")); + const CORBA::ULong tagID = 9654; + char *tag = 0; + try + { + IOP::TaggedComponent_var mytag = ri->get_effective_component (tagID); + tag = reinterpret_cast <char *> ( mytag->component_data.get_buffer ()); + ACE_CString new_string = CORBA::string_dup (tag); + CORBA::Object_var forward = this->agent_->next_member (tag); + ACE_THROW (PortableInterceptor::ForwardRequest (forward.in ())); + } + catch (CORBA::BAD_PARAM&) + { + ACE_DEBUG ((LM_DEBUG, "Tagged Component not found\n")); + } +} + +void +Client_Request_Interceptor::receive_other ( + PortableInterceptor::ClientRequestInfo_ptr) +{ +} diff --git a/CIAO/ciao/FTComponentServer/ClientInterceptor/Client_Request_Interceptor.h b/CIAO/ciao/FTComponentServer/ClientInterceptor/Client_Request_Interceptor.h new file mode 100644 index 00000000000..0e80b6570a3 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/ClientInterceptor/Client_Request_Interceptor.h @@ -0,0 +1,83 @@ +// -*- C++ -*- + +#ifndef CLIENT_REQUEST_INTERCEPTOR_H +#define CLIENT_REQUEST_INTERCEPTOR_H + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PI/PI.h" +#include "tao/PortableInterceptorC.h" +#include "tao/LocalObject.h" +#include "tao/ORB.h" +#include "tao/CORBA_String.h" + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +class Agent_i; + +class Client_Request_Interceptor + : public virtual PortableInterceptor::ClientRequestInterceptor, + public virtual TAO_Local_RefCounted_Object +{ +public: + + /// Constructor. + Client_Request_Interceptor (const char *orb_id, Agent_i *agent); + + /** + * @name Methods Required by the Client Request Interceptor + * Interface + * + * These are methods that must be implemented since they are pure + * virtual in the abstract base class. They are the canonical + * methods required for all client request interceptors. + */ + //@{ + /// Return the name of this ClientRequestinterceptor. + virtual char * name (void); + + virtual void destroy (void); + + virtual void send_request ( + PortableInterceptor::ClientRequestInfo_ptr ri); + + virtual void send_poll ( + PortableInterceptor::ClientRequestInfo_ptr ri); + + virtual void receive_reply ( + PortableInterceptor::ClientRequestInfo_ptr ri); + + virtual void receive_exception ( + PortableInterceptor::ClientRequestInfo_ptr ri); + + virtual void receive_other ( + PortableInterceptor::ClientRequestInfo_ptr ri); + //@} + +private: + + ///The ID of the ORB this interceptor is registered with. + CORBA::String_var orb_id_; + + /// Pseudo-reference to the ORB this interceptor is registered + /// with. + CORBA::ORB_var orb_; + + /// The number of requests intercepted by this interceptor. + CORBA::ULong request_count_; + + Agent_i *agent_; +}; + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#endif /* CLIENT_REQUEST_INTERCEPTOR_H */ diff --git a/CIAO/ciao/FTComponentServer/ClientInterceptor/ci_export.h b/CIAO/ciao/FTComponentServer/ClientInterceptor/ci_export.h new file mode 100644 index 00000000000..832307cc21a --- /dev/null +++ b/CIAO/ciao/FTComponentServer/ClientInterceptor/ci_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl CI +// ------------------------------ +#ifndef CI_EXPORT_H +#define CI_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (CI_HAS_DLL) +# define CI_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && CI_HAS_DLL */ + +#if !defined (CI_HAS_DLL) +# define CI_HAS_DLL 1 +#endif /* ! CI_HAS_DLL */ + +#if defined (CI_HAS_DLL) && (CI_HAS_DLL == 1) +# if defined (CI_BUILD_DLL) +# define CI_Export ACE_Proper_Export_Flag +# define CI_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define CI_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* CI_BUILD_DLL */ +# define CI_Export ACE_Proper_Import_Flag +# define CI_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define CI_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* CI_BUILD_DLL */ +#else /* CI_HAS_DLL == 1 */ +# define CI_Export +# define CI_SINGLETON_DECLARATION(T) +# define CI_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* CI_HAS_DLL == 1 */ + +// Set CI_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (CI_NTRACE) +# if (ACE_NTRACE == 1) +# define CI_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define CI_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !CI_NTRACE */ + +#if (CI_NTRACE == 1) +# define CI_TRACE(X) +#else /* (CI_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define CI_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (CI_NTRACE == 1) */ + +#endif /* CI_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/CommonIDL/Agent.idl b/CIAO/ciao/FTComponentServer/CommonIDL/Agent.idl new file mode 100644 index 00000000000..030461f0deb --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CommonIDL/Agent.idl @@ -0,0 +1,11 @@ +// +// $Id$ +// + +#include "LWFTDataStructures.idl" + +interface Agent +{ + Object next_member (in string m); + void update_rank_list (in RankList rank_list); +}; diff --git a/CIAO/ciao/FTComponentServer/CommonIDL/FTCommonIdl.mpc b/CIAO/ciao/FTComponentServer/CommonIDL/FTCommonIdl.mpc new file mode 100644 index 00000000000..eb44cba4dc3 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CommonIDL/FTCommonIdl.mpc @@ -0,0 +1,12 @@ +project(*): taolib, taoidldefaults, ciao_lib { + idlflags += -Wb,export_macro=FT_Common_Export -Wb,export_include=ft_common_export.h + macros += FT_COMMON_BUILD_DLL + + IDL_Files { + LWFTDataStructures.idl + StateSynchronizationAgent.idl + ReplicatedApplication.idl + ReplicationManager.idl + Agent.idl + } +} diff --git a/CIAO/ciao/FTComponentServer/CommonIDL/LWFTDataStructures.idl b/CIAO/ciao/FTComponentServer/CommonIDL/LWFTDataStructures.idl new file mode 100644 index 00000000000..100ba1fbf9c --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CommonIDL/LWFTDataStructures.idl @@ -0,0 +1,27 @@ +// -*- IDL -*- + +//============================================================================= +/** + * @file LWFTDataStructures.idl + * + * $Id$ + * + * @author Friedhelm Wolf (fwolf@dre.vanderbilt.edu) + */ +//============================================================================= + +#ifndef _LWFT_DATASTRUCTURES_IDL_ +#define _LWFT_DATASTRUCTURES_IDL_ + +typedef sequence<Object> ObjectList; + +struct Rank +{ + string object_id; + boolean now; + ObjectList ior_list; +}; + +typedef sequence<Rank> RankList; + +#endif /* _LWFT_DATASTRUCTURES_IDL_ */ diff --git a/CIAO/ciao/FTComponentServer/CommonIDL/ReplicatedApplication.idl b/CIAO/ciao/FTComponentServer/CommonIDL/ReplicatedApplication.idl new file mode 100644 index 00000000000..6df83655e66 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CommonIDL/ReplicatedApplication.idl @@ -0,0 +1,28 @@ +// -*- IDL -*- + +//============================================================================= +/** + * @file ReplicatedApplication.idl + * + * $Id$ + * + * @author Friedhelm Wolf (fwolf@dre.vanderbilt.edu) + */ +//============================================================================= + +#ifndef _REPLICATED_APPLICATION_IDL_ +#define _REPLICATED_APPLICATION_IDL_ + +interface ReplicatedApplication +{ + /// setter method for the interal state + /// @param state_value represents the internal state encapsulated + /// into an any value + void set_state (in any state_value); + + /// getter method the the internal state + /// remark: it's not clear if this is necessary + any get_state (); +}; + +#endif /* _REPLICATED_APPLICATION_IDL_ */ diff --git a/CIAO/ciao/FTComponentServer/CommonIDL/ReplicationManager.idl b/CIAO/ciao/FTComponentServer/CommonIDL/ReplicationManager.idl new file mode 100644 index 00000000000..be52f27f90e --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CommonIDL/ReplicationManager.idl @@ -0,0 +1,33 @@ +// -*- IDL -*- + +//============================================================================= +/** + * @file ReplicationManager.idl + * + * $Id$ + * + * @author Friedhelm Wolf (fwolf@dre.vanderbilt.edu) + */ +//============================================================================= + +#ifndef _REPLICATION_MANAGER_IDL_ +#define _REPLICATION_MANAGER_IDL_ + +#include "LWFTDataStructures.idl" +#include "StateSynchronizationAgent.idl" + +interface ReplicationManager +{ + RankList register_agent (in Object agent_reference); + void register_application (in string object_id, in double load, + in string host_id, in string process_id, + in short role, in Object server_reference); + RankList register_state_synchronization_agent (in string host_id, + in string process_id, + in StateSynchronizationAgent agent); + void util_update (in string host_id, in double utilization); + void proc_failure (in string process_id); + Object get_next (in string object_id); +}; + +#endif /* _REPLICATION_MANAGER_IDL_ */ diff --git a/CIAO/ciao/FTComponentServer/CommonIDL/StateSynchronizationAgent.idl b/CIAO/ciao/FTComponentServer/CommonIDL/StateSynchronizationAgent.idl new file mode 100644 index 00000000000..a4572c287d2 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CommonIDL/StateSynchronizationAgent.idl @@ -0,0 +1,35 @@ +// -*- IDL -*- + +//============================================================================= +/** + * @file StateSynchronizationAgent.idl + * + * $Id$ + * + * @author Friedhelm Wolf (fwolf@dre.vanderbilt.edu) + */ +//============================================================================= + +#ifndef _REPLICATION_AGENT_IDL_ +#define _REPLICATION_AGENT_IDL_ + +#include "ReplicatedApplication.idl" +#include "LWFTDataStructures.idl" + +interface StateSynchronizationAgent +{ + /// triggers an serial update of the state information + /// to all registered replicas + void state_changed (in string object_id); + + /// used by the ReplicationManager to update information about + /// active replicas + void update_rank_list (in RankList replicas); + + /// informs the replication manager about applications for which + /// it is responsible for replication + void register_application (in string objec_id, + in ReplicatedApplication app); +}; + +#endif /* _REPLICATION_AGENT_IDL_ */ diff --git a/CIAO/ciao/FTComponentServer/CommonIDL/ft_common_export.h b/CIAO/ciao/FTComponentServer/CommonIDL/ft_common_export.h new file mode 100644 index 00000000000..1eddc040b64 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/CommonIDL/ft_common_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl FT_Common +// ------------------------------ +#ifndef FT_COMMON_EXPORT_H +#define FT_COMMON_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (FT_COMMON_HAS_DLL) +# define FT_COMMON_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && FT_COMMON_HAS_DLL */ + +#if !defined (FT_COMMON_HAS_DLL) +# define FT_COMMON_HAS_DLL 1 +#endif /* ! FT_COMMON_HAS_DLL */ + +#if defined (FT_COMMON_HAS_DLL) && (FT_COMMON_HAS_DLL == 1) +# if defined (FT_COMMON_BUILD_DLL) +# define FT_Common_Export ACE_Proper_Export_Flag +# define FT_COMMON_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define FT_COMMON_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* FT_COMMON_BUILD_DLL */ +# define FT_Common_Export ACE_Proper_Import_Flag +# define FT_COMMON_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define FT_COMMON_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* FT_COMMON_BUILD_DLL */ +#else /* FT_COMMON_HAS_DLL == 1 */ +# define FT_Common_Export +# define FT_COMMON_SINGLETON_DECLARATION(T) +# define FT_COMMON_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* FT_COMMON_HAS_DLL == 1 */ + +// Set FT_COMMON_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (FT_COMMON_NTRACE) +# if (ACE_NTRACE == 1) +# define FT_COMMON_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define FT_COMMON_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !FT_COMMON_NTRACE */ + +#if (FT_COMMON_NTRACE == 1) +# define FT_COMMON_TRACE(X) +#else /* (FT_COMMON_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define FT_COMMON_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (FT_COMMON_NTRACE == 1) */ + +#endif /* FT_COMMON_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/Configurator_Factory.cpp b/CIAO/ciao/FTComponentServer/Configurator_Factory.cpp new file mode 100644 index 00000000000..3060e2775d9 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurator_Factory.cpp @@ -0,0 +1,48 @@ +#include "Configurator_Factory.h" + +#include "ace/Arg_Shifter.h" +#include "ciao/CIAO_common.h" +#include "Configurators/Server_Configurator.h" + +namespace CIAO +{ + namespace Deployment + { + ComponentServer_Configurator * + Configurator_Factory::operator() (int &argc, ACE_TCHAR **argv) + { + CIAO_TRACE ("Configurator_Factory::operator()"); + this->parse_args (argc, argv); + + ComponentServer_Configurator *ptr = 0; + ACE_NEW_THROW_EX (ptr, + ComponentServer_Configurator (this->rt_), + CORBA::NO_MEMORY (TAO::VMCID, + CORBA::COMPLETED_NO)); + + return ptr; + } + + void + Configurator_Factory::parse_args (int &argc, ACE_TCHAR **argv) + { + CIAO_TRACE ("Configurator_Factory::parse_args"); + ACE_Arg_Shifter shifter (argc, argv); + + this->rt_ = false; + + while (shifter.is_anything_left ()) + { + if (shifter.cur_arg_strncasecmp (ACE_TEXT("-r")) == 0) + { + this->rt_ = true; + shifter.consume_arg (); + } + else + { + shifter.ignore_arg (); + } + } + } + } +} diff --git a/CIAO/ciao/FTComponentServer/Configurator_Factory.h b/CIAO/ciao/FTComponentServer/Configurator_Factory.h new file mode 100644 index 00000000000..4887bda9d9c --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurator_Factory.h @@ -0,0 +1,39 @@ +/** + * @file Configurator_Factory.h + * @author William R. Otte <wotte@dre.vanderbilt.edu> + * @author Nanbor Wang <> + * + * Factory for creating configurators, based on old NodeApplication_Options + * class + */ + +#ifndef CIAO_CONFIGURATOR_FACTORY_H +#define CIAO_CONFIGURATOR_FACTORY_H +#include /**/ "ace/pre.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "CIAO_FTComponentServer_svnt_export.h" + +namespace CIAO +{ + namespace Deployment + { + class ComponentServer_Configurator; + + class CIAO_FTComponentServer_svnt_Export Configurator_Factory + { + public: + ComponentServer_Configurator * operator () (int &argc, ACE_TCHAR **argv); + + private: + void parse_args (int &argc, ACE_TCHAR **argv); + bool rt_; + }; + } +} +#include /**/ "ace/post.h" + +#endif diff --git a/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager.cpp b/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager.cpp new file mode 100755 index 00000000000..a34353fe5c7 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager.cpp @@ -0,0 +1,240 @@ +// $Id$ + +#include "Basic_Config_Manager.h" +#include "ciao/CIAO_common.h" +#include "ace/SString.h" +#include "tao/SystemException.h" +#include "tao/DiffServPolicy/DiffServPolicy.h" +#include "tao/DiffServPolicy/Client_Network_Priority_Policy.h" +#include "tao/DiffServPolicy/Server_Network_Priority_Policy.h" + +namespace CIAO +{ + namespace Deployment + { + + void + Basic_Config_Manager::init (CORBA::ORB_ptr orb) + { + this->orb_ = CORBA::ORB::_duplicate (orb); + } + + int + Basic_Config_Manager::pre_orb_initialize (void) + { + return 0; + } + + int + Basic_Config_Manager::post_orb_initialize (CORBA::ORB_ptr) + { + return 0; + } + + void + Basic_Config_Manager::init_resources + (const ServerResource &server_resource) + { + CIAO_DEBUG ((LM_DEBUG,"Basic_Config_Manager::init_resources\n")); + + if (CORBA::is_nil (this->orb_.in())) + { + CIAO_ERROR ((LM_ERROR, + "Basic_Config_Manager has not been properly initialized\n")); + throw CORBA::INTERNAL (); + } + + const PolicySets &sets = server_resource.orb_config.policy_set; + for (CORBA::ULong i = 0; i < sets.length (); ++i) + { + CORBA::ULong np = sets[i].policies.length (); + if (np == 0) + continue; + + CORBA::PolicyList_var policy_list = new CORBA::PolicyList (np); + policy_list->length (np); + CORBA::ULong index = 0; + CORBA::ULong array_index = np; + + // Create a list of policies + for (CORBA::ULong pc = 0; pc < np; ++pc) + { + CORBA::Policy_var temp_policy = + this->create_single_policy (sets[i].policies[pc]); + + if (CORBA::is_nil (temp_policy.in ())) + { + array_index = array_index - 1; + policy_list->length (array_index); + } + else + { + policy_list[index] = temp_policy; + index = index + 1; + } + } + + // Bind the policy list to the name. The bind operation should + // surrender the ownership of the newly created PolicyList + // sequence to the map. + if (array_index != 0) + { + if (this->policy_map_.bind (sets[i].Id.in (), + policy_list) != 0) + { + CIAO_ERROR ((LM_ERROR, + "Error binding Policy_Set with name: %s\n", + sets[i].Id.in ())); + throw CORBA::INTERNAL (); + } + else + { + CIAO_DEBUG ((LM_DEBUG, + "Basic_Config_Manager::init_resource" + " added policy set : %s with %d policies\n", + sets[i].Id.in (), array_index)); + } + } + else + { + CIAO_DEBUG ((LM_DEBUG, + "Basic_Config_Manager::init_resource" + " added policy set : %s with %d policies\n", + sets[i].Id.in (), array_index)); + } + } + } + + bool + Basic_Config_Manager::policy_exists (const char *name) + { + if (name == 0) + { + CIAO_ERROR ((LM_ERROR, + "Invalid name string found in " + "Basic_Config_Manager::policy_exists\n")); + throw CORBA::INTERNAL (); + } + + POLICY_MAP::ENTRY *entry = 0; + + if (this->policy_map_.find (name, entry) != 0) + { + return false; + } + + return true; + } + + CORBA::PolicyList * + Basic_Config_Manager::find_policies_by_name (const char *name) + { + if (name == 0) + { + CIAO_DEBUG ((LM_DEBUG, + "Invalid name string found in find_policies_by_name\n")); + throw CORBA::INTERNAL (); + } + + POLICY_MAP::ENTRY *entry = 0; + + CORBA::PolicyList_var retv; + + if (this->policy_map_.find (name, entry) != 0) + { + CIAO_DEBUG ((LM_DEBUG, + "Unable to find a PolicyList named %s\n", + name)); + retv = 0; + } + else + { + retv = new CORBA::PolicyList (entry->int_id_.in ()); + } + return retv._retn (); + } + + CORBA::Policy_ptr + Basic_Config_Manager::create_single_policy + (const PolicyDef &policy_def) + { + CORBA::Policy_var retv; + + switch (policy_def._d ()) + { + case TAO::NETWORK_PRIORITY_TYPE: + { + const NWPriorityModelPolicyDef &nw_tmp + = policy_def.NWPriorityModelDef (); + retv = this->orb_->_create_policy (TAO::NETWORK_PRIORITY_TYPE); + + TAO::NetworkPriorityPolicy_var nw_priority = + TAO::NetworkPriorityPolicy::_narrow (retv.in ()); + + nw_priority->network_priority_model ( + (TAO::NetworkPriorityModel) nw_tmp.nw_priority_model); + + nw_priority->request_diffserv_codepoint ( + (TAO::DiffservCodepoint) nw_tmp.request_dscp); + + nw_priority->reply_diffserv_codepoint ( + (TAO::DiffservCodepoint) nw_tmp.reply_dscp); + + retv = nw_priority._retn (); + + if (! CORBA::is_nil (retv.in ())) + CIAO_DEBUG ((LM_DEBUG, + "NAConfigManager::Create NetworkPriority policy: %d\n", + nw_tmp.nw_priority_model)); + } + break; + + case TAO::CLIENT_NETWORK_PRIORITY_TYPE: + { + const CNWPriorityModelPolicyDef &cnw_tmp + = policy_def.CNWPriorityModelDef (); + retv = this->orb_->_create_policy (TAO::CLIENT_NETWORK_PRIORITY_TYPE); + + TAO::NetworkPriorityPolicy_var cnw_priority = + TAO::NetworkPriorityPolicy::_narrow (retv.in ()); + + cnw_priority->request_diffserv_codepoint ( + (TAO::DiffservCodepoint) cnw_tmp.request_dscp); + + cnw_priority->reply_diffserv_codepoint ( + (TAO::DiffservCodepoint) cnw_tmp.reply_dscp); + + retv = cnw_priority._retn (); + + if (! CORBA::is_nil (retv.in ())) + CIAO_DEBUG ((LM_DEBUG, + "NAConfigManager::Create NetworkPriority policy \n")); + } + break; + + default: + retv = 0; + } + + return retv._retn (); + } + + } +} + +using CIAO::Deployment::Config_Manager; +using CIAO::Deployment::Basic_Config_Manager; + +extern "C" Basic_Config_Manager_Export Config_Manager *create_basic_config_manager (void); + +extern "C" +{ + Config_Manager * + create_basic_config_manager (void) + { + Basic_Config_Manager *config; + ACE_NEW_RETURN (config, Basic_Config_Manager, 0); + return config; + } +} + diff --git a/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager.h b/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager.h new file mode 100755 index 00000000000..0f1f0b03b64 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager.h @@ -0,0 +1,79 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Basic_Config_Manager.h + * + * $Id$ + * + */ +//============================================================================= + + +#ifndef CIAO_NACONFIG_MANAGER_H +#define CIAO_NACONFIG_MANAGER_H +#include /**/ <ace/pre.h> + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Null_Mutex.h" +#include "ace/SString.h" +#include "ace/Hash_Map_Manager_T.h" +#include "ciao/ComponentServer/CIAO_ServerResourcesC.h" + +#include "Config_Manager.h" +#include "Basic_Config_Manager_export.h" + +namespace CIAO +{ + namespace Deployment + { + /** + */ + class Basic_Config_Manager_Export Basic_Config_Manager + : public Config_Manager + { + public: + virtual ~Basic_Config_Manager (void) {} + + virtual int pre_orb_initialize (void); + + virtual int post_orb_initialize (CORBA::ORB_ptr o); + + virtual void init (CORBA::ORB_ptr orb); + + /// Initializing the NAResource_Config_Manager + virtual void init_resources (const ServerResource &info); + + /// Query a policy set by name + virtual CORBA::PolicyList *find_policies_by_name (const char *name); + + virtual bool policy_exists (const char *name); + + private: + /// Cached an ORB reference. + CORBA::ORB_var orb_; + + CORBA::Policy_ptr create_single_policy + (const PolicyDef &policy_def); + + /// Hash_Map stuff. + typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + CORBA::PolicyList_var, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> POLICY_MAP; + + /// Internal TP names to id map. + POLICY_MAP policy_map_; + }; +} + } + +#include /**/ "ace/post.h" +#endif /* CIAO_NACONFIG_MANAGER_H */ + diff --git a/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager.inl b/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager.inl new file mode 100755 index 00000000000..67203a91ff8 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager.inl @@ -0,0 +1,12 @@ +// $Id$ + +ACE_INLINE +CIAO::NAResource_Config_Manager::NAResource_Config_Manager () +{ +} + +ACE_INLINE +CIAO::NAResource_Config_Manager::~NAResource_Config_Manager () +{ +} + diff --git a/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager_export.h b/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager_export.h new file mode 100644 index 00000000000..51cb9778168 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/Basic_Config_Manager_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl Basic_Config_Manager +// ------------------------------ +#ifndef BASIC_CONFIG_MANAGER_EXPORT_H +#define BASIC_CONFIG_MANAGER_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (BASIC_CONFIG_MANAGER_HAS_DLL) +# define BASIC_CONFIG_MANAGER_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && BASIC_CONFIG_MANAGER_HAS_DLL */ + +#if !defined (BASIC_CONFIG_MANAGER_HAS_DLL) +# define BASIC_CONFIG_MANAGER_HAS_DLL 1 +#endif /* ! BASIC_CONFIG_MANAGER_HAS_DLL */ + +#if defined (BASIC_CONFIG_MANAGER_HAS_DLL) && (BASIC_CONFIG_MANAGER_HAS_DLL == 1) +# if defined (BASIC_CONFIG_MANAGER_BUILD_DLL) +# define Basic_Config_Manager_Export ACE_Proper_Export_Flag +# define BASIC_CONFIG_MANAGER_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define BASIC_CONFIG_MANAGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* BASIC_CONFIG_MANAGER_BUILD_DLL */ +# define Basic_Config_Manager_Export ACE_Proper_Import_Flag +# define BASIC_CONFIG_MANAGER_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define BASIC_CONFIG_MANAGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* BASIC_CONFIG_MANAGER_BUILD_DLL */ +#else /* BASIC_CONFIG_MANAGER_HAS_DLL == 1 */ +# define Basic_Config_Manager_Export +# define BASIC_CONFIG_MANAGER_SINGLETON_DECLARATION(T) +# define BASIC_CONFIG_MANAGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* BASIC_CONFIG_MANAGER_HAS_DLL == 1 */ + +// Set BASIC_CONFIG_MANAGER_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (BASIC_CONFIG_MANAGER_NTRACE) +# if (ACE_NTRACE == 1) +# define BASIC_CONFIG_MANAGER_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define BASIC_CONFIG_MANAGER_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !BASIC_CONFIG_MANAGER_NTRACE */ + +#if (BASIC_CONFIG_MANAGER_NTRACE == 1) +# define BASIC_CONFIG_MANAGER_TRACE(X) +#else /* (BASIC_CONFIG_MANAGER_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define BASIC_CONFIG_MANAGER_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (BASIC_CONFIG_MANAGER_NTRACE == 1) */ + +#endif /* BASIC_CONFIG_MANAGER_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/Configurators/Basic_Configurator_export.h b/CIAO/ciao/FTComponentServer/Configurators/Basic_Configurator_export.h new file mode 100644 index 00000000000..098b4c87f0d --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/Basic_Configurator_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl Basic_Configurator +// ------------------------------ +#ifndef BASIC_CONFIGURATOR_EXPORT_H +#define BASIC_CONFIGURATOR_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (BASIC_CONFIGURATOR_HAS_DLL) +# define BASIC_CONFIGURATOR_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && BASIC_CONFIGURATOR_HAS_DLL */ + +#if !defined (BASIC_CONFIGURATOR_HAS_DLL) +# define BASIC_CONFIGURATOR_HAS_DLL 1 +#endif /* ! BASIC_CONFIGURATOR_HAS_DLL */ + +#if defined (BASIC_CONFIGURATOR_HAS_DLL) && (BASIC_CONFIGURATOR_HAS_DLL == 1) +# if defined (BASIC_CONFIGURATOR_BUILD_DLL) +# define Basic_Configurator_Export ACE_Proper_Export_Flag +# define BASIC_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define BASIC_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* BASIC_CONFIGURATOR_BUILD_DLL */ +# define Basic_Configurator_Export ACE_Proper_Import_Flag +# define BASIC_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define BASIC_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* BASIC_CONFIGURATOR_BUILD_DLL */ +#else /* BASIC_CONFIGURATOR_HAS_DLL == 1 */ +# define Basic_Configurator_Export +# define BASIC_CONFIGURATOR_SINGLETON_DECLARATION(T) +# define BASIC_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* BASIC_CONFIGURATOR_HAS_DLL == 1 */ + +// Set BASIC_CONFIGURATOR_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (BASIC_CONFIGURATOR_NTRACE) +# if (ACE_NTRACE == 1) +# define BASIC_CONFIGURATOR_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define BASIC_CONFIGURATOR_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !BASIC_CONFIGURATOR_NTRACE */ + +#if (BASIC_CONFIGURATOR_NTRACE == 1) +# define BASIC_CONFIGURATOR_TRACE(X) +#else /* (BASIC_CONFIGURATOR_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define BASIC_CONFIGURATOR_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (BASIC_CONFIGURATOR_NTRACE == 1) */ + +#endif /* BASIC_CONFIGURATOR_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/Configurators/ComponentServer_Configurator_export.h b/CIAO/ciao/FTComponentServer/Configurators/ComponentServer_Configurator_export.h new file mode 100644 index 00000000000..9793cd0ed44 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/ComponentServer_Configurator_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl ComponentServer_Configurator +// ------------------------------ +#ifndef COMPONENTSERVER_CONFIGURATOR_EXPORT_H +#define COMPONENTSERVER_CONFIGURATOR_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (COMPONENTSERVER_CONFIGURATOR_HAS_DLL) +# define COMPONENTSERVER_CONFIGURATOR_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && COMPONENTSERVER_CONFIGURATOR_HAS_DLL */ + +#if !defined (COMPONENTSERVER_CONFIGURATOR_HAS_DLL) +# define COMPONENTSERVER_CONFIGURATOR_HAS_DLL 1 +#endif /* ! COMPONENTSERVER_CONFIGURATOR_HAS_DLL */ + +#if defined (COMPONENTSERVER_CONFIGURATOR_HAS_DLL) && (COMPONENTSERVER_CONFIGURATOR_HAS_DLL == 1) +# if defined (COMPONENTSERVER_CONFIGURATOR_BUILD_DLL) +# define ComponentServer_Configurator_Export ACE_Proper_Export_Flag +# define COMPONENTSERVER_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define COMPONENTSERVER_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* COMPONENTSERVER_CONFIGURATOR_BUILD_DLL */ +# define ComponentServer_Configurator_Export ACE_Proper_Import_Flag +# define COMPONENTSERVER_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define COMPONENTSERVER_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* COMPONENTSERVER_CONFIGURATOR_BUILD_DLL */ +#else /* COMPONENTSERVER_CONFIGURATOR_HAS_DLL == 1 */ +# define ComponentServer_Configurator_Export +# define COMPONENTSERVER_CONFIGURATOR_SINGLETON_DECLARATION(T) +# define COMPONENTSERVER_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* COMPONENTSERVER_CONFIGURATOR_HAS_DLL == 1 */ + +// Set COMPONENTSERVER_CONFIGURATOR_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (COMPONENTSERVER_CONFIGURATOR_NTRACE) +# if (ACE_NTRACE == 1) +# define COMPONENTSERVER_CONFIGURATOR_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define COMPONENTSERVER_CONFIGURATOR_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !COMPONENTSERVER_CONFIGURATOR_NTRACE */ + +#if (COMPONENTSERVER_CONFIGURATOR_NTRACE == 1) +# define COMPONENTSERVER_CONFIGURATOR_TRACE(X) +#else /* (COMPONENTSERVER_CONFIGURATOR_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define COMPONENTSERVER_CONFIGURATOR_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (COMPONENTSERVER_CONFIGURATOR_NTRACE == 1) */ + +#endif /* COMPONENTSERVER_CONFIGURATOR_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/Configurators/Config_Manager.cpp b/CIAO/ciao/FTComponentServer/Configurators/Config_Manager.cpp new file mode 100644 index 00000000000..47ee45a81a4 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/Config_Manager.cpp @@ -0,0 +1,11 @@ +#include "Config_Manager.h" + +namespace CIAO +{ + namespace Deployment + { + Config_Manager::~Config_Manager (void) + { + } + } +} diff --git a/CIAO/ciao/FTComponentServer/Configurators/Config_Manager.h b/CIAO/ciao/FTComponentServer/Configurators/Config_Manager.h new file mode 100755 index 00000000000..2ce46aa980f --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/Config_Manager.h @@ -0,0 +1,53 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Config_Manager.h + * + * $Id$ + * + */ +//============================================================================= + + +#ifndef CIAO_CONFIG_MANAGER_H +#define CIAO_CONFIG_MANAGER_H +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ciao/ComponentServer/CIAO_ServerResourcesC.h" + +namespace CIAO +{ + namespace Deployment + { + /** + */ + class Config_Manager + { + public: + virtual ~Config_Manager (void) {}; + + virtual int pre_orb_initialize (void) = 0; + + virtual int post_orb_initialize (CORBA::ORB_ptr o) = 0; + + virtual void init_resources (const ServerResource &info) = 0; + + virtual void init (CORBA::ORB_ptr orb) = 0; + + virtual CORBA::PolicyList *find_policies_by_name (const char *name)= 0; + + virtual bool policy_exists (const char *name) = 0; + }; + } +} + +#include /**/ "ace/post.h" +#endif /* CIAO_CONFIG_MANAGER_H */ + diff --git a/CIAO/ciao/FTComponentServer/Configurators/Configurators.mpc b/CIAO/ciao/FTComponentServer/Configurators/Configurators.mpc new file mode 100644 index 00000000000..dc072ddb6dc --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/Configurators.mpc @@ -0,0 +1,21 @@ +project(CIAO_FT_Basic_Configurator) : ccm_stub, ciao_ft_componentserver_stub, ciao_lib { + dynamicflags += COMPONENTSERVER_CONFIGURATOR_BUILD_DLL + Source_Files { + Server_Configurator.cpp + } + Header_Files { + Server_Configurator.h + } +} + +project(CIAO_FT_Basic_Config_Manager) : ciao_lib, ciao_config_manager, ciao_ft_componentserver_stub, \ + diffservpolicy { + dynamicflags += BASIC_CONFIG_MANAGER_BUILD_DLL + Source_Files { + Basic_Config_Manager.cpp + } + Header_Files { + Basic_Config_Manager.h + } +} + diff --git a/CIAO/ciao/FTComponentServer/Configurators/NA_Configurator_Export.h b/CIAO/ciao/FTComponentServer/Configurators/NA_Configurator_Export.h new file mode 100755 index 00000000000..2e30fd59cc1 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/NA_Configurator_Export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl CIAO_NA_Configurator +// ------------------------------ +#ifndef CIAO_NA_CONFIGURATOR_EXPORT_H +#define CIAO_NA_CONFIGURATOR_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (CIAO_NA_CONFIGURATOR_HAS_DLL) +# define CIAO_NA_CONFIGURATOR_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && CIAO_NA_CONFIGURATOR_HAS_DLL */ + +#if !defined (CIAO_NA_CONFIGURATOR_HAS_DLL) +# define CIAO_NA_CONFIGURATOR_HAS_DLL 1 +#endif /* ! CIAO_NA_CONFIGURATOR_HAS_DLL */ + +#if defined (CIAO_NA_CONFIGURATOR_HAS_DLL) && (CIAO_NA_CONFIGURATOR_HAS_DLL == 1) +# if defined (CIAO_NA_CONFIGURATOR_BUILD_DLL) +# define CIAO_NA_Configurator_Export ACE_Proper_Export_Flag +# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* CIAO_NA_CONFIGURATOR_BUILD_DLL */ +# define CIAO_NA_Configurator_Export ACE_Proper_Import_Flag +# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* CIAO_NA_CONFIGURATOR_BUILD_DLL */ +#else /* CIAO_NA_CONFIGURATOR_HAS_DLL == 1 */ +# define CIAO_NA_Configurator_Export +# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARATION(T) +# define CIAO_NA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* CIAO_NA_CONFIGURATOR_HAS_DLL == 1 */ + +// Set CIAO_NA_CONFIGURATOR_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (CIAO_NA_CONFIGURATOR_NTRACE) +# if (ACE_NTRACE == 1) +# define CIAO_NA_CONFIGURATOR_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define CIAO_NA_CONFIGURATOR_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !CIAO_NA_CONFIGURATOR_NTRACE */ + +#if (CIAO_NA_CONFIGURATOR_NTRACE == 1) +# define CIAO_NA_CONFIGURATOR_TRACE(X) +#else /* (CIAO_NA_CONFIGURATOR_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define CIAO_NA_CONFIGURATOR_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (CIAO_NA_CONFIGURATOR_NTRACE == 1) */ + +#endif /* CIAO_NA_CONFIGURATOR_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/Configurators/NoOp/FT_NoOp_Configurator.mpc b/CIAO/ciao/FTComponentServer/Configurators/NoOp/FT_NoOp_Configurator.mpc new file mode 100644 index 00000000000..50cb9d50665 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/NoOp/FT_NoOp_Configurator.mpc @@ -0,0 +1,12 @@ +project(CIAO_FT_NoOp_Configurator) : ccm_stub, ciao_ft_componentserver_stub, ciao_ft_componentserver_configurator, ciao_lib { + + Source_Files { + NoOp_Configurator.cpp + } + + Header_Files { + NoOp_Configurator.h + } +} + + diff --git a/CIAO/ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator.cpp b/CIAO/ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator.cpp new file mode 100644 index 00000000000..e4c377e436a --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator.cpp @@ -0,0 +1,46 @@ +// $Id$ + +#include "NoOp_Configurator.h" + +namespace CIAO +{ + namespace Deployment + { + + NoOp_Configurator::~NoOp_Configurator (void) + { + // Not much to do. + } + + int + NoOp_Configurator::pre_orb_initialize () + { + return 0; + } + + int + NoOp_Configurator::post_orb_initialize (CORBA::ORB_ptr) + { + return 0; + } + + int + NoOp_Configurator::init_resource_manager + (const ::Components::ConfigValues & /*properties*/) + { + // @@ Currently do thing. We should go over the resource struct in + // the future and throw exceptions if there are + // un-recognizable/supported stuff in it. + return 0; + } + + CORBA::PolicyList * + NoOp_Configurator::find_container_policies + (const ::Components::ConfigValues & /*properties*/) + { + // Not much to do. + + return 0; + } + } +} diff --git a/CIAO/ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator.h b/CIAO/ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator.h new file mode 100644 index 00000000000..d84715d5bca --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator.h @@ -0,0 +1,66 @@ +/** $Id$ + * @file NoOp_Configurator.h + * @brief This file contains the noop configurator. + */ + +#ifndef NOOP_CONFIGURATOR_H +#define NOOP_CONFIGURATOR_H + +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include <ccm/CCM_StandardConfiguratorC.h> + +#include "ciao/ComponentServer/Configurators/Server_Configurator.h" +#include "NoOp_Configurator_export.h" + +namespace CIAO +{ + namespace Deployment + { + /** + * @class NoOP_Configurator + * + * @brief The NoOp_Configurator doesn't do anything. + */ + class NoOp_Configurator_Export NoOp_Configurator + : public ComponentServer_Configurator + { + public: + /// Default destructor. + virtual ~NoOp_Configurator (void); + + /** + * @brief "pre_orb_initialize" is called before ORB_init. + */ + virtual int pre_orb_initialize (void); + + /** + * @brief "post_orb_initialize" is called after NodeApplication + * get a hold at this object. + */ + virtual int post_orb_initialize (CORBA::ORB_ptr o); + + /** + * @brief "init_resource_manager" is called by NodeApplication when + * it receives an "install" commands. + */ + virtual int + init_resource_manager (const ::Components::ConfigValues &properties); + + /** + * @brief get a policyset by its name. + */ + virtual CORBA::PolicyList * + find_container_policies (const ::Components::ConfigValues &properties); + }; + } +} + +#include /**/ "ace/post.h" +#endif /* NOOP_CONFIGURATOR_H */ diff --git a/CIAO/ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator_export.h b/CIAO/ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator_export.h new file mode 100644 index 00000000000..b6b3a9ec841 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/NoOp/NoOp_Configurator_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl NoOp_Configurator +// ------------------------------ +#ifndef NOOP_CONFIGURATOR_EXPORT_H +#define NOOP_CONFIGURATOR_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (NOOP_CONFIGURATOR_HAS_DLL) +# define NOOP_CONFIGURATOR_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && NOOP_CONFIGURATOR_HAS_DLL */ + +#if !defined (NOOP_CONFIGURATOR_HAS_DLL) +# define NOOP_CONFIGURATOR_HAS_DLL 1 +#endif /* ! NOOP_CONFIGURATOR_HAS_DLL */ + +#if defined (NOOP_CONFIGURATOR_HAS_DLL) && (NOOP_CONFIGURATOR_HAS_DLL == 1) +# if defined (NOOP_CONFIGURATOR_BUILD_DLL) +# define NoOp_Configurator_Export ACE_Proper_Export_Flag +# define NOOP_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define NOOP_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* NOOP_CONFIGURATOR_BUILD_DLL */ +# define NoOp_Configurator_Export ACE_Proper_Import_Flag +# define NOOP_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define NOOP_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* NOOP_CONFIGURATOR_BUILD_DLL */ +#else /* NOOP_CONFIGURATOR_HAS_DLL == 1 */ +# define NoOp_Configurator_Export +# define NOOP_CONFIGURATOR_SINGLETON_DECLARATION(T) +# define NOOP_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* NOOP_CONFIGURATOR_HAS_DLL == 1 */ + +// Set NOOP_CONFIGURATOR_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (NOOP_CONFIGURATOR_NTRACE) +# if (ACE_NTRACE == 1) +# define NOOP_CONFIGURATOR_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define NOOP_CONFIGURATOR_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !NOOP_CONFIGURATOR_NTRACE */ + +#if (NOOP_CONFIGURATOR_NTRACE == 1) +# define NOOP_CONFIGURATOR_TRACE(X) +#else /* (NOOP_CONFIGURATOR_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define NOOP_CONFIGURATOR_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (NOOP_CONFIGURATOR_NTRACE == 1) */ + +#endif /* NOOP_CONFIGURATOR_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.cpp b/CIAO/ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.cpp new file mode 100644 index 00000000000..4ec837c06fe --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.cpp @@ -0,0 +1,513 @@ +// $Id$ + +#include "RTConfig_Manager.h" +#include "ciao/CIAO_common.h" +#include "ace/SString.h" + +#if !defined (__ACE_INLINE__) +# include "RTConfig_Manager.inl" +#endif /* __ACE_INLINE__ */ + +void +CIAO::Deployment::RTResource_Config_Manager::init (CORBA::ORB_ptr orb) +{ + CORBA::Object_var object = + orb->resolve_initial_references ("RTORB"); + this->rtorb_ = RTCORBA::RTORB::_narrow (object.in ()); +} + +int +CIAO::Deployment::RTResource_Config_Manager::pre_orb_initialize (void) +{ + return 0; +} + +int +CIAO::Deployment::RTResource_Config_Manager::post_orb_initialize (CORBA::ORB_ptr) +{ + return 0; +} + +void +CIAO::Deployment::RTResource_Config_Manager::print_resources +(const ServerResource &server_resource) +{ + const ORBResource &orb_resource + = server_resource.orb_config.orb_resources[0]; + + CORBA::ULong i; + + // Creating and binding name with RT Threadpool + for (i = 0; i < orb_resource.threadpool_list.length (); ++i) + { + CIAO_DEBUG ((LM_DEBUG, + "-RTResource_Config_Manager::print_resource threadpool: %s\n" + "\tStack size: %d\n" + "\tStatic: %d\n" + "\tDynamic %d\n" + "\tDefault Prio: %d\n" + "\tBuffering %s\n" + "\tMax Buffered: %d\n" + "\tBuffer Size %d\n", + orb_resource.threadpool_list[i].Id.in (), + orb_resource.threadpool_list[i].stacksize, + orb_resource.threadpool_list[i].static_threads, + orb_resource.threadpool_list[i].dynamic_threads, + orb_resource.threadpool_list[i].default_priority, + (orb_resource.threadpool_list[i].allow_request_buffering ? "Y" : "N"), + orb_resource.threadpool_list[i].max_buffered_requests, + orb_resource.threadpool_list[i].max_request_buffer_size)); + } + + for (i = 0; i < orb_resource.threadpool_with_lanes_list.length (); ++i) + { + CIAO_DEBUG ((LM_DEBUG, + "-RTResource_Config_Manager::print_resource threadpool_with %d, lanes: %s\n", + orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length (), + orb_resource.threadpool_with_lanes_list[i].Id.in ())); + + for (CORBA::ULong l = 0; + l < orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length (); + ++l) + { + CIAO_DEBUG ((LM_DEBUG, + "\tLane %d:\n" + "\t\tPriority: %d\n" + "\t\tStatic: %d\n" + "\t\tDynamic: %d\n", + l, + orb_resource.threadpool_with_lanes_list[i].threadpool_lanes[l].lane_priority, + orb_resource.threadpool_with_lanes_list[i].threadpool_lanes[l].static_threads, + orb_resource.threadpool_with_lanes_list[i].threadpool_lanes[l].dynamic_threads)); + } + CIAO_DEBUG ((LM_DEBUG, + "\tStack size: %d\n" + "\tBorrowing: %s\n" + "\tBuffering %s\n" + "\tMax Buffered: %d\n" + "\tBuffer Size %d\n", + orb_resource.threadpool_with_lanes_list[i].stacksize, + (orb_resource.threadpool_with_lanes_list[i].allow_borrowing ? "Y" : "N"), + (orb_resource.threadpool_with_lanes_list[i].allow_request_buffering ? "Y" : "N"), + orb_resource.threadpool_with_lanes_list[i].max_buffered_requests, + orb_resource.threadpool_with_lanes_list[i].max_request_buffer_size)); + } + + for (i = 0; i < orb_resource.connection_bands_list.length (); ++i) + { + CIAO_DEBUG ((LM_DEBUG, + "-RTResource_Config_Manager::print_resource connection %d bands: %s\n", + orb_resource.connection_bands_list[i].bands.length (), + orb_resource.connection_bands_list[i].Id.in ())); + + for (CORBA::ULong l = 0; + l < orb_resource.connection_bands_list[i].bands.length (); + ++l) + { + CIAO_DEBUG ((LM_DEBUG, + "\tBand %d Prio: %d -- %d\n", + l, + orb_resource.connection_bands_list[i].bands[l].low, + orb_resource.connection_bands_list[i].bands[l].high)); + } + } +} + +void +CIAO::Deployment::RTResource_Config_Manager::init_resources +(const ServerResource &server_resource) +{ + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource.\n")); + + if (CORBA::is_nil (this->rtorb_.in())) + { + CIAO_ERROR ((LM_ERROR, + "RTResource_Config_Manager has not been properly initialized.\n")); + throw CORBA::INTERNAL (); + } + + this->print_resources (server_resource); + // return; + + const ORBResource &orb_resource + = server_resource.orb_config.orb_resources[0]; + + CORBA::ULong i; + + // Creating and binding name with RT Threadpool + for (i = 0; i < orb_resource.threadpool_list.length (); ++i) + { + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource threadpool: %s\n", + orb_resource.threadpool_list[i].Id.in ())); + RTCORBA::ThreadpoolId thr_id = + this->rtorb_->create_threadpool + (orb_resource.threadpool_list[i].stacksize, + orb_resource.threadpool_list[i].static_threads, + orb_resource.threadpool_list[i].dynamic_threads, + orb_resource.threadpool_list[i].default_priority, + orb_resource.threadpool_list[i].allow_request_buffering, + orb_resource.threadpool_list[i].max_buffered_requests, + orb_resource.threadpool_list[i].max_request_buffer_size); + // Simply pass back the exception here + // for now. We need to have a better way + // to handle execption here. + if (this->threadpool_map_.bind (orb_resource.threadpool_list[i].Id.in (), + thr_id) != 0) + { + CIAO_ERROR ((LM_ERROR, "Error binding thread pool Id: %s to map when initializing RTNodeApplication resources.\n", orb_resource.threadpool_list[i].Id.in ())); + throw CORBA::INTERNAL (); + } + else + { + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource added thread pool: %s\n", + orb_resource.threadpool_list[i].Id.in ())); + } + } + + for (i = 0; i < orb_resource.threadpool_with_lanes_list.length (); ++i) + { + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource threadpool_with %d, lanes: %s\n", + orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length (), + orb_resource.threadpool_with_lanes_list[i].Id.in ())); + + // Duplicate RTCORBA lanes + RTCORBA::ThreadpoolLanes lanes + (orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length ()); + lanes.length (orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length ()); + + for (CORBA::ULong l = 0; + l < orb_resource.threadpool_with_lanes_list[i].threadpool_lanes.length (); + ++l) + { + lanes[l].lane_priority + = orb_resource.threadpool_with_lanes_list[i].threadpool_lanes[l].lane_priority; + lanes[l].static_threads + = orb_resource.threadpool_with_lanes_list[i].threadpool_lanes[l].static_threads; + lanes[l].dynamic_threads + = orb_resource.threadpool_with_lanes_list[i].threadpool_lanes[l].dynamic_threads; + } + + RTCORBA::ThreadpoolId thr_id = + this->rtorb_->create_threadpool_with_lanes + (orb_resource.threadpool_with_lanes_list[i].stacksize, + lanes, + orb_resource.threadpool_with_lanes_list[i].allow_borrowing, + orb_resource.threadpool_with_lanes_list[i].allow_request_buffering, + orb_resource.threadpool_with_lanes_list[i].max_buffered_requests, + orb_resource.threadpool_with_lanes_list[i].max_request_buffer_size); + // Simply pass back the exception here + // for now. We need to have a better way + // to handle execption here. + + if (this->threadpool_map_.bind (orb_resource.threadpool_with_lanes_list[i].Id.in (), + thr_id) != 0) + { + CIAO_ERROR ((LM_ERROR, + "Error binding thread pool name: %s to map when " + "initializing RTNodeApplication resources.\n", + orb_resource.threadpool_with_lanes_list[i].Id.in ())); + throw CORBA::INTERNAL (); + } + + else + { + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource added thread pool with lanes: %s\n", + orb_resource.threadpool_with_lanes_list[i].Id.in ())); + } + } + + for (i = 0; i < orb_resource.connection_bands_list.length (); ++i) + { + RTCORBA::PriorityBands + safebands(orb_resource.connection_bands_list[i].bands.length ()); + safebands.length (orb_resource.connection_bands_list[i].bands.length ()); + + for (CORBA::ULong l = 0; + l < orb_resource.connection_bands_list[i].bands.length (); + ++l) + { + safebands[l].low = orb_resource.connection_bands_list[i].bands[l].low; + safebands[l].high = orb_resource.connection_bands_list[i].bands[l].high; + } + + if (this->priority_bands_map_.bind (orb_resource.connection_bands_list[i].Id.in (), + safebands) != 0) + { + CIAO_ERROR ((LM_ERROR, + "Error binding priority bands name: %s to map " + "when initializing RTNodeApplication resources.\n", + orb_resource.connection_bands_list[i].Id.in ())); + throw CORBA::INTERNAL (); + } + else + { + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource added connection bands: %s\n", + orb_resource.connection_bands_list[i].Id.in ())); + } + } + + // now initialize the policy set part of it. + // server_resource.orb_config.policy_set + const PolicySets &sets = server_resource.orb_config.policy_set; + for (CORBA::ULong i = 0; i < sets.length (); ++i) + { + CORBA::ULong const np = sets[i].policies.length (); + if (np == 0) + continue; + + CORBA::PolicyList_var policy_list = new CORBA::PolicyList (np); + policy_list->length (np); + CORBA::ULong index = 0; + CORBA::ULong array_index = np; + + // Create a list of policies + for (CORBA::ULong pc = 0; pc < np; ++pc) + { + CORBA::Policy_var temp_policy = + this->create_single_policy (sets[i].policies[pc]); + if (CORBA::is_nil (temp_policy.in ())) + { + array_index = array_index - 1; + policy_list->length (array_index); + } + else + { + policy_list[index] = CORBA::Policy::_duplicate (temp_policy.in ()); + index = index + 1; + } + } + + // Bind the policy list to the name. The bind operation should + // surrender the ownership of the newly created PolicyList + // sequence to the map. + if (array_index != 0) + { + if (this->policy_map_.bind (sets[i].Id.in (), + policy_list._retn ()) != 0) + { + CIAO_ERROR ((LM_ERROR, + "Error binding Policy_Set with name: %s\n", + sets[i].Id.in ())); + throw CORBA::INTERNAL (); + } + else + { + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource " + "added policy set: %s with %d policies\n", + sets[i].Id.in (), array_index)); + } + } + else + { + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::init_resource " + "added policy set: %s with %d policies\n", + sets[i].Id.in (), array_index)); + } + } +} + +void +CIAO::Deployment::RTResource_Config_Manager::fini () +{ + TP_MAP::ITERATOR iter = this->threadpool_map_.begin (); + TP_MAP::ITERATOR end = this->threadpool_map_.end (); + + for (; iter != end; ++iter) + { + this->rtorb_->destroy_threadpool ((*iter).int_id_); + } + +} + +RTCORBA::ThreadpoolId +CIAO::Deployment::RTResource_Config_Manager::find_threadpool_by_name (const char *name) +{ + if (name == 0) + { + CIAO_ERROR ((LM_ERROR, + "Invalid name string found in \"find_threadpool_by_name\"\n")); + throw CORBA::BAD_PARAM (); + } + + + RTCORBA::ThreadpoolId ret_id = 0; // return id + + if (this->threadpool_map_.find (name, ret_id) != 0) + { + CIAO_ERROR ((LM_ERROR, + "Unable to find a threadpool named %s\n", + name)); + throw CORBA::INTERNAL (); + } + + return ret_id; +} + +RTCORBA::PriorityBands * +CIAO::Deployment::RTResource_Config_Manager::find_priority_bands_by_name (const char *name) +{ + if (name == 0) + { + CIAO_ERROR ((LM_ERROR, + "Invalid name string found in \"find_priority_bands_by_name\"\n")); + throw CORBA::BAD_PARAM (); + } + + PB_MAP::ENTRY *entry = 0; + + if (this->priority_bands_map_.find (name, entry) != 0) + { + CIAO_ERROR ((LM_ERROR, + "Unable to find a connection bands named %s\n", + name)); + throw CORBA::INTERNAL (); + } + + RTCORBA::PriorityBands_var retv = new RTCORBA::PriorityBands; + (*retv.ptr ()) = (*entry->int_id_.ptr ()); + return retv._retn (); +} + +bool +CIAO::Deployment::RTResource_Config_Manager::policy_exists (const char *name) +{ + if (name == 0) + { + CIAO_DEBUG ((LM_DEBUG, + "Invalid name string found in " + "CIAO::Deployment::NAResource_Config_Manager::policy_exists\n")); + throw CORBA::INTERNAL (); + } + + POLICY_MAP::ENTRY *entry = 0; + + if (this->policy_map_.find (name, entry) != 0) + { + return false; + } + + return true; +} + +CORBA::PolicyList * +CIAO::Deployment::RTResource_Config_Manager::find_policies_by_name (const char *name) +{ + if (name == 0) + { + CIAO_ERROR ((LM_ERROR, + "Invalid name string found in \"find_policies_by_name\"\n")); + throw CORBA::BAD_PARAM (); + } + + + CIAO_DEBUG ((LM_DEBUG, "RTResource_Config_Manager::find_policies_by_name: %s\n", + name)); + + POLICY_MAP::ENTRY *entry = 0; + + if (this->policy_map_.find (name, entry) != 0) + { + CIAO_ERROR ((LM_ERROR, + "Unable to find a PolicyList named %s\n", + name)); + throw CORBA::INTERNAL (); + } + + // duplicate the sequence PolicyList. + CORBA::PolicyList_var retv = + new CORBA::PolicyList (entry->int_id_.in ()); + + CIAO_DEBUG ((LM_DEBUG, "RTResource_Config_Manager::find_policies_by_name ok.\n")); + + return retv._retn (); +} + +CORBA::Policy_ptr +CIAO::Deployment::RTResource_Config_Manager::create_single_policy +(const PolicyDef &policy_def) +{ + // if (CIAO::Deployment::debug_level () > 9) + CIAO_DEBUG ((LM_DEBUG, + "RTResource_Config_Manager::create_single_policy: %d\n", + policy_def._d ())); + + CORBA::Policy_var retv; + + switch (policy_def._d ()) + { + case RTCORBA::PRIORITY_MODEL_POLICY_TYPE: + { + const PriorityModelPolicyDef &tmp + = policy_def.PriorityModelDef (); + + retv = this->rtorb_->create_priority_model_policy ((RTCORBA::PriorityModel) tmp.priority_model, + tmp.server_priority); + + if (! CORBA::is_nil (retv.in ())) + CIAO_DEBUG ((LM_DEBUG, + "Create PriorityModel policy: %d - %d\n", + tmp.priority_model, tmp.server_priority)); + } + break; + + case RTCORBA::THREADPOOL_POLICY_TYPE: + { + RTCORBA::ThreadpoolId tpid = + this->find_threadpool_by_name (policy_def.ThreadpoolDef().Id.in ()); + + retv = this->rtorb_->create_threadpool_policy (tpid); + + if (! CORBA::is_nil (retv.in ())) + CIAO_DEBUG ((LM_DEBUG, + "Create Threadpool policy: %s, TPid: %d\n", + policy_def.ThreadpoolDef().Id.in (), tpid)); + } + break; + + case RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE: + { + RTCORBA::PriorityBands_var bands = + this->find_priority_bands_by_name (policy_def.PriorityBandedConnectionDef().Id.in ()); + + retv = + this->rtorb_->create_priority_banded_connection_policy (bands.in ()); + + if (! CORBA::is_nil (retv.in ())) + { + CIAO_DEBUG ((LM_DEBUG, + "Created Banded Connection policy: %s\n", + policy_def.PriorityBandedConnectionDef().Id.in ())); + } + } + break; + + default: + retv = 0; + } + + return retv._retn (); +} + +CIAO::Deployment::RTResource_Config_Manager::~RTResource_Config_Manager () +{ + this->fini (); +} + +extern "C" CIAO_RTNA_Configurator_Export CIAO::Deployment::Config_Manager +*create_rt_config_manager (void); + +CIAO::Deployment::Config_Manager * +create_rt_config_manager (void) +{ + CIAO::Deployment::RTResource_Config_Manager *config; + ACE_NEW_RETURN (config, CIAO::Deployment::RTResource_Config_Manager, 0); + return config; +} diff --git a/CIAO/ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.h b/CIAO/ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.h new file mode 100644 index 00000000000..fbbea84d706 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.h @@ -0,0 +1,138 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file RTConfig_Manager.h + * + * $Id$ + * + * This file contains classes that manage name to configuration + * mapping info in a RTComponentServer. + * + * @author Nanbor Wang <nanbor@cs.wustl.edu> + */ +//============================================================================= + + +#ifndef CIAO_RTCONFIG_MANAGER_H +#define CIAO_RTCONFIG_MANAGER_H +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Null_Mutex.h" +#include "ace/SString.h" +#include "ace/Hash_Map_Manager_T.h" +#include "tao/RTCORBA/RTCORBA.h" +#include "ciao/ComponentServer/CIAO_ServerResourcesC.h" + +#include "ciao/ComponentServer/Configurators/Config_Manager.h" +#include "RTNA_Configurator_Export.h" + +namespace CIAO +{ + namespace Deployment + { + /** + * @brief RTResource_Config_Manager maintains a collection of + * RTCORBA related resources. + * + * This class is responsible to create and manage a list of RTCORBA + * related resources that are global to an RT ComponentServer. The + * information required to create and configure these resources are + * passed in via the @a info argument in the @c init method. These + * resources are identified by names and can be used to associate + * these resources with related RTPolicies. These resources are + * destoryed along with this class. + * + * Currently, the only resources supported (and managed) by this + * class are Threadpool and Threadpool_with_Lanes. + */ + class RTResource_Config_Manager : public Config_Manager + { + public: + RTResource_Config_Manager (void); + ~RTResource_Config_Manager (void); + + virtual void init (CORBA::ORB_ptr orb); + + virtual int pre_orb_initialize (void); + + virtual int post_orb_initialize (CORBA::ORB_ptr o); + + /// Initializing the RTResource_Config_Manager + virtual void init_resources (const ServerResource &info); + + /// Finalizing the RTResource_Config_Manager and the resources it + /// manages. + void fini (); + + /// Query a policy set by name + virtual CORBA::PolicyList *find_policies_by_name (const char *name); + + virtual bool policy_exists (const char *name); + + protected: + void print_resources (const ServerResource &info); + + /// Query a thread pool by name. + RTCORBA::ThreadpoolId find_threadpool_by_name (const char *name); + + + /// Query a priority bands info by name. + RTCORBA::PriorityBands *find_priority_bands_by_name (const char *name); + + private: + /// Cached an ORB reference. + CORBA::ORB_var orb_; + + // Cached an RTORB reference. + RTCORBA::RTORB_var rtorb_; + + /// Hash_Map stuff. + typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + RTCORBA::ThreadpoolId, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> TP_MAP; + + typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + RTCORBA::PriorityBands_var, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> PB_MAP; + + /// Internal TP name to id map. + TP_MAP threadpool_map_; + + /// Internal PB name to priority bands map. + PB_MAP priority_bands_map_; + + /// create a single policy + CORBA::Policy_ptr create_single_policy + (const PolicyDef &policy_def); + + /// Hash_Map stuff. + typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + CORBA::PolicyList_var, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> POLICY_MAP; + + /// Internal TP names to id map. + POLICY_MAP policy_map_; +}; +} +} + +#if defined (__ACE_INLINE__) +# include "RTConfig_Manager.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* CIAO_RTCONFIG_MANAGER_H */ + diff --git a/CIAO/ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.inl b/CIAO/ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.inl new file mode 100644 index 00000000000..08aaef9f6ad --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/RT/RTConfig_Manager.inl @@ -0,0 +1,8 @@ +// $Id$ + + +ACE_INLINE +CIAO::Deployment::RTResource_Config_Manager::RTResource_Config_Manager () +{ +} + diff --git a/CIAO/ciao/FTComponentServer/Configurators/RT/RTNA_Configurator_Export.h b/CIAO/ciao/FTComponentServer/Configurators/RT/RTNA_Configurator_Export.h new file mode 100644 index 00000000000..689a871c7e5 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/RT/RTNA_Configurator_Export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl CIAO_RTNA_Configurator +// ------------------------------ +#ifndef CIAO_RTNA_CONFIGURATOR_EXPORT_H +#define CIAO_RTNA_CONFIGURATOR_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (CIAO_RTNA_CONFIGURATOR_HAS_DLL) +# define CIAO_RTNA_CONFIGURATOR_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && CIAO_RTNA_CONFIGURATOR_HAS_DLL */ + +#if !defined (CIAO_RTNA_CONFIGURATOR_HAS_DLL) +# define CIAO_RTNA_CONFIGURATOR_HAS_DLL 1 +#endif /* ! CIAO_RTNA_CONFIGURATOR_HAS_DLL */ + +#if defined (CIAO_RTNA_CONFIGURATOR_HAS_DLL) && (CIAO_RTNA_CONFIGURATOR_HAS_DLL == 1) +# if defined (CIAO_RTNA_CONFIGURATOR_BUILD_DLL) +# define CIAO_RTNA_Configurator_Export ACE_Proper_Export_Flag +# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* CIAO_RTNA_CONFIGURATOR_BUILD_DLL */ +# define CIAO_RTNA_Configurator_Export ACE_Proper_Import_Flag +# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* CIAO_RTNA_CONFIGURATOR_BUILD_DLL */ +#else /* CIAO_RTNA_CONFIGURATOR_HAS_DLL == 1 */ +# define CIAO_RTNA_Configurator_Export +# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARATION(T) +# define CIAO_RTNA_CONFIGURATOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* CIAO_RTNA_CONFIGURATOR_HAS_DLL == 1 */ + +// Set CIAO_RTNA_CONFIGURATOR_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (CIAO_RTNA_CONFIGURATOR_NTRACE) +# if (ACE_NTRACE == 1) +# define CIAO_RTNA_CONFIGURATOR_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define CIAO_RTNA_CONFIGURATOR_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !CIAO_RTNA_CONFIGURATOR_NTRACE */ + +#if (CIAO_RTNA_CONFIGURATOR_NTRACE == 1) +# define CIAO_RTNA_CONFIGURATOR_TRACE(X) +#else /* (CIAO_RTNA_CONFIGURATOR_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define CIAO_RTNA_CONFIGURATOR_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (CIAO_RTNA_CONFIGURATOR_NTRACE == 1) */ + +#endif /* CIAO_RTNA_CONFIGURATOR_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/Configurators/RTNodeApp_Configurator.cpp b/CIAO/ciao/FTComponentServer/Configurators/RTNodeApp_Configurator.cpp new file mode 100644 index 00000000000..5f199f366aa --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/RTNodeApp_Configurator.cpp @@ -0,0 +1,108 @@ +// $Id$ + +#include "RTNodeApp_Configurator.h" +#include "DAnCE/Deployment/CIAO_ServerResourcesC.h" +#include "tao/RTPortableServer/RTPortableServer.h" + +CIAO::RTNodeApp_Configurator::~RTNodeApp_Configurator () +{ +} + +int +CIAO::RTNodeApp_Configurator::pre_orb_initialize () +{ + CIAO_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::pre_orb_init\n")); + + return 0; +} + +int +CIAO::RTNodeApp_Configurator::post_orb_initialize (CORBA::ORB_ptr o) +{ + CIAO_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::post_orb_init\n")); + + this->orb_ = CORBA::ORB::_duplicate (o); + + CORBA::Object_var object = + this->orb_->resolve_initial_references ("RTORB"); + + this->rtorb_ = + RTCORBA::RTORB::_narrow (object.in ()); + + this->config_manager_.init (this->rtorb_.in ()); + + return 0; +} + +int +CIAO::RTNodeApp_Configurator::init_resource_manager +(const ::Deployment::Properties &properties) +{ + + // if (CIAO::debug_level () > 9) + CIAO_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::init_resource_manager\n")); + // @@ Should we cache the properties that we consumed here? + + for (CORBA::ULong i = 0; i < properties.length (); ++i) + { + // if (CIAO::debug_level () > 9) + CIAO_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::init_resource_manager processing property: %s\n", + properties[i].name.in ())); + + if (ACE_OS::strcmp ("CIAOServerResources", properties[i].name.in ()) == 0) + { + const CIAO::DAnCE::ServerResource *svr_resource; + if (properties[i].value >>= svr_resource) + { + this->config_manager_.init_resources (*svr_resource); + // Now we have the information to initialize the manager. + } + else + CIAO_ERROR_RETURN ((LM_ERROR, + "ERROR: RTNodeApp_Configurator::init_resource_manager unable to extract CIAOServerResources\n"), -1); + } + + // Ignore other stuff + } + + return 0; +} + +CORBA::PolicyList * +CIAO::RTNodeApp_Configurator::find_container_policies +(const ::Deployment::Properties &properties) +{ + CIAO_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::find_container_policies\n")); + // @@ Should we cache the properties that we consumed here? + + for (CORBA::ULong i = 0; i < properties.length (); ++i) + { + CIAO_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::find_container_policies processing property: %s\n", + properties[i].name.in ())); + + if (ACE_OS::strcmp ("ContainerPolicySet", properties[i].name) == 0) + { + const char *policy_name = 0; + if (properties[i].value >>= policy_name) + { + return this->config_manager_.find_policies_by_name (policy_name); + } + else + CIAO_ERROR_RETURN ((LM_ERROR, + "ERROR: RTNodeApp_Configurator::find_container_policies unable to extract ContainerPolicySet\n"), 0); + } + } + + return 0; +} + + +extern "C" CIAO_RTNA_Configurator_Export CIAO::NodeApp_Configurator *create_nodeapp_configurator (void); + +CIAO::NodeApp_Configurator * +create_nodeapp_configurator (void) +{ + CIAO::RTNodeApp_Configurator *config = 0; + ACE_NEW_RETURN (config, CIAO::RTNodeApp_Configurator, 0); + return config; +} diff --git a/CIAO/ciao/FTComponentServer/Configurators/RTNodeApp_Configurator.h b/CIAO/ciao/FTComponentServer/Configurators/RTNodeApp_Configurator.h new file mode 100644 index 00000000000..fc2388b6aff --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/RTNodeApp_Configurator.h @@ -0,0 +1,78 @@ +// $Id$ +/**======================================================== + * + * @file RTNodeApp_Configurator.h + * + * @Brief This file contains the implementation of + * the RTNodeApp_Configurator, a concrete NodeApp_Configurator for + * setting up real-time support for NodeApplication. + * + * + * @author Nanbor Wang <nanbor@exothermic.txcorp.com> + *========================================================*/ + +#ifndef RTNODEAPP_CONFIGURATOR_H +#define RTNODEAPP_CONFIGURATOR_H +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "NodeApp_Configurator.h" +#include "RTNA_Configurator_Export.h" +#include "tao/RTCORBA/RTCORBA.h" +#include "RTConfig_Manager.h" + +namespace CIAO +{ + /** + * @class RTNodeApp_Configurator + * + * @brief This class implements a concrete NodeApp_Configurator for + * setting up the NodeApplication process for RT support. + **/ + class CIAO_RTNA_Configurator_Export RTNodeApp_Configurator : + public NodeApp_Configurator + { + public: + /// Default destructor. + virtual ~RTNodeApp_Configurator (void); + + /** + * @brief "pre_orb_initialize" is called before ORB_init. + */ + virtual int pre_orb_initialize (void); + + /** + * @brief "initialize" is called after NodeApplication get a hold + * at this object. + */ + virtual int post_orb_initialize (CORBA::ORB_ptr o); + + /** + * @brief "init_resource_manager" is called by NodeApplication when + * it receives an "install" commands. + */ + virtual int + init_resource_manager (const ::Deployment::Properties &properties); + + /** + * @brief get a policyset by its name. + */ + virtual CORBA::PolicyList * + find_container_policies (const ::Deployment::Properties &properties); + + protected: + CORBA::ORB_var orb_; + + RTCORBA::RTORB_var rtorb_; + + RTResource_Config_Manager config_manager_; + }; +} + +#include /**/ "ace/post.h" +#endif /* RTNODEAPP_CONFIGURATOR_H */ diff --git a/CIAO/ciao/FTComponentServer/Configurators/Server_Configurator.cpp b/CIAO/ciao/FTComponentServer/Configurators/Server_Configurator.cpp new file mode 100755 index 00000000000..406817972de --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/Server_Configurator.cpp @@ -0,0 +1,334 @@ +// $Id$ + +#include "Server_Configurator.h" +#include "ace/Log_Msg.h" +#include "ciao/CIAO_common.h" +#include "ciao/ComponentServer/CIAO_ServerResourcesC.h" + +namespace CIAO +{ + namespace Deployment + { + + ComponentServer_Configurator::ComponentServer_Configurator (bool rt) + : rt_support_ (rt) + { + } + + ComponentServer_Configurator::~ComponentServer_Configurator (void) + { + // Not much to do. + } + + void + ComponentServer_Configurator::set_rt_support (void) + { + this->rt_support_ = 1; + } + + bool + ComponentServer_Configurator::rt_support (void) + { + return this->rt_support_; + } + + bool + ComponentServer_Configurator::create_config_managers (void) + { + typedef CIAO::Deployment::Config_Manager * (*na_intelligent_designer)(void); + typedef CIAO::Deployment::Config_Manager * (*rtna_intelligent_designer)(void); + CIAO::Deployment::Config_Manager* ptr = 0; + CIAO::Deployment::Config_Manager* rt_ptr = 0; + + int retval = this->config_dll_.open (/*ACE_DLL_PREFIX*/ ACE_TEXT ("CIAO_Basic_Config_Manager"), + ACE_DEFAULT_SHLIB_MODE, + 0); + + if (0 != retval) + { + CIAO_ERROR_RETURN ((LM_ERROR, + CLINFO "ComponentServer_Configurator - Error loading CIAO_Basic_Config_manager DLL: %p\n", + "dll.open"), + false); + } + + // Cast the void* to non-pointer type first - it's not legal to + // cast a pointer-to-object directly to a pointer-to-function. + void *void_ptr = + this->config_dll_.symbol (ACE_TEXT ("create_basic_config_manager")); + + ptrdiff_t tmp = reinterpret_cast<ptrdiff_t> (void_ptr); + + // "id" is for na_intelligent-designer. + na_intelligent_designer config_id = + reinterpret_cast<na_intelligent_designer> (tmp); + + if (0 == config_id) + { + CIAO_ERROR_RETURN ((LM_ERROR, + CLINFO "ComponentServer_Configurator - Error loading CIAO_Basic_Configurator entrypoint: %p\n", + "dll.symbol"), + false); + } + + ptr = config_id (); + + if (0 == ptr) + { + CIAO_ERROR_RETURN ((LM_ERROR, + CLINFO "ComponentServer_Configurator: Error creating ComponentServer_Configurator\n"), + false); + } + + this->na_config_manager_.reset (ptr); + + if (this->rt_support_) + { + int rt_retval = this->config_dll_.open (ACE_DLL_PREFIX ACE_TEXT ("CIAO_RTNA_Configurator"), + ACE_DEFAULT_SHLIB_MODE, + false); + + if (0 != rt_retval) + { + CIAO_ERROR_RETURN ((LM_ERROR, + "ComponentServer_Configurator - Error while loading CIAO_RTNA_Configurator: %p\n", + "dll.open"), + false); + } + + // Cast the void* to non-pointer type first - it's not legal to + // cast a pointer-to-object directly to a pointer-to-function. + void *rt_void_ptr = + this->config_dll_.symbol (ACE_TEXT ("create_rt_config_manager")); + ptrdiff_t rt_tmp = reinterpret_cast<ptrdiff_t> (rt_void_ptr); + + // "id" is for na_intelligent-designer. + rtna_intelligent_designer rt_config_id = + reinterpret_cast<rtna_intelligent_designer> (rt_tmp); + + if (0 == rt_config_id) + { + CIAO_ERROR_RETURN ((LM_ERROR, + CLINFO "ComponentServer_Configurator: Error while using RTNA entrypoint: %p", + "dll.symbol"), + false); + } + + rt_ptr = rt_config_id (); + + if (0 == rt_ptr) + { + CIAO_ERROR_RETURN ((LM_ERROR, + CLINFO "ComponentServer_Configurator: Error creating RTComponentServer_Configurator\n"), + false); + } + + this->rt_config_manager_.reset (rt_ptr); + } + + return true; + } + + int + ComponentServer_Configurator::pre_orb_initialize () + { + CIAO_DEBUG ((LM_TRACE,CLINFO "ComponentServer_Configurator::pre_orb_init\n")); + + (*this->na_config_manager_.get ()).pre_orb_initialize (); + if (this->rt_support_) + { + (*this->rt_config_manager_.get ()).pre_orb_initialize (); + } + + return 0; + } + + int + ComponentServer_Configurator::post_orb_initialize (CORBA::ORB_ptr o) + { + CIAO_DEBUG ((LM_TRACE, CLINFO "ComponentServer_Configurator::post_orb_init\n")); + this->orb_ = CORBA::ORB::_duplicate (o); + + (*this->na_config_manager_.get ()).init (this->orb_.in ()); + if (this->rt_support_ == 1) + { + (*this->rt_config_manager_.get ()).init (this->orb_.in ()); + } + + (*this->na_config_manager_.get ()).post_orb_initialize (this->orb_.in ()); + if (this->rt_support_ == 1) + { + (*this->rt_config_manager_.get ()).post_orb_initialize (this->orb_.in ()); + } + + return 0; + } + + int + ComponentServer_Configurator::init_resource_manager + (const ::Components::ConfigValues &properties) + { + for (CORBA::ULong i = 0; i < properties.length (); ++i) + { + if (ACE_OS::strcmp ("CIAOServerResources", properties[i]->name ()) == 0) + { + const ServerResource *svr_resource; + if (properties[i]->value () >>= svr_resource) + { + (*this->na_config_manager_.get ()). + init_resources (*svr_resource); + + if (this->rt_support_ == 1) + { + (*this->rt_config_manager_.get ()). + init_resources (*svr_resource); + } + } + else + { + CIAO_ERROR_RETURN ((LM_ERROR, + CLINFO "ERROR: ComponentServer_Configurator::" + "init_resource_manager unable to extract" + "CIAOServerResources\n"), -1); + } + } + } + + return 0; + } + + CORBA::PolicyList * + ComponentServer_Configurator::find_container_policies + (const ::Components::ConfigValues &properties) + { + if (!this->na_config_manager_.get ()) + return 0; + + CORBA::PolicyList *configured_policies = 0; + CORBA::PolicyList *rt_configured_policies = 0; + + for (CORBA::ULong i = 0; i < properties.length (); ++i) + { + if (ACE_OS::strcmp ("ContainerPolicySet", properties[i]->name ()) == 0) + { + const char *policy_name; + if (properties[i]->value () >>= policy_name) + { + configured_policies = (*this->na_config_manager_.get ()). + find_policies_by_name (policy_name); + + CORBA::ULong p_length = 0; + if (configured_policies != 0) + { + p_length = configured_policies->length (); + } + + if (this->rt_support_ == 1) + { + rt_configured_policies = (*this->rt_config_manager_.get ()). + find_policies_by_name (policy_name); + } + + CORBA::PolicyList_var temp_policies; + CORBA::ULong rtp_length = 0; + if (rt_configured_policies != 0) + { + rtp_length = rt_configured_policies->length (); + temp_policies = rt_configured_policies; + } + else + { + return configured_policies; + } + + CORBA::ULong final_length = p_length + rtp_length; + temp_policies->length (final_length); + + for (CORBA::ULong i = 0; i < p_length; ++i) + { + temp_policies[i+rtp_length] = + CORBA::Policy::_duplicate ((*configured_policies)[i]); + } + return temp_policies._retn (); + } + else + { + CIAO_ERROR_RETURN ((LM_ERROR, + CLINFO "ERROR: ComponentServer_Configurator:" + "find_container_policies unable to extract" + "ContainerPolicySet\n"), 0); + } + } + } + return 0; + } + + CORBA::PolicyList * + ComponentServer_Configurator::find_policies_by_name (const char *policy_name) + { + if (!this->na_config_manager_.get ()) + return 0; + + CORBA::PolicyList *configured_policies = 0; + CORBA::PolicyList *rt_configured_policies = 0; + + configured_policies = (*this->na_config_manager_.get ()). + find_policies_by_name (policy_name); + + CORBA::ULong p_length = 0; + if (configured_policies != 0) + { + p_length = configured_policies->length (); + } + + if (this->rt_support_ == 1) + { + rt_configured_policies = (*this->rt_config_manager_.get ()). + find_policies_by_name (policy_name); + } + + CORBA::PolicyList_var temp_policies; + CORBA::ULong rtp_length = 0; + if (rt_configured_policies != 0) + { + rtp_length = rt_configured_policies->length (); + temp_policies = rt_configured_policies; + } + else + { + return configured_policies; + } + + CORBA::ULong final_length = p_length + rtp_length; + temp_policies->length (final_length); + + for (CORBA::ULong i = 0; i < p_length; ++i) + { + temp_policies[i+rtp_length] = + CORBA::Policy::_duplicate ((*configured_policies)[i]); + } + return temp_policies._retn (); + } + + bool + ComponentServer_Configurator::policy_exists (const char *policy_set_id) + { + if (!this->na_config_manager_.get ()) + return 0; + + bool result; + result = (*this->na_config_manager_.get ()). + policy_exists (policy_set_id); + + if (result == false) + { + if (this->rt_support_ == 1) + { + result = (*this->rt_config_manager_.get ()). + policy_exists (policy_set_id); + } + } + return result; + } + } +} diff --git a/CIAO/ciao/FTComponentServer/Configurators/Server_Configurator.h b/CIAO/ciao/FTComponentServer/Configurators/Server_Configurator.h new file mode 100644 index 00000000000..4a8074b083d --- /dev/null +++ b/CIAO/ciao/FTComponentServer/Configurators/Server_Configurator.h @@ -0,0 +1,125 @@ +//$Id$ +/**======================================================== + * + * @file ComponentServer_Configurator.h + * + * @Brief This file contains the implementation of + * the basic ComponentServer_Configurator interface, the one + * that does nothing more + * + * @author Nanbor Wang <nanbor@exothermic.txcorp.com> + *========================================================*/ + +#ifndef COMPONENTSERVER_CONFIGURATOR_H +#define COMPONENTSERVER_CONFIGURATOR_H +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/DLL.h" +#include "ace/Auto_Ptr.h" +#include "ccm/CCM_StandardConfiguratorC.h" +#include "ComponentServer_Configurator_export.h" +#include "Config_Manager.h" + +namespace CIAO +{ + namespace Deployment + { + /** + * + * @class ComponentServer_Configurator + * + * @brief This class defines and implements the default + * ComponentServer_Configurator base class that's needed for configuring the + * ComponentServer application process. + **/ + class ComponentServer_Configurator_Export ComponentServer_Configurator + { + public: + + /// Default constructor. + ComponentServer_Configurator (bool rt); + + /// Default destructor. + virtual ~ComponentServer_Configurator (void); + + /** + * @brief "pre_orb_initialize" is called before ORB_init. + */ + virtual int pre_orb_initialize (void); + + /** + * @brief "post_orb_initialize" is called after ComponentServer + * get a hold at this object. + */ + virtual int post_orb_initialize (CORBA::ORB_ptr o); + + /** + * @brief "init_resource_manager" is called by ComponentServer when + * it receives an "install" commands. + */ + virtual int + init_resource_manager (const ::Components::ConfigValues &properties); + + /** + * @brief get a policyset by its name. + */ + virtual CORBA::PolicyList * + find_container_policies (const ::Components::ConfigValues &properties); + + /// @@ Perhaps we also need a finalizer method here. Perhaps we + /// even need to differentiate finalizer before ORB is destroyed + /// and the one after that. + + bool rt_support (void); + + void set_rt_support (void); + + virtual bool create_config_managers (void); + + bool policy_exists (const char *policy_set_id); + + CORBA::PolicyList * + find_policies_by_name (const char *name); + + protected: + + int rt_support_; + + CORBA::ORB_var orb_; + + auto_ptr<Config_Manager> rt_config_manager_; + + auto_ptr<Config_Manager> na_config_manager_; + + ACE_DLL config_dll_; + }; + } +} + +/** + * For dynamically linkable concrete ComponentServer_Configurator + * implementation, remember to create a factory method using "C" + * calling convention in the CPP file as follow: + + extern "C" EXPORT_MACRO CIAO::ComponentServer_Configurator *create_nodeapp_configurator (void); + + CIAO::ComponentServer_Configurator * + create_nodeapp_configurator (void) + { + concrete_ComponentServer_Configurator *config; + ACE_NEW_RETURN (config, concrete_ComponentServer_Configurator, 0); + return config; + } + +*/ + + +#include /**/ "ace/post.h" +#endif /* NODEAPP_CONFIGURATOR_H */ + diff --git a/CIAO/ciao/FTComponentServer/ServerInterceptor/IOR_Interceptor.cpp b/CIAO/ciao/FTComponentServer/ServerInterceptor/IOR_Interceptor.cpp new file mode 100644 index 00000000000..6ee65169257 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/ServerInterceptor/IOR_Interceptor.cpp @@ -0,0 +1,63 @@ +#include "IOR_Interceptor.h" +#include "ObjectReferenceFactory.h" +#include "tao/ORB_Constants.h" + +ACE_RCSID (Hello, + IOR_Interceptor, + "$Id$") + +IOR_Interceptor::IOR_Interceptor (void) +{ +} + +char * +IOR_Interceptor::name (void) +{ + return CORBA::string_dup ("IOR_Interceptor"); +} + +void +IOR_Interceptor::destroy (void) +{ +} + +void +IOR_Interceptor::establish_components ( + PortableInterceptor::IORInfo_ptr /* info */) +{ +} + +void +IOR_Interceptor::components_established ( + PortableInterceptor::IORInfo_ptr info) +{ + PortableInterceptor::ObjectReferenceFactory_var old_orf = + info->current_factory (); + + PortableInterceptor::ObjectReferenceFactory * tmp; + ACE_NEW_THROW_EX (tmp, + ObjectReferenceFactory (old_orf.in ()), + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + + PortableInterceptor::ObjectReferenceFactory_var orf = tmp; + + info->current_factory (orf.in ()); +} + +void +IOR_Interceptor::adapter_manager_state_changed ( + const char *, + PortableInterceptor::AdapterState) +{ +} + +void +IOR_Interceptor:: adapter_state_changed ( + const PortableInterceptor::ObjectReferenceTemplateSeq &, + PortableInterceptor::AdapterState) +{ +} diff --git a/CIAO/ciao/FTComponentServer/ServerInterceptor/IOR_Interceptor.h b/CIAO/ciao/FTComponentServer/ServerInterceptor/IOR_Interceptor.h new file mode 100644 index 00000000000..ca75d85160f --- /dev/null +++ b/CIAO/ciao/FTComponentServer/ServerInterceptor/IOR_Interceptor.h @@ -0,0 +1,64 @@ +// -*- C++ -*- + +#ifndef IOR_INTERCEPTOR_H +#define IOR_INTERCEPTOR_H + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/IORInterceptor/IORInterceptor.h" +#include "tao/PortableInterceptorC.h" +#include "tao/LocalObject.h" + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +class IOR_Interceptor + : public virtual PortableInterceptor::IORInterceptor_3_0, + public virtual TAO_Local_RefCounted_Object +{ +public: + + IOR_Interceptor (void); + + /** + * @name Methods Required by the IOR Interceptor Interface + * + * These are methods that must be implemented since they are pure + * virtual in the abstract base class. They are the canonical + * methods required for all IOR interceptors. + */ + //@{ + /// Return the name of this IORInterceptor. + virtual char * name (void); + + /// Cleanup resources acquired by this IORInterceptor. + virtual void destroy (void); + + /// Add the tagged components to the IOR. + virtual void establish_components ( + PortableInterceptor::IORInfo_ptr info); + + virtual void components_established ( + PortableInterceptor::IORInfo_ptr info); + + virtual void adapter_manager_state_changed ( + const char * id, + PortableInterceptor::AdapterState state); + + virtual void adapter_state_changed ( + const PortableInterceptor::ObjectReferenceTemplateSeq & templates, + PortableInterceptor::AdapterState state); + +}; + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#endif /* IOR_INTERCEPTOR_H */ diff --git a/CIAO/ciao/FTComponentServer/ServerInterceptor/ObjectReferenceFactory.cpp b/CIAO/ciao/FTComponentServer/ServerInterceptor/ObjectReferenceFactory.cpp new file mode 100644 index 00000000000..b3b5e80c70b --- /dev/null +++ b/CIAO/ciao/FTComponentServer/ServerInterceptor/ObjectReferenceFactory.cpp @@ -0,0 +1,55 @@ +#include "ObjectReferenceFactory.h" +#include "tao/PortableServer/PortableServer.h" +#include "tao/Stub.h" +#include "tao/Profile.h" +#include "tao/debug.h" + +ACE_RCSID (Hello, + ObjectReferenceFactory, + "$Id$") + +ObjectReferenceFactory::ObjectReferenceFactory ( + PortableInterceptor::ObjectReferenceFactory * old_orf) + : old_orf_ (old_orf) +{ + CORBA::add_ref (old_orf); +} + +ObjectReferenceFactory::~ObjectReferenceFactory (void) +{ +} + +CORBA::Object_ptr +ObjectReferenceFactory::make_object ( + const char *repository_id, + const PortableInterceptor::ObjectId & id) +{ + ACE_ASSERT (repository_id != 0); + + CORBA::String_var s = PortableServer::ObjectId_to_string (id); + + CORBA::Object_var ref = this->old_orf_->make_object (repository_id, id); + + TAO_MProfile &mp = ref->_stubobj ()->base_profiles (); + + IOP::TaggedComponent mytag; + const char* tag = s.in (); + CORBA::ULong tag_id = 9654; + size_t tag_length = ACE_OS::strlen (tag); + mytag.tag = tag_id; + mytag.component_data.length (tag_length + 1); + + CORBA::Octet *buf = mytag.component_data.get_buffer (); + ACE_OS::memcpy (buf, tag, tag_length + 1); + buf[tag_length] = '\0'; + + const CORBA::ULong profile_count = mp.profile_count (); + + for (CORBA::ULong i = 0; i < profile_count; ++i) + { + TAO_Profile *profile = mp.get_profile (i); + profile->add_tagged_component (mytag); + } + + return ref._retn (); +} diff --git a/CIAO/ciao/FTComponentServer/ServerInterceptor/ObjectReferenceFactory.h b/CIAO/ciao/FTComponentServer/ServerInterceptor/ObjectReferenceFactory.h new file mode 100644 index 00000000000..eec42bb929c --- /dev/null +++ b/CIAO/ciao/FTComponentServer/ServerInterceptor/ObjectReferenceFactory.h @@ -0,0 +1,65 @@ +// -*- C++ -*- + +#ifndef TAO_OBJECT_REFERENCE_FACTORY_H +#define TAO_OBJECT_REFERENCE_FACTORY_H + +#include "ObjectReferenceFactoryC.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +class ObjectReferenceFactory + : public virtual OBV_lwft::ObjectReferenceFactory + , public virtual CORBA::DefaultValueRefCountBase +{ + public: + + /// Constructor + ObjectReferenceFactory ( + PortableInterceptor::ObjectReferenceFactory * old_orf); + + /** + * @name PortableInterceptor::ObjectReferenceFactory Methods + * + * Methods required by the + * PortableInterceptor::ObjectReferenceFactory interface. + */ + //@{ + virtual CORBA::Object_ptr make_object ( + const char *repository_id, + const PortableInterceptor::ObjectId & id); + //@} + +protected: + + /// Destructor + /** + * Protected destructor to enforce proper memory management via + * reference counting. + */ + ~ObjectReferenceFactory (void); + +private: + + /// The old ObjectReferenceFactory used to create object references. + /** + * This ObjectReferenceFactory will still be used when creating + * object references. However, it will be invoked through this + * ObjectReferenceFactory. + */ + PortableInterceptor::ObjectReferenceFactory_var old_orf_; + +}; + + +#if defined (_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#endif /* TAO_OBJECT_REFERENCE_FACTORY_H */ diff --git a/CIAO/ciao/FTComponentServer/ServerInterceptor/ObjectReferenceFactory.idl b/CIAO/ciao/FTComponentServer/ServerInterceptor/ObjectReferenceFactory.idl new file mode 100644 index 00000000000..36623e2728d --- /dev/null +++ b/CIAO/ciao/FTComponentServer/ServerInterceptor/ObjectReferenceFactory.idl @@ -0,0 +1,16 @@ +// -*- IDL -*- + +#ifndef OBJECT_REFERENCE_FACTORY_IDL +#define OBJECT_REFERENCE_FACTORY_IDL + +#include "tao/ObjRefTemplate/ObjectReferenceTemplate_include.pidl" + +module lwft +{ + + valuetype ObjectReferenceFactory + : PortableInterceptor::ObjectReferenceFactory {}; + +}; + +#endif /* OBJECT_REFERENCE_FACTORY_IDL */ diff --git a/CIAO/ciao/FTComponentServer/ServerInterceptor/ServerInterceptor.mpc b/CIAO/ciao/FTComponentServer/ServerInterceptor/ServerInterceptor.mpc new file mode 100644 index 00000000000..97984c868dd --- /dev/null +++ b/CIAO/ciao/FTComponentServer/ServerInterceptor/ServerInterceptor.mpc @@ -0,0 +1,16 @@ +project(*) : rtportableserver, pi_server, interceptors, iorinterceptor, taoidldefaults, ciao_lib { + dynamicflags = SI_BUILD_DLL + idlflags += -Wb,export_macro=SI_Export -Wb,export_include=si_export.h + + IDL_Files { + idlflags += -SS + ObjectReferenceFactory.idl + } + + Source_Files { + ObjectReferenceFactory.cpp + ObjectReferenceFactoryC.cpp + ServerORBInitializer.cpp + IOR_Interceptor.cpp + } +} diff --git a/CIAO/ciao/FTComponentServer/ServerInterceptor/ServerORBInitializer.cpp b/CIAO/ciao/FTComponentServer/ServerInterceptor/ServerORBInitializer.cpp new file mode 100644 index 00000000000..0d8a3e735be --- /dev/null +++ b/CIAO/ciao/FTComponentServer/ServerInterceptor/ServerORBInitializer.cpp @@ -0,0 +1,47 @@ +#include "ServerORBInitializer.h" +#include "IOR_Interceptor.h" +#include "tao/ORB_Constants.h" +#include "tao/PortableServer/PortableServer.h" + +ACE_RCSID (Hello, + ServerORBInitializer, + "$Id$") + +void +ServerORBInitializer::pre_init ( + PortableInterceptor::ORBInitInfo_ptr /* info */) +{ +} + +void +ServerORBInitializer::post_init ( + PortableInterceptor::ORBInitInfo_ptr info) +{ + + CORBA::Object_var obj = + info->resolve_initial_references ("POACurrent"); + + PortableServer::Current_var poa_current = + PortableServer::Current::_narrow (obj.in ()); + + ACE_ASSERT (!CORBA::is_nil (poa_current.in ())); + + + CORBA::String_var orb_id = info->orb_id (); + + // Create and register the test's IORInterceptor + + PortableInterceptor::IORInterceptor_ptr ior_intercept; + ACE_NEW_THROW_EX (ior_intercept, + IOR_Interceptor, + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + + PortableInterceptor::IORInterceptor_var ior_interceptor = + ior_intercept; + + info->add_ior_interceptor (ior_interceptor.in ()); +} diff --git a/CIAO/ciao/FTComponentServer/ServerInterceptor/ServerORBInitializer.h b/CIAO/ciao/FTComponentServer/ServerInterceptor/ServerORBInitializer.h new file mode 100644 index 00000000000..d89802b15d6 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/ServerInterceptor/ServerORBInitializer.h @@ -0,0 +1,52 @@ +// -*- C++ -*- + +#ifndef SERVER_ORB_INITIALIZER_H +#define SERVER_ORB_INITIALIZER_H + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PI/PI.h" +#include "tao/LocalObject.h" + +#include "si_export.h" + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +class SI_Export ServerORBInitializer + : public virtual PortableInterceptor::ORBInitializer, + public virtual TAO_Local_RefCounted_Object +{ +public: + + /** + * @name Methods Required by the ORBInitializer Interface + * + * These are methods that must be implemented since they are pure + * virtual in the abstract base class. They are the canonical + * methods required for all ORB initializers. + */ + //@{ + /// The pre-initialization hook. + virtual void pre_init ( + PortableInterceptor::ORBInitInfo_ptr info); + + /// The post-initialization hook. + virtual void post_init ( + PortableInterceptor::ORBInitInfo_ptr info); + //@} + +}; + + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#endif /* SERVER_ORB_INITIALIZER_H */ diff --git a/CIAO/ciao/FTComponentServer/ServerInterceptor/si_export.h b/CIAO/ciao/FTComponentServer/ServerInterceptor/si_export.h new file mode 100644 index 00000000000..03f8cf1951d --- /dev/null +++ b/CIAO/ciao/FTComponentServer/ServerInterceptor/si_export.h @@ -0,0 +1,57 @@ +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl SI +// ------------------------------ +#ifndef SI_EXPORT_H +#define SI_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (SI_HAS_DLL) +# define SI_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && SI_HAS_DLL */ + +#if !defined (SI_HAS_DLL) +# define SI_HAS_DLL 1 +#endif /* ! SI_HAS_DLL */ + +#if defined (SI_HAS_DLL) && (SI_HAS_DLL == 1) +# if defined (SI_BUILD_DLL) +# define SI_Export ACE_Proper_Export_Flag +# define SI_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define SI_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* SI_BUILD_DLL */ +# define SI_Export ACE_Proper_Import_Flag +# define SI_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define SI_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* SI_BUILD_DLL */ +#else /* SI_HAS_DLL == 1 */ +# define SI_Export +# define SI_SINGLETON_DECLARATION(T) +# define SI_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* SI_HAS_DLL == 1 */ + +// Set SI_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (SI_NTRACE) +# if (ACE_NTRACE == 1) +# define SI_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define SI_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !SI_NTRACE */ + +#if (SI_NTRACE == 1) +# define SI_TRACE(X) +#else /* (SI_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define SI_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (SI_NTRACE == 1) */ + +#endif /* SI_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/CorbaStateUpdate.cpp b/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/CorbaStateUpdate.cpp new file mode 100644 index 00000000000..00a3872d2f3 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/CorbaStateUpdate.cpp @@ -0,0 +1,29 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file CorbaStateUpdate.cpp + * + * $Id$ + * + * @author Friedhelm Wolf (fwolf@dre.vanderbilt.edu) + */ +//============================================================================= + +#include "CorbaStateUpdate.h" + +CorbaStateUpdate::CorbaStateUpdate(ReplicatedApplication_ptr application) + : application_ (ReplicatedApplication::_duplicate (application)) +{ +} + +CorbaStateUpdate::~CorbaStateUpdate() +{ +} + +void +CorbaStateUpdate::set_state (const ::CORBA::Any & state_value) +{ + if (!CORBA::is_nil (application_.in ())) + application_->set_state (state_value); +} diff --git a/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/CorbaStateUpdate.h b/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/CorbaStateUpdate.h new file mode 100644 index 00000000000..c98d9e592f7 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/CorbaStateUpdate.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file CorbaStateUpdate.h + * + * $Id$ + * + * @author Friedhelm Wolf (fwolf@dre.vanderbilt.edu) + */ +//============================================================================= + +#ifndef _CORBA_STATE_UPDATE_H_ +#define _CORBA_STATE_UPDATE_H_ + +#include "StatefulObject.h" +#include "ReplicatedApplicationC.h" + +/** + * @class CorbaStateUpdate + * + * @brief Implementation of the StatefulObject interface that uses + * a ReplicatedApplication CORBA object to disseminate state information + */ +class CorbaStateUpdate : public StatefulObject +{ +public: + + /// ctor + CorbaStateUpdate (ReplicatedApplication_ptr application); + + /// dtor + virtual ~CorbaStateUpdate (); + + /// method to set the + virtual void set_state (const ::CORBA::Any & state_value); + +private: + ReplicatedApplication_var application_; +}; + +#endif /* _CORBA_STATE_UPDATE_H_ */ diff --git a/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/SSA.mpc b/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/SSA.mpc new file mode 100644 index 00000000000..fde9367460a --- /dev/null +++ b/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/SSA.mpc @@ -0,0 +1,16 @@ +project(*Agent) : portableserver, ciao_lib { + + after += FTCommonIdl + macros += SSA_EXPORT_BUILD_DLL + libs += FTCommonIdl + includes += ../CommonIDL + + IDL_Files { + } + + Source_Files { + StatefulObject.cpp + CorbaStateUpdate.cpp + StateSynchronizationAgent_i.cpp + } +} diff --git a/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/StateSynchronizationAgent_i.cpp b/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/StateSynchronizationAgent_i.cpp new file mode 100644 index 00000000000..ba3eaf6ca70 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/StateSynchronizationAgent_i.cpp @@ -0,0 +1,376 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file StateSynchronizationAgent_i.cpp + * + * $Id$ + * + * @author Friedhelm Wolf (fwolf@dre.vanderbilt.edu) + */ +//============================================================================= + +#include "StateSynchronizationAgent_i.h" +#include "CorbaStateUpdate.h" + +#ifdef FLARE_USES_DDS +# include "DDSStateUpdate_T.h" +# include "StateDcps_impl.h" +#endif + +StateSynchronizationAgent_i::StateSynchronizationAgent_i ( + CORBA::ORB_ptr orb, + const std::string & host_id, + const std::string & process_id, + bool use_corba) + : orb_ (CORBA::ORB::_duplicate (orb)), + host_id_ (host_id), + process_id_ (process_id), +#ifdef FLARE_USES_DDS + domain_id_ (0), + domain_participant_ (DDS::DomainParticipant::_nil ()), + publisher_ (DDS::Publisher::_nil ()), + subscriber_ (DDS::Subscriber::_nil ()), +#endif /* FLARE_USES_DDS */ + use_corba_ (use_corba) +{ +#ifdef FLARE_USES_DDS + if (!use_corba_) + { + if (!this->create_participant ()) + throw DDSFailure ("SSA could not create DDS participant\n"); + + if (!this->create_publisher ()) + throw DDSFailure ("SSA could not create DDS publisher\n"); + + if (!this->create_subscriber ()) + throw DDSFailure ("SSA could not create DDS subscriber\n"); + } +#endif /* FLARE_USES_DDS */ +} + +StateSynchronizationAgent_i::~StateSynchronizationAgent_i () +{ +#ifdef FLARE_USES_DDS + if (!use_corba_) + { + this->delete_subscriber (); + this->delete_publisher (); + this->delete_participant (); + } +#endif /* FLARE_USES_DDS */ +} + +void +StateSynchronizationAgent_i::state_changed (const char * object_id) +{ + ACE_DEBUG ((LM_TRACE, + "SSA::state_changed (%s) called.\n", + object_id)); + + // get application reference + ReplicatedApplication_var app; + + if (application_map_.find (ACE_CString (object_id), + app) != 0) + { + ACE_DEBUG ((LM_ERROR, + "(%P|%t) SSA::state_changed () " + "could not find application for object id %s\n", + object_id)); + return; + } + + // get state from the application + CORBA::Any_var state; + try + { + state = app->get_state (); + } + catch (const CORBA::SystemException& ex) + { + ACE_DEBUG ((LM_ERROR, + "(%P|%t) SSA::state_changed () " + "exception whil calling the get_state method for application %s:\n" + "%s", + object_id, ex._info ().c_str ())); + return; + } + + // send state to each element in the replica_map_ + REPLICA_OBJECT_LIST replica_group; + if (replica_map_.find (ACE_CString (object_id), + replica_group) != 0) + { + ACE_DEBUG ((LM_ERROR, + "(%P|%t) SSA::state_changed () " + "could not find replicas for the application %s\n", + object_id)); + return; + } + + ReplicatedApplication_var replica; + for (REPLICA_OBJECT_LIST::iterator it = replica_group.begin (); + it != replica_group.end (); + ++it) + { + try + { + // set the state on this replica + (*it)->set_state (state.in ()); + } + catch (const CORBA::SystemException& ex) + { + ACE_DEBUG ((LM_WARNING, + "(%P|%t) SSA::state_changed () " + "exception while contacting a server replica for %s.\n", + object_id)); + } + } +} + +void +StateSynchronizationAgent_i::update_rank_list (const RankList & rank_list) +{ + if (use_corba_) + { + // protect operations on the map + ACE_Guard <ACE_Thread_Mutex> guard (replica_map_mutex_); + + // reset content of the internal map + replica_map_.close(); + replica_map_.open(); + + ACE_DEBUG ((LM_TRACE, "SSA::update_rank_list with:\n")); + + // for each replication group in the replica group list + for (size_t i = 0; i < rank_list.length (); ++i) + { + ACE_DEBUG ((LM_TRACE, "\toid = %s (%d entries)\n", + rank_list[i].object_id.in (), + rank_list.length ())); + + // use the application id as a key for the map + ACE_CString oid (rank_list[i].object_id); + + // create a new list for every replication group + REPLICA_OBJECT_LIST replica_object_list; + + // for each entry of a replica group + for (size_t j = 0; j < rank_list[i].ior_list.length (); ++j) + { + try + { + // it is assumed that the strings identifying rank_list are + // stringified object references and can be resolved + // and used to contact the corresponding StateSynchronizationAgent + replica_object_list.push_back ( + STATEFUL_OBJECT_PTR ( + new CorbaStateUpdate ( + ReplicatedApplication::_narrow (rank_list[i].ior_list[j])))); + } + catch (const CORBA::SystemException& ex) + { + ACE_DEBUG ((LM_WARNING, + "(%P|%t) SSA::" + "update_replica_groups could not resolve stringified " + "object reference %s\n", + rank_list[i].ior_list[j].in ())); + } + } + + // add one replication group to the map + replica_map_.bind (oid, replica_object_list); + } + } // end if (use_corba_) +} + +void +StateSynchronizationAgent_i::register_application (const char * object_id, + ReplicatedApplication_ptr app) +{ + ACE_DEBUG ((LM_TRACE, "SSA::register_application (%s) called.\n", object_id)); + + ACE_CString oid (object_id); + + if (application_map_.bind (oid, ReplicatedApplication::_duplicate (app)) < 0) + { + ACE_DEBUG ((LM_WARNING, + "(%P|%t) SSA::register_application () " + "could not bind application %s to the map successfully\n", + object_id)); + } + +#ifdef FLARE_USES_DDS + + // if we use DDS for communication + if (!use_corba_) + { + try + { + // protect operations on the map + ACE_Guard <ACE_Thread_Mutex> guard (replica_map_mutex_); + + ACE_DEBUG ((LM_TRACE, "SSA::register_application add DDS participant" + " for application %s\n", object_id)); + + // create a new list which will have only one entry for DDS + REPLICA_OBJECT_LIST replica_object_list; + + // register a DDS participant for this application + replica_object_list.push_back ( + STATEFUL_OBJECT_PTR ( + new DDSStateUpdate_T <CORBA::Long, + State, + StateTypeSupport, + StateDataWriter, + StateDataReader, + StateSeq> ( + oid.c_str (), + this->get_unique_id (oid.c_str ()), + domain_participant_.in (), + publisher_.in (), + subscriber_.in (), + app))); + + ACE_CString oid (object_id); + + // this should work without doing a rebind, since there is only + // one application of the same type per process + replica_map_.bind (oid, replica_object_list); + } + catch (const DDSFailure & ex) + { + std::cerr << "SSA::register_application () DDS problem : " + << ex.description () + << std::endl; + } + } + +#endif /* FLARE_USES_DDS */ +} + +#ifdef FLARE_USES_DDS + +bool +StateSynchronizationAgent_i::create_participant () +{ + DDS::DomainParticipantFactory_var dpf + = DDS::DomainParticipantFactory::get_instance (); + + if (CORBA::is_nil (dpf.in ())) + { + return false; + } + + domain_participant_ = + dpf->create_participant (domain_id_, + PARTICIPANT_QOS_DEFAULT, + DDS::DomainParticipantListener::_nil (), + DDS::ANY_STATUS); + + if (CORBA::is_nil (domain_participant_.in ())) + { + return false; + } + + return true; +} + +bool +StateSynchronizationAgent_i::delete_participant () +{ + DDS::DomainParticipantFactory_var dpf + = DDS::DomainParticipantFactory::get_instance (); + + if (CORBA::is_nil (dpf.in ())) + { + return false; + } + + DDS::ReturnCode_t status = + dpf->delete_participant (domain_participant_.in ()); + + if (status != DDS::RETCODE_OK) + { + return false; + } + + return true; +} + +bool +StateSynchronizationAgent_i::create_publisher () +{ + DDS::PublisherQos pub_qos; + domain_participant_->get_default_publisher_qos (pub_qos); + + publisher_ = + domain_participant_->create_publisher (pub_qos, + DDS::PublisherListener::_nil (), + DDS::ANY_STATUS); + + if (CORBA::is_nil (publisher_.in ())) + { + return false; + } + + return true; +} + +bool +StateSynchronizationAgent_i::delete_publisher () +{ + DDS::ReturnCode_t status = + domain_participant_->delete_publisher (publisher_.in ()); + + if (status != DDS::RETCODE_OK) + { + return false; + } + + return true; +} + +bool +StateSynchronizationAgent_i::create_subscriber () +{ + subscriber_ = + domain_participant_->create_subscriber (SUBSCRIBER_QOS_DEFAULT, + DDS::SubscriberListener::_nil (), + DDS::ANY_STATUS); + + if (CORBA::is_nil (subscriber_.in ())) + { + return false; + } + + return true; +} + +bool +StateSynchronizationAgent_i::delete_subscriber () +{ + DDS::ReturnCode_t status = + domain_participant_->delete_subscriber (subscriber_.in ()); + + if (status != DDS::RETCODE_OK) + { + return false; + } + + return true; +} + +#endif /* FLARE_USES_DDS */ + +std::string +StateSynchronizationAgent_i::get_unique_id (const std::string & app_name) +{ + std::string unique_id (app_name); + + // make name unique by adding host and process id + unique_id += "_" + host_id_ + "_" + process_id_; + + return unique_id; +} diff --git a/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/StateSynchronizationAgent_i.h b/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/StateSynchronizationAgent_i.h new file mode 100644 index 00000000000..69c6900971a --- /dev/null +++ b/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/StateSynchronizationAgent_i.h @@ -0,0 +1,125 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file StateSynchronizationAgent_i.h + * + * $Id$ + * + * @author Friedhelm Wolf (fwolf@dre.vanderbilt.edu) + */ +//============================================================================= + +#ifndef _REPLICATION_AGENT_I_H_ +#define _REPLICATION_AGENT_I_H_ +#include <list> +#include "ace/Hash_Map_Manager_T.h" +#include "ace/Thread_Mutex.h" +#include "ace/Refcounted_Auto_Ptr.h" +#include "StateSynchronizationAgentS.h" +#include "StatefulObject.h" +#include "ssa_export.h" + +#if defined (FLARE_USES_DDS) +# include <ccpp_dds_dcps.h> +# include "DDSFailure.h" +#endif + +class SSA_Export StateSynchronizationAgent_i : public POA_StateSynchronizationAgent +{ + public: + /// ctor + /// @param reference to a simple long value representing + /// the state of the application + StateSynchronizationAgent_i (CORBA::ORB_ptr orb, + const std::string & host_id, + const std::string & process_id, + bool use_corba = true); + + /// dtor + ~StateSynchronizationAgent_i (); + + /// implementation of the StateSynchronizationAgent interface + virtual void state_changed (const char * object_id); + + /// implementation of the StateSynchronizationAgent interface + virtual void update_rank_list (const RankList & rank_list); + + /// implementation of the StateSynchronizationAgent interface + virtual void register_application (const char * object_id, + ReplicatedApplication_ptr app); + + typedef ACE_Refcounted_Auto_Ptr <StatefulObject, + ACE_Null_Mutex> STATEFUL_OBJECT_PTR; + + typedef std::list<STATEFUL_OBJECT_PTR> REPLICA_OBJECT_LIST; + + typedef ACE_Hash_Map_Manager_Ex< + ACE_CString, + REPLICA_OBJECT_LIST, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> OBJECTID_REPLICA_MAP; + + typedef ACE_Hash_Map_Manager_Ex< + ACE_CString, + ReplicatedApplication_var, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> OBJECTID_APPLICATION_MAP; + + private: + +#ifdef FLARE_USES_DDS + + bool create_participant (); + bool delete_participant (); + bool create_publisher (); + bool delete_publisher (); + bool create_subscriber (); + bool delete_subscriber (); + +#endif /* FLARE_USES_DDS */ + + std::string get_unique_id (const std::string & app_name); + + private: + /// orb reference + CORBA::ORB_var orb_; + + /// host on which the agent is running + std::string host_id_; + + /// process in which the agent is running + std::string process_id_; + + /// keeps lists of replicas associated to application ids + OBJECTID_REPLICA_MAP replica_map_; + + /// keeps references to all applications running in this process + OBJECTID_APPLICATION_MAP application_map_; + + /// mutex for multithreaded access of the replica map + ACE_Thread_Mutex replica_map_mutex_; + +#ifdef FLARE_USES_DDS + + /// id of the DDS domain + DDS::DomainId_t domain_id_; + + /// DDS Domain Participant + DDS::DomainParticipant_var domain_participant_; + + /// DDS Publisher for this Domain + DDS::Publisher_var publisher_; + + /// DDS Subscriber for this Domain + DDS::Subscriber_var subscriber_; + +#endif /* FLARE_USES_DDS */ + + /// decides whether replicas should be updated through corba or dds + bool use_corba_; +}; + +#endif /* _REPLICATED_APPLICATION_H_ */ diff --git a/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/StatefulObject.cpp b/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/StatefulObject.cpp new file mode 100644 index 00000000000..0b8bdfcedbc --- /dev/null +++ b/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/StatefulObject.cpp @@ -0,0 +1,21 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file StatefulObject.cpp + * + * $Id$ + * + * @author Friedhelm Wolf (fwolf@dre.vanderbilt.edu) + */ +//============================================================================= + +#include "StatefulObject.h" + +StatefulObject::StatefulObject() +{ +} + +StatefulObject::~StatefulObject() +{ +} diff --git a/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/StatefulObject.h b/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/StatefulObject.h new file mode 100644 index 00000000000..40e63f5e675 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/StatefulObject.h @@ -0,0 +1,44 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file StatefulObject.h + * + * $Id$ + * + * @author Friedhelm Wolf (fwolf@dre.vanderbilt.edu) + */ +//============================================================================= + +#ifndef _STATEFUL_OBJECT_H_ +#define _STATEFUL_OBJECT_H_ + +// forward declaration +namespace CORBA { + class Any; +}; + +/** + * @class StatefulObject + * + * @brief Abstract Base class for objects that have a set_state method. + * + * This class shields differences in how to disseminate state throughout + * the system (e.g. either by standard CORBA calls, AMI or DDS) from + * the state synchronization agent + */ +class StatefulObject +{ +public: + + /// ctor + StatefulObject (); + + /// dtor + virtual ~StatefulObject (); + + /// method to set the + virtual void set_state (const ::CORBA::Any & state_value) = 0; +}; + +#endif /* _STATEFUL_OBJECT_H_ */ diff --git a/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/ssa_export.h b/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/ssa_export.h new file mode 100644 index 00000000000..9ba172e9162 --- /dev/null +++ b/CIAO/ciao/FTComponentServer/StateSynchronizationAgent/ssa_export.h @@ -0,0 +1,116 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl SSA_Export +// ------------------------------ +#ifndef SSA_EXPORT_EXPORT_H +#define SSA_EXPORT_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (SSA_EXPORT_HAS_DLL) +# define SSA_EXPORT_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && SSA_EXPORT_HAS_DLL */ + +#if !defined (SSA_EXPORT_HAS_DLL) +# define SSA_EXPORT_HAS_DLL 1 +#endif /* ! SSA_EXPORT_HAS_DLL */ + +#if defined (SSA_EXPORT_HAS_DLL) && (SSA_EXPORT_HAS_DLL == 1) +# if defined (SSA_EXPORT_BUILD_DLL) +# define SSA_Export_Export ACE_Proper_Export_Flag +# define SSA_EXPORT_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define SSA_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* SSA_EXPORT_BUILD_DLL */ +# define SSA_Export_Export ACE_Proper_Import_Flag +# define SSA_EXPORT_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define SSA_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* SSA_EXPORT_BUILD_DLL */ +#else /* SSA_EXPORT_HAS_DLL == 1 */ +# define SSA_Export_Export +# define SSA_EXPORT_SINGLETON_DECLARATION(T) +# define SSA_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* SSA_EXPORT_HAS_DLL == 1 */ + +// Set SSA_EXPORT_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (SSA_EXPORT_NTRACE) +# if (ACE_NTRACE == 1) +# define SSA_EXPORT_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define SSA_EXPORT_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !SSA_EXPORT_NTRACE */ + +#if (SSA_EXPORT_NTRACE == 1) +# define SSA_EXPORT_TRACE(X) +#else /* (SSA_EXPORT_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define SSA_EXPORT_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (SSA_EXPORT_NTRACE == 1) */ + +#endif /* SSA_EXPORT_EXPORT_H */ + +// End of auto generated file. + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl SSA +// ------------------------------ +#ifndef SSA_EXPORT_H +#define SSA_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (SSA_HAS_DLL) +# define SSA_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && SSA_HAS_DLL */ + +#if !defined (SSA_HAS_DLL) +# define SSA_HAS_DLL 1 +#endif /* ! SSA_HAS_DLL */ + +#if defined (SSA_HAS_DLL) && (SSA_HAS_DLL == 1) +# if defined (SSA_BUILD_DLL) +# define SSA_Export ACE_Proper_Export_Flag +# define SSA_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define SSA_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* SSA_BUILD_DLL */ +# define SSA_Export ACE_Proper_Import_Flag +# define SSA_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define SSA_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* SSA_BUILD_DLL */ +#else /* SSA_HAS_DLL == 1 */ +# define SSA_Export +# define SSA_SINGLETON_DECLARATION(T) +# define SSA_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* SSA_HAS_DLL == 1 */ + +// Set SSA_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (SSA_NTRACE) +# if (ACE_NTRACE == 1) +# define SSA_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define SSA_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !SSA_NTRACE */ + +#if (SSA_NTRACE == 1) +# define SSA_TRACE(X) +#else /* (SSA_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define SSA_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (SSA_NTRACE == 1) */ + +#endif /* SSA_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/tests/CIAO_ComponentServer/Activator/client.cpp b/CIAO/tests/CIAO_ComponentServer/Activator/client.cpp index ffa31a181e5..173a37cd88d 100644 --- a/CIAO/tests/CIAO_ComponentServer/Activator/client.cpp +++ b/CIAO/tests/CIAO_ComponentServer/Activator/client.cpp @@ -175,6 +175,10 @@ ACE_TMAIN (int argc, char **argv) { ACE_ERROR ((LM_ERROR, "Error: Caught RemoveFailure exception.\n")); } + catch (::CORBA::Exception &e) + { + ACE_ERROR ((LM_ERROR, "Error: Caught %s.\n", e._info ().c_str ())); + } catch (...) { ACE_ERROR ((LM_ERROR, "Error: Caught unknown exception\n")); diff --git a/CIAO/tests/CIAO_ComponentServer/SimpleComponent/client.cpp b/CIAO/tests/CIAO_ComponentServer/SimpleComponent/client.cpp index 0452d615c17..ca86329642d 100644 --- a/CIAO/tests/CIAO_ComponentServer/SimpleComponent/client.cpp +++ b/CIAO/tests/CIAO_ComponentServer/SimpleComponent/client.cpp @@ -147,16 +147,24 @@ ACE_TMAIN (int argc, char **argv) } sc->trigger (); + + ACE_DEBUG ((LM_TRACE, "called sc->trigger ()\n")); cont1a->remove_home (home.in ()); + + ACE_DEBUG ((LM_TRACE, "called remove home ()\n")); server1->remove_container (cont1a.in ()); - - //ACE_DEBUG ((LM_DEBUG, "Removing component server\n")); + + ACE_DEBUG ((LM_DEBUG, "called remove_container ()\n")); + sa->remove_component_server (server1.in ()); - //ACE_DEBUG ((LM_DEBUG, "Componentserver removed\n")); + + ACE_DEBUG ((LM_DEBUG, "Componentserver removed\n")); orb->destroy (); + + ACE_DEBUG ((LM_TRACE, "ORB detroyed\n")); } catch (::Components::CreateFailure &e) { @@ -166,6 +174,10 @@ ACE_TMAIN (int argc, char **argv) { ACE_ERROR ((LM_ERROR, "Error: Caught RemoveFailure exception.\n")); } + catch (::CORBA::Exception &e) + { + ACE_ERROR ((LM_ERROR, "Error: Caught %s\n", e._info ().c_str ())); + } catch (...) { ACE_ERROR ((LM_ERROR, "Error: Caught unknown exception\n")); |