diff options
19 files changed, 1418 insertions, 228 deletions
diff --git a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp index 7f07705f78a..d4852279d0e 100644 --- a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp +++ b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp @@ -4,13 +4,21 @@ #include "ace/Null_Mutex.h" #include "ace/OS_NS_string.h" #include "NodeManager/NodeDaemonC.h" +#include "Container_Base.h" + +//@@ VS: Currently, the DAM relies on the deployment_config_ to supply +//it with the NodeManager IOR that the latter obtained from the +//deployment_file. With static configuration, the NodeManager is +//created by the DAM, since it is not up and running already. Hence +//the need to have this dependency on NodeManager implementation. +#include "NodeManager/NodeDaemon_Impl.h" #if !defined (__ACE_INLINE__) # include "DomainApplicationManager_Impl.inl" #endif /* __ACE_INLINE__ */ -CIAO::DomainApplicationManager_Impl:: -DomainApplicationManager_Impl (CORBA::ORB_ptr orb, +CIAO::DomainApplicationManager_Impl_Base:: +DomainApplicationManager_Impl_Base (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, Deployment::TargetManager_ptr manager, const Deployment::DeploymentPlan & plan, @@ -37,16 +45,16 @@ DomainApplicationManager_Impl (CORBA::ORB_ptr orb, ACE_CHECK; } -CIAO::DomainApplicationManager_Impl::~DomainApplicationManager_Impl () +CIAO::DomainApplicationManager_Impl_Base::~DomainApplicationManager_Impl_Base () { if (CIAO::debug_level () > 1) { - ACE_DEBUG ((LM_DEBUG, "DomainApplicationManager destroyed\n")); + ACE_DEBUG ((LM_DEBUG, "Base_DomainApplicationManager destroyed\n")); } } void -CIAO::DomainApplicationManager_Impl:: +CIAO::DomainApplicationManager_Impl_Base:: init (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Deployment::ResourceNotAvailable, @@ -70,8 +78,7 @@ init (ACE_ENV_SINGLE_ARG_DECL) { // Get the NodeManager object reference. ::Deployment::NodeManager_var my_node_manager = - this->deployment_config_.get_node_manager - (this->node_manager_names_[i].c_str ()); + this->get_node_manager (this->node_manager_names_[i].c_str ()); // Get the child deployment plan reference. ACE_Hash_Map_Entry @@ -106,7 +113,7 @@ init (ACE_ENV_SINGLE_ARG_DECL) if (CORBA::is_nil (app_manager.in ())) { - ACE_DEBUG ((LM_DEBUG, "DomainAppMgr::init () received a nil\ + ACE_DEBUG ((LM_DEBUG, "Base_DomainAppMgr::init () received a nil\ reference for NodeApplicationManager\n")); ACE_THROW (Deployment::StartError ()); } @@ -119,7 +126,7 @@ init (ACE_ENV_SINGLE_ARG_DECL) ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "DomainApplicationManager_Impl::init\t\n"); + "DomainApplicationManager_Impl_Base::init\t\n"); ACE_RE_THROW; } ACE_ENDTRY; @@ -127,11 +134,11 @@ init (ACE_ENV_SINGLE_ARG_DECL) } bool -CIAO::DomainApplicationManager_Impl:: +CIAO::DomainApplicationManager_Impl_Base:: get_plan_info (void) { - if ( this->deployment_config_.init (this->deployment_file_) == -1 ) - return 0; + if (deployment_config_.init (deployment_file_) != 0) + return 0; const CORBA::ULong length = this->plan_.instance.length (); @@ -164,8 +171,7 @@ get_plan_info (void) // Check if there is a corresponding NodeManager instance existing // If not present return false ::Deployment::NodeManager_var mgr = - this->deployment_config_.get_node_manager - (this->plan_.instance [index].node.in ()); + this->get_node_manager (this->plan_.instance [index].node.in ()); if (CORBA::is_nil (mgr.in ())) return 0; /* Failure */ @@ -188,7 +194,7 @@ get_plan_info (void) //@@ We should ask those spec writers to look at the code below, hopefully // They will realize some thing. int -CIAO::DomainApplicationManager_Impl:: +CIAO::DomainApplicationManager_Impl_Base:: split_plan (void) { // Initialize the total number of child deployment plans specified @@ -218,8 +224,7 @@ split_plan (void) // Fill in the node_manager_ field. artifacts.node_manager_ = - this->deployment_config_.get_node_manager - (this->node_manager_names_[i].c_str ()); + this->get_node_manager (this->node_manager_names_[i].c_str ()); this->artifact_map_.bind (node_manager_names_[i], artifacts); } @@ -316,7 +321,7 @@ split_plan (void) } void -CIAO::DomainApplicationManager_Impl:: +CIAO::DomainApplicationManager_Impl_Base:: add_connections (const Deployment::Connections & incoming_conn) { @@ -334,7 +339,7 @@ add_connections (const Deployment::Connections & incoming_conn) } void -CIAO::DomainApplicationManager_Impl:: +CIAO::DomainApplicationManager_Impl_Base:: startLaunch (const ::Deployment::Properties & configProperty, ::CORBA::Boolean start ACE_ENV_ARG_DECL) @@ -343,6 +348,7 @@ startLaunch (const ::Deployment::Properties & configProperty, ::Deployment::StartError, ::Deployment::InvalidProperty)) { + ACE_DEBUG ((LM_DEBUG, "In DAM::startLaunch, num_child_plans = %d\n", num_child_plans_)); ACE_UNUSED_ARG (start); ACE_TRY { @@ -363,7 +369,7 @@ startLaunch (const ::Deployment::Properties & configProperty, if (CORBA::is_nil (my_nam)) { - ACE_DEBUG ((LM_DEBUG, "While starting launch, the DomainApplicationManager\ + ACE_DEBUG ((LM_DEBUG, "While starting launch, the Base_DomainApplicationManager\ has a nil reference for NodeApplicationManager\n")); ACE_THROW (Deployment::StartError ()); } @@ -371,12 +377,16 @@ startLaunch (const ::Deployment::Properties & configProperty, ::Deployment::Connections_var retn_connections; + ACE_DEBUG ((LM_DEBUG, "before DAM to call NAM %s \n", + this->node_manager_names_[i].c_str ())); // Obtained the returned NodeApplication object reference // and the returned Connections variable. ::Deployment::Application_var temp_application = my_nam->startLaunch (configProperty, retn_connections.out (), 0); // This is a mistake. This should never be here. + ACE_DEBUG ((LM_DEBUG, "after DAM to call NAM %s \n", + this->node_manager_names_[i].c_str ())); // Narrow down to NodeApplication object reference ::Deployment::NodeApplication_var my_na = @@ -386,7 +396,7 @@ startLaunch (const ::Deployment::Properties & configProperty, if (CORBA::is_nil (my_na.in ())) { - ACE_DEBUG ((LM_DEBUG, "The DomainApplicationManager receives a nil\ + ACE_DEBUG ((LM_DEBUG, "The Base_DomainApplicationManager receives a nil\ reference of NodeApplication after calling\ startLaunch on NodeApplicationManager.\n")); ACE_THROW (Deployment::StartError ()); @@ -404,16 +414,17 @@ startLaunch (const ::Deployment::Properties & configProperty, ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "DomainApplicationManager_Impl::startLaunch\t\n"); + "DomainApplicationManager_Impl_Base::startLaunch\t\n"); ACE_RE_THROW; } ACE_ENDTRY; ACE_CHECK; + ACE_DEBUG ((LM_DEBUG, "Exiting DAM::startLaunch, num_child_plans = %d\n", num_child_plans_)); } void -CIAO::DomainApplicationManager_Impl:: +CIAO::DomainApplicationManager_Impl_Base:: finishLaunch (::CORBA::Boolean start ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, @@ -469,7 +480,7 @@ finishLaunch (::CORBA::Boolean start ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "DomainApplicationManager_Impl::finishLaunch\t\n"); + "DomainApplicationManager_Impl_Base::finishLaunch\t\n"); ACE_RE_THROW; } ACE_ENDTRY; @@ -478,7 +489,7 @@ finishLaunch (::CORBA::Boolean start } void -CIAO::DomainApplicationManager_Impl:: +CIAO::DomainApplicationManager_Impl_Base:: start (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, ::Deployment::StartError)) @@ -508,7 +519,7 @@ start (ACE_ENV_SINGLE_ARG_DECL) ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "DomainApplicationManager_Impl::start\t\n"); + "DomainApplicationManager_Impl_Base::start\t\n"); ACE_RE_THROW; } ACE_ENDTRY; @@ -517,7 +528,7 @@ start (ACE_ENV_SINGLE_ARG_DECL) } void -CIAO::DomainApplicationManager_Impl:: +CIAO::DomainApplicationManager_Impl_Base:: destroyApplication (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, ::Deployment::StopError)) @@ -550,7 +561,7 @@ destroyApplication (ACE_ENV_SINGLE_ARG_DECL) ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "DomainApplicationManager_Impl::destroyApplication\t\n"); + "DomainApplicationManager_Impl_Base::destroyApplication\t\n"); ACE_RE_THROW; } ACE_ENDTRY; @@ -559,7 +570,7 @@ destroyApplication (ACE_ENV_SINGLE_ARG_DECL) } void -CIAO::DomainApplicationManager_Impl:: +CIAO::DomainApplicationManager_Impl_Base:: destroyManager (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Deployment::StopError)) @@ -588,7 +599,7 @@ destroyManager (ACE_ENV_SINGLE_ARG_DECL) ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "DomainApplicationManager_Impl::destroyManager\t\n"); + "DomainApplicationManager_Impl_Base::destroyManager\t\n"); ACE_RE_THROW; } ACE_ENDTRY; @@ -598,7 +609,7 @@ destroyManager (ACE_ENV_SINGLE_ARG_DECL) // Returns the DeploymentPlan associated with this ApplicationManager. ::Deployment::DeploymentPlan * -CIAO::DomainApplicationManager_Impl:: +CIAO::DomainApplicationManager_Impl_Base:: getPlan (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { @@ -613,7 +624,7 @@ getPlan (ACE_ENV_SINGLE_ARG_DECL) } Deployment::Connections * -CIAO::DomainApplicationManager_Impl:: +CIAO::DomainApplicationManager_Impl_Base:: get_outgoing_connections (const Deployment::DeploymentPlan &plan) { Deployment::Connections_var connections; @@ -633,7 +644,7 @@ get_outgoing_connections (const Deployment::DeploymentPlan &plan) } bool -CIAO::DomainApplicationManager_Impl:: +CIAO::DomainApplicationManager_Impl_Base:: get_outgoing_connections_i (const char * instname, Deployment::Connections & retv) { @@ -720,7 +731,7 @@ get_outgoing_connections_i (const char * instname, } void -CIAO::DomainApplicationManager_Impl:: +CIAO::DomainApplicationManager_Impl_Base:: dump_connections (const ::Deployment::Connections & connections) { const CORBA::ULong conn_len = connections.length (); @@ -742,3 +753,42 @@ dump_connections (const ::Deployment::Connections & connections) ACE_DEBUG ((LM_DEBUG, "endpoint: \n")); } } + + +CIAO::Static_DomainApplicationManager_Impl:: +Static_DomainApplicationManager_Impl (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + Deployment::TargetManager_ptr manager, + const Deployment::DeploymentPlan & plan, + const char * deployment_file, + Static_Config_EntryPoints_Maps* static_config_entrypoints_maps) + ACE_THROW_SPEC ((CORBA::SystemException)) + : DomainApplicationManager_Impl_Base (orb, poa, manager, plan, deployment_file) +{ + Static_NodeDaemon_Impl *static_node_daemon_impl; + // Create and install the CIAO Daemon servant + static_node_daemon_impl = + new CIAO::Static_NodeDaemon_Impl("NodeDaemon", + orb, + poa, + "", //exe location + 0, //spawn delay + static_config_entrypoints_maps); + // Activate the ourself. + PortableServer::ObjectId_var oid + = this->poa_->activate_object (static_node_daemon_impl + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Object_var obj = + this->poa_->id_to_reference (oid.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // And cache the object reference. + this->static_node_manager_ = + Deployment::NodeManager::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; +} + diff --git a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h index 5f2a4aa6239..74af60addba 100644 --- a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h +++ b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h @@ -47,7 +47,7 @@ namespace CIAO * deploying an application on the domain level, i.e. across * nodes. It specializes the ApplicationManager abstract interface. */ - class DomainApplicationManager_Export DomainApplicationManager_Impl + class DomainApplicationManager_Export DomainApplicationManager_Impl_Base : public virtual POA_Deployment::DomainApplicationManager, public virtual PortableServer::RefCountServantBase { @@ -66,11 +66,11 @@ namespace CIAO } Chained_Artifacts; /// Constructor - DomainApplicationManager_Impl (CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - Deployment::TargetManager_ptr manager, - const Deployment::DeploymentPlan &plan, - const char * deployment_file) + DomainApplicationManager_Impl_Base (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + Deployment::TargetManager_ptr manager, + const Deployment::DeploymentPlan &plan, + const char * deployment_file) ACE_THROW_SPEC ((CORBA::SystemException)); @@ -183,7 +183,7 @@ namespace CIAO protected: /// Destructor - virtual ~DomainApplicationManager_Impl (void); + virtual ~DomainApplicationManager_Impl_Base (void); /** * (1) Parse the global deployment plan, get the total number of @@ -226,6 +226,9 @@ namespace CIAO /// Dump connections, a static method static void dump_connections (const ::Deployment::Connections & connections); + virtual ::Deployment::NodeManager_ptr + get_node_manager (const char* name) = 0; + protected: /// location of the Domainapplication CORBA::String_var domainapp_path_; @@ -285,6 +288,61 @@ namespace CIAO ::Deployment::Connections_var all_connections_; }; + + + /** + * @class DomainApplicationManager_Impl + * + */ + class DomainApplicationManager_Impl + : public virtual DomainApplicationManager_Impl_Base + { + public: + /// Constructor + DomainApplicationManager_Impl (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + Deployment::TargetManager_ptr manager, + const Deployment::DeploymentPlan &plan, + const char * deployment_file) + ACE_THROW_SPEC ((CORBA::SystemException)); + + protected: + /// Destructor + virtual ~DomainApplicationManager_Impl (void); + + virtual ::Deployment::NodeManager_ptr get_node_manager (const char* name); + }; + + struct Static_Config_EntryPoints_Maps; + + /** + * @class Static_DomainApplicationManager_Impl + * + */ + class Static_DomainApplicationManager_Impl + : public virtual DomainApplicationManager_Impl_Base + { + public: + /// Constructor + Static_DomainApplicationManager_Impl (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + Deployment::TargetManager_ptr manager, + const Deployment::DeploymentPlan &plan, + const char * deployment_file, + Static_Config_EntryPoints_Maps* static_config_entrypoints_maps) + ACE_THROW_SPEC ((CORBA::SystemException)); + + protected: + /// Destructor + virtual ~Static_DomainApplicationManager_Impl (void); + + virtual ::Deployment::NodeManager_ptr get_node_manager (const char* name); + + protected: + ::Deployment::NodeManager_var static_node_manager_; + + }; + } #if defined (__ACE_INLINE__) diff --git a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.inl b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.inl index b50adfbc712..5ffd34609c1 100644 --- a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.inl +++ b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.inl @@ -2,15 +2,56 @@ // // $Id$ + + ACE_INLINE const char * -CIAO::DomainApplicationManager_Impl::get_uuid () const +CIAO::DomainApplicationManager_Impl_Base::get_uuid () const { return this->uuid_; } ACE_INLINE void -CIAO::DomainApplicationManager_Impl::set_uuid (const char * uuid) +CIAO::DomainApplicationManager_Impl_Base::set_uuid (const char * uuid) { // Copy this uuid reference this->uuid_ = CORBA::string_dup (uuid); } + +ACE_INLINE +CIAO::DomainApplicationManager_Impl:: +DomainApplicationManager_Impl (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + Deployment::TargetManager_ptr manager, + const Deployment::DeploymentPlan & plan, + const char * deployment_file) + ACE_THROW_SPEC ((CORBA::SystemException)) + : DomainApplicationManager_Impl_Base (orb, poa, manager, plan, deployment_file) +{ +} + +ACE_INLINE +CIAO::DomainApplicationManager_Impl:: +~DomainApplicationManager_Impl () +{ +} + +ACE_INLINE ::Deployment::NodeManager_ptr +CIAO::DomainApplicationManager_Impl:: +get_node_manager (const char* name) +{ + return this->deployment_config_.get_node_manager (name); +} + +ACE_INLINE +CIAO::Static_DomainApplicationManager_Impl:: +~Static_DomainApplicationManager_Impl () +{ +} + +ACE_INLINE ::Deployment::NodeManager_ptr +CIAO::Static_DomainApplicationManager_Impl:: +get_node_manager (const char* name) +{ + ACE_UNUSED_ARG (name); + return ::Deployment::NodeManager::_duplicate (static_node_manager_.in ()); +} diff --git a/TAO/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.cpp b/TAO/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.cpp index 0aaea995377..d54a3c7d51d 100644 --- a/TAO/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.cpp +++ b/TAO/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.cpp @@ -3,18 +3,20 @@ #include "NodeApplicationManager_Impl.h" #include "ace/Process.h" #include "ace/OS_NS_stdio.h" +#include "ciao/Container_Base.h" +#include "ciao/NodeApplication_Impl.h" #if !defined (__ACE_INLINE__) # include "NodeApplicationManager_Impl.inl" #endif /* __ACE_INLINE__ */ -CIAO::NodeApplicationManager_Impl::~NodeApplicationManager_Impl (void) +CIAO::NodeApplicationManager_Impl_Base::~NodeApplicationManager_Impl_Base (void) { } Deployment::NodeApplicationManager_ptr -CIAO::NodeApplicationManager_Impl::init ( +CIAO::NodeApplicationManager_Impl_Base::init ( const char *nodeapp_location, const CORBA::ULong delay, const Deployment::DeploymentPlan & plan, @@ -60,7 +62,7 @@ CIAO::NodeApplicationManager_Impl::init ( ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "NodeApplicationManager_Impl::init\t\n"); + "NodeApplicationManager_Impl_Base::init\t\n"); ACE_RE_THROW; } ACE_ENDTRY; @@ -72,7 +74,7 @@ CIAO::NodeApplicationManager_Impl::init ( } void -CIAO::NodeApplicationManager_Impl:: +CIAO::NodeApplicationManager_Impl_Base:: parse_config_value (ACE_CString & str ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, @@ -84,128 +86,8 @@ parse_config_value (ACE_CString & str ACE_THROW ( CORBA::NO_IMPLEMENT() ); } -Deployment::NodeApplication_ptr -CIAO::NodeApplicationManager_Impl:: -create_node_application (const ACE_CString & options - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - Deployment::ResourceNotAvailable, - Deployment::StartError, - Deployment::InvalidProperty)) -{ - Deployment::NodeApplication_var retval; - Deployment::Properties_var prop; - - ACE_NEW_THROW_EX (prop, - Deployment::Properties, - CORBA::INTERNAL ()); - ACE_CHECK_RETURN (Deployment::NodeApplication::_nil()); - - // @@ Create a new callback servant. - CIAO::NodeApplication_Callback_Impl * callback_servant = 0; - ACE_NEW_THROW_EX (callback_servant, - CIAO::NodeApplication_Callback_Impl (this->orb_.in (), - this->callback_poa_.in (), - this->objref_.in (), - prop.in ()), - CORBA::NO_MEMORY ()); - ACE_CHECK_RETURN (Deployment::NodeApplication::_nil()); - - PortableServer::ServantBase_var servant_var (callback_servant); - PortableServer::ObjectId_var cb_id - = this->callback_poa_->activate_object (callback_servant - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (Deployment::NodeApplication::_nil()); - - ACE_Process node_application; - ACE_Process_Options p_options; - - ACE_TRY - { - CORBA::Object_var cb_obj = - this->callback_poa_->id_to_reference (cb_id.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - CIAO::NodeApplication_Callback_var cb = - CIAO::NodeApplication_Callback::_narrow (cb_obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - CORBA::String_var cb_ior = - this->orb_->object_to_string (cb.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // spawn the new NodeApplication. - p_options.command_line ("%s -k %s" - "%s", - this->nodeapp_path_.c_str (), - cb_ior.in (), - options.c_str ()); - - p_options.avoid_zombies (1); - - if (node_application.spawn (p_options) == -1) - { - if (CIAO::debug_level () > 1) - ACE_DEBUG ((LM_ERROR, "Fail to spawn a NodeApplication process\n")); - ACE_TRY_THROW (Deployment::ResourceNotAvailable ()); - } - - // wait for nodeApp to pass back its object reference. with a - // timeout value. using perform_work and stuff. - - int looping = 1; - - ACE_Time_Value timeout (this->spawn_delay_, 0); - - while (looping) - { - this->orb_->perform_work (timeout - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - retval = callback_servant->get_nodeapp_ref (); - - if (timeout == ACE_Time_Value::zero || !CORBA::is_nil (retval.in ())) - looping = 0; - } - - if (CORBA::is_nil (retval.in ())) - { - if (CIAO::debug_level () > 1) - ACE_DEBUG ((LM_ERROR, "Fail to acquire the NodeApplication object\n")); - - ACE_TRY_THROW (Deployment::ResourceNotAvailable ()); - } - - { - //ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0); - this->nodeapp_ = Deployment::NodeApplication::_duplicate (retval.in ()); - } - } - ACE_CATCHANY - { - this->callback_poa_->deactivate_object (cb_id.in ()); - ACE_TRY_CHECK; - - ACE_RE_THROW; - } - ACE_ENDTRY; - ACE_CHECK_RETURN (Deployment::NodeApplication::_nil ()); - - this->callback_poa_->deactivate_object (cb_id.in () ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (Deployment::NodeApplication::_nil ()); - - if (CIAO::debug_level () > 1) - ACE_DEBUG ((LM_DEBUG, "CIAO::NodeApplicationManager_Impl::NodeApplication spawned!\n")); - - return retval._retn (); -} - Deployment::Connections * -CIAO::NodeApplicationManager_Impl:: +CIAO::NodeApplicationManager_Impl_Base:: create_connections (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Deployment::ResourceNotAvailable, @@ -267,7 +149,7 @@ create_connections (ACE_ENV_SINGLE_ARG_DECL) } Deployment::Application_ptr -CIAO::NodeApplicationManager_Impl:: +CIAO::NodeApplicationManager_Impl_Base:: startLaunch (const Deployment::Properties & configProperty, Deployment::Connections_out providedReference, CORBA::Boolean start @@ -289,6 +171,7 @@ startLaunch (const Deployment::Properties & configProperty, Deployment::ImplementationInfos infos; + ACE_DEBUG ((LM_DEBUG, "In NAM::startLaunch\n")); if (!(infos << (this->plan_))) { if (CIAO::debug_level () > 1) @@ -353,7 +236,7 @@ startLaunch (const Deployment::Properties & configProperty, void -CIAO::NodeApplicationManager_Impl:: +CIAO::NodeApplicationManager_Impl_Base:: destroyApplication (Deployment::Application_ptr app ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException @@ -370,3 +253,203 @@ destroyApplication (Deployment::Application_ptr app this->nodeapp_->remove (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; } + + +CIAO::NodeApplicationManager_Impl::~NodeApplicationManager_Impl (void) +{ +} + +CIAO::NodeApplicationManager_Impl:: +NodeApplicationManager_Impl (CORBA::ORB_ptr o, + PortableServer::POA_ptr p) + : NodeApplicationManager_Impl_Base (o, p) +{ +} + +Deployment::NodeApplication_ptr +CIAO::NodeApplicationManager_Impl:: +create_node_application (const ACE_CString & options + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Deployment::ResourceNotAvailable, + Deployment::StartError, + Deployment::InvalidProperty)) +{ + Deployment::NodeApplication_var retval; + Deployment::Properties_var prop; + + ACE_DEBUG ((LM_DEBUG, "create_node_application\n")); + ACE_NEW_THROW_EX (prop, + Deployment::Properties, + CORBA::INTERNAL ()); + ACE_CHECK_RETURN (Deployment::NodeApplication::_nil()); + + // @@ Create a new callback servant. + CIAO::NodeApplication_Callback_Impl * callback_servant = 0; + ACE_NEW_THROW_EX (callback_servant, + CIAO::NodeApplication_Callback_Impl (this->orb_.in (), + this->callback_poa_.in (), + this->objref_.in (), + prop.in ()), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (Deployment::NodeApplication::_nil()); + + PortableServer::ServantBase_var servant_var (callback_servant); + PortableServer::ObjectId_var cb_id + = this->callback_poa_->activate_object (callback_servant + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (Deployment::NodeApplication::_nil()); + + ACE_Process node_application; + ACE_Process_Options p_options; + + ACE_TRY + { + CORBA::Object_var cb_obj = + this->callback_poa_->id_to_reference (cb_id.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CIAO::NodeApplication_Callback_var cb = + CIAO::NodeApplication_Callback::_narrow (cb_obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::String_var cb_ior = + this->orb_->object_to_string (cb.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // spawn the new NodeApplication. + p_options.command_line ("%s -k %s" + "%s", + this->nodeapp_path_.c_str (), + cb_ior.in (), + options.c_str ()); + + p_options.avoid_zombies (1); + + if (node_application.spawn (p_options) == -1) + { + if (CIAO::debug_level () > 1) + ACE_DEBUG ((LM_ERROR, "Fail to spawn a NodeApplication process\n")); + ACE_TRY_THROW (Deployment::ResourceNotAvailable ()); + } + + // wait for nodeApp to pass back its object reference. with a + // timeout value. using perform_work and stuff. + + int looping = 1; + + ACE_Time_Value timeout (this->spawn_delay_, 0); + + while (looping) + { + this->orb_->perform_work (timeout + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + retval = callback_servant->get_nodeapp_ref (); + + if (timeout == ACE_Time_Value::zero || !CORBA::is_nil (retval.in ())) + looping = 0; + } + + if (CORBA::is_nil (retval.in ())) + { + if (CIAO::debug_level () > 1) + ACE_DEBUG ((LM_ERROR, "Fail to acquire the NodeApplication object\n")); + + ACE_TRY_THROW (Deployment::ResourceNotAvailable ()); + } + + { + //ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0); + this->nodeapp_ = Deployment::NodeApplication::_duplicate (retval.in ()); + } + } + ACE_CATCHANY + { + this->callback_poa_->deactivate_object (cb_id.in ()); + ACE_TRY_CHECK; + + ACE_RE_THROW; + } + ACE_ENDTRY; + ACE_CHECK_RETURN (Deployment::NodeApplication::_nil ()); + + this->callback_poa_->deactivate_object (cb_id.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (Deployment::NodeApplication::_nil ()); + + if (CIAO::debug_level () > 1) + ACE_DEBUG ((LM_DEBUG, "CIAO::NodeApplicationManager_Impl::NodeApplication spawned!\n")); + + return retval._retn (); +} + +CIAO::Static_NodeApplicationManager_Impl::~Static_NodeApplicationManager_Impl (void) +{ +} + +CIAO::Static_NodeApplicationManager_Impl:: +Static_NodeApplicationManager_Impl (CORBA::ORB_ptr o, + PortableServer::POA_ptr p, + Static_Config_EntryPoints_Maps* static_config_entrypoints_maps) + : NodeApplicationManager_Impl_Base (o, p), + static_config_entrypoints_maps_ (static_config_entrypoints_maps) +{ +} + +Deployment::NodeApplication_ptr +CIAO::Static_NodeApplicationManager_Impl:: +create_node_application (const ACE_CString & options + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Deployment::ResourceNotAvailable, + Deployment::StartError, + Deployment::InvalidProperty)) +{ + CIAO::Static_NodeApplication_Impl *nodeapp_servant; + + ACE_DEBUG ((LM_DEBUG, "create_static_node_application\n")); + + ACE_NEW_RETURN (nodeapp_servant, + CIAO::Static_NodeApplication_Impl (orb_.in (), + poa_.in (), + this->static_config_entrypoints_maps_), + Deployment::NodeApplication::_nil () + ); + if (nodeapp_servant->init (ACE_ENV_SINGLE_ARG_PARAMETER)) + { + ACE_DEBUG ((LM_DEBUG, "NodeApplication Failed on creating and\ + initializing the session container!")); + return Deployment::NodeApplication::_nil (); + } + ACE_TRY_CHECK; + + // CONFIGURING NodeApplication + PortableServer::ObjectId_var nodeapp_oid + = poa_->activate_object (nodeapp_servant + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Object_var + obj = poa_->id_to_reference (nodeapp_oid.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Deployment::NodeApplication_var nodeapp_obj = + Deployment::NodeApplication::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (nodeapp_obj.in ())) + { + ACE_ERROR ((LM_ERROR, "Unable to activate NodeApplication object\n")); + return Deployment::NodeApplication::_nil (); + } + + this->nodeapp_ = Deployment::NodeApplication::_duplicate (nodeapp_obj.in ()); + + return nodeapp_obj._retn (); +} diff --git a/TAO/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.h b/TAO/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.h index f6ad72f4a79..58d4bdbbef3 100644 --- a/TAO/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.h +++ b/TAO/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.h @@ -34,13 +34,13 @@ namespace CIAO /** * @class NodeApplicationManager_Impl */ - class CIAO_NAM_Export NodeApplicationManager_Impl + class CIAO_NAM_Export NodeApplicationManager_Impl_Base : public virtual POA_Deployment::NodeApplicationManager, public virtual PortableServer::RefCountServantBase { public: /// Constructor - NodeApplicationManager_Impl (CORBA::ORB_ptr o, + NodeApplicationManager_Impl_Base (CORBA::ORB_ptr o, PortableServer::POA_ptr p); /*=========================================================== @@ -102,7 +102,7 @@ namespace CIAO protected: /// Destructor - virtual ~NodeApplicationManager_Impl (void); + virtual ~NodeApplicationManager_Impl_Base (void); // Internal help function to create new NodeApplicationProcess virtual Deployment::NodeApplication_ptr @@ -111,7 +111,7 @@ namespace CIAO ACE_THROW_SPEC ((CORBA::SystemException, Deployment::ResourceNotAvailable, Deployment::StartError, - Deployment::InvalidProperty)); + Deployment::InvalidProperty))=0; // Helper function to get the connection. virtual Deployment::Connections * @@ -173,6 +173,65 @@ namespace CIAO // Synchronize access to the object set. TAO_SYNCH_MUTEX lock_; }; + + /** + * @class NodeApplicationManager_Impl + */ + class NodeApplicationManager_Impl + : public virtual NodeApplicationManager_Impl_Base + { + public: + /// Constructor + NodeApplicationManager_Impl (CORBA::ORB_ptr o, + PortableServer::POA_ptr p); + + protected: + /// Destructor + virtual ~NodeApplicationManager_Impl (void); + + // Internal help function to create new NodeApplicationProcess + // Here we override it to create an in-process NodeApplication object + virtual Deployment::NodeApplication_ptr + create_node_application (const ACE_CString & options + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Deployment::ResourceNotAvailable, + Deployment::StartError, + Deployment::InvalidProperty)); + }; + + struct Static_Config_EntryPoints_Maps; + + /** + * @class Static_NodeApplicationManager_Impl + */ + class Static_NodeApplicationManager_Impl + : public virtual NodeApplicationManager_Impl_Base + { + public: + /// Constructor + Static_NodeApplicationManager_Impl (CORBA::ORB_ptr o, + PortableServer::POA_ptr p, + Static_Config_EntryPoints_Maps* static_config_entrypoints_maps); + + protected: + /// Destructor + virtual ~Static_NodeApplicationManager_Impl (void); + + // Internal help function to create new NodeApplicationProcess + // Here we override it to create an in-process NodeApplication object + virtual Deployment::NodeApplication_ptr + create_node_application (const ACE_CString & options + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Deployment::ResourceNotAvailable, + Deployment::StartError, + Deployment::InvalidProperty)); + + Static_Config_EntryPoints_Maps* static_config_entrypoints_maps_; + + }; + } #if defined (__ACE_INLINE__) diff --git a/TAO/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.inl b/TAO/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.inl index 24908a047a4..5a29debbb53 100644 --- a/TAO/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.inl +++ b/TAO/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.inl @@ -2,8 +2,8 @@ // $Id$ ACE_INLINE -CIAO::NodeApplicationManager_Impl:: -NodeApplicationManager_Impl (CORBA::ORB_ptr o, +CIAO::NodeApplicationManager_Impl_Base:: +NodeApplicationManager_Impl_Base (CORBA::ORB_ptr o, PortableServer::POA_ptr p) : orb_ (CORBA::ORB::_duplicate (o)), poa_ (PortableServer::POA::_duplicate (p)), @@ -20,7 +20,7 @@ NodeApplicationManager_Impl (CORBA::ORB_ptr o, ACE_INLINE Deployment::NodeApplicationManager_ptr -CIAO::NodeApplicationManager_Impl::get_nodeapp_manager (void) +CIAO::NodeApplicationManager_Impl_Base::get_nodeapp_manager (void) { return this->objref_.in (); } diff --git a/TAO/CIAO/DAnCE/NodeManager/NodeDaemon.mpc b/TAO/CIAO/DAnCE/NodeManager/NodeDaemon.mpc index e3e6e3bac78..ebd14ea1d1b 100644 --- a/TAO/CIAO/DAnCE/NodeManager/NodeDaemon.mpc +++ b/TAO/CIAO/DAnCE/NodeManager/NodeDaemon.mpc @@ -29,3 +29,21 @@ project(Node_Daemon): ciao_deployment_stub, ciao_deployment_svnt, ciao_server_dn Node_Daemon.cpp } } + +project(libNode_Daemon): ciao_server_dnc,ciao_deployment_svnt, ciao_deployment_stub, iortable, ifr_client, naming { + sharedname = Node_Daemon + requires += exceptions + includes += /usr/include + libpaths += /usr/lib + after += NodeApplicationManager NodeDaemon_stub + libs += NodeDaemon_stub NodeApplicationManager + + IDL_Files { + } + + Source_Files { + NodeDaemonS.cpp + NodeDaemon_Impl.cpp + Node_Daemon.cpp + } +} diff --git a/TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.cpp b/TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.cpp index a48fa385a45..0e10bf87d14 100644 --- a/TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.cpp +++ b/TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.cpp @@ -1,9 +1,9 @@ // $Id$ #include "NodeDaemon_Impl.h" -#include "../NodeApplicationManager/NodeApplicationManager_Impl.h" +#include "ciao/Container_Base.h" -CIAO::NodeDaemon_Impl::NodeDaemon_Impl (const char *name, +CIAO::NodeDaemon_Impl_Base::NodeDaemon_Impl_Base (const char *name, CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, const char * nodapp_loc, @@ -36,7 +36,7 @@ CIAO::NodeDaemon_Impl::NodeDaemon_Impl (const char *name, ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "NodeDaemon_Impl::constructor\t\n"); + "NodeDaemon_Impl_Base::constructor\t\n"); // @@ This is bogus and will not work with emulated exceptions // -- Bala ACE_RE_THROW; @@ -45,27 +45,27 @@ CIAO::NodeDaemon_Impl::NodeDaemon_Impl (const char *name, ACE_CHECK; } -CIAO::NodeDaemon_Impl::~NodeDaemon_Impl () +CIAO::NodeDaemon_Impl_Base::~NodeDaemon_Impl_Base () { } PortableServer::POA_ptr -CIAO::NodeDaemon_Impl::_default_POA (void) +CIAO::NodeDaemon_Impl_Base::_default_POA (void) { return PortableServer::POA::_duplicate (this->poa_.in ()); } char * -CIAO::NodeDaemon_Impl::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +CIAO::NodeDaemon_Impl_Base::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((CORBA::SystemException)) { return CORBA::string_dup (this->name_.in ()); } void -CIAO::NodeDaemon_Impl::shutdown (ACE_ENV_SINGLE_ARG_DECL) +CIAO::NodeDaemon_Impl_Base::shutdown (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { this->orb_->shutdown (0 ACE_ENV_ARG_PARAMETER); @@ -73,7 +73,7 @@ CIAO::NodeDaemon_Impl::shutdown (ACE_ENV_SINGLE_ARG_DECL) } void -CIAO::NodeDaemon_Impl::joinDomain (const Deployment::Domain & , +CIAO::NodeDaemon_Impl_Base::joinDomain (const Deployment::Domain & , Deployment::TargetManager_ptr , Deployment::Logger_ptr ACE_ENV_ARG_DECL) @@ -83,34 +83,29 @@ CIAO::NodeDaemon_Impl::joinDomain (const Deployment::Domain & , } void -CIAO::NodeDaemon_Impl::leaveDomain (ACE_ENV_SINGLE_ARG_DECL) +CIAO::NodeDaemon_Impl_Base::leaveDomain (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { //Implementation undefined. ACE_THROW (CORBA::NO_IMPLEMENT ()); } - Deployment::NodeApplicationManager_ptr -CIAO::NodeDaemon_Impl::preparePlan (const Deployment::DeploymentPlan &plan +CIAO::NodeDaemon_Impl_Base::preparePlan (const Deployment::DeploymentPlan &plan ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Deployment::StartError, Deployment::PlanError)) { + ACE_DEBUG ((LM_DEBUG, "In NDI:preparePlan\n")); // Return cached manager ACE_TRY { if (CORBA::is_nil (this->manager_.in ())) { //Implementation undefined. - CIAO::NodeApplicationManager_Impl *app_mgr; - ACE_NEW_THROW_EX (app_mgr, - CIAO::NodeApplicationManager_Impl ( - this->orb_.in (), - this->poa_.in ()), - CORBA::NO_MEMORY ()); - ACE_TRY_CHECK; + CIAO::NodeApplicationManager_Impl_Base *app_mgr; + app_mgr = create_node_app_manager (this->orb_.in (), this->poa_.in ()); PortableServer::ServantBase_var safe (app_mgr); @@ -138,7 +133,7 @@ CIAO::NodeDaemon_Impl::preparePlan (const Deployment::DeploymentPlan &plan ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "NodeDaemon_Impl::preparePlan\t\n"); + "NodeDaemon_Impl_Base::preparePlan\t\n"); ACE_RE_THROW; } ACE_ENDTRY; @@ -150,7 +145,7 @@ CIAO::NodeDaemon_Impl::preparePlan (const Deployment::DeploymentPlan &plan } void -CIAO::NodeDaemon_Impl::destroyManager (Deployment::NodeApplicationManager_ptr +CIAO::NodeDaemon_Impl_Base::destroyManager (Deployment::NodeApplicationManager_ptr ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Deployment::StopError)) @@ -173,8 +168,10 @@ CIAO::NodeDaemon_Impl::destroyManager (Deployment::NodeApplicationManager_ptr ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "NodeDaemon_Impl::destroyManager\t\n"); + "NodeDaemon_Impl_Base::destroyManager\t\n"); ACE_RE_THROW; } ACE_ENDTRY; } + + diff --git a/TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.h b/TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.h index a30fe5a2244..0d5a08170b7 100644 --- a/TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.h +++ b/TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.h @@ -22,6 +22,7 @@ #include /**/ "ace/pre.h" #include "NodeDaemonS.h" +#include "NodeApplicationManager/NodeApplicationManager_Impl.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -46,14 +47,17 @@ namespace CIAO * This class implements the CIAO:NodeDaemon interface. * */ - class NodeDaemon_Impl + + class NodeApplicationManager_Impl_Base; + + class NodeDaemon_Impl_Base : public virtual POA_CIAO::NodeDaemon, public virtual PortableServer::RefCountServantBase { public: /// Constructor - NodeDaemon_Impl (const char *name, + NodeDaemon_Impl_Base (const char *name, CORBA::ORB_ptr orb, PortableServer::POA_ptr p, const char * nodeapp_loc, @@ -99,7 +103,11 @@ namespace CIAO /// through the reference counting mechanism (i.e. to /// disallow calling operator delete() on an instance of /// this class. - virtual ~NodeDaemon_Impl (void); + virtual ~NodeDaemon_Impl_Base (void); + + virtual ::CIAO::NodeApplicationManager_Impl_Base * + create_node_app_manager (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa)=0; // Keep a pointer to the managing ORB serving this servant. CORBA::ORB_var orb_; @@ -122,6 +130,71 @@ namespace CIAO // Cache reference of last NodeAppManager Deployment::NodeApplicationManager_var manager_; }; + + /** + * @class NodeDaemon_Impl + * + */ + class NodeDaemon_Impl + : public virtual NodeDaemon_Impl_Base + { + public: + + /// Constructor + NodeDaemon_Impl (const char *name, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr p, + const char * nodeapp_loc, + int spawn_delay); + + protected: + /// Since this class is reference counted, making this + /// destructor protected to enforce proper memory managment + /// through the reference counting mechanism (i.e. to + /// disallow calling operator delete() on an instance of + /// this class. + virtual ~NodeDaemon_Impl (void); + + CIAO::NodeApplicationManager_Impl_Base * + CIAO::NodeDaemon_Impl::create_node_app_manager (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa); + }; + + class NodeApplicationManager_Impl; + struct Static_Config_EntryPoints_Maps; + + /** + * @class Static_NodeDaemon_Impl + * + */ + class Static_NodeDaemon_Impl + : public virtual NodeDaemon_Impl_Base + { + public: + + /// Constructor + Static_NodeDaemon_Impl (const char *name, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr p, + const char * nodeapp_loc, + int spawn_delay, + Static_Config_EntryPoints_Maps* static_config_entrypoints_maps + ); + + protected: + /// Since this class is reference counted, making this + /// destructor protected to enforce proper memory managment + /// through the reference counting mechanism (i.e. to + /// disallow calling operator delete() on an instance of + /// this class. + virtual ~Static_NodeDaemon_Impl (void); + + CIAO::NodeApplicationManager_Impl_Base * + CIAO::Static_NodeDaemon_Impl::create_node_app_manager (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa); + + Static_Config_EntryPoints_Maps* static_config_entrypoints_maps_; + }; } #if defined(_MSC_VER) && (_MSC_VER >= 1200) diff --git a/TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.inl b/TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.inl index 6318deb79a0..3e3fbd3d0d8 100644 --- a/TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.inl +++ b/TAO/CIAO/DAnCE/NodeManager/NodeDaemon_Impl.inl @@ -1,2 +1,52 @@ /* -*- C++ -*- */ // $Id$ + +ACE_INLINE +CIAO::NodeDaemon_Impl:: +NodeDaemon_Impl (const char *name, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + const char * nodapp_loc, + int spawn_delay) + : NodeDaemon_Impl_Base (name, orb, poa, nodapp_loc, spawn_delay) +{} + +ACE_INLINE +CIAO::NodeDaemon_Impl:: +~NodeDaemon_Impl () +{} + +ACE_INLINE +CIAO::NodeApplicationManager_Impl_Base* +CIAO::NodeDaemon_Impl:: +create_node_app_manager (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa) +{ + return new CIAO::NodeApplicationManager_Impl (orb, poa); +} + +ACE_INLINE +CIAO::Static_NodeDaemon_Impl:: +Static_NodeDaemon_Impl (const char *name, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + const char * nodapp_loc, + int spawn_delay, + Static_Config_EntryPoints_Maps* static_config_entrypoints_maps) + : NodeDaemon_Impl_Base (name, orb, poa, nodapp_loc, spawn_delay), + static_config_entrypoints_maps_ (static_config_entrypoints_maps) +{} + +ACE_INLINE +CIAO::Static_NodeDaemon_Impl:: +~Static_NodeDaemon_Impl () +{} + +ACE_INLINE +CIAO::NodeApplicationManager_Impl_Base * +CIAO::Static_NodeDaemon_Impl:: +create_node_app_manager (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa) +{ + return new CIAO::Static_NodeApplicationManager_Impl (orb, poa, this->static_config_entrypoints_maps_); +} diff --git a/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.mpc b/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.mpc index 2909e3da5d0..a00d9a1548c 100644 --- a/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.mpc +++ b/TAO/CIAO/DAnCE/RepositoryManager/RepositoryManager.mpc @@ -23,3 +23,21 @@ project(Repository_Manager): ciao_server_dnc,ciao_deployment_svnt, ciao_deployme RepositoryManager_Impl.cpp } } + +project(libRepository_Manager): ciao_server_dnc,ciao_deployment_svnt, ciao_deployment_stub, xerces { + sharedname = RepositoryManager + requires += exceptions + includes += /usr/include + libpaths += /usr/lib + libs += Config_Handlers + after += Config_Handlers + + IDL_Files { + RepositoryManager.idl + } + + Source_Files { + Update_Plan.cpp + RepositoryManager_Impl.cpp + } +} diff --git a/TAO/CIAO/DAnCE/RepositoryManager/Repository_Manager.cpp b/TAO/CIAO/DAnCE/RepositoryManager/Repository_Manager.cpp index b6406da05e2..c0e23c4f564 100644 --- a/TAO/CIAO/DAnCE/RepositoryManager/Repository_Manager.cpp +++ b/TAO/CIAO/DAnCE/RepositoryManager/Repository_Manager.cpp @@ -151,7 +151,9 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[]) rep_impl->installPackage ("PC", package_url); pc = rep_impl->findPackageByName ("PC"); + //ACE_DEBUG ((LM_DEBUG, "Dumping package configuration===start\n")); //Deployment::DnC_Dump::dump (*pc); + //ACE_DEBUG ((LM_DEBUG, "Dumping package configuration===end\n")); CIAO::REF_MAP ref_map; CIAO::REF_MAP primary_ref_map; @@ -160,7 +162,9 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[]) // update the deployment plan IDL data structure. CIAO::traverse_package (pc, plan, ref_map, primary_ref_map); + //ACE_DEBUG ((LM_DEBUG, "Dumping deployment plan===start\n")); //Deployment::DnC_Dump::dump (plan); + //ACE_DEBUG ((LM_DEBUG, "Dumping deployment plan===end\n")); // Pass the parsed plan to the Execution Manager to start the // Deployment Process. diff --git a/TAO/CIAO/DAnCE/StaticConfigurator/StaticDAnCEApp.cpp b/TAO/CIAO/DAnCE/StaticConfigurator/StaticDAnCEApp.cpp new file mode 100644 index 00000000000..d8611ec5e03 --- /dev/null +++ b/TAO/CIAO/DAnCE/StaticConfigurator/StaticDAnCEApp.cpp @@ -0,0 +1,265 @@ +// $Id$ + +#include "NodeApplication_Impl.h" +#include "DeploymentC.h" +#include "CIAO/DAnCE/NodeApplicationManager/ImplementationInfo.h" +#include "CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h" +#include "CIAO/DAnCE/RepositoryManager/Update_Plan.h" +#include "CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h" +#include "Config_Handlers/DnC_Dump.h" +#include "orbsvcs/orbsvcs/Naming/Transient_Naming_Context.h" +#include "ace/OS_NS_stdio.h" +#include "ace/streams.h" +#include "ace/Get_Opt.h" +#include "tao/IORTable/IORTable.h" +#include "tao/CDR.h" +#include "CIAO/DAnCE/Config_Handlers/XercesString.h" +#include <xercesc/util/XMLUniDefs.hpp> +#include <xercesc/parsers/XercesDOMParser.hpp> +#include <xercesc/parsers/AbstractDOMParser.hpp> +#include "CIAO/DAnCE/Config_Handlers/Config_Handler_export.h" +#include "CIAO/DAnCE/Config_Handlers/Domain_Handler.h" +#include "CIAO/DAnCE/Config_Handlers/PC_Handler.h" +#include "CIAO/DAnCE/Config_Handlers/Plan_Handler.h" +#include "CIAO/DAnCE/Config_Handlers/CompImplDesc_Handler.h" +#include "CIAO/DAnCE/Config_Handlers/DnC_Dump.h" +#include "CIAO/DAnCE/Config_Handlers/Utils.h" +#include "CIAO/DAnCE/Config_Handlers/Config_Error_Handler.h" +#include "plan.h" + +using Config_Handler::XStr; +using xercesc::XMLUni; +using xercesc::XMLString; +using xercesc::XMLException; +using xercesc::DOMException; +using xercesc::DOMBuilder; +using xercesc::DOMImplementationRegistry; +using xercesc::DOMImplementationLS; +using xercesc::DOMImplementation; +using xercesc::DOMAttr; +using xercesc::DOMNamedNodeMap; +using xercesc::DOMLocator; +using xercesc::DOMError; +using xercesc::DOMNodeList; +using xercesc::DOMDocument; +using xercesc::DOMDocumentTraversal; +using xercesc::DOMNodeIterator; +using xercesc::DOMNode; +using xercesc::DOMNodeFilter; +using xercesc::XercesDOMParser; +using xercesc::AbstractDOMParser; +using namespace std; +using namespace CIAO; + +const char * exec_ior = "file://exec_mgr.ior"; +const char * node_daemon_ior = 0; +const char * init_file = "deployment.dat"; + +static void +usage (const ACE_TCHAR* program) +{ + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Usage: %s -p <URI> -d <URI> -k <EX_IOR> \ + -t <NODE_MANAGER_IOR> \n") + ACE_TEXT (" <URI>: URI identifying the package\n"), + program)); +} + +int +ACE_TMAIN (int argc, ACE_TCHAR *argv[]) +{ + // top level package URL + char* package_url = 0; + + // deployment plan URL + char* plan_url = 0; + + // Initialize the ORB so that CORBA::Any will work + // + CORBA::ORB_var orb = + CORBA::ORB_init (argc, + argv, + ""); + /* + ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("p:d:k:t:i:")); + int c; + + while ((c = get_opt ()) != EOF) + { + switch (c) + { + case 'p': + package_url = get_opt.opt_arg (); + break; + case 'i': + init_file = get_opt.opt_arg (); + break; + case 'd': + plan_url = get_opt.opt_arg (); + break; + case 'k': + exec_ior = get_opt.opt_arg (); + break; + case 't': + node_daemon_ior = get_opt.opt_arg (); + break; + default: + usage(argv[0]); + return -1; + } + } + + if (package_url == 0) { + usage(argv[0]); + return -1; + } + + if (plan_url == 0) { + usage(argv[0]); + return -1; + } + + try + { + xercesc::XMLPlatformUtils::Initialize(); + } + + catch (const XMLException& xml_e) + { + char* message = XMLString::transcode (xml_e.getMessage()); + ACE_Auto_Basic_Array_Ptr<char> cleanup_message (message); + ACE_DEBUG ((LM_DEBUG, "Error during initialization : %s\n", message)); + return 1; + } + */ + try + { + Deployment::DeploymentPlan plan; + + TAO_InputCDR in_cdr(plan_cdr_buffer, sizeof(plan_cdr_buffer)-1 ); + + in_cdr >> plan; + + //ACE_DEBUG ((LM_DEBUG, "Dumping deployment plan===start\n")); + //Deployment::DnC_Dump::dump (plan); + //ACE_DEBUG ((LM_DEBUG, "Dumping deployment plan===end\n")); + + // Pass the parsed plan to the Execution Manager to start the + // Deployment Process. + + // Get reference to Root POA. + CORBA::Object_var obj + = orb->resolve_initial_references ("RootPOA" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POA_var poa + = PortableServer::POA::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Activate POA manager + PortableServer::POAManager_var mgr + = poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + mgr->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + int homes_table_size = + sizeof (homes_table)/sizeof(HomeAttributes); + + CIAO::HOMECREATOR_FUNCPTR_MAP home_creator_fptr_map; + CIAO::HOMESERVANTCREATOR_FUNCPTR_MAP homesvnt_creator_fptr_map; + CIAO::Static_Config_EntryPoints_Maps maps; + maps.home_creator_funcptr_map_ = &home_creator_fptr_map; + maps.home_servant_creator_funcptr_map_ = &homesvnt_creator_fptr_map; + + int i=0; + for (i=0; i<homes_table_size; ++i) + { + home_creator_fptr_map.bind (homes_table[i].executor_entrypt_, + homes_table[i].executor_fptr_); + + homesvnt_creator_fptr_map.bind (homes_table[i].servant_entrypt_, + homes_table[i].servant_fptr_); + } + + Static_DomainApplicationManager_Impl* dapp_mgr = + new CIAO::Static_DomainApplicationManager_Impl + (orb.in (), + poa.in (), + Deployment::TargetManager::_nil (), + plan, + init_file, + &maps); + + dapp_mgr->init (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (Deployment::DomainApplicationManager::_nil()); + + dapp_mgr->set_uuid (plan.UUID.in ()); + + // Create a dummy set of properties and start the + // Launching of applications + Deployment::Properties_var properties; + ACE_NEW_RETURN (properties, + Deployment::Properties, + 1); + ACE_DEBUG ((LM_DEBUG, "Executor: start Launch application.....")); + // Start the Application immediately + int start = 1; + dapp_mgr->startLaunch (properties.in (), start); + ACE_DEBUG ((LM_DEBUG, "[success]\n")); + + ACE_DEBUG ((LM_DEBUG, "Executor: finish Launch application.....")); + // Call finish Launch to complete the connections + dapp_mgr->finishLaunch (start); + ACE_DEBUG ((LM_DEBUG, "[success]\n")); + + ACE_DEBUG ((LM_DEBUG, "Executor: Application Deployed successfully \n")); + + // Run the main event loop for the ORB. + orb->run (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "Executor: destroy the application.....")); + dapp_mgr->destroyApplication (); + ACE_DEBUG ((LM_DEBUG, "[success]\n")); + + poa->destroy (1, 1 ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + catch (CORBA::Exception& ex) + { + ACE_PRINT_EXCEPTION (ex, "Caught CORBA Exception: "); + return -1; + } + catch (const DOMException& e) + { + const unsigned int maxChars = 2047; + XMLCh errText[maxChars + 1]; + + ACE_ERROR ((LM_ERROR, "\nException occured while parsing %s: \ + \n",plan_url)); + ACE_ERROR ((LM_ERROR, "DOMException code: %d\n ", e.code)); + if (DOMImplementation::loadDOMExceptionMsg (e.code, errText, maxChars)) + { + char* message = XMLString::transcode (errText); + ACE_Auto_Basic_Array_Ptr<char> cleanup_message (message); + ACE_ERROR ((LM_ERROR, "Message is: %s\n", message)); + } + //ACE_PRINT_EXCEPTION ("Caught DOM Exception: "); + ACE_ERROR ((LM_ERROR, "Caught DOM exception\n")); + return -1; + } + catch (...) + { + ACE_ERROR ((LM_ERROR, "Caught unknown exception\n")); + return -1; + } + + return 0; +} diff --git a/TAO/CIAO/DAnCE/StaticConfigurator/StaticDAnCEApp.mpc b/TAO/CIAO/DAnCE/StaticConfigurator/StaticDAnCEApp.mpc new file mode 100644 index 00000000000..34969b767d3 --- /dev/null +++ b/TAO/CIAO/DAnCE/StaticConfigurator/StaticDAnCEApp.mpc @@ -0,0 +1,56 @@ +// -*- MPC -*- +// $Id$ + +project(StaticDAnCEApp): ciao_deployment_stub, ciao_deployment_svnt, ciao_server_dnc, taoexe, xerces, naming_serv { + exename = StaticDAnCEApp + requires += exceptions + includes += /usr/include + includes += ../NodeApplicationManager ../DomainApplicationManager ../NodeManager + libpaths += /usr/lib + libs += Config_Handlers + after += Config_Handlers + libs += RepositoryManager DomainApplicationManager NodeApplicationManager Node_Daemon NodeDaemon_stub + after += RepositoryManager DomainApplicationManager NodeApplicationManager Node_Daemon NodeDaemon_stub + + libs += RobotAssembly_svnt + libs += RobotAssembly_stub + + libs += HumanMachineInterface_exec + libs += ManagementWorkInstructions_exec + libs += PalletConveyorManager_exec + libs += WatchSettingManager_exec + libs += RobotManager_exec + libs += HumanMachineInterface_stub + libs += ManagementWorkInstructions_stub + libs += PalletConveyorManager_stub + libs += WatchSettingManager_stub + libs += RobotManager_stub + libs += HumanMachineInterface_svnt + libs += ManagementWorkInstructions_svnt + libs += PalletConveyorManager_svnt + libs += WatchSettingManager_svnt + libs += RobotManager_svnt + + after += RobotAssembly_svnt + after += RobotAssembly_stub + after += HumanMachineInterface_exec + after += ManagementWorkInstructions_exec + after += PalletConveyorManager_exec + after += WatchSettingManager_exec + after += RobotManager_exec + after += HumanMachineInterface_svnt + after += ManagementWorkInstructions_svnt + after += PalletConveyorManager_svnt + after += WatchSettingManager_svnt + after += RobotManager_svnt + after += HumanMachineInterface_stub + after += ManagementWorkInstructions_stub + after += PalletConveyorManager_stub + after += WatchSettingManager_stub + after += RobotManager_stub + + Source_Files { + StaticDAnCEApp.cpp + } +} + diff --git a/TAO/CIAO/DAnCE/StaticConfigurator/StaticDAnCEParser.cpp b/TAO/CIAO/DAnCE/StaticConfigurator/StaticDAnCEParser.cpp new file mode 100644 index 00000000000..8d466c904c7 --- /dev/null +++ b/TAO/CIAO/DAnCE/StaticConfigurator/StaticDAnCEParser.cpp @@ -0,0 +1,314 @@ +// $Id$ + +#include "NodeApplication_Impl.h" +#include "DeploymentC.h" +#include "CIAO/DAnCE/NodeApplicationManager/ImplementationInfo.h" +#include "CIAO/DAnCE/RepositoryManager/RepositoryManager_Impl.h" +#include "CIAO/DAnCE/RepositoryManager/Update_Plan.h" +#include "CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h" +#include "Config_Handlers/DnC_Dump.h" +#include "orbsvcs/orbsvcs/Naming/Transient_Naming_Context.h" +#include "ace/OS_NS_stdio.h" +#include "ace/streams.h" +#include "ace/Get_Opt.h" +#include "tao/IORTable/IORTable.h" +#include "tao/CDR.h" +#include "CIAO/DAnCE/Config_Handlers/XercesString.h" +#include <xercesc/util/XMLUniDefs.hpp> +#include <xercesc/parsers/XercesDOMParser.hpp> +#include <xercesc/parsers/AbstractDOMParser.hpp> +#include "CIAO/DAnCE/Config_Handlers/Config_Handler_export.h" +#include "CIAO/DAnCE/Config_Handlers/Domain_Handler.h" +#include "CIAO/DAnCE/Config_Handlers/PC_Handler.h" +#include "CIAO/DAnCE/Config_Handlers/Plan_Handler.h" +#include "CIAO/DAnCE/Config_Handlers/CompImplDesc_Handler.h" +#include "CIAO/DAnCE/Config_Handlers/DnC_Dump.h" +#include "CIAO/DAnCE/Config_Handlers/Utils.h" +#include "CIAO/DAnCE/Config_Handlers/Config_Error_Handler.h" + +using Config_Handler::XStr; +using xercesc::XMLUni; +using xercesc::XMLString; +using xercesc::XMLException; +using xercesc::DOMException; +using xercesc::DOMBuilder; +using xercesc::DOMImplementationRegistry; +using xercesc::DOMImplementationLS; +using xercesc::DOMImplementation; +using xercesc::DOMAttr; +using xercesc::DOMNamedNodeMap; +using xercesc::DOMLocator; +using xercesc::DOMError; +using xercesc::DOMNodeList; +using xercesc::DOMDocument; +using xercesc::DOMDocumentTraversal; +using xercesc::DOMNodeIterator; +using xercesc::DOMNode; +using xercesc::DOMNodeFilter; +using xercesc::XercesDOMParser; +using xercesc::AbstractDOMParser; +using namespace std; +using namespace CIAO; + +const char * exec_ior = "file://exec_mgr.ior"; +const char * node_daemon_ior = 0; +const char * init_file = "deployment.dat"; + +static void +usage (const ACE_TCHAR* program) +{ + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Usage: %s -p <URI> -d <URI> -k <EX_IOR> \ + -t <NODE_MANAGER_IOR> \n") + ACE_TEXT (" <URI>: URI identifying the package\n"), + program)); +} + +int +ACE_TMAIN (int argc, ACE_TCHAR *argv[]) +{ + // top level package URL + char* package_url = 0; + + // deployment plan URL + char* plan_url = 0; + + // Initialize the ORB so that CORBA::Any will work + // + CORBA::ORB_var orb = + CORBA::ORB_init (argc, + argv, + ""); + + ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("p:d:k:t:i:")); + int c; + + while ((c = get_opt ()) != EOF) + { + switch (c) + { + case 'p': + package_url = get_opt.opt_arg (); + break; + case 'i': + init_file = get_opt.opt_arg (); + break; + case 'd': + plan_url = get_opt.opt_arg (); + break; + case 'k': + exec_ior = get_opt.opt_arg (); + break; + case 't': + node_daemon_ior = get_opt.opt_arg (); + break; + default: + usage(argv[0]); + return -1; + } + } + + if (package_url == 0) { + usage(argv[0]); + return -1; + } + + if (plan_url == 0) { + usage(argv[0]); + return -1; + } + + try + { + xercesc::XMLPlatformUtils::Initialize(); + } + + catch (const XMLException& xml_e) + { + char* message = XMLString::transcode (xml_e.getMessage()); + ACE_Auto_Basic_Array_Ptr<char> cleanup_message (message); + ACE_DEBUG ((LM_DEBUG, "Error during initialization : %s\n", message)); + return 1; + } + + try + { + // get a reference to the parser. + std::auto_ptr<DOMBuilder> plan_parser (CIAO::Config_Handler::Utils:: + create_parser ()); + CIAO::Config_Handler::Config_Error_Handler handler; + plan_parser->setErrorHandler(&handler); + + std::auto_ptr<DOMBuilder> tpd_parser (CIAO::Config_Handler::Utils:: + create_parser ()); + CIAO::Config_Handler::Config_Error_Handler tpd_handler; + tpd_parser->setErrorHandler(&tpd_handler); + + // use the parser to parse the deployment plan URL and create + // a DOM document. + DOMDocument* plan_doc = plan_parser->parseURI (plan_url); + if (handler.getErrors()) + { + return 1; + } + + //DOMDocument* tpd_doc = tpd_parser->parseURI (package_url); + + //ACE_UNUSED_ARG (tpd_doc); + + if (tpd_handler.getErrors()) + { + return 1; + } + + if (plan_doc == NULL) + { + ACE_DEBUG ((LM_DEBUG, "Null DOM Document obtained, \ + May be the URL is wrong!!\n")); + throw CIAO::Null_Dom_Document (); + } + + // free up DOMBuilder. DOMBuilder also deletes the DOMDocument memory. + //auto_ptr<DOMBuilder> cleanup_parser (parser); + + // call the Deployment Plan handler to parse the XML descriptor. + CIAO::Config_Handler::Plan_Handler plan_handler (plan_doc, + DOMNodeFilter::SHOW_ELEMENT | + DOMNodeFilter::SHOW_TEXT); + Deployment::DeploymentPlan plan; + plan_handler.process_plan (plan); + + // call the PackageConfiguration handler to parse the XML descriptor. + Deployment::PackageConfiguration* pc; + + CIAO::RepositoryManager_Impl *rep_impl = 0; + ACE_NEW_RETURN (rep_impl, + CIAO::RepositoryManager_Impl (), + -1); + PortableServer::ServantBase_var owner_transfer (rep_impl); + + rep_impl->installPackage ("PC", package_url); + pc = rep_impl->findPackageByName ("PC"); + //ACE_DEBUG ((LM_DEBUG, "Dumping package configuration===start\n")); + //Deployment::DnC_Dump::dump (*pc); + //ACE_DEBUG ((LM_DEBUG, "Dumping package configuration===end\n")); + + CIAO::REF_MAP ref_map; + CIAO::REF_MAP primary_ref_map; + + // traverse the PackageConfiguration IDL data structure and + // update the deployment plan IDL data structure. + CIAO::traverse_package (pc, plan, ref_map, primary_ref_map); + + char out_char_array[100000]; + TAO_OutputCDR out_cdr(out_char_array, sizeof(out_char_array) ); + + out_cdr << plan; + + Deployment::ImplementationInfos infos; + //ImplementationInfo impl_info; + + if (!(infos << plan)) + { + if (CIAO::debug_level () > 1) + ACE_DEBUG ((LM_DEBUG, "Failed to create Component Implementation Infos!\n")); + + } + + CORBA::ULong i; + const CORBA::ULong info_len = infos.length (); + for (i = 0; i < info_len; ++i) + {/* + ACE_DEBUG ((LM_DEBUG, "The info for installation: \n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n", + infos[i].component_instance_name.in (), + infos[i].executor_dll.in (), + infos[i].executor_entrypt.in (), + infos[i].servant_dll.in (), + infos[i].servant_entrypt.in () )); + */ + } + + + FILE* fp = fopen ("plan.h", "w"); + + for (i=0;i < info_len; ++i) + { + ACE_OS::fprintf (fp, + "extern \"C\" ::Components::HomeExecutorBase_ptr %s (void);\n", + infos[i].executor_entrypt.in ()); + ACE_OS::fprintf (fp, + "extern \"C\" ::PortableServer::Servant %s \n", + infos[i].servant_entrypt.in ()); + ACE_OS::fprintf (fp, + "\t\t(::Components::HomeExecutorBase_ptr p,\n"); + ACE_OS::fprintf (fp, + "\t\t::CIAO::Session_Container *c\n"); + ACE_OS::fprintf (fp, + "\t\tACE_ENV_ARG_DECL_WITH_DEFAULTS);\n"); + } + + ACE_OS::fprintf (fp, "struct HomeAttributes\n"); + ACE_OS::fprintf (fp, "{\n"); + ACE_OS::fprintf (fp, " ACE_TString component_instance_name_;\n"); + ACE_OS::fprintf (fp, " /// Specify the entrypoint to component executor DLL.\n"); + ACE_OS::fprintf (fp, " ACE_TString executor_entrypt_;\n"); + ACE_OS::fprintf (fp, " ::CIAO::HomeFactory executor_fptr_;\n"); + ACE_OS::fprintf (fp, " /// Specify the entrypoint to component servant DLL.\n"); + ACE_OS::fprintf (fp, " ACE_TString servant_entrypt_;\n"); + ACE_OS::fprintf (fp, " ::CIAO::ServantFactory servant_fptr_;\n"); + ACE_OS::fprintf (fp, "};\n"); + ACE_OS::fprintf (fp, "//Homes\n"); + ACE_OS::fprintf (fp, "HomeAttributes homes_table[]= \n"); + ACE_OS::fprintf (fp, "{\n"); + for (i=0;i < info_len; ++i) + { + ACE_OS::fprintf (fp, "\t{\"%s\", \"%s\", %s, \"%s\", %s}", + infos[i].component_instance_name.in (), + infos[i].executor_entrypt.in (), + infos[i].executor_entrypt.in (), + infos[i].servant_entrypt.in (), + infos[i].servant_entrypt.in () ); + + if (i != info_len-1) + ACE_OS::fprintf (fp, ",\n"); + } + ACE_OS::fprintf (fp, "};\n\n"); + + ACE_OS::fprintf (fp, "char plan_cdr_buffer[%d] = {", out_cdr.total_length ()); + for (int i=0; i < out_cdr.total_length (); ++i) + { + ACE_OS::fprintf(fp, "0x%X", out_char_array[i]); + if (i<out_cdr.total_length ()) + ACE_OS::fprintf(fp, ",\n"); + } + ACE_OS::fprintf (fp, "};\n\n"); + + fclose (fp); + + } + catch (const DOMException& e) + { + const unsigned int maxChars = 2047; + XMLCh errText[maxChars + 1]; + + ACE_ERROR ((LM_ERROR, "\nException occured while parsing %s: \ + \n",plan_url)); + ACE_ERROR ((LM_ERROR, "DOMException code: %d\n ", e.code)); + if (DOMImplementation::loadDOMExceptionMsg (e.code, errText, maxChars)) + { + char* message = XMLString::transcode (errText); + ACE_Auto_Basic_Array_Ptr<char> cleanup_message (message); + ACE_ERROR ((LM_ERROR, "Message is: %s\n", message)); + } + //ACE_PRINT_EXCEPTION ("Caught DOM Exception: "); + ACE_ERROR ((LM_ERROR, "Caught DOM exception\n")); + return -1; + } + catch (...) + { + ACE_ERROR ((LM_ERROR, "Caught unknown exception\n")); + return -1; + } + + return 0; +} diff --git a/TAO/CIAO/DAnCE/StaticConfigurator/StaticDAnCEParser.mpc b/TAO/CIAO/DAnCE/StaticConfigurator/StaticDAnCEParser.mpc new file mode 100644 index 00000000000..18e936321b8 --- /dev/null +++ b/TAO/CIAO/DAnCE/StaticConfigurator/StaticDAnCEParser.mpc @@ -0,0 +1,18 @@ +// -*- MPC -*- +// $Id$ + +project(StaticDAnCEParser): ciao_deployment_stub, ciao_deployment_svnt, ciao_server_dnc, taoexe, xerces { + exename = StaticDAnCEParser + requires += exceptions + includes += /usr/include + includes += ../NodeApplicationManager ../DomainApplicationManager ../NodeManager + libpaths += /usr/lib + libs += Config_Handlers + after += Config_Handlers + libs += TAO_IORTable RepositoryManager NodeApplicationManager DomainApplicationManager Node_Daemon + after += TAO_IORTable RepositoryManager NodeApplicationManager DomainApplicationManager Node_Daemon + + Source_Files { + StaticDAnCEParser.cpp + } +} diff --git a/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.cpp b/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.cpp index 5c8c4fcf553..0c507ce0208 100644 --- a/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.cpp +++ b/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.cpp @@ -6,13 +6,13 @@ # include "NodeApplication_Impl.inl" #endif /* __ACE_INLINE__ */ -CIAO::NodeApplication_Impl::~NodeApplication_Impl (void) +CIAO::NodeApplication_Impl_Base::~NodeApplication_Impl_Base (void) { delete this->container_; } void -CIAO::NodeApplication_Impl::finishLaunch ( +CIAO::NodeApplication_Impl_Base::finishLaunch ( const Deployment::Connections & providedReference, CORBA::Boolean start ACE_ENV_ARG_DECL) @@ -98,7 +98,7 @@ CIAO::NodeApplication_Impl::finishLaunch ( ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "NodeApplication_Impl::finishLaunch\t\n"); + "NodeApplication_Impl_Base::finishLaunch\t\n"); ACE_RE_THROW; } @@ -106,7 +106,7 @@ CIAO::NodeApplication_Impl::finishLaunch ( } void -CIAO::NodeApplication_Impl::start (ACE_ENV_SINGLE_ARG_DECL) +CIAO::NodeApplication_Impl_Base::start (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Deployment::StartError)) { @@ -125,7 +125,7 @@ CIAO::NodeApplication_Impl::start (ACE_ENV_SINGLE_ARG_DECL) } void -CIAO::NodeApplication_Impl::start_i (Funct_Ptr functor +CIAO::NodeApplication_Impl_Base::start_i (Funct_Ptr functor ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Deployment::StartError)) @@ -143,7 +143,7 @@ CIAO::NodeApplication_Impl::start_i (Funct_Ptr functor } Deployment::Properties * -CIAO::NodeApplication_Impl::properties (ACE_ENV_SINGLE_ARG_DECL) +CIAO::NodeApplication_Impl_Base::properties (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { Deployment::Properties * tmp; @@ -157,7 +157,7 @@ CIAO::NodeApplication_Impl::properties (ACE_ENV_SINGLE_ARG_DECL) } Deployment::ComponentInfos * -CIAO::NodeApplication_Impl::install ( +CIAO::NodeApplication_Impl_Base::install ( const ::Deployment::ImplementationInfos & impl_infos ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, @@ -267,7 +267,7 @@ CIAO::NodeApplication_Impl::install ( // versions of emulated exception parameters. Please remove // the "_WITH_DEFAULTS" Components::CCMHome_ptr -CIAO::NodeApplication_Impl::install_home ( +CIAO::NodeApplication_Impl_Base::install_home ( const ::Deployment::ImplementationInfo & impl_info ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, @@ -300,7 +300,7 @@ CIAO::NodeApplication_Impl::install_home ( } void -CIAO::NodeApplication_Impl::remove (ACE_ENV_SINGLE_ARG_DECL) +CIAO::NodeApplication_Impl_Base::remove (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::RemoveFailure)) { @@ -331,7 +331,7 @@ CIAO::NodeApplication_Impl::remove (ACE_ENV_SINGLE_ARG_DECL) } void -CIAO::NodeApplication_Impl::remove_home (const char * comp_ins_name +CIAO::NodeApplication_Impl_Base::remove_home (const char * comp_ins_name ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::RemoveFailure)) @@ -358,7 +358,7 @@ CIAO::NodeApplication_Impl::remove_home (const char * comp_ins_name } Components::CCMHomes * -CIAO::NodeApplication_Impl::get_homes (ACE_ENV_SINGLE_ARG_DECL) +CIAO::NodeApplication_Impl_Base::get_homes (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { Components::CCMHomes * tmp; @@ -387,14 +387,10 @@ CIAO::NodeApplication_Impl::get_homes (ACE_ENV_SINGLE_ARG_DECL) } CORBA::Long -CIAO::NodeApplication_Impl::init (ACE_ENV_SINGLE_ARG_DECL) +CIAO::NodeApplication_Impl_Base::init (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { - ACE_NEW_THROW_EX (this->container_, - CIAO::Session_Container (this->orb_.in (), - 0, - 0), - CORBA::NO_MEMORY ()); + this->create_container (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (-1); return this->container_->init (0, @@ -406,7 +402,7 @@ CIAO::NodeApplication_Impl::init (ACE_ENV_SINGLE_ARG_DECL) } CORBA::Object_ptr -CIAO::NodeApplication_Impl::get_node_application_manager ( +CIAO::NodeApplication_Impl_Base::get_node_application_manager ( ACE_ENV_SINGLE_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((CORBA::SystemException)) { @@ -415,13 +411,13 @@ CIAO::NodeApplication_Impl::get_node_application_manager ( PortableServer::POA_ptr -CIAO::NodeApplication_Impl::_default_POA (void) +CIAO::NodeApplication_Impl_Base::_default_POA (void) { return PortableServer::POA::_duplicate (this->poa_.in ()); } void -CIAO::NodeApplication_Impl::remove_components (ACE_ENV_SINGLE_ARG_DECL) +CIAO::NodeApplication_Impl_Base::remove_components (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::RemoveFailure)) { @@ -450,7 +446,7 @@ CIAO::NodeApplication_Impl::remove_components (ACE_ENV_SINGLE_ARG_DECL) } void -CIAO::NodeApplication_Impl::remove_component (const char * comp_ins_name +CIAO::NodeApplication_Impl_Base::remove_component (const char * comp_ins_name ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Components::RemoveFailure)) @@ -489,7 +485,7 @@ CIAO::NodeApplication_Impl::remove_component (const char * comp_ins_name // start point for configurations. /* void -CIAO::NodeApplication_Impl:: +CIAO::NodeApplication_Impl_Base:: parse_config_values (const ::Deployment::Properties & properties, struct home_installation_info &component_install_info ACE_ENV_ARG_DECL) @@ -538,3 +534,53 @@ parse_config_values (const ::Deployment::Properties & properties, // the modeling tool will ensure the complete info to presented in the properties. } */ + +CIAO::NodeApplication_Impl:: +NodeApplication_Impl (CORBA::ORB_ptr o, + PortableServer::POA_ptr p) + : NodeApplication_Impl_Base (o, p) +{ +} + +CIAO::NodeApplication_Impl:: +~NodeApplication_Impl () +{ +} + +CIAO::Container* +CIAO::NodeApplication_Impl::create_container (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_NEW_THROW_EX (this->container_, + CIAO::Session_Container (this->orb_.in (), + 0, + 0), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); +} + +CIAO::Static_NodeApplication_Impl:: +Static_NodeApplication_Impl (CORBA::ORB_ptr o, + PortableServer::POA_ptr p, + Static_Config_EntryPoints_Maps* static_config_entrypoints_map) + : NodeApplication_Impl_Base (o, p), + static_config_entrypoints_map_ (static_config_entrypoints_map) +{ +} + +CIAO::Container* +CIAO::Static_NodeApplication_Impl::create_container (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_NEW_THROW_EX (this->container_, + CIAO::Session_Container (this->orb_.in (), + 1, + this->static_config_entrypoints_map_), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); +} + +CIAO::Static_NodeApplication_Impl:: +~Static_NodeApplication_Impl () +{ +} diff --git a/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.h b/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.h index 64e497f2fdb..aef22a45e9d 100644 --- a/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.h +++ b/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.h @@ -49,17 +49,17 @@ using CIAO::Utility::write_IOR; namespace CIAO { - class CIAO_SERVER_Export NodeApplication_Impl + class CIAO_SERVER_Export NodeApplication_Impl_Base : public virtual POA_Deployment::NodeApplication { public: // Default constructor. - NodeApplication_Impl (CORBA::ORB_ptr o, + NodeApplication_Impl_Base (CORBA::ORB_ptr o, PortableServer::POA_ptr p); // Default destructor. - virtual ~NodeApplication_Impl (void); + virtual ~NodeApplication_Impl_Base (void); /** @@ -166,6 +166,9 @@ namespace CIAO protected: + virtual Container* create_container (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException))=0; + // @@ (OO) Methods internal to the class, e.g. protected and not // defined in IDL should not be using default arguments. // Please drop the "_WITH_DEFAULTS" in all of the below @@ -243,6 +246,43 @@ namespace CIAO Components::InvalidConfiguration)); */ }; + + class CIAO_SERVER_Export NodeApplication_Impl + : public NodeApplication_Impl_Base + { + public: + + // Default constructor. + NodeApplication_Impl (CORBA::ORB_ptr o, + PortableServer::POA_ptr p); + + Container* create_container (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Default destructor. + virtual ~NodeApplication_Impl (); + }; + + class CIAO_SERVER_Export Static_NodeApplication_Impl + : public NodeApplication_Impl_Base + { + public: + + // Default constructor. + Static_NodeApplication_Impl (CORBA::ORB_ptr o, + PortableServer::POA_ptr p, + Static_Config_EntryPoints_Maps* static_config_entrypoints_map); + + Container* create_container (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Default destructor. + virtual ~Static_NodeApplication_Impl (); + + protected: + Static_Config_EntryPoints_Maps* static_config_entrypoints_map_; + }; + } #if defined (__ACE_INLINE__) diff --git a/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.inl b/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.inl index dd541db9b70..7a35f0f386f 100644 --- a/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.inl +++ b/TAO/CIAO/DAnCE/ciao/NodeApplication_Impl.inl @@ -2,8 +2,8 @@ // $Id$ ACE_INLINE -CIAO::NodeApplication_Impl:: -NodeApplication_Impl (CORBA::ORB_ptr o, +CIAO::NodeApplication_Impl_Base:: +NodeApplication_Impl_Base (CORBA::ORB_ptr o, PortableServer::POA_ptr p) : orb_ (CORBA::ORB::_duplicate (o)), |