summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TAO/CIAO/ChangeLog23
-rw-r--r--TAO/CIAO/DnC/ExecutionManager/ExecutionManager_Impl.cpp137
-rw-r--r--TAO/CIAO/DnC/ExecutionManager/ExecutionManager_Impl.h176
-rw-r--r--TAO/CIAO/DnC/ExecutionManager/ExecutionManager_Impl.inl15
-rw-r--r--TAO/CIAO/DnC/Node/NodeApplicationManager_Impl.h148
-rw-r--r--TAO/CIAO/DnC/Node/NodeApplication_Impl.h90
-rw-r--r--TAO/CIAO/DnC/NodeApplicationManager/CIAO_NodeApplicationManager.idl46
-rw-r--r--TAO/CIAO/DnC/NodeApplicationManager/NodeApplicationManager.cpp181
-rw-r--r--TAO/CIAO/DnC/NodeApplicationManager/NodeApplicationManager.mpc16
-rw-r--r--TAO/CIAO/DnC/NodeApplicationManager/NodeApplicationManager_Impl.cpp507
-rw-r--r--TAO/CIAO/DnC/NodeApplicationManager/NodeApplicationManager_Impl.h288
-rw-r--r--TAO/CIAO/DnC/NodeApplicationManager/NodeApplicationManager_Impl.inl27
-rw-r--r--TAO/CIAO/DnC/NodeManager/NodeDaemon.idl35
-rw-r--r--TAO/CIAO/DnC/NodeManager/NodeDaemon.mpc35
-rw-r--r--TAO/CIAO/DnC/NodeManager/NodeDaemon_Impl.cpp161
-rw-r--r--TAO/CIAO/DnC/NodeManager/NodeDaemon_Impl.h159
-rw-r--r--TAO/CIAO/DnC/NodeManager/NodeDaemon_Impl.inl12
-rw-r--r--TAO/CIAO/DnC/NodeManager/Node_Daemon.cpp271
18 files changed, 2089 insertions, 238 deletions
diff --git a/TAO/CIAO/ChangeLog b/TAO/CIAO/ChangeLog
index 59a947fd47d..bc58a8df2de 100644
--- a/TAO/CIAO/ChangeLog
+++ b/TAO/CIAO/ChangeLog
@@ -1,3 +1,26 @@
+Mon May 17 19:01:36 2004 Tao Lu <lu@dre.vanderbilt.edu>
+
+ * DnC/ExecutionManager/ExecutionManager_Impl.cpp:
+ * DnC/ExecutionManager/ExecutionManager_Impl.h:
+ * DnC/ExecutionManager/ExecutionManager_Impl.inl:
+ * DnC/NodeApplicationManager/CIAO_NodeApplicationManager.idl:
+ * DnC/NodeApplicationManager/NodeApplicationManager.cpp:
+ * DnC/NodeApplicationManager/NodeApplicationManager.mpc:
+ * DnC/NodeApplicationManager/NodeApplicationManager_Impl.cpp:
+ * DnC/NodeApplicationManager/NodeApplicationManager_Impl.h:
+ * DnC/NodeApplicationManager/NodeApplicationManager_Impl.inl:
+ * DnC/NodeManager/NodeDaemon.idl:
+ * DnC/NodeManager/NodeDaemon.mpc:
+ * DnC/NodeManager/NodeDaemon_Impl.cpp:
+ * DnC/NodeManager/NodeDaemon_Impl.h:
+ * DnC/NodeManager/NodeDaemon_Impl.inl:
+ * DnC/NodeManager/Node_Daemon.cpp:
+ Added these files.
+
+ * DnC/Node/NodeApplicationManager_Impl.h
+ * DnC/Node/NodeApplication_Impl.h
+ Removed these files.
+
Mon May 17 16:17:40 2004 Jaiganesh B <jai@dre.vanderbilt.edu>
* DnC/Config_Handlers/Plan_Handler.cpp:
diff --git a/TAO/CIAO/DnC/ExecutionManager/ExecutionManager_Impl.cpp b/TAO/CIAO/DnC/ExecutionManager/ExecutionManager_Impl.cpp
new file mode 100644
index 00000000000..3218380203e
--- /dev/null
+++ b/TAO/CIAO/DnC/ExecutionManager/ExecutionManager_Impl.cpp
@@ -0,0 +1,137 @@
+/* -*- C++ -*- */
+// $Id$
+
+#include "ExecutionManager_Impl.h"
+
+#if !defined (__ACE_INLINE__)
+# include "ExecutionManager_Impl.inl"
+#endif /* __ACE_INLINE__ */
+
+CIAO::ExecutionManager_Impl::~ExecutionManager_Impl ()
+{
+ // @@ functionality not clear for now.
+}
+
+int
+CIAO::ExecutionManager_Impl::init (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+
+}
+
+DomainApplicationManager_ptr
+CIAO::ExecutionManager_Impl::preparePlan (const Deployment::DeploymentPlan & plan,
+ CORBA::Boolean commitResources
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Deployment::ResourceNotAvailable,
+ Deployment::PlanError,
+ Deployment::StartError
+ ))
+{
+ /*-----------------------------------------------------
+ * 1. Note: possible manipulation of the plan?
+ **/
+
+
+ /*-----------------------------------------------------
+ * 2. Create the DomainApplicationManager
+ **/
+
+ CIAO::DomainApplicationManager_Impl * servant = 0;
+
+ // @@ Future changes are expected to happend for the constructor! -- Tao.
+ ACE_NEW_RETURN (servant,
+ CIAO::DomainApplicationManager_Impl
+ (this->orb_.in (),
+ this->poa_.in (),
+ this->tm_cache_.in ()),
+ 0);
+
+ PortableServer::ServantBase_var save_servant (servant);
+
+ /*-----------------------------------------------------
+ * 3. Get ObjRef of the DomainApplicationManager
+ *
+ * @@ Note: Unlike Assembly_Factory I don't do the
+ * IOR table registration. Since the spec specifies
+ * that this operation should return the objectref only.
+ *
+ * I will put the IOR registration into the client program which
+ * starts assembly process and instantiate the ExecutionManager_Impl
+ * interface.
+ **/
+
+ // Register with our POA and activate the object.
+ PortableServer::ObjectId_var oid
+ = this->poa_->activate_object (servant
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ // Get the reference of the object.
+ CORBA::Object_var objref
+ = this->poa_->id_to_reference (oid.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ this->dam_cache_ =
+ Deployment::DomainApplicationManager::_narrow (objref.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ // Ask the DomainApplicationManager to initialize itself.
+ if (this->dam_cache_->init (deployment_config_file_.in ()) == -1)
+ {
+ // should the DomainApplicationManager be deleted?
+ // if the program got terminated at this point then we don't care
+ // since all these interfaces reside in the same process.
+ return 0;
+ }
+ // Put the object reference into the list.
+ CORBA::ULong len = dam_list_->length ();
+ dam_list_->length (len+1);
+
+ (*dam_list)[len] = dam_cache_.in ();
+
+ return this->dam_cache_.ptr ();
+}
+
+
+
+Deployment::DomainApplicationManagers *
+CIAO::getManagers (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ Deployment::DomainApplicationManagers_var
+ tmp (this->dam_list_);
+ return tmp._retn ();
+}
+
+
+void destroyManager (Deployment::DomainApplicationManager_ptr manager
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Deployment::StopError))
+{
+ if (manager == 0)
+ ACE_THROW (Deployment::StopError ());
+ else
+ {
+ //@@ I probably should make sure that the pointer is a valid
+ // objectref here, which implies searching in the list. --Tao
+ Deployment::DomainApplicationManager_var
+ tmp (manager);
+
+ //@@ All bookkeeping could come in here! --Tao
+
+ PortableServer::ObjectId_var oid
+ = this->poa_->reference_to_id (tmp.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ this->poa_->deactivate_object (oid.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ }
+
+}
diff --git a/TAO/CIAO/DnC/ExecutionManager/ExecutionManager_Impl.h b/TAO/CIAO/DnC/ExecutionManager/ExecutionManager_Impl.h
new file mode 100644
index 00000000000..11ede10226b
--- /dev/null
+++ b/TAO/CIAO/DnC/ExecutionManager/ExecutionManager_Impl.h
@@ -0,0 +1,176 @@
+//$Id$
+/*=======================================================================
+ *
+ * @file ExecutionManager_Impl.h
+ *
+ * This file contains implementation for :
+ * Deployment::ExecutionManager interface.
+ *
+ * @auther Tao Lu <lu@dre.vanderbilt.edu>
+ *
+ *======================================================================*/
+
+#ifndef EXECUTIONMANAGER_IMPL_H
+#define EXECUTIONMANAGER_IMPL_H
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Active_Map_Manager_T.h"
+#include "ace/Synch_Traits.h"
+#include "../DeploymentS.h"
+#include "Deployment_Configuration.h"
+
+/**
+ *
+ * @class ExecutionManager_Impl
+ *
+ * @brief This class implements the ExecutionManger. ExecutionManager starts
+ * the execution process after the planning stage.
+ *
+ * Serval assumptions I made now:
+ *
+ * 1. There are 1 ExecutionManager per application. => AssemblyFactory
+ *
+ * 2. This interface will be brought up at or before the actual execution
+ * of an application starts.
+ *
+ * 3. No XML parsing is be done in this interface, the requrest will be
+ * forwarded to the DomainApplicationManager.
+ *
+ **/
+
+
+/*@@ Note: Right now we have tow Deployment namespace:
+ *
+ * 1. ::Components::Deployment => from the old spec
+ * 2. ::Deployment => from the new spec.
+ *
+ * I plan to keep the new spec seperated from the old one
+ * until I figure out how much of the "pure" code reuse
+ * we could have in the DnC implementation.
+ **/
+
+namespace CIAO
+{
+ class ExecutionManager_Impl :
+ public virtual POA_Deployment::ExecutionManager,
+ public virtual PortableServer::RefCountServantBase
+ {
+
+ public:
+
+ // Default constructor.
+ ExecutionManager_Impl (CORBA::ORB_ptr orb,
+ PortableServer::poa_ptr poa,
+ char * config_file
+ ACE_ENV_ARG_DECL);
+
+ // Default destructor.
+ ~ExecutionManager_Impl ();
+
+
+ // Generate an ApplicationManager factory.
+ virtual DomainApplicationManager_ptr
+ preparePlan
+ (
+ const Deployment::DeploymentPlan & plan,
+ CORBA::Boolean commitResources
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ Deployment::ResourceNotAvailable,
+ Deployment::PlanError,
+ Deployment::StartError
+ ));
+
+ // Return a set of the currently held DomainApplicationMnager.
+ virtual Components::Deployment::DomainApplicationManagers *
+ getManagers (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((
+ CORBA::SystemException
+ ));
+
+
+ // Destroy a specific manager.
+ virtual void
+ destroyManager
+ (
+ Deployment::DomainApplicationManager_ptr manager
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ Components::Deployment::StopError
+ ));
+
+
+ /*==================================================================
+ * Below are CIAO specific helper member functions.
+ * They are ported from the AssemblyFactory_Impl class from
+ * the old DnC spec.
+ *================================================================*/
+
+ /* Initialize the ExecutionManager with a configuration file.
+ * @This method is also responsible for:
+ * 1. initialize targetmanager
+ *
+ * //2. initialize the nodelist (daemon list)
+ * This step has been postponed to the DomainApplicationMananger.
+ *
+ * 3. .....more?
+ **/
+ int init (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SEPC ((CORBA::SystemExecption));
+
+ // Some other helper funtions might be really helpful in the future.
+ // For example for GUI support..
+ // 1. Lookup for DomainApplicationManager.
+ // 2. Lookup for NodeManager.
+
+ protected:
+
+ // Cached last created DomainApplicationManager Factory.
+ Deployment::DomainApplicationManager_var
+ dam_cache_;
+
+ // Cached TargetManager.
+ Deployment::TargetManager_var tm_cache_;
+
+ // Cached logger
+ Deployment::Logger logger_cache_;
+
+ // Keep a list of managed DomainApplicationManager objects.
+ Deployment::DomainApplicationManagers_var
+ dam_list_;
+
+ /// Keep a list of managed NodeManager objects.
+ ACE_Active_Map_Manager
+ <Deployment::NodeManager_var>
+ nodemanager_map_;
+
+ // Deployment Configuration Info (INFO of Nodes for now)
+ //CIAO_Deployment_Configuration deployment_config_;
+ CORBA::String_var deployment_config_file_;
+
+ // Cached ORB pointer
+ CORBA::ORB_var orb_;
+
+ // Cached POA pointer
+ PortableServer::POA_var poa_;
+
+ // Synchronize mutex. This is just a place holder, this interface
+ // is supposed to run in singl thread mode only for now.
+ ACE_SYNCH_MUTEX lock_;
+ };
+
+};
+
+#if defined (__ACE_INLINE__)
+# include "ExecutionManager_Impl.inl"
+#endif /*__ACE_INLINE__*/
+
+#include /**/ "ace/post.h"
+#endif /* EXECUTIONMANAGER_IMPL_H */
diff --git a/TAO/CIAO/DnC/ExecutionManager/ExecutionManager_Impl.inl b/TAO/CIAO/DnC/ExecutionManager/ExecutionManager_Impl.inl
new file mode 100644
index 00000000000..caf4a2d3b8a
--- /dev/null
+++ b/TAO/CIAO/DnC/ExecutionManager/ExecutionManager_Impl.inl
@@ -0,0 +1,15 @@
+/* -*- C++ -*- */
+// $Id$
+ACE_INLINE
+CIAO::ExecutionManager_Impl::ExecutionManager_Impl (CORBA::ORB_ptr orb,
+ PortableServer::poa_ptr poa,
+ char * config_file
+ ACE_ENV_ARG_DECL)
+ : orb_ (CORBA::ORB::_duplicate (orb)),
+ poa_ (PortableServer::POA::_deplicate (poa)),
+ deployment_config_file_ (CORBA::string_dup (config_file))
+{
+ ACE_NEW_THROW_EX (dam_list_,
+ Deployment::DomainApplicationManagers,
+ CORBA::NO_MEMORY());
+}
diff --git a/TAO/CIAO/DnC/Node/NodeApplicationManager_Impl.h b/TAO/CIAO/DnC/Node/NodeApplicationManager_Impl.h
deleted file mode 100644
index 5c196329f6e..00000000000
--- a/TAO/CIAO/DnC/Node/NodeApplicationManager_Impl.h
+++ /dev/null
@@ -1,148 +0,0 @@
-//$Id$:
-/**
- *
- * @file NodeApplicationManager_Impl.h
- *
- * @auther Tao Lu <lu@dre.vanderbilt.edu>
- *
- **/
-// @@ Tao: IMHO, its a good practice to have CIAO included to make
-// things as clear as possible.
-#ifndef NODEAPPLICATIONMANAGER_IMPL_H
-#define NODEAPPLICATIONMANAGER_IMPL_H
-
-
-#include /**/ "ace/pre.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "ace/Synch_Traits.h"
-#include "DnC_DeploymentS.h"
-
-// @@Tao: Since you are doing an implementation of the DnC, should
-// this be in Deployment namespace. Wouldn't it be better put it in
-// CIAO namespace?
-
-// @@Bala, we will think more about the namespace issue. One point is we
-// should follow the spec for portability issue.
-namespace Deployment
-{
- /**
- *
- * @class NodeApplicationManager_Impl
- *
- * @brief This class implements the NodeApplicationManager interface.
- * This interface is very simillar to the old DnC CIAO_Daemon.
- *
- **/
- class NodeApplicationManager_Impl
- : public virtual POA_Deployment::NodeApplicationManager,
- public virtual PortableServer::RefCountServantBase
- {
- public:
-
- // constructor.
- NodeApplicationManager (NodeApplicationManagerManager_ptr nam_ptr,
- ACE_ENV_ARG_DECL_WITH_DEFAULTS);
-
- // Default destructor.
- virtual ~NodeApplicationManager (void);
-
- /**
- * @method startLaunch
- *
- * @brief
- *
- */
- virtual ::Deployment::Application_ptr
- startLaunch (const Deployment::Properties & configProperty,
- Deployment::Connections_out providedReference,
- CORBA::Boolean start
- ACE_ENV_ARG_DECL_WITH_DEFAULTS)
- ACE_THROW_SPEC ((
- CORBA::SystemException,
- Deployment::ResourceNotAvailable,
- Deployment::StartError,
- Deployment::InvalidProperty
- ));
-
- /**
- * @method start
- *
- * @brief
- *
- */
- irtual void destroyApplication (Deployment::Application_ptr app
- ACE_ENV_ARG_DECL_WITH_DEFAULTS)
- ACE_THROW_SPEC ((
- CORBA::SystemException,
- Deployment::StopError
- ));
-
- /**
- * @name internal operations using the ACE_Map methods
- */
- int obj_bind (const char *orb_id, CORBA::Object_ptr obj);
- int obj_unbind (const char *orb_id);
-
- int na_bind (const char *orb_id, ::Deployment::NodeApplication_ptr na);
- int na_unbind (const char *orb_id);
-
- protected:
-
- // @@ Tao: DO you really two locks here? Can't you use just one
- // and synchronize access to the map. Do you need so much
- // concurrency out here?
- typedef ACE_Hash_Map_Manager_Ex<const char *,
- CORBA::Object_ptr,
- ACE_Hash<const char *>,
- ACE_Equal_To<const char *>,
- TAO_SYNCH_MUTEX> OBJ_Table;
- typedef OBJ_Table::iterator OBJ_Iterator;
-
- // CIAO's Object_Set<> could be used here as well.
- // It takes o(n) time to do find though.
- typedef ACE_Hash_Map_Manager_Ex<const char *,
- ::Deployment::NodeApplication_ptr,
- ACE_Hash<const char *>,
- ACE_Equal_To<const char *>,
- TAO_SYNCH_MUTEX> NodeApplication_Table;
-
- typedef NodeApplication_Table::iterator NodeApplication_Iterator;
-
- //Cached Plan
- DeploymentPlan_var plan_;
-
- //Launched Application(NodeApplication) but not terminated yet.
- NodeApplication_Table nodeapplication_table;
-
- // management?
- // Cached NodeManager
- NodeManager_var node_manager_;
-
- // Cached DomainApplication
- DomainApplication_var domain_application_;
-
- // Keep a pointer to the managing ORB serving this servant.
- CORBA::ORB_var orb_;
-
- // Keep a pointer to the managing POA.
- PortableServer::POA_var poa_;
-
- // My Canonical name.
- CORBA::String_var name_;
-
- // Internal object hash table.
- OBJ_Table OBJ_table_;
-
-
- }; /* class NodeApplicationManager_Impl */
-
-
-}; /* namespace Deployment */
-
-#include /**/ "ace/post.h"
-
-#endif /* NODEAPPLICATIONMANAGER_IMPL_H */
diff --git a/TAO/CIAO/DnC/Node/NodeApplication_Impl.h b/TAO/CIAO/DnC/Node/NodeApplication_Impl.h
deleted file mode 100644
index 6356a26c017..00000000000
--- a/TAO/CIAO/DnC/Node/NodeApplication_Impl.h
+++ /dev/null
@@ -1,90 +0,0 @@
-//$Id$:
-/**
- *
- * @file NodeApplication_Impl.h
- *
- * @auther Tao Lu <lu@dre.vanderbilt.edu>
- *
- **/
-
-#ifndef NODEAPPLICATION_IMPL_H
-#define NODEAPPLICATION_IMPL_H
-
-#include /**/ "ace/pre.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "DnC_DeploymentS.h"
-
-namespace Deployment
-{
-
- /**
- *
- * @class NodeApplication_Impl
- *
- * @brief This class implements the NodeApplication interface.
- * This interface is simillar to the old DnC CIAO_Daemon.
- *
- **/
- class NodeApplication_Impl
- : public virtual POA_Deployment::NodeApplication
- {
- public:
-
- // constructor.
- NodeApplication (NodeApplicationManager_ptr nam_ptr,
- ACE_ENV_ARG_DECL_WITH_DEFAULTS);
-
- // Default destructor.
- virtual ~NodeApplication (void);
-
- /**
- * @method finishLaunch
- *
- * @brief
- *
- */
- virtual void finishLaunch (const Deployment::Connections & providedReference,
- CORBA::Boolean start
- ACE_ENV_ARG_DECL_WITH_DEFAULTS)
- ACE_THROW_SPEC ((CORBA::SystemException,
- Deployment::StartError,
- Deployment::InvalidConnection
- ));
-
- /**
- * @method start
- *
- * @brief
- *
- */
- virtual void start (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
- ACE_THROW_SPEC ((CORBA::SystemException,
- Deployment::StartError
- ));
-
- protected:
- // Cached Manager
- NodeApplicationManager_var node_application_manager_;
-
- // Cached ComponentServer
- // Note: Need to deal with the namespace refactoring.
- ComponentServer_var component_server_;
-
- // Cached ComponentInstallation
- ComponentInstallation_var component_installation_;
-
- // Cached ServerActivator
- ServerActivator_var server_activator_;
-
- }; /* class NodeApplication_Impl */
-
-
-}; /* namespace Deployment */
-
-#include /**/ "ace/post.h"
-
-#endif /* NODEAPPLICATION_IMPL_H */
diff --git a/TAO/CIAO/DnC/NodeApplicationManager/CIAO_NodeApplicationManager.idl b/TAO/CIAO/DnC/NodeApplicationManager/CIAO_NodeApplicationManager.idl
new file mode 100644
index 00000000000..c8f27dfde92
--- /dev/null
+++ b/TAO/CIAO/DnC/NodeApplicationManager/CIAO_NodeApplicationManager.idl
@@ -0,0 +1,46 @@
+// $Id$
+
+/**
+ * This IDL file is used to combine the ServerActivator
+ * interface in the old spec with the NodeApplicationManager
+ * interface in the new spec.
+ *
+ * NodeApplicationManager will be like an abstract base class, which means
+ * that when ever a servant of the type is needed CIAO_NodeApplicationManager
+ * should be used instead.
+ */
+
+/**
+ * @@ Compile this file with:
+ *
+ * tao_idl -I ../.. \
+ * -Wb,export_macro=CIAO_Export \
+ * -Wb,export_include=CIAO_export.h \
+ * -Wb,pre_include="ace/pre.h" \
+ * -Wb,post_include="ace/post.h" \
+ * CCM_Deployment.idl
+ */
+//@@ The export macro file should be fixed.
+
+
+#if !defined (CIAO_NODEAPPLICATIONMANAGER_IDL)
+#define CIAO_NODEAPPLICATIONMANAGER_IDL
+
+#include "../Deployment.idl"
+//#include "ciao/CCM_Base.idl"
+// for some exception definitions. Future refactorying might be required.
+
+#include "ciao/CCM_Component.idl"
+// For ConfigValues.
+
+module CIAO
+{
+ interface NodeApplicationManager_Callback
+ {
+ NodeApplicationManager
+ register_node_application (in Deployment::NodeApplication na,
+ out Components::ConfigValues config);
+ };
+};
+
+#endif /* CIAO_NODEAPPLICATIONMANAGER_IDL */
diff --git a/TAO/CIAO/DnC/NodeApplicationManager/NodeApplicationManager.cpp b/TAO/CIAO/DnC/NodeApplicationManager/NodeApplicationManager.cpp
new file mode 100644
index 00000000000..7d1770bdf2e
--- /dev/null
+++ b/TAO/CIAO/DnC/NodeApplicationManager/NodeApplicationManager.cpp
@@ -0,0 +1,181 @@
+// $Id$
+
+/**
+ * @file NodeApplicationManager.cpp
+ *
+ * @brief CIAO's NodeApplicationManager implementation
+ * This program is mainly for debug purpose.
+ */
+
+#include "NodeApplicationManager_Impl.h"
+#include "tao/IORTable/IORTable.h"
+#include "ace/SString.h"
+#include "ace/Read_Buffer.h"
+#include "ace/Get_Opt.h"
+#include "ace/OS_NS_stdio.h"
+
+char *ior_file_name_ = 0;
+
+//@@ This needs to be changed.
+const char *comserv_path_ = "../ComponentServer/ComponentServer";
+char *installation_ior_ = 0;
+CORBA::ULong spawn_wait_ = 5;
+
+int
+parse_args (int argc, char *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "n:o:d:i:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'o': // get the file name to write to
+ ior_file_name_ = get_opts.opt_arg ();
+ break;
+
+ case 'n': // get the path name to the component server
+ comserv_path_ = get_opts.opt_arg ();
+ break;
+
+ case 'd': // get the path name to the component server
+ spawn_wait_ = ACE_OS::atoi (get_opts.opt_arg ());
+ break;
+
+ case 'i': // get the ior to a ComponentInstallation interface
+ installation_ior_ = get_opts.opt_arg ();
+ break;
+
+ case '?': // display help for use of the server.
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s"
+ "-n <component server pathname>"
+ "-o <ior_output_file>"
+ "-d <time (in second) to wait for component server>"
+ "\n",
+ argv [0]),
+ -1);
+ }
+
+ if (installation_ior_ == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "An IOR to a ComponentInstallation interface is needed."
+ " Specified with \"-i <ior>\"\n"),
+ -1);
+
+ return 0;
+}
+
+int
+write_IOR(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 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+ ACE_TRY_NEW_ENV
+ {
+ // Initialize orb
+ CORBA::ORB_var orb = CORBA::ORB_init (argc,
+ argv,
+ ""
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (parse_args (argc, argv) != 0)
+ return -1;
+
+ // 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;
+
+ CIAO::NodeApplicationManager_Impl *nam_servant;
+
+ ACE_NEW_RETURN (nam_servant,
+ CIAO::NodeApplicationManager_Impl (orb.in (),
+ poa.in ()),
+ -1);
+
+ nam_servant->init (comserv_path_,
+ spawn_wait_,
+ installation_ior_,
+ 0,
+ 0
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ PortableServer::ServantBase_var safe_servant (nam_servant);
+
+ CORBA::String_var str = orb->object_to_string (nam_servant->_ciao_get_objref ()
+ ACE_ENV_ARG_PARAMETER);
+
+ CORBA::Object_var table_object =
+ orb->resolve_initial_references ("IORTable"
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ IORTable::Table_var adapter =
+ IORTable::Table::_narrow (table_object.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (adapter.in ()))
+ {
+ ACE_ERROR ((LM_ERROR, "Nil IORTable\n"));
+ }
+ else
+ {
+ adapter->bind ("NodeApplicationManager", str.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+
+ write_IOR (str.in ());
+ ACE_DEBUG ((LM_INFO, "NodeApplicationManager IOR: %s\n", str.in ()));
+
+ // End Deployment part
+
+ ACE_DEBUG ((LM_DEBUG,
+ "Running NodeApplicationManager...\n"));
+
+ // Run the main event loop for the ORB.
+ orb->run (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "server::main\t\n");
+ return 1;
+ }
+ ACE_ENDTRY;
+
+ return 0;
+}
diff --git a/TAO/CIAO/DnC/NodeApplicationManager/NodeApplicationManager.mpc b/TAO/CIAO/DnC/NodeApplicationManager/NodeApplicationManager.mpc
new file mode 100644
index 00000000000..2f80bc1ca1c
--- /dev/null
+++ b/TAO/CIAO/DnC/NodeApplicationManager/NodeApplicationManager.mpc
@@ -0,0 +1,16 @@
+// -*- MPC -*-
+// $Id$
+
+project(NodeApplicationManager): ciao_server, iortable {
+ requries = dnc
+ Source_Files {
+ NodeApplicationManager.cpp
+ }
+}
+
+project(NodeApplicationManager_test_client) : ciao_server {
+ requries = dnc
+ Source_Files {
+ NodeApplicationManager_test_client.cpp
+ }
+}
diff --git a/TAO/CIAO/DnC/NodeApplicationManager/NodeApplicationManager_Impl.cpp b/TAO/CIAO/DnC/NodeApplicationManager/NodeApplicationManager_Impl.cpp
new file mode 100644
index 00000000000..aebc57ed822
--- /dev/null
+++ b/TAO/CIAO/DnC/NodeApplicationManager/NodeApplicationManager_Impl.cpp
@@ -0,0 +1,507 @@
+// $Id$
+
+#include "NodeApplicationManager_Impl.h"
+#include "ace/Process.h"
+#include "ace/Read_Buffer.h"
+#include "ace/OS_NS_stdio.h"
+
+#if !defined (__ACE_INLINE__)
+# include "NodeApplicationManager_Impl.inl"
+#endif /* __ACE_INLINE__ */
+
+CIAO::NodeApplicationManager_Callback_Impl::
+NodeApplicationManager_Callback_Impl (CORBA::ORB_ptr o,
+ PortableServer::POA_ptr p,
+ Deployment::NodeApplicationManager_ptr nam,
+ const Components::ConfigValues &config )
+ : orb_ (CORBA::ORB::_duplicate (o)),
+ poa_ (PortableServer::POA::_duplicate (p)),
+ nam_ (nam)
+{
+ this->config_ = new Components::ConfigValues (config);
+}
+
+CIAO::NodeApplicationManager_Callback_Impl::~NodeApplicationManager_Callback_Impl ()
+{
+}
+
+PortableServer::POA_ptr
+CIAO::NodeApplicationManager_Callback_Impl::_default_POA (void)
+{
+ return PortableServer::POA::_duplicate (this->poa_.in ());
+}
+
+Deployment::NodeApplicationManager_ptr
+CIAO::NodeApplicationManager_Callback_Impl::
+register_node_application (Deployment::NodeApplication_ptr na,
+ Components::ConfigValues_out config
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ config = this->config_._retn ();
+
+ this->na_ = Deployment::NodeApplication::_duplicate (na);
+ return Deployment::NodeApplicationManager::_duplicate (this->nam_);
+}
+
+Deployment::NodeApplication_ptr
+CIAO::NodeApplicationManager_Callback_Impl::get_nodeapp_ref (void)
+{
+ // Relinquish the ownership of the server reference. This method
+ // should only be called from the CIAO_NodeApplicationManager.
+ return this->na_._retn ();
+}
+
+
+//===============================================================
+//========NodeApplicationManager_Impl============================
+CIAO::NodeApplicationManager_Impl::~NodeApplicationManager_Impl ()
+{
+ // @@ remove all NodeApplication's?
+}
+
+PortableServer::POA_ptr
+CIAO::NodeApplicationManager_Impl::_default_POA (void)
+{
+ return PortableServer::POA::_duplicate (this->poa_.in ());
+}
+
+int
+CIAO::CIAO_NodeApplicationManager_Impl::
+init (const char *nodeapp_location,
+ CORBA::ULong spawn_delay,
+ const char *installation_ior,
+ const char *default_svcconf,
+ const char *svc_conf_map
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ ACE_UNUSED_ARG (spawn_delay); // @@ We need to use this argumetn
+ // later to determine is a
+ // NodeApplication has been spawned
+ // successfully.
+
+ if (nodeapp_location == 0)
+ ACE_THROW_RETURN (CORBA::BAD_PARAM (), -1);
+
+ if (spawn_delay_ == 0)
+ ACE_THROW_RETURN (CORBA::BAD_PARAM (), -1);
+
+ // Initialize svc.conf map
+ if (this->init_svcconf_map (svc_conf_map) != 0)
+ ACE_THROW_RETURN (CORBA::BAD_PARAM (), -1);
+
+ if (default_svcconf != 0)
+ this->default_svcconf_file_ = default_svcconf;
+
+ this->nodeapp_path_ = CORBA::string_dup (nodeapp_location);
+
+ this->installation_ior_ = CORBA::string_dup (installation_ior);
+
+ PortableServer::POAManager_var mgr
+ = this->poa_->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+
+ CORBA::PolicyList policies (0);
+
+ // Create a separate POA for callback objects.
+ this->callback_poa_ =
+ this->poa_->create_POA ("callback_poa",
+ mgr.in (),
+ policies
+ ACE_ENV_ARG_PARAMETER);
+
+ ACE_CHECK_RETURN (-1);
+
+ // Activate the CIAO_NodeApplicationManager Object.
+ PortableServer::ObjectId_var oid
+ = this->poa_->activate_object (this
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+
+ CORBA::Object_var obj = this->poa_->id_to_reference (oid.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+
+ // And cache the object reference.
+ this->objref_ = NodeApplicationManager::_narrow (obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+
+ this->ior_ = this->orb_->object_to_string (this->objref_.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+
+ return 0;
+}
+
+int
+CIAO::NodeApplicationManager_Impl::init_svcconf_map (const char *filename)
+{
+ // It's fine if no svcconf map filename is provided. User assumes
+ // it's okay to use the default.
+ if (filename == 0)
+ return 0;
+
+ FILE *inf = ACE_OS::fopen (filename, "r");
+
+ if (inf != NULL)
+ {
+ ACE_Read_Buffer ior_buffer (inf);
+ char *data = 0;
+
+ while ((data = ior_buffer.read ('\n')) != 0)
+ {
+ ACE_CString aline (data);
+
+ // Each entry line is a comma delimited (hint, pathname) tuple.
+ ssize_t delpos = aline.find (',');
+
+ // Skip over comments (lines that start with '#' or invalid entries
+ // (lines without delimitor.)
+ if (aline[0] == '#' || delpos == ACE_CString::npos)
+ continue;
+
+ ACE_CString hint = aline.substring (0, delpos);
+ ACE_CString svcconf_name = aline.substring (delpos+1);
+
+ switch (this->svc_conf_map_.bind (hint, svcconf_name))
+ {
+ case 0:
+ // All is fine.
+ // Debug info:
+ ACE_DEBUG ((LM_DEBUG,
+ "Bound svc.conf hint \"%s\" successfully\n",
+ hint.c_str ()));
+ break;
+
+ case 1:
+ ACE_DEBUG ((LM_DEBUG,
+ "Duplication svc.conf hint \"%s\" found - ignore\n",
+ hint.c_str ()));
+ break;
+
+ case -1:
+ default:
+ // Unrecoverable error!!
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ "Fail to bind svc.conf hint \"%s\" - abort\n",
+ hint.c_str ()),
+ -1);
+ }
+ }
+ }
+ else
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Fail to open svcconf map data file: %s.\n",
+ filename),
+ -1);
+
+ return 0;
+}
+
+const char *
+CIAO::NodeApplicationManager_Impl::lookup_svcconf_pathname (const char *hint) const
+{
+ // Change this function to change the strategy of applying svc.conf files.
+
+ if (hint == 0)
+ {
+ if (this->default_svcconf_file_.length () > 0)
+ return this->default_svcconf_file_.c_str ();
+ else
+ return 0;
+ }
+
+ SVCCONF_MAP::ENTRY *entry;
+ if (this->svc_conf_map_.find (hint, entry) == 0)
+ return entry->int_id_.c_str ();
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Unable to find matching svc.conf file from hint: %s\n",
+ hint),
+ 0);
+}
+
+//@@ I assume that this functions will never be called in the current scheme.
+// These functions are maintained as place holders only for future
+// RT CIAO specific configurations.
+//@@ we should use the InvalidProperty exception!! Change needed! --Tao
+void
+CIAO::NodeApplicationManager_Impl::
+parse_config_value (const Components::ConfigValues &options,
+ NodeApp_Config_Info &config_info
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Deployment::InvalidProperty))
+{
+ for (CORBA::ULong l = 0; l < options.length (); ++l)
+ {
+ if (ACE_OS::strcmp (options[l]->name (), "CIAO-svcconf-id") == 0)
+ {
+ const char *str_in = 0;
+ if (options[l]->value () >>= str_in)
+ config_info.svcconf_hint_ = CORBA::string_dup (str_in);
+ ACE_CHECK;
+ }
+ else if (ACE_OS::strcmp (options[l]->name (), "CIAO-rtcad-filename") == 0)
+ {
+ const char *str_in = 0;
+ if (options[l]->value () >>= str_in)
+ config_info.rtcad_filename_ = CORBA::string_dup (str_in);
+ ACE_CHECK;
+ }
+ else
+ {
+ Components::InvalidConfiguration *exc = 0;
+
+ ACE_NEW_THROW_EX (exc,
+ Components::InvalidConfiguration,
+ CORBA::NO_MEMORY ());
+
+ exc->name = CORBA::string_dup (options[l]->name ());
+ exc->reason = Components::InvalidConfigValueType;
+#if defined (ACE_HAS_EXCEPTIONS)
+
+ auto_ptr<Deployment::InvalidProperty> safety (exc);
+
+ // Direct throw because we don't have the ACE_TRY_ENV.
+ exc->_raise ();
+#else
+ // We can not use ACE_THROW here.
+ ACE_TRY_ENV.exception (exc);
+#endif
+ }
+ }
+}
+
+
+Deployment::NodeApplication_ptr
+CIAO::NodeApplicationManager_Impl::
+create_node_application (const Components::ConfigValues & config
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Deployment::StartError,
+ Deployment::InvalidProperty))
+{
+ NodeApp_Config_Info config_info;
+ this->parse_config_value (config,
+ config_info
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ ACE_DEBUG ((LM_DEBUG, "CIAO::NodeApplicationManager_Impl::create_node_application\n"));
+
+ //@@ all configuration is subject to future fix! --Tao
+ Deployment::NodeApplication_var retval;
+
+ // @@ Need to figure out a way to pass the config data over to the
+ // NodeApplication. One option will be to convert it (again) into
+ // an XML document and psss it along in the command line.
+
+ // @@ Create a new callback servant.
+ CIAO::NodeApplicationManager_Callback_Impl *callback_servant = 0;
+ ACE_NEW_THROW_EX (callback_servant,
+ CIAO::NodeApplicationManager_Callback_Impl (this->orb_.in (),
+ this->callback_poa_.in (),
+ this->objref_.in (),
+ config),
+ CORBA::INTERNAL ());
+ ACE_CHECK_RETURN (0);
+
+ 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 (0);
+
+ ACE_Process node_application;
+ ACE_Process_Options 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::NodeApplicationManager_Callback_var cb =
+ CIAO::NodeApplicationManager_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;
+
+ const char *svcconf_path =
+ this->lookup_svcconf_pathname (config_info.svcconf_hint_.in ());
+
+ // spawn the new NodeApplication.
+ ACE_CString additional_options;
+
+ if (svcconf_path != 0)
+ {
+ ACE_DEBUG((LM_DEBUG, "Using svcconf file: %s\n",
+ svcconf_path));
+ additional_options += ACE_CString (" -ORBSvcConf ");
+ additional_options += ACE_CString (svcconf_path);
+ }
+
+ if (config_info.rtcad_filename_.in () != 0)
+ {
+ ACE_DEBUG((LM_DEBUG, "Using RTCAD file: %s\n",
+ config_info.rtcad_filename_.in ()));
+ additional_options += ACE_CString (" -r ");
+ additional_options += ACE_CString (config_info.rtcad_filename_.in ());
+ }
+
+ options.command_line ("%s -k %s -ORBInitRef ComponentInstallation=%s "
+ "%s",
+ this->nodeapp_path_.in (),
+ cb_ior.in (),
+ this->installation_ior_.in (),
+ additional_options.c_str ());
+
+ options.avoid_zombies (1);
+
+ if (node_application.spawn (options) == -1)
+ {
+ ACE_DEBUG ((LM_ERROR, "Fail to spawn a NodeApplication process\n"));
+ ACE_TRY_THROW (Components::CreateFailure ());
+ }
+
+ // wait for server 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 ()))
+ {
+ ACE_DEBUG ((LM_ERROR, "Fail to acquire the NodeApplication object\n"));
+ ACE_TRY_THROW (Components::CreateFailure ());
+ }
+
+ {
+ ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
+
+ // Add the server reference to this->cs_set_;
+ this->cs_set_.add (retval.in ());
+ }
+ }
+ ACE_CATCHANY
+ {
+ this->callback_poa_->deactivate_object (cb_id.in ());
+ ACE_TRY_CHECK;
+
+ ACE_RE_THROW;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (0);
+
+ this->callback_poa_->deactivate_object (cb_id.in ());
+ ACE_CHECK_RETURN (0);
+
+ return retval._retn ();
+}
+
+virtual Deployment::Application_ptr
+CIAO::NodeApplicationManager_Impl::
+startLaunch (const Deployment::Properties & configProperty,
+ Deployment::Connections_out providedReference,
+ CORBA::Boolean start
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException
+ , Deployment::ResourceNotAvailable
+ , Deployment::StartError
+ , Deployment::InvalidProperty))
+{
+ /**
+ * 1. First Map properties to TAO/CIAO specific property/configurations
+ * 2. Necessary property checking (needed?)
+ * 3. Call create_nade_application to spawn new process.
+ * 4. Initialize the NodeApplication.
+ * 5. get the provided connection endpoints back and return them.
+ */
+ ACE_TRY
+ {
+
+ }
+ ACE_CATCHANY
+ {
+ }
+ ACE_ENDTRY;
+
+ ACE_CHECK_RETURN (0);
+
+ return;
+
+}
+
+
+virtual void
+CIAO::NodeApplicationManager_Impl::
+destroyApplication (Deployment::Application_ptr app
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException
+ , Deployment::StopError))
+{
+ ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_);
+
+ if (this->cs_set_.object_in_set (app) == 0)
+ ACE_THROW (Deployment::StopError ());
+
+ app->remove (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_CHECK;
+
+ // Should we remove the server still even if the previous call failed.
+
+ if (this->cs_set_.remove (app) == -1)
+ ACE_THROW (Deployment::StopError ());
+}
+
+
+/*
+Deployment::NodeApplications *
+CIAO::NodeApplicationManager_Impl::get_node_servers (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
+
+ Components::Deployment::ComponentServers_var retval;
+
+ ACE_NEW_THROW_EX (retval.out (),
+ Components::Deployment::ComponentServers (),
+ CORBA::INTERNAL ());
+ ACE_CHECK_RETURN (0);
+
+ CORBA::ULong len = this->cs_set_.size ();
+ retval->length (len); // resize
+
+#if 0
+ // TAO is broken here. Both <replace>, <get_buffer> and friends are missing.
+ this->cs_set_.copy (len, retval->get_buffer (0));
+#else
+ for (CORBA::ULong i = 0; i < len; ++i)
+ {
+ retval[i] = this->cs_set_.at (i);
+ }
+#endif
+
+ return retval._retn ();
+}
+*/
diff --git a/TAO/CIAO/DnC/NodeApplicationManager/NodeApplicationManager_Impl.h b/TAO/CIAO/DnC/NodeApplicationManager/NodeApplicationManager_Impl.h
new file mode 100644
index 00000000000..03be48c615f
--- /dev/null
+++ b/TAO/CIAO/DnC/NodeApplicationManager/NodeApplicationManager_Impl.h
@@ -0,0 +1,288 @@
+//$Id$
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file NodeApplicationManager_Impl.h
+ *
+ * This file contains implementation for the servant of
+ * Deployment::NodeApplicationManager. It contains the
+ * the functionality of Components::Deployment::ServerActivator interface.
+ *
+//=============================================================================
+
+
+#ifndef CIAO_NODEAPPLICATIONMANAGER_IMPL_H
+#define CIAO_NODEAPPLICATIONMANAGER_IMPL_H
+#include /**/ "ace/pre.h"
+
+#include "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "../DeploymentS.h"
+#include "CIAO_NodeApplicationManagerS.h"
+
+#include "ciao/Object_Set_T.h"
+
+namespace CIAO
+{
+ /**
+ * @class NodeApplicationManager_Callback
+ *
+ * @brief A call back interface for NodeApplication.
+ *
+ * Notice that this implementation is *NOT* thread-safe.
+ */
+
+ //@@ Need to generate the export file. --Tao
+ class CIAO_NODEAPPLICATIONMANAGER_Export NodeApplicationManager_Callback_Impl
+ : public virtual POA_CIAO::NodeApplicationManager_Callback,
+ public virtual PortableServer::RefCountServantBase
+ {
+ public:
+ friend class NodeApplicationManager_Impl;
+
+ /// Constructor.
+ NodeApplicationManager_Callback_Impl (CORBA::ORB_ptr o,
+ PortableServer::POA_ptr p,
+ Deployment::NodeApplicationManager_ptr nam,
+ const Components::ConfigValues &cofig);
+
+ /// Destructor.
+ ~NodeApplicationManager_Callback_Impl ();
+
+ /// Get the containing POA. This operation does *not*
+ /// increase the reference count of the POA.
+ virtual PortableServer::POA_ptr _default_POA (void);
+
+ /// Record the NodeApplication reference returned by the newly
+ /// spawned NodeApplication and give it back a reference to CIAO_NodeApplicationManager.
+ Deployment::NodeApplicationManager_ptr
+ register_node_application (Deployment::NodeApplication_ptr na,
+ Components::ConfigValues_out config
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ protected:
+ Deployment::NodeApplication_ptr get_nodeapp_ref (void);
+
+ CORBA::ORB_var orb_;
+
+ PortableServer::POA_var poa_;
+
+ /// This servant only lives as long as a call to the
+ /// create_node_application method in NodeApplicationManager, so there's
+ /// no need to duplicate the object reference here.
+ Deployment::NodeApplicationManager_ptr nam_;
+
+ Deployment::NodeApplication_var na_;
+
+ Components::ConfigValues_var config_;
+ };
+
+ /**
+ * @class NodeApplicationManager_Impl
+ */
+ class CIAO_NODEAPPLICATIONMANAGER_Export NodeApplicationManager_Impl
+ : public virtual POA_Deployment::NodeApplicationManager,
+ public virtual PortableServer::RefCountServantBase
+ {
+ public:
+ /// Constructor
+ NodeApplicationManager_Impl (CORBA::ORB_ptr o,
+ PortableServer::POA_ptr p);
+
+ /// Destructor
+ virtual ~NodeApplicationManager_Impl (void);
+
+
+ /*===========================================================
+ * Below are operations from the NodeApplicationManager
+ *
+ *============================================================*/
+
+ //@@ The return type is NodeApplication_ptr actually.
+ // Mappings between configureVals and Properpies needs to be fixed. --Tao
+ virtual Deployment::Application_ptr
+ startLaunch (const Deployment::Properties & configProperty,
+ Deployment::Connections_out providedReference,
+ CORBA::Boolean start
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException
+ , Deployment::ResourceNotAvailable
+ , Deployment::StartError
+ , Deployment::InvalidProperty));
+
+ //
+ virtual void destroyApplication (Deployment::Application_ptr app
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException
+ , Deployment::StopError));
+
+
+ /*===========================================================
+ * Below are operations from the old ServerActivatro
+ *
+ *============================================================*/
+ /// Get the containing POA. This operation does *not*
+ /// increase the reference count of the POA.
+ virtual PortableServer::POA_ptr _default_POA (void);
+
+ /**
+ * Initialize the NodeApplicationManager. The currently implementation
+ * of CIAO_NodeApplicationManager can only activate CIAO's own
+ * NodeApplication processes. You should specify the location
+ * (pathname) of the NodeApplication and the delay
+ * CIAO_NodeApplicationManager should wait (in second) for NodeApplication to
+ * call back.
+ *
+ * @param nodeapp_location A null-termiated char * string pointing
+ * to the pathname of a NodeApplication executable.
+
+ * @param delay instructs how long (in second) a CIAO_NodeApplicationManager
+ * should wait for a newly spawned NodeApplication to pass back
+ * its IOR.
+ *
+ * @param installation_ior A null-terminated char * string
+ * pointing to the stringified IOR of a ComponentInstallation that
+ * CIAO_NodeApplicationManager can use to location component implementation DLL.
+ *
+ * @param default_svcconf A null-terminated char * string pointing
+ * to the pathname of the default svcconf file a NodeApplication
+ * should use (specified using -ORBSvcConfFile) if no hint is given.
+ *
+ * @param svcconf_map_file A null-terminated char * string
+ * pointing to the pathname of a (hint, svcconf pathname) map.
+ *
+ * @Note: Need to add the initialization of Plan Here!!!! --Tao
+ */
+ int init (const char *nodeapp_location,
+ CORBA::ULong delay,
+ const char *installation_ior,
+ const char *default_svcconf,
+ const char *svcconf_map_file
+ // Need to add an augment of plan here!!! --Tao
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException
+ , Deployment::InvalidProperty));
+
+ /// Return the cached NodeApplicationManager object reference. Do not
+ /// release this object reference, or put it into an var.
+ /// @@ I dont understand the comment above --Tao
+ Deployment::NodeApplicationManager_ptr
+ _ciao_get_objref (void);
+
+ // Helper function.
+ const char *_ciao_get_ior (void);
+
+ protected:
+ /**
+ * Contains the information extracted from
+ * create_component_server's ConfigValue argument that
+ * ServerActivation cares.
+ */
+ typedef struct CS_config
+ {
+ // ConfigValue::name: CIAO-svcconf-id
+ CORBA::String_var svcconf_hint_;
+
+ // ConfigValue::Name: CIAO-rtcad-filename
+ CORBA::String_var rtcad_filename_;
+ } NodeApp_Config_Info; //CompServ_Config_Info;
+
+ // Internal help function to create new NodeApplicationProcess
+ virtual Deployment::NodeApplication_ptr
+ create_node_application (const Components::ConfigValues & config
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException
+ , Deployment::StartError
+ , Deployment::InvalidProperty));
+
+ /* Not sure if this will be useful here.
+ virtual Deployment::NodeApplications *
+ get_node_applications (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+ */
+
+ /**
+ * Initialize svc_conf_map_ with the supplied filename.
+ */
+ int init_svcconf_map (const char *map_file);
+
+ /**
+ * Returns the pathname to the effective svc.conf file based on
+ * "hint." It may return the default svc.conf file when there's
+ * no hint (hint == 0) and we do have a default svc.conf path.
+ */
+ const char *lookup_svcconf_pathname (const char *hint) const;
+
+ /**
+ * Parse the ConfigValue arguement of the function
+ * create_component_server and extractg the information into
+ */
+ void parse_config_value (const Components::ConfigValues &options,
+ NodeApp_Config_Info &config_info
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Components::InvalidConfiguration));
+
+
+ protected:
+ /// location of the Nodeapplication
+ CORBA::String_var nodeapp_path_;
+
+ /// Keep a pointer to the managing ORB serving this servant.
+ CORBA::ORB_var orb_;
+
+ /// Keep a pointer to the managing POA.
+ PortableServer::POA_var poa_;
+
+ /// Child poa that uses active object map.
+ PortableServer::POA_var callback_poa_;
+
+ /// Cached the IOR string to ComponentInstallation Interface
+ CORBA::String_var installation_ior_;
+
+ /// Specify the time in second NodeApplicationManager will wait for a
+ /// child NodeApplication to callback. Default is 5 second.
+ CORBA::ULong spawn_delay_;
+
+ /// Cache a object reference to this servant.
+ Deployment::NodeApplicationManager_var objref_;
+
+ /// Cache the ior of the previous reference
+ CORBA::String_var ior_;
+
+ /// Synchronize access to the object set.
+ TAO_SYNCH_MUTEX lock_;
+
+ /// Default svc.conf filename.
+ ACE_CString default_svcconf_file_;
+
+ typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
+ ACE_CString,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> SVCCONF_MAP;
+
+ /// Map of (canonical svc.conf id, svc.conf) mapping
+ SVCCONF_MAP svc_conf_map_;
+
+ /// Keep a list of managed ComponentServer objects.
+ Object_Set<Deployment::NodeApplication, Deployment::NodeApplication_var> na_set_;
+
+ /// Cached plan (This should be the part of the whole plan local to this node)
+ /// The plan will be initialized when init is called.
+ Deployment::DeploymentPlan_var plan_;
+ };
+}
+
+#if defined (__ACE_INLINE__)
+# include "CIAO_NodeApplicationManager_Impl.inl"
+#endif /* __ACE_INLINE__ */
+
+#include /**/ "ace/post.h"
+#endif /* CIAO_NODEAPPLICATIONMANAGER_IMPL_H */
diff --git a/TAO/CIAO/DnC/NodeApplicationManager/NodeApplicationManager_Impl.inl b/TAO/CIAO/DnC/NodeApplicationManager/NodeApplicationManager_Impl.inl
new file mode 100644
index 00000000000..36c9d5453c3
--- /dev/null
+++ b/TAO/CIAO/DnC/NodeApplicationManager/NodeApplicationManager_Impl.inl
@@ -0,0 +1,27 @@
+/* -*- C++ -*- */
+// $Id$
+
+ACE_INLINE
+CIAO::NodeApplicationManager_Impl::
+NodeApplicationManager_Impl (CORBA::ORB_ptr o,
+ PortableServer::POA_ptr p)
+ : orb_ (CORBA::ORB::_duplicate (o)),
+ poa_ (PortableServer::POA::_duplicate (p)),
+ spawn_delay_ (5)
+{
+}
+
+ACE_INLINE
+Deployment::NodeApplicationManager_ptr
+CIAO::NodeApplicationManager_Impl::
+_ciao_get_objref ()
+{
+ return this->objref_.in ();
+}
+
+ACE_INLINE const char *
+CIAO::NodeApplicationManager_Impl::
+_ciao_get_ior ()
+{
+ return this->ior_.in ();
+}
diff --git a/TAO/CIAO/DnC/NodeManager/NodeDaemon.idl b/TAO/CIAO/DnC/NodeManager/NodeDaemon.idl
new file mode 100644
index 00000000000..28aeddfc97d
--- /dev/null
+++ b/TAO/CIAO/DnC/NodeManager/NodeDaemon.idl
@@ -0,0 +1,35 @@
+// $Id$
+
+/**
+ * @file NodeDaemon.idl
+ *
+ * @brief Controling interface for managing and controling CIAO daemon.
+ */
+
+#include "../Deployment.idl"
+
+
+module CIAO
+{
+ exception NotFound {};
+
+ /**
+ * @brief CIAO daemon process control program.
+ *
+ * @@The Inheritage might cause binary code bloating but
+ * it's an easy way of combining features. In the future we could
+ * move this definition into Deployment.idl.
+ */
+ interface NodeDaemon : Deployment::NodeManager
+ {
+ // Canonical name of this daemon
+ readonly attribute string name;
+
+ // Acquire a specific service
+ Object get_service (in string svc_name)
+ raises (NotFound);
+
+ // Shutdown the daemon process.
+ oneway void shutdown ();
+ };
+};
diff --git a/TAO/CIAO/DnC/NodeManager/NodeDaemon.mpc b/TAO/CIAO/DnC/NodeManager/NodeDaemon.mpc
new file mode 100644
index 00000000000..0e35318176c
--- /dev/null
+++ b/TAO/CIAO/DnC/NodeManager/NodeDaemon.mpc
@@ -0,0 +1,35 @@
+// -*- MPC -*-
+// $Id$
+
+project(Node_Daemon): ciao_server, iortable {
+ requires += dnc
+ IDL_Files {
+ NodeDaemon.idl
+ }
+
+ Source_Files {
+ NodeDaemonC.cpp
+ NodeDaemonS.cpp
+ NodeDaemon_Impl.cpp
+ Node_Daemon.cpp
+ }
+}
+
+project(NodeDaemonController) : ciao_server, acexml, rtcorba {
+ requires += dnc
+ libs += CIAO_XML_Helpers
+ libpaths += ../XML_Helpers
+ after += XML_Helpers
+
+ IDL_Files {
+ NodeDaemon.idl
+ }
+
+ Source_Files {
+ NodeDaemonC.cpp
+ DaemonController.cpp
+ controller_i.cpp
+ Daemon_Commands.cpp
+ Softpkg_Commands.cpp
+ }
+}
diff --git a/TAO/CIAO/DnC/NodeManager/NodeDaemon_Impl.cpp b/TAO/CIAO/DnC/NodeManager/NodeDaemon_Impl.cpp
new file mode 100644
index 00000000000..174a5018ff0
--- /dev/null
+++ b/TAO/CIAO/DnC/NodeManager/NodeDaemon_Impl.cpp
@@ -0,0 +1,161 @@
+// $Id$
+
+#include "NodeDaemon_Impl.h"
+
+#if !defined (__ACE_INLINE__)
+# include "NodeDaemon_Impl.inl"
+#endif /* __ACE_INLINE__ */
+
+CIAO::NodeDaemon_Impl::~NodeDaemon_Impl ()
+{
+ for (Iterator i = this->table_.begin ();
+ i != this->table_.end ();
+ ++i)
+ {
+ // Deallocate the id.
+ CORBA::string_free (ACE_const_cast (char *, (*i).ext_id_));
+
+ // Release the Object.
+ CORBA::release ((*i).int_id_);
+ }
+
+ this->table_.unbind_all ();
+}
+
+PortableServer::POA_ptr
+CIAO::NodeDaemon_Impl::_default_POA (void)
+{
+ return PortableServer::POA::_duplicate (this->poa_.in ());
+}
+
+char *
+CIAO::NodeDaemon_Impl::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ return CORBA::string_dup (this->name_.in ());
+}
+
+CORBA::Object_ptr
+CIAO::NodeDaemon_Impl::get_service (const char * svc_name
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ CIAO::NotFound))
+{
+ CORBA::Object_ptr found = CORBA::Object::_nil ();
+
+ this->table_.find (svc_name, found);
+
+ if (CORBA::is_nil (found))
+ ACE_THROW_RETURN (CIAO::NotFound (), 0);
+
+ return CORBA::Object::_duplicate (found);
+}
+
+void
+CIAO::NodeDaemon_Impl::shutdown (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ this->orb_->shutdown (0 ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+int
+CIAO::NodeDaemon_Impl::bind (const char *id,
+ CORBA::Object_ptr obj)
+{
+ // Make sure that the supplied Object reference is valid,
+ // i.e. not nil.
+ if (id == 0 || CORBA::is_nil (obj))
+ {
+ errno = EINVAL;
+ return -1;
+ };
+
+ CORBA::String_var name = CORBA::string_dup (id);
+ CORBA::Object_var object = CORBA::Object::_duplicate (obj);
+
+ int result = this->table_.bind (name.in (),
+ object.in ());
+
+ if (result == 0)
+ {
+ // Transfer ownership to the Object Table.
+ (void) name._retn ();
+ (void) object._retn ();
+ }
+
+ return result;
+}
+
+int
+CIAO::NodeDaemon_Impl::unbind (const char *id)
+{
+ Table::ENTRY *entry = 0;
+
+ int result = this->table_.find (id, entry);
+
+ if (result == 0)
+ {
+ // Deallocate the external ID and obtain the ORB core pointer
+ // before unbinding the entry since the entry is deallocated
+ // during the call to unbind().
+ CORBA::string_free (ACE_const_cast (char *, entry->ext_id_));
+ CORBA::Object_ptr obj = entry->int_id_;
+
+ result = this->table_.unbind (entry);
+
+ if (result != 0)
+ return result;
+
+ CORBA::release (obj);
+ }
+
+ return result;
+}
+
+
+void
+CIAO::NodeDaemon_Impl::
+joinDomain (const Deployment::Domain & domain,
+ Deployment::TargetManager_ptr manager,
+ Deployment::Logger_ptr log
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ //Implementation undefined.
+}
+
+
+
+void
+CIAO::NodeDaemon_Impl::
+leaveDomain (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ //Implementation undefined.
+}
+
+
+::Deployment::NodeApplicationManager_ptr
+CIAO::NodeDaemon_Impl::
+preparePlan (const Deployment::DeploymentPlan & plan
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException
+ , Deployment::StartError
+ , Deployment::PlanError
+ ))
+{
+ //Implementation undefined.
+ return CORBA::nil();
+}
+
+
+void
+CIAO::NodeDaemon_Impl::
+destroyManager (Deployment::NodeApplicationManager_ptr appManager
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException
+ , Deployment::StopError))
+{
+
+}
diff --git a/TAO/CIAO/DnC/NodeManager/NodeDaemon_Impl.h b/TAO/CIAO/DnC/NodeManager/NodeDaemon_Impl.h
new file mode 100644
index 00000000000..8bd69ccc55f
--- /dev/null
+++ b/TAO/CIAO/DnC/NodeManager/NodeDaemon_Impl.h
@@ -0,0 +1,159 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Daemon_Impl.h
+ *
+ * $Id$
+ *
+ * This file contains servant implementation for CIAO's daemon process control
+ * interface.
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+
+#ifndef CIAO_NODEDAEMON_IMPL_H
+#define CIAO_NODEDAEMON_IMPL_H
+#include /**/ "ace/pre.h"
+
+#include "NodeDaemonS.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Synch.h"
+#include "ace/Hash_Map_Manager_T.h"
+#include "ace/Functor.h"
+
+namespace CIAO
+{
+ /**
+ * @class NodeDaemon_Impl
+ *
+ * @brief Servant implementation CIAO's daemon process control interface
+ *
+ * This class implements the CIAO:NodeDaemon interface.
+ *
+ */
+ class NodeDaemon_Impl
+ : public virtual POA_CIAO::NodeDaemon,
+ public virtual PortableServer::RefCountServantBase
+ {
+ public:
+
+ /// Constructor
+ NodeDaemon_Impl (const char *name,
+ CORBA::ORB_ptr o,
+ PortableServer::POA_ptr p);
+
+ /// Destructor
+ virtual ~NodeDaemon_Impl (void);
+
+ /***************************************************
+ *@@ Below are helper operations for the NodeDaemon which
+ * don't belong to the NodeManager interface.
+ ***************************************************/
+
+ /// Get the containing POA. This operation does *not*
+ /// increase the reference count of the POA.
+ virtual PortableServer::POA_ptr _default_POA (void);
+
+ /// CIAO::Daemon defined attributes/operations.
+
+ virtual char * name (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual CORBA::Object_ptr get_service (const char * svc_name
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ CIAO::NotFound));
+
+ virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ /**
+ * @name CIAO::Daemon_Impl internal operations using the
+ * canonical ACE_Map methods
+ */
+ //@{
+ int bind (const char *orb_id, CORBA::Object_ptr obj);
+ int unbind (const char *orb_id);
+ //@}
+
+
+ /***************************************************
+ *@@ Below are operation from NodeManager Interface.
+ *
+ ***************************************************/
+ virtual void joinDomain (
+ const Deployment::Domain & domain,
+ Deployment::TargetManager_ptr manager,
+ Deployment::Logger_ptr log
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException
+ ));
+
+ // TAO_IDL - Generated from
+ // be/be_visitor_operation/operation_ch.cpp:46
+
+ virtual void leaveDomain (
+ ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException
+ ));
+
+ // TAO_IDL - Generated from
+ // be/be_visitor_operation/operation_ch.cpp:46
+
+ virtual ::Deployment::NodeApplicationManager_ptr preparePlan (
+ const Deployment::DeploymentPlan & plan
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException
+ , Deployment::StartError
+ , Deployment::PlanError
+ ));
+
+ // TAO_IDL - Generated from
+ // be/be_visitor_operation/operation_ch.cpp:46
+
+ virtual void destroyManager (
+ Deployment::NodeApplicationManager_ptr appManager
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException
+ , Deployment::StopError
+ ));
+
+ protected:
+ typedef ACE_Hash_Map_Manager_Ex<const char *, CORBA::Object_ptr, ACE_Hash<const char *>, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX> Table;
+ typedef Table::iterator Iterator;
+
+ /// Keep a pointer to the managing ORB serving this servant.
+ CORBA::ORB_var orb_;
+
+ /// Keep a pointer to the managing POA.
+ PortableServer::POA_var poa_;
+
+ /// My Canonical name.
+ CORBA::String_var name_;
+
+ /// Internal object hash table.
+ Table table_;
+ };
+}
+
+#if defined (__ACE_INLINE__)
+# include "NodeDaemon_Impl.inl"
+#endif /* __ACE_INLINE__ */
+
+#include /**/ "ace/post.h"
+#endif /* CIAO_NODEDAEMON_IMPL_H */
diff --git a/TAO/CIAO/DnC/NodeManager/NodeDaemon_Impl.inl b/TAO/CIAO/DnC/NodeManager/NodeDaemon_Impl.inl
new file mode 100644
index 00000000000..eb83918f2fc
--- /dev/null
+++ b/TAO/CIAO/DnC/NodeManager/NodeDaemon_Impl.inl
@@ -0,0 +1,12 @@
+/* -*- C++ -*- */
+// $Id$
+
+ACE_INLINE
+CIAO::NodeDaemon_Impl::NodeDaemon_Impl (const char *name,
+ CORBA::ORB_ptr o,
+ PortableServer::POA_ptr p)
+ : orb_ (CORBA::ORB::_duplicate (o)),
+ poa_ (PortableServer::POA::_duplicate (p)),
+ name_ (CORBA::string_dup (name))
+{
+}
diff --git a/TAO/CIAO/DnC/NodeManager/Node_Daemon.cpp b/TAO/CIAO/DnC/NodeManager/Node_Daemon.cpp
new file mode 100644
index 00000000000..eb9c08eb0a8
--- /dev/null
+++ b/TAO/CIAO/DnC/NodeManager/Node_Daemon.cpp
@@ -0,0 +1,271 @@
+// $Id$
+
+/**
+ * @file Node_Daemon.cpp
+ *
+ * @brief CIAO's Node Daemon implementation
+ *
+ * NodeDaemon is the bootstraping mechanism to create new
+ * NodeApplication on the localhost. We currently depend on
+ * starting the NodeApplicationManager process on some specific port of all
+ * the hosts that have NodeApplication install to function properly.
+ */
+
+
+#include "../NodeApplicationManager/NodeApplicationManager_Impl.h"
+//@@ The old ServerActivator is replaced.
+
+#include "ciao/ComponentInstallation_Impl.h"
+//@@ I have decided to keep this interface as a help class --Tao
+
+#include "NodeManager_Impl.h"
+#include "ciao/Server_init.h"
+#include "tao/IORTable/IORTable.h"
+#include "ace/SString.h"
+#include "ace/Read_Buffer.h"
+#include "ace/Get_Opt.h"
+
+const char *ior_file_name_ = "daemon.ior";
+const char *comserv_path_ = "../ComponentServer/ComponentServer";
+//@@ this will be changed to ... --Tao
+
+CORBA::ULong spawn_wait_ = 5;
+const char *installation_datafile_ = "CIAO_Installation_Data.ini";
+char *section_name_ = 0;
+char *default_svcconf_ = 0;
+char *svcconf_config_ = 0;
+
+
+int
+parse_args (int argc, char *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "i:n:o:d:s:c:m:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'o': // get the file name to write to
+ ior_file_name_ = get_opts.opt_arg ();
+ break;
+
+ case 'n': // get the path name to the component server
+ comserv_path_ = get_opts.opt_arg ();
+ break;
+
+ case 'd': // time to wait before we consider a ComponentServer
+ // fails to start.
+ spawn_wait_ = ACE_OS::atoi (get_opts.opt_arg ());
+ break;
+
+ case 'i': // get the name for the ComponentInstallation data file
+ installation_datafile_ = get_opts.opt_arg ();
+ break;
+
+ case 's': // get the section name to use in ComponentInstallation data file
+ section_name_ = get_opts.opt_arg ();
+ break;
+
+ case 'c': // get the default svc.conf filename for ComponentServer
+ default_svcconf_ = get_opts.opt_arg ();
+ break;
+
+ case 'm': // get the svc.conf map configuration filename
+ svcconf_config_ = get_opts.opt_arg ();
+ break;
+
+ case '?': // display help for use of the server.
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s\n"
+ "-n <component server pathname>\n"
+ "-o <ior_output_file>\n"
+ "-d <time (in second) to wait for component server>\n"
+ "-i <installation data filename>\n"
+ "-s <section name to use in installation data file>\n"
+ "\n",
+ argv [0]),
+ -1);
+ }
+
+ return 0;
+}
+
+int
+write_IOR(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 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+ ACE_TRY_NEW_ENV
+ {
+ // Initialize orb
+ CORBA::ORB_var orb = CORBA::ORB_init (argc,
+ argv,
+ ""
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CIAO::Server_init (orb.in ());
+
+ if (parse_args (argc, argv) != 0)
+ return -1;
+
+ // 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;
+
+ CORBA::Object_var table_object =
+ orb->resolve_initial_references ("IORTable"
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ IORTable::Table_var adapter =
+ IORTable::Table::_narrow (table_object.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (adapter.in ()))
+ {
+ ACE_ERROR_RETURN ((LM_ERROR, "Nil IORTable\n"), -1);
+ }
+
+ // Create and install the CIAO Daemon servant
+ CIAO::NodeDaemon_Impl *daemon_servant = 0;
+ ACE_NEW_RETURN (daemon_servant,
+ CIAO::NodeDaemon_Impl("NodeDaemon",
+ orb.in (),
+ poa.in ()),
+ -1);
+ PortableServer::ServantBase_var safe_daemon (daemon_servant);
+ // Implicit activation
+ CIAO::NodeDaemon_var daemon = daemon_servant->_this ();
+
+ // Create and install the ComponentInstallation servant
+
+ CIAO::ComponentInstallation_Impl *installation_servant = 0;
+
+ ACE_NEW_RETURN (installation_servant,
+ CIAO::ComponentInstallation_Impl (orb.in (),
+ poa.in ()),
+ -1);
+
+ installation_servant->init (installation_datafile_,
+ section_name_
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ PortableServer::ServantBase_var safe_installation (installation_servant);
+
+ Components::Deployment::ComponentInstallation_var installation
+ = installation_servant->_this ();
+
+ CORBA::String_var str = orb->object_to_string (installation.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ adapter->bind ("ComponentInstallation", str.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ //@@ Is the binding with the Daemon really necessary? --Tao
+ // This turned out to be for the debug purpose.
+ if (daemon_servant->bind ("ComponentInstallation", installation.in ()) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Failed to register ComponentInstallation with CIAO Daemon\n"),
+ -1);
+
+ // Create and install the NodeApplicationManager servant
+ //@@ Node CIAO_NodeApplicationManager got actually created.
+ CIAO::CIAO_NodeApplicationManager_Impl *nam_servant = 0;
+
+ ACE_NEW_RETURN (nam_servant,
+ CIAO::CIAO_NodeApplicationManager_Impl (orb.in (),
+ poa.in ()),
+ -1);
+
+ nam_servant->init (comserv_path_,
+ spawn_wait_,
+ str.in (),
+ default_svcconf_,
+ svcconf_config_
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ PortableServer::ServantBase_var safe_nam (nam_servant);
+
+ //Do we need a narrow/_is_a here? Maybe the client side verification is enough.
+ Deployment::NodeApplicationManager_ptr nam
+ = nam_servant->_ciao_get_objref ();
+
+ str = orb->object_to_string (nam
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ adapter->bind ("NodeApplicationManager", str.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ //@@ Again, is this necessary? For debugging.
+ if (daemon_servant->bind ("NodeApplicationManager", nam) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Failed to register NodeApplicationManager with CIAO NodeDaemon\n"),
+ -1);
+
+ // Now register daemon with IOR table and write its IOR.
+ str = orb->object_to_string (daemon.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ adapter->bind ("CIAO_NodeDaemon", str.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ write_IOR (str.in ());
+ ACE_DEBUG ((LM_INFO, "CIAO_NodeDaemon IOR: %s\n", str.in ()));
+
+ // 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;
+
+ // End Deployment part
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO_NodeDaemon is running...\n"));
+
+ // Run the main event loop for the ORB.
+ orb->run (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "CIAO_NodeDaemon::main\t\n");
+ return 1;
+ }
+ ACE_ENDTRY;
+
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO_NodeDaemon has closed\n"));
+ return 0;
+}