summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjai <jai@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2004-07-01 20:53:36 +0000
committerjai <jai@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2004-07-01 20:53:36 +0000
commit4c555a4d9a3e6549e15e27347ddd9c7042f75c14 (patch)
tree10d77303d8fc84f802f687c5279baee3436a012b
parent0b0bf48b0a2ff7fbe00769ac257511f8a175d119 (diff)
downloadATCD-4c555a4d9a3e6549e15e27347ddd9c7042f75c14.tar.gz
Thu Jul 1 15:51:14 2004 Jaiganesh B <jai@dre.vanderbilt.edu>
-rw-r--r--TAO/CIAO/ChangeLog24
-rw-r--r--TAO/CIAO/DAnCE/DomainApplicationManager/Deployment_Configuration.cpp130
-rw-r--r--TAO/CIAO/DAnCE/DomainApplicationManager/Deployment_Configuration.h133
-rw-r--r--TAO/CIAO/DAnCE/DomainApplicationManager/Deployment_Configuration.inl1
-rw-r--r--TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager.mpc16
-rw-r--r--TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Export.h58
-rw-r--r--TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp759
-rw-r--r--TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h295
-rw-r--r--TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.inl16
-rw-r--r--TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager.idl26
-rw-r--r--TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager.mpc31
-rw-r--r--TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager_Impl.cpp154
-rw-r--r--TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager_Impl.h131
-rw-r--r--TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager_Impl.inl2
-rw-r--r--TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager_stub_export.h54
-rw-r--r--TAO/CIAO/DAnCE/ExecutionManager/Execution_Manager.cpp230
16 files changed, 2060 insertions, 0 deletions
diff --git a/TAO/CIAO/ChangeLog b/TAO/CIAO/ChangeLog
index 7ced955a2d6..5f1f76e12e0 100644
--- a/TAO/CIAO/ChangeLog
+++ b/TAO/CIAO/ChangeLog
@@ -1,3 +1,27 @@
+Thu Jul 1 15:51:14 2004 Jaiganesh B <jai@dre.vanderbilt.edu>
+
+ * DAnCE/DomainApplicationManager/Deployment_Configuration.cpp:
+ * DAnCE/DomainApplicationManager/Deployment_Configuration.h:
+ * DAnCE/DomainApplicationManager/Deployment_Configuration.inl:
+ * DAnCE/DomainApplicationManager/DomainApplicationManager.mpc:
+ *
+ DAnCE/DomainApplicationManager/DomainApplicationManager_Export.h:
+ *
+ DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp:
+ * DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h:
+ *
+ DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.inl:
+ * DAnCE/ExecutionManager/ExecutionManager.idl:
+ * DAnCE/ExecutionManager/ExecutionManager.mpc:
+ * DAnCE/ExecutionManager/ExecutionManager_Impl.cpp:
+ * DAnCE/ExecutionManager/ExecutionManager_Impl.h:
+ * DAnCE/ExecutionManager/ExecutionManager_Impl.inl:
+ * DAnCE/ExecutionManager/ExecutionManager_stub_export.h:
+ * DAnCE/ExecutionManager/Execution_Manager.cpp:
+
+ Checking in the DomainApplicationManager and ExecutionManager
+ interfaces.
+
Thu Jul 1 15:47:45 2004 Jaiganesh B <jai@dre.vanderbilt.edu>
* DAnCE/NodeApplication/NodeApplication.cpp:
diff --git a/TAO/CIAO/DAnCE/DomainApplicationManager/Deployment_Configuration.cpp b/TAO/CIAO/DAnCE/DomainApplicationManager/Deployment_Configuration.cpp
new file mode 100644
index 00000000000..c42e892081d
--- /dev/null
+++ b/TAO/CIAO/DAnCE/DomainApplicationManager/Deployment_Configuration.cpp
@@ -0,0 +1,130 @@
+// $Id$
+
+#include "Deployment_Configuration.h"
+
+#include "ace/OS_NS_stdio.h"
+
+#if !defined (__ACE_INLINE__)
+# include "Deployment_Configuration.inl"
+#endif /* __ACE_INLINE__ */
+
+const int NAME_BUFSIZE = 1024;
+
+CIAO::Deployment_Configuration::Deployment_Configuration (CORBA::ORB_ptr o)
+ : orb_ (CORBA::ORB::_duplicate (o))
+{
+}
+
+CIAO::Deployment_Configuration::~Deployment_Configuration (void)
+{
+ this->deployment_info_.unbind_all ();
+}
+
+int
+CIAO::Deployment_Configuration::init (const char *filename)
+{
+ // @@ We should change to use ACE_Configuration here.
+
+ if (filename == 0)
+ return -1;
+
+ FILE *inf = ACE_OS::fopen (filename, "r");
+
+ if (inf == NULL)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Fail to open node manager map data file: %s.\n",
+ filename),
+ -1);
+
+ char destination[NAME_BUFSIZE], ior[NAME_BUFSIZE];
+
+ int first = 1;
+
+ while (fscanf (inf, "%s %s", destination, ior ) != EOF)
+ {
+ this->deployment_info_.bind (destination, ior);
+
+ if (first)
+ {
+ this->default_node_manager_.IOR_ = ior;
+ first = 0;
+ }
+ }
+
+ return 0;
+}
+
+const char *
+CIAO::Deployment_Configuration::get_node_manager_ior (const char *name)
+{
+ if (name == 0)
+ return get_default_node_manager_ior ();
+
+ ACE_Hash_Map_Entry
+ <ACE_CString,
+ CIAO::Deployment_Configuration::Node_Manager_Info> *entry;
+
+ if (this->deployment_info_.find (ACE_CString (name),
+ entry) != 0)
+ return 0; // no valid name found.
+
+ return entry->int_id_.IOR_.c_str ();
+}
+
+const char *
+CIAO::Deployment_Configuration::get_default_node_manager_ior (void)
+{
+ if (this->default_node_manager_.IOR_.length () == 0)
+ return 0;
+ return this->default_node_manager_.IOR_.c_str ();
+}
+
+::Deployment::NodeManager_ptr
+CIAO::Deployment_Configuration::get_node_manager (const char *name
+ ACE_ENV_ARG_DECL)
+{
+ if (name == 0)
+ return get_default_node_manager (ACE_ENV_SINGLE_ARG_PARAMETER);
+
+ ACE_Hash_Map_Entry
+ <ACE_CString,
+ CIAO::Deployment_Configuration::Node_Manager_Info> *entry;
+
+ if (this->deployment_info_.find (ACE_CString (name),
+ entry) != 0)
+ return 0; // no valid name found.
+
+ if (CORBA::is_nil (entry->int_id_.node_manager_.in ()))
+ {
+ CORBA::Object_var temp = this->orb_->string_to_object
+ (entry->int_id_.IOR_.c_str ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ entry->int_id_.node_manager_ =
+ ::Deployment::NodeManager::_narrow (temp.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+ }
+ return ::Deployment::NodeManager::_duplicate
+ (entry->int_id_.node_manager_.in ());
+}
+
+::Deployment::NodeManager_ptr
+CIAO::Deployment_Configuration::get_default_node_manager (ACE_ENV_SINGLE_ARG_DECL)
+{
+ if (CORBA::is_nil (this->default_node_manager_.node_manager_.in ()))
+ {
+ CORBA::Object_var temp = this->orb_->string_to_object
+ (this->default_node_manager_.IOR_.c_str ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ this->default_node_manager_.node_manager_ =
+ ::Deployment::NodeManager::_narrow (temp.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+ }
+ return ::Deployment::NodeManager::_duplicate
+ (this->default_node_manager_.node_manager_.in ());
+}
diff --git a/TAO/CIAO/DAnCE/DomainApplicationManager/Deployment_Configuration.h b/TAO/CIAO/DAnCE/DomainApplicationManager/Deployment_Configuration.h
new file mode 100644
index 00000000000..3fe47051fcf
--- /dev/null
+++ b/TAO/CIAO/DAnCE/DomainApplicationManager/Deployment_Configuration.h
@@ -0,0 +1,133 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Deployment_Configuration.h
+ *
+ * $Id$
+ *
+ * The Deployment_Configuration provides abstraction for the
+ * deployment mechanisms.
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ * @author Gan Deng <gan.deng@vanderbilt.edu>
+ */
+//=============================================================================
+
+
+#ifndef CIAO_DEPLOYMENT_CONFIGURATION_H
+#define CIAO_DEPLOYMENT_CONFIGURATION_H
+#include /**/ "ace/pre.h"
+
+#include "ace/Hash_Map_Manager_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "DeploymentC.h"
+
+#include "tao/Valuetype/ValueBase.h"
+#include "tao/Valuetype/Valuetype_Adapter_Impl.h"
+
+namespace CIAO
+{
+ /**
+ * @class Deployment_Configuration
+ *
+ * @brief A class that provides strategies on deployment topology.
+ *
+ * This class provides strategies on how the DomainApplicationManager
+ * should deploy an deployment plan at domain-level. This is achieved
+ * by providing mappings from deployment destination names to actually
+ * NodeManager daemon IORs, and the strategy for which default NodeManager
+ * daemons a deployment mechanism should use.
+ *
+ * This is a trivial implementation of the deployment configuration
+ * strategy. We can enhance this class later on to provide
+ * different deployment location strategies, such as naming service.
+ */
+ class Deployment_Configuration
+ {
+ public:
+ typedef struct _node_manager_info
+ {
+ _node_manager_info (const char *ior = 0)
+ {
+ IOR_ = ior;
+ }
+
+ ACE_CString IOR_;
+ ::Deployment::NodeManager_var node_manager_;
+ } Node_Manager_Info;
+
+ Deployment_Configuration (CORBA::ORB_ptr o);
+
+ /// Destructor
+ virtual ~Deployment_Configuration (void);
+
+ /**
+ * Init method takes the filename to a configuration file which
+ * has a simple line format of name, ior string delimited by a
+ * space in each line.
+ *
+ * name IOR-string
+ *
+ * @retval 0 on success.
+ * @retval -1 otherwise.
+ */
+ int init (const char *filename);
+
+ /**
+ * @retval 0 if no valid name were found. When @c name = 0, then
+ * this function behave exactly as get_default_activator_ior.
+ */
+ virtual const char *get_node_manager_ior (const char *name);
+
+ /**
+ * Return the default NodeManager the DomainApplicationManager
+ * should use to deploy a component. In this implementation, the
+ * first entry in the deployment configuration data file is always
+ * the entry for default activator.
+ *
+ * @retval 0 if no valid daemon is configured.
+ */
+ virtual const char *get_default_node_manager_ior ();
+
+ /**
+ * @retval nil if no valid name were found.
+ */
+ virtual ::Deployment::NodeManager_ptr
+ get_node_manager (const char *name
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+
+ /**
+ * Return the reference to the default NodeManager the
+ * DomainApplicationManager should use to deploy a node-level
+ * deployment plan..
+ *
+ * @retval nil if no valid daemon is configured.
+ */
+ virtual ::Deployment::NodeManager_ptr
+ get_default_node_manager (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
+
+ protected:
+ CORBA::ORB_var orb_;
+
+ ACE_Hash_Map_Manager_Ex<ACE_CString,
+ Node_Manager_Info,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> deployment_info_;
+
+ Node_Manager_Info default_node_manager_;
+ };
+
+}
+
+#if defined (__ACE_INLINE__)
+# include "Deployment_Configuration.inl"
+#endif /* __ACE_INLINE__ */
+
+#include /**/ "ace/post.h"
+#endif /* CIAO_DEPLOYMENT_CONFIGURATION_H */
diff --git a/TAO/CIAO/DAnCE/DomainApplicationManager/Deployment_Configuration.inl b/TAO/CIAO/DAnCE/DomainApplicationManager/Deployment_Configuration.inl
new file mode 100644
index 00000000000..cfa1da318d3
--- /dev/null
+++ b/TAO/CIAO/DAnCE/DomainApplicationManager/Deployment_Configuration.inl
@@ -0,0 +1 @@
+// $Id$
diff --git a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager.mpc b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager.mpc
new file mode 100644
index 00000000000..0224dda614f
--- /dev/null
+++ b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager.mpc
@@ -0,0 +1,16 @@
+// -*- MPC -*-
+// $Id$
+
+project (DomainApplicationManager): taolib, ciao_deployment_stub, ciao_deployment_svnt {
+ after += Config_Handlers Node_Daemon
+
+ sharedname = DomainApplicationManager
+ dynamicflags = DOMAINAPPLICATIONMANAGER_BUILD_DLL
+ libs += TAO_Valuetype CIAO_DnC_Client CIAO_DnC_Server Config_Handlers TAO_IFR_Client
+
+ Source_Files {
+ DomainApplicationManager_Impl.cpp
+ Deployment_Configuration.cpp
+ }
+}
+
diff --git a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Export.h b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Export.h
new file mode 100644
index 00000000000..31fa9b914b7
--- /dev/null
+++ b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Export.h
@@ -0,0 +1,58 @@
+
+// -*- C++ -*-
+// $Id$
+// Definition for Win32 Export directives.
+// This file is generated automatically by generate_export_file.pl -s DomainApplicationManager
+// ------------------------------
+#ifndef DOMAINAPPLICATIONMANAGER_EXPORT_H
+#define DOMAINAPPLICATIONMANAGER_EXPORT_H
+
+#include "ace/config-all.h"
+
+#if defined (ACE_AS_STATIC_LIBS) && !defined (DOMAINAPPLICATIONMANAGER_HAS_DLL)
+# define DOMAINAPPLICATIONMANAGER_HAS_DLL 0
+#endif /* ACE_AS_STATIC_LIBS && DOMAINAPPLICATIONMANAGER_HAS_DLL */
+
+#if !defined (DOMAINAPPLICATIONMANAGER_HAS_DLL)
+# define DOMAINAPPLICATIONMANAGER_HAS_DLL 1
+#endif /* ! DOMAINAPPLICATIONMANAGER_HAS_DLL */
+
+#if defined (DOMAINAPPLICATIONMANAGER_HAS_DLL) && (DOMAINAPPLICATIONMANAGER_HAS_DLL == 1)
+# if defined (DOMAINAPPLICATIONMANAGER_BUILD_DLL)
+# define DomainApplicationManager_Export ACE_Proper_Export_Flag
+# define DOMAINAPPLICATIONMANAGER_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T)
+# define DOMAINAPPLICATIONMANAGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# else /* DOMAINAPPLICATIONMANAGER_BUILD_DLL */
+# define DomainApplicationManager_Export ACE_Proper_Import_Flag
+# define DOMAINAPPLICATIONMANAGER_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T)
+# define DOMAINAPPLICATIONMANAGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# endif /* DOMAINAPPLICATIONMANAGER_BUILD_DLL */
+#else /* DOMAINAPPLICATIONMANAGER_HAS_DLL == 1 */
+# define DomainApplicationManager_Export
+# define DOMAINAPPLICATIONMANAGER_SINGLETON_DECLARATION(T)
+# define DOMAINAPPLICATIONMANAGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+#endif /* DOMAINAPPLICATIONMANAGER_HAS_DLL == 1 */
+
+// Set DOMAINAPPLICATIONMANAGER_NTRACE = 0 to turn on library specific tracing even if
+// tracing is turned off for ACE.
+#if !defined (DOMAINAPPLICATIONMANAGER_NTRACE)
+# if (ACE_NTRACE == 1)
+# define DOMAINAPPLICATIONMANAGER_NTRACE 1
+# else /* (ACE_NTRACE == 1) */
+# define DOMAINAPPLICATIONMANAGER_NTRACE 0
+# endif /* (ACE_NTRACE == 1) */
+#endif /* !DOMAINAPPLICATIONMANAGER_NTRACE */
+
+#if (DOMAINAPPLICATIONMANAGER_NTRACE == 1)
+# define DOMAINAPPLICATIONMANAGER_TRACE(X)
+#else /* (DOMAINAPPLICATIONMANAGER_NTRACE == 1) */
+# if !defined (ACE_HAS_TRACE)
+# define ACE_HAS_TRACE
+# endif /* ACE_HAS_TRACE */
+# define DOMAINAPPLICATIONMANAGER_TRACE(X) ACE_TRACE_IMPL(X)
+# include "ace/Trace.h"
+#endif /* (DOMAINAPPLICATIONMANAGER_NTRACE == 1) */
+
+#endif /* DOMAINAPPLICATIONMANAGER_EXPORT_H */
+
+// End of auto generated file.
diff --git a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp
new file mode 100644
index 00000000000..b8574c98d46
--- /dev/null
+++ b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp
@@ -0,0 +1,759 @@
+// $Id$
+
+#include "DomainApplicationManager_Impl.h"
+#include "ace/Null_Mutex.h"
+#include "ace/OS_NS_string.h"
+
+#include "CIAO/DnC/Config_Handlers/DnC_Dump.h"
+
+#include "NodeManager/NodeDaemonC.h"
+
+#if !defined (__ACE_INLINE__)
+# include "DomainApplicationManager_Impl.inl"
+#endif /* __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))
+ : orb_ (CORBA::ORB::_duplicate (orb)),
+ poa_ (PortableServer::POA::_duplicate (poa)),
+ target_manager_ (Deployment::TargetManager::_duplicate (manager)),
+ plan_ (plan),
+ num_child_plans_ (0),
+ // @@ (OO) The default size for an ACE_Hash_Map_Mapanger is quiet
+ // large. The maximum size of an ACE_Hash_Map_Manager is
+ // also fixed, i.e. it does not grow dynamically on demand.
+ // Make sure the default size of artifact_map_ is
+ // appropriate for your needs. You may also want to make
+ // the size configurable at compile-time, at least.
+ deployment_file_ (CORBA::string_dup (deployment_file)),
+ deployment_config_ (orb)
+{
+ ACE_NEW_THROW_EX (this->all_connections_,
+ Deployment::Connections (),
+ CORBA::NO_MEMORY ());
+ ACE_CHECK;
+}
+
+CIAO::DomainApplicationManager_Impl::~DomainApplicationManager_Impl ()
+{
+ if (CIAO::debug_level () > 1)
+ {
+ ACE_DEBUG ((LM_DEBUG, "DomainApplicationManager destroyed\n"));
+ }
+}
+
+void
+CIAO::DomainApplicationManager_Impl::
+init (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Deployment::ResourceNotAvailable,
+ Deployment::StartError,
+ Deployment::PlanError))
+{
+ ACE_TRY
+ {
+ // (1) Call get_plan_info() method to get the total number
+ // of child plans and list of NodeManager names, and
+ // (2) Check the validity of the global deployment plan.
+ if (! this->get_plan_info ())
+ ACE_THROW (Deployment::PlanError ());
+
+ // Call split_plan()
+ if (! this->split_plan ())
+ ACE_THROW (Deployment::PlanError ());
+
+ // Invoke preparePlan for each child deployment plan.
+ for (CORBA::ULong i = 0; i < this->num_child_plans_; ++i)
+ {
+ // Get the NodeManager object reference.
+ ::Deployment::NodeManager_var my_node_manager =
+ this->deployment_config_.get_node_manager
+ (this->node_manager_names_[i].c_str ());
+
+ // Get the child deployment plan reference.
+ ACE_Hash_Map_Entry
+ <ACE_CString,
+ Chained_Artifacts> *entry;
+
+ if (this->artifact_map_.find (this->node_manager_names_[i],
+ entry) != 0)
+ ACE_THROW (Deployment::PlanError ());
+
+ Chained_Artifacts & artifacts = entry->int_id_;
+
+ // Dump plans
+ if (CIAO::debug_level () > 1)
+ {
+ Deployment::DnC_Dump::dump (artifacts.child_plan_);
+ }
+
+ // Call preparePlan() method on the NodeManager with the
+ // corresponding child plan as input, which returns a
+ // NodeApplicationManager object reference.
+ Deployment::ApplicationManager_var tmp_app_manager =
+ my_node_manager->preparePlan (artifacts.child_plan_
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ Deployment::NodeApplicationManager_var app_manager
+ = Deployment::NodeApplicationManager::_narrow (tmp_app_manager.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (app_manager.in ()))
+ {
+ ACE_DEBUG ((LM_DEBUG, "DomainAppMgr::init () received a nil\
+ reference for NodeApplicationManager\n"));
+ ACE_THROW (Deployment::StartError ());
+ }
+ ACE_TRY_CHECK;
+
+ // Cache the NodeApplicationManager object reference.
+ artifacts.node_application_manager_ = app_manager._retn ();
+ }
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "DomainApplicationManager_Impl::init\t\n");
+ ACE_RE_THROW;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK;
+}
+
+bool
+CIAO::DomainApplicationManager_Impl::
+get_plan_info (void)
+{
+ if ( this->deployment_config_.init (this->deployment_file_) == -1 )
+ return 0;
+
+ const CORBA::ULong length = this->plan_.instance.length ();
+
+ // Error: If there are no nodes in the plan => No nodes to deploy the
+ // components
+ if (length == 0)
+ return false;
+
+ // Copy the name of the node in the plan on to the node manager
+ // array, Making sure that duplicates are not added twice
+ int num_plans = 0;
+ for (CORBA::ULong index = 0; index < length; index ++)
+ {
+ bool matched = false;
+
+ const CORBA::ULong number_node_managers = this->node_manager_names_.size ();
+ for (CORBA::ULong i = 0; i < number_node_managers; ++i)
+ // If a match is found do not add it to the list of unique
+ // node names
+ if (ACE_OS::strcmp (this->plan_.instance [index].node.in (),
+ (this->node_manager_names_ [i]).c_str ()) == 0)
+ {
+ // Break out -- Duplicates found
+ matched = true;
+ break;
+ }
+
+ if (! matched)
+ {
+ // 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 ());
+
+ if (CORBA::is_nil (mgr.in ()))
+ return 0; /* Failure */
+
+ // Add this unique node_name to the list of NodeManager names
+ this->node_manager_names_.push_back (this->plan_.instance [index].node.in ());
+
+ // Increment the number of plans
+ ++ num_plans;
+ }
+ }
+
+ // Set the length of the Node Managers
+ this->num_child_plans_ = num_plans;
+
+ // Indicate success
+ return true;
+}
+
+//@@ We should ask those spec writers to look at the code below, hopefully
+// They will realize some thing.
+int
+CIAO::DomainApplicationManager_Impl::
+split_plan (void)
+{
+ // Initialize the total number of child deployment plans specified
+ // by the global plan.
+ CORBA::ULong i;
+ for ( i = 0; i < this->num_child_plans_; ++i)
+ {
+ ::Deployment::DeploymentPlan_var tmp_plan;
+ ACE_NEW_RETURN (tmp_plan,
+ ::Deployment::DeploymentPlan,
+ 0);
+
+ tmp_plan->UUID = CORBA::string_dup (this->plan_.UUID.in ());
+
+ tmp_plan->implementation.length (0);
+ tmp_plan->instance.length (0);
+ tmp_plan->connection.length (0);
+ tmp_plan->externalProperty.length (0);
+ tmp_plan->dependsOn.length (0);
+ tmp_plan->artifact.length (0);
+ tmp_plan->infoProperty.length (0);
+
+ Chained_Artifacts artifacts;
+
+ // Fill in the child_plan_ field, relinquishing ownership
+ artifacts.child_plan_ = tmp_plan._retn ();
+
+ // Fill in the node_manager_ field.
+ artifacts.node_manager_ =
+ this->deployment_config_.get_node_manager
+ (this->node_manager_names_[i].c_str ());
+
+ this->artifact_map_.bind (node_manager_names_[i], artifacts);
+ }
+
+ // (1) Iterate over the <instance> field of the global DeploymentPlan
+ // variabl.
+ // (2) Retrieve the necessary information to contruct the node-level
+ // plans one by one.
+ for ( i = 0; i < (this->plan_.instance).length (); ++i)
+ {
+ // Fill in the child deployment plan in the map.
+
+ // Get the instance deployment description
+ const ::Deployment::InstanceDeploymentDescription & my_instance =
+ (this->plan_.instance)[i];
+
+ // Find the corresponding child deployment plan entry in
+ // the hash map for this instance.
+ ACE_Hash_Map_Entry
+ <ACE_CString,
+ Chained_Artifacts> *entry;
+
+ if (this->artifact_map_.find
+ (ACE_CString (my_instance.node.in ()),
+ entry) != 0)
+ return 0; // no valid name found.
+
+ // Get the child plan.
+ ::Deployment::DeploymentPlan_var &child_plan =
+ (entry->int_id_).child_plan_;
+
+ // Fill in the contents of the child plan entry.
+
+ // Append the "MonolithicDeploymentDescriptions implementation"
+ // field with a new "implementation", which is specified by the
+ // <implementationRef> field of <my_instance> entry. NOTE: The
+ // <artifactRef> field needs to be changed accordingly.
+ const ::Deployment::MonolithicDeploymentDescription & my_implementation =
+ (this->plan_.implementation)[my_instance.implementationRef];
+
+ //Deployment::DnC_Dump::dump (this->plan_);
+ //Deployment::DnC_Dump::dump ( (this->plan_.implementation)[my_instance.implementationRef]);
+
+ //ACE_DEBUG ((LM_DEBUG, "My implementation"));
+ //Deployment::DnC_Dump::dump (my_implementation);
+
+ CORBA::ULong index_imp = child_plan->implementation.length ();
+ child_plan->implementation.length (++index_imp);
+ child_plan->implementation[index_imp-1] = my_implementation;
+
+ // Initialize with the correct sequence length.
+ CORBA::ULongSeq ulong_seq;
+ ulong_seq.length (my_implementation.artifactRef.length ());
+
+ // Append the "ArtifactDeploymentDescriptions artifact" field
+ // with some new "artifacts", which is specified by the
+ // <artifactRef> sequence of <my_implementation> entry.
+ const CORBA::ULong impl_length = my_implementation.artifactRef.length ();
+ for (CORBA::ULong iter = 0;
+ iter < impl_length;
+ iter ++)
+ {
+ CORBA::ULong artifact_ref = my_implementation.artifactRef[iter];
+
+ // Fill in the <artifact> field of the child plan
+ CORBA::ULong index_art = child_plan->artifact.length ();
+ child_plan->artifact.length (++index_art);
+ child_plan->artifact[index_art-1] =
+ (this->plan_.artifact)[artifact_ref];
+
+ // Fill in the <artifactRef> field of the MonolithicDeploymentDescription
+ ulong_seq[iter] = index_art-1;
+ }
+
+ // Change the <artifactRef> field of the "implementation".
+ child_plan->implementation[index_imp-1].artifactRef = ulong_seq;
+
+ // Append the "InstanceDeploymentDescription instance" field with
+ // a new "instance", which is almost the same as the "instance" in
+ // the global plan except the <implementationRef> field.
+ // NOTE: The <implementationRef> field needs to be changed accordingly.
+ CORBA::ULong index_ins = child_plan->instance.length ();
+ child_plan->instance.length (++index_ins);
+ child_plan->instance[index_ins-1] = my_instance;
+
+ // Change the <implementationRef> field of the "instance".
+ // @@ The implementationRef starts from 0.
+ // @@TODO: Below logic needs to be changed once we want to avoid
+ // duplicate <implementation> for the optimization.
+ child_plan->instance[index_ins-1].implementationRef = index_ins-1;
+ }
+
+ return 1;
+}
+
+void
+CIAO::DomainApplicationManager_Impl::
+add_connections (const Deployment::Connections & incoming_conn)
+{
+
+ CORBA::ULong old_len = this->all_connections_->length ();
+
+ // Expand the length of the <all_connection_> sequence.
+ this->all_connections_->length (old_len + incoming_conn.length ());
+
+ // @@ (OO) Please change "i++" to "++i". The prefix increment
+ // operator is more efficient than the postfix increment
+ // operator.
+
+ // @@ (OO) The "continue loop" condition portion of the for
+ // statement is executed during each loop iteration. To
+ // improve performance execute it only once outside the
+ // for-loop.
+
+ // Store the connections to the <all_conections_> sequence
+ const CORBA::ULong conn_lenth = incoming_conn.length ();
+ for (CORBA::ULong i = 0; i < conn_lenth; ++i)
+ {
+ (*this->all_connections_)[old_len + i] = incoming_conn[i];
+ }
+}
+
+void
+CIAO::DomainApplicationManager_Impl::
+startLaunch (const ::Deployment::Properties & configProperty,
+ ::CORBA::Boolean start
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Deployment::ResourceNotAvailable,
+ ::Deployment::StartError,
+ ::Deployment::InvalidProperty))
+{
+ ACE_UNUSED_ARG (start);
+ ACE_TRY
+ {
+ // Invoke startLaunch() operations on each cached NodeApplicationManager
+ for (CORBA::ULong i = 0; i < this->num_child_plans_; ++i)
+ {
+ // Get the NodeApplicationManager object reference.
+ ACE_Hash_Map_Entry
+ <ACE_CString,
+ Chained_Artifacts> *entry;
+
+ if (this->artifact_map_.find (this->node_manager_names_[i],
+ entry) != 0)
+ ACE_THROW (Deployment::StartError ()); // Should never happen!
+
+ ::Deployment::NodeApplicationManager_ptr my_nam =
+ (entry->int_id_).node_application_manager_.in ();
+
+ if (CORBA::is_nil (my_nam))
+ {
+ ACE_DEBUG ((LM_DEBUG, "While starting launch, the DomainApplicationManager\
+ has a nil reference for NodeApplicationManager\n"));
+ ACE_THROW (Deployment::StartError ());
+ }
+ ACE_TRY_CHECK;
+
+ ::Deployment::Connections_var retn_connections;
+
+ // 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.
+
+ // Narrow down to NodeApplication object reference
+ ::Deployment::NodeApplication_var my_na =
+ ::Deployment::NodeApplication::_narrow (temp_application.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (my_na.in ()))
+ {
+ ACE_DEBUG ((LM_DEBUG, "The DomainApplicationManager receives a nil\
+ reference of NodeApplication after calling\
+ startLaunch on NodeApplicationManager.\n"));
+ ACE_THROW (Deployment::StartError ());
+ }
+ ACE_TRY_CHECK;
+
+ // Cache the returned set of connections into the list.
+ this->add_connections (retn_connections);
+
+ // Cache the returned NodeApplication object reference into
+ // the hash table.
+ (entry->int_id_).node_application_ = my_na._retn ();
+ }
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "DomainApplicationManager_Impl::startLaunch\t\n");
+ ACE_RE_THROW;
+ return; // @@ (OO) What purpose does this "return" statement
+ // serve?
+ }
+ ACE_ENDTRY;
+
+ ACE_CHECK_RETURN (0);
+}
+
+void
+CIAO::DomainApplicationManager_Impl::
+finishLaunch (::CORBA::Boolean start
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Deployment::StartError))
+{
+ ACE_TRY
+ {
+ // Invoke finishLaunch() operation on each cached NodeApplication object.
+ for (CORBA::ULong i = 0; i < this->num_child_plans_; ++i)
+ {
+ // Get the NodeApplication object reference.
+ ACE_Hash_Map_Entry <ACE_CString, Chained_Artifacts> * entry;
+
+ if (this->artifact_map_.find (this->node_manager_names_[i],
+ entry) != 0)
+ ACE_THROW (Deployment::StartError ()); // Should never happen!
+
+ //@@ Note: Don't delete the below debugging helpers.
+ // Dump the connections for debug purpose.
+ if (CIAO::debug_level () > 1)
+ {
+ ACE_DEBUG ((LM_DEBUG, "==============================================\n"));
+ ACE_DEBUG ((LM_DEBUG, "dump incomming connection for child plan:%d\n", i));
+ dump_connections (this->all_connections_.in ());
+ ACE_DEBUG ((LM_DEBUG, "==============================================\n"));
+ }
+
+ // Get the Connections variable.
+ Deployment::Connections * my_connections =
+ this->get_outgoing_connections ((entry->int_id_).child_plan_);
+
+ if (my_connections == 0)
+ ACE_THROW (Deployment::StartError ());
+
+ Deployment::Connections_var safe (my_connections);
+
+ // Dump the connections for debug purpose.
+ if (CIAO::debug_level () > 1)
+ {
+ ACE_DEBUG ((LM_DEBUG, "==============================================\n"));
+ ACE_DEBUG ((LM_DEBUG, "dump outgoingcomming connection for child plan:%d\n", i));
+ dump_connections (safe.in ());
+ ACE_DEBUG ((LM_DEBUG, "==============================================\n"));
+ }
+
+ // Invoke finishLaunch() operation on NodeApplication.
+ entry->int_id_.node_application_->finishLaunch (safe.in (),
+ start
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "DomainApplicationManager_Impl::finishLaunch\t\n");
+ ACE_RE_THROW;
+ }
+ ACE_ENDTRY;
+
+ ACE_CHECK_RETURN (0);
+}
+
+void
+CIAO::DomainApplicationManager_Impl::
+start (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Deployment::StartError))
+{
+ ACE_TRY
+ {
+ // Invoke start() operation on each cached NodeApplication object.
+ for (CORBA::ULong i = 0; i < this->num_child_plans_; ++i)
+ {
+ // Get the NodeApplication object reference.
+ ACE_Hash_Map_Entry
+ <ACE_CString,
+ Chained_Artifacts> *entry;
+
+ if (this->artifact_map_.find (this->node_manager_names_[i],
+ entry) != 0)
+ ACE_THROW (Deployment::StartError ()); // Should never happen!
+
+ // @@TODO: This might cause problem!
+ ::Deployment::NodeApplication_var my_na =
+ (entry->int_id_).node_application_.in ();
+
+ my_na->start (ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "DomainApplicationManager_Impl::start\t\n");
+ ACE_RE_THROW;
+ }
+ ACE_ENDTRY;
+
+ ACE_CHECK_RETURN (0);
+}
+
+void
+CIAO::DomainApplicationManager_Impl::
+destroyApplication (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Deployment::StopError))
+{
+ ACE_TRY
+ {
+ // Invoke destroyManager() operation on each cached
+ // NodeManager object.
+ for (CORBA::ULong i = 0; i < this->num_child_plans_; ++i)
+ {
+ // Get the NodeManager and NodeApplicationManager object references.
+ ACE_Hash_Map_Entry
+ <ACE_CString,
+ Chained_Artifacts> *entry;
+
+ if (this->artifact_map_.find (this->node_manager_names_[i],
+ entry) != 0)
+ ACE_THROW (Deployment::StopError ()); // Should never happen!
+
+ ::Deployment::NodeApplicationManager_ptr my_node_application_manager =
+ (entry->int_id_).node_application_manager_.in ();
+
+ // Invoke destoryApplication() operation on the NodeApplicationManger.
+ // Since we have the first arg is not used by NAM anyway.
+ my_node_application_manager->destroyApplication (0
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "DomainApplicationManager_Impl::destroyApplication\t\n");
+ ACE_RE_THROW;
+ }
+ ACE_ENDTRY;
+
+ ACE_CHECK;
+}
+
+// @@ (OO) Method definitions should never use "_WITH_DEFAULTS"
+// versions of emulated exception parameters. Please remove
+// the "_WITH_DEFAULTS"
+void
+CIAO::DomainApplicationManager_Impl::
+destroyManager (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Deployment::StopError))
+{
+ ACE_TRY
+ {
+ for (CORBA::ULong i = 0; i < this->num_child_plans_; ++i)
+ {
+ // Get the NodeManager and NodeApplicationManager object references.
+ ACE_Hash_Map_Entry
+ <ACE_CString,
+ Chained_Artifacts> *entry;
+
+ if (this->artifact_map_.find (this->node_manager_names_[i],
+ entry) != 0)
+ ACE_THROW (Deployment::StopError ()); // Should never happen!
+
+ ::Deployment::NodeManager_var my_node_manager =
+ (entry->int_id_).node_manager_;
+
+ // Since we have the first arg is not used by NM anyway.
+ my_node_manager->destroyManager (0 ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "DomainApplicationManager_Impl::destroyManager\t\n");
+ ACE_RE_THROW;
+ }
+ ACE_ENDTRY;
+
+ ACE_CHECK;
+}
+
+// Returns the DeploymentPlan associated with this ApplicationManager.
+::Deployment::DeploymentPlan *
+CIAO::DomainApplicationManager_Impl::
+getPlan (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ Deployment::DeploymentPlan_var plan = 0;
+ // Make a deep copy of the Plan
+ ACE_NEW_THROW_EX (plan,
+ Deployment::DeploymentPlan (this->plan_),
+ CORBA::NO_MEMORY ());
+
+ // Transfer ownership
+ return plan._retn ();
+}
+
+Deployment::Connections *
+CIAO::DomainApplicationManager_Impl::
+get_outgoing_connections (const Deployment::DeploymentPlan &plan)
+{
+ Deployment::Connections_var connections;
+ ACE_NEW_RETURN (connections,
+ Deployment::Connections,
+ 0);
+
+ // For each component instance in the child plan ...
+ for (CORBA::ULong i = 0; i < plan.instance.length (); ++i)
+ {
+ // Get the component instance name
+ if (!get_outgoing_connections_i (plan.instance[i].name.in (),
+ connections.inout ()))
+ return 0;
+ }
+ return connections._retn ();
+}
+
+bool
+CIAO::DomainApplicationManager_Impl::
+get_outgoing_connections_i (const char * instname,
+ Deployment::Connections & retv)
+{
+ // Search in all the connections in the plan.
+ for (CORBA::ULong i = 0; i < this->plan_.connection.length(); ++i)
+ {
+ CORBA::ULong len = retv.length ();
+
+ // Current connection that we are looking at.
+ const Deployment::PlanConnectionDescription & curr_conn =
+ this->plan_.connection[i];
+
+ //The modeling tool should make sure there are always 2 endpoints
+ //in a connection.
+ const CORBA::ULong curr_conn_len = curr_conn.internalEndpoint.length ();
+ for (CORBA::ULong p_index = 0;
+ p_index < curr_conn_len;
+ ++p_index)
+ {
+ const Deployment::PlanSubcomponentPortEndpoint & endpoint =
+ curr_conn.internalEndpoint[p_index];
+
+ // If the component name matches the name of one of the
+ // endpoints in the connection.
+ if (ACE_OS::strcmp (this->plan_.instance[endpoint.instanceRef].name.in (),
+ instname) == 0 )
+ {
+ //Look at the port kind to make sure it's what we are interested in.
+ if (endpoint.kind != Deployment::Facet &&
+ endpoint.kind != Deployment::EventConsumer)
+ {
+ // The other endpoints in this connection is what we want.
+ CORBA::ULong index = (p_index +1)%2;
+
+ //Cache the name of the other component for later usage (search).
+ ACE_CString name =
+ this->plan_.instance[curr_conn.internalEndpoint[index].instanceRef].name.in ();
+
+ //Cache the name of the port from the other component for searching later.
+ ACE_CString port_name =
+ curr_conn.internalEndpoint[index].portName.in ();
+
+ bool found = false;
+
+ // Now we have to search in the received connections to get the objRef.
+ const CORBA::ULong all_conn_len = this->all_connections_->length ();
+ for (CORBA::ULong conn_index = 0;
+ conn_index < all_conn_len;
+ ++conn_index)
+ {
+ //ACE_DEBUG ((LM_DEBUG, "step4\n"));
+
+ const Deployment::Connection curr_rev_conn = this->all_connections_[conn_index];
+
+ // We need to look at the instance name and the port name to confirm.
+ if (ACE_OS::strcmp (curr_rev_conn.instanceName.in (),
+ name.c_str ()) == 0 &&
+ ACE_OS::strcmp (curr_rev_conn.portName.in (),
+ port_name.c_str ()) == 0)
+ {
+ //ACE_DEBUG ((LM_DEBUG, "step5\n"));
+
+ retv.length (len+1);
+ retv[len].instanceName = instname;
+ retv[len].portName = endpoint.portName.in ();
+ retv[len].kind = endpoint.kind;
+ retv[len].endpoint = CORBA::Object::_duplicate(curr_rev_conn.endpoint.in ());
+ ++len;
+ found = true;
+ break; // Since we know there is only 2 endpoints in a connection.
+ // so we dont have to worry about multiplex Receptacle etc.
+ }
+ }
+
+ // We didnt find the counter part connection even we are sure there must be 1.
+ if (!found) return false;
+ break; // We know we have found the connection so even we are still on
+ // internalpoint 0 we can skip internalpoint 1.
+ }
+ }
+ } /* close for loop on internal endpoints */
+ } /* close for loop on all connections in the plan */
+ return 1;
+}
+
+void
+CIAO::DomainApplicationManager_Impl::
+dump_connections (const ::Deployment::Connections & connections)
+{
+ const CORBA::ULong conn_len = connections.length ();
+ for (CORBA::ULong i = 0; i < conn_len; ++i)
+ {
+ ACE_DEBUG ((LM_DEBUG, "instanceName: %s\n", connections[i].instanceName.in ()));
+ ACE_DEBUG ((LM_DEBUG, "portName: %s\n", connections[i].portName.in ()));
+ ACE_DEBUG ((LM_DEBUG, "portkind: "));
+ switch (connections[i].kind) {
+ case Deployment::Facet: ACE_DEBUG ((LM_DEBUG, "Facet\n")); break;
+ case Deployment::SimplexReceptacle: ACE_DEBUG ((LM_DEBUG, "SimplexReceptacle\n")); break;
+ case Deployment::MultiplexReceptacle: ACE_DEBUG ((LM_DEBUG, "MultiplexReceptacle\n")); break;
+ case Deployment::EventEmitter: ACE_DEBUG ((LM_DEBUG, "EventEmitter\n")); break;
+ case Deployment::EventPublisher: ACE_DEBUG ((LM_DEBUG, "EventPublisher\n")); break;
+ case Deployment::EventConsumer: ACE_DEBUG ((LM_DEBUG, "EventConsumer\n")); break;
+ }
+
+ // object reference.
+ ACE_DEBUG ((LM_DEBUG, "endpoint: \n"));
+ }
+}
diff --git a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h
new file mode 100644
index 00000000000..5f2a4aa6239
--- /dev/null
+++ b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h
@@ -0,0 +1,295 @@
+//==================================================================
+/**
+ * @file DomainApplicationManager_Impl.h
+ *
+ * $Id$
+ *
+ * This file contains implementation for the servant of
+ * Deployment::DomainApplicationManager.
+ *
+ * @author Gan Deng <gan.deng@vanderbilt.edu>
+ * @author Arvind S. Krishna <arvindk@dre.vanderbilt.edu>
+ * @author Tao Lu <lu@dre.vanderbilt.edu>
+ */
+//=====================================================================
+
+#ifndef CIAO_DOMAINAPPLICATIONMANAGER_IMPL_H
+#define CIAO_DOMAINAPPLICATIONMANAGER_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 "ace/Hash_Map_Manager.h"
+#include "ace/Vector_T.h"
+#include "ace/Functor.h"
+#include "ace/OS_NS_string.h"
+#include "DeploymentS.h"
+
+#include "tao/Valuetype/ValueBase.h"
+#include "tao/Valuetype/Valuetype_Adapter_Impl.h"
+
+#include "Deployment_Configuration.h"
+#include "DomainApplicationManager_Export.h"
+#include "ciao/CIAO_common.h"
+
+namespace CIAO
+{
+ /**
+ * @class DomainApplicationManager_Impl
+ *
+ * @brief A servant for the Deployment::DomainApplicationManager
+ * interface. The DomainApplicationManager is responsible for
+ * deploying an application on the domain level, i.e. across
+ * nodes. It specializes the ApplicationManager abstract interface.
+ */
+ class DomainApplicationManager_Export DomainApplicationManager_Impl
+ : public virtual POA_Deployment::DomainApplicationManager,
+ public virtual PortableServer::RefCountServantBase
+ {
+ public:
+ /// Define the type which contains a list of DnC artifacts.
+ /// @@ Assumption: Each NodeApplicationManager create only one
+ /// NodeApplication when the startLaunch() operation is invoked,
+ /// which means all the nodes on that child plan are collocated in
+ /// the same process.
+ typedef struct _chained_artifacts
+ {
+ ::Deployment::NodeManager_var node_manager_;
+ ::Deployment::DeploymentPlan_var child_plan_;
+ ::Deployment::NodeApplicationManager_var node_application_manager_;
+ ::Deployment::NodeApplication_var node_application_;
+ } 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)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+
+ /*===========================================================
+ * Below are helper methods for the DomainApplicationManager
+ *
+ *============================================================*/
+ /**
+ * Initialize the DomainApplicationManager.
+ * (1) Set the total number of child plans.
+ * (2) Set the list of NodeManager names, which is an array of strings.
+ * The <node_manager_names> is a pointer to an array of ACE_CString
+ * objets, which is allocated by the caller and deallocated by the
+ * DomainApplicationManager destructor.
+ * (3) Check the validity of the deployment plan and the deployment
+ * information data file.
+ * (4) Call split_plan () member function.
+ * (5) Invoke all the preparePlan () operations on all the corresponding
+ * NodeManagers with child plans.
+ *
+ *
+ * @@ What else do we need to initialize here?
+ */
+ void init (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Deployment::ResourceNotAvailable,
+ Deployment::StartError,
+ Deployment::PlanError));
+
+ /**
+ * set_uuid method on the DomainApplicationManager assigns the
+ * UUID of the associated plan to this Manager. This helps in
+ * reverse lookup operations such as given a manager, obtaining
+ * the UUID associated. The get_uuid method is used in this case.
+ */
+ void set_uuid (const char * uuid);
+
+ const char * get_uuid () const;
+
+ /*===========================================================
+ * Below are operations from the DomainApplicationManager
+ *
+ *============================================================*/
+
+ /**
+ * Executes the application, but does not start it yet. Users can
+ * optionally provide launch-time configuration properties to
+ * override properties that are part of the plan. Raises the
+ * InvalidProperty exception if a configuration property is
+ * invalid. Raises the StartError exception if an error occurs
+ * during launching. Raises the ResourceNotAvailable exception if
+ * the commitResources parameter to the prepare operation of the
+ * ExecutionManager was true, if late resource allocation is used,
+ * and one of the requested resources is not available.
+ */
+ virtual void
+ startLaunch (const ::Deployment::Properties & configProperty,
+ ::CORBA::Boolean start
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Deployment::ResourceNotAvailable,
+ ::Deployment::StartError,
+ ::Deployment::InvalidProperty));
+
+ /**
+ * The second step in launching an application in the
+ * domain-level. If the start parameter is true, the application
+ * is started as well. Raises the StartError exception if
+ * launching or starting the application fails.
+ */
+ virtual void finishLaunch (::CORBA::Boolean start
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Deployment::StartError));
+
+ /**
+ * Starts the application. Raises the StartError exception if
+ * starting the application fails.
+ */
+ virtual void start (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Deployment::StartError));
+
+ /**
+ * Terminates a running application. Raises the StopError
+ * exception if an error occurs during termination. Raises the
+ * InvalidReference exception if the appliction referen is
+ * unknown.
+ */
+ virtual void destroyApplication (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ::Deployment::StopError));
+
+ /**
+ * Returns the DeploymentPlan associated with this ApplicationManager.
+ */
+ virtual ::Deployment::DeploymentPlan * getPlan (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ /**
+ * This is a helper function to destroy the NodeAppManager.
+ * Since we don't want to do so in the destructor so we will
+ * ask the ExecutionManager to do this on us when the same IDL
+ * op invoked on it. This is part of the result for merging DAM
+ * with DA.
+ */
+ virtual void destroyManager (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Deployment::StopError));
+
+ protected:
+ /// Destructor
+ virtual ~DomainApplicationManager_Impl (void);
+
+ /**
+ * (1) Parse the global deployment plan, get the total number of
+ * child plans included in the global plan, and get the list of
+ * names of NodeManagers for each child plan.
+ * (2) Check whether all the NodeManager names are present in the
+ * deployment information data file.
+ */
+ bool get_plan_info (void);
+
+ /**
+ * Split the global (domain-level) deployment plan to a set of
+ * local (node-level) deployment plans. The set of local plans
+ * are cached in the ACE hash map member variable.
+ * Also, fill in the <node_manager_> field of the Chained_Artifacts
+ * struct.
+ */
+ int split_plan (void);
+
+
+ /**
+ * Cache the incoming connections, which is a sequence of Connections,
+ * into the <all_connections_> list.
+ */
+ void add_connections (const Deployment::Connections & incoming_conn);
+
+ /**
+ * Given a child deployment plan, find the <Connections> sequence
+ * of the "providedReference" for the component instances in the
+ * child deployment plan as Receiver side.
+ */
+ Deployment::Connections *
+ get_outgoing_connections (const Deployment::DeploymentPlan &plan);
+
+ /// This is a helper function to find the connection for a component.
+ bool
+ get_outgoing_connections_i (const char * instname,
+ Deployment::Connections & retv);
+
+ /// Dump connections, a static method
+ static void dump_connections (const ::Deployment::Connections & connections);
+
+ protected:
+ /// location of the Domainapplication
+ CORBA::String_var domainapp_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_;
+
+ /// Cache a object reference to this servant.
+ /// Deployment::DomainApplicationManager_var objref_;
+
+ /// Cache the ior of the previous reference
+ CORBA::String_var ior_;
+
+ /// Cached TargetManager.
+ Deployment::TargetManager_var target_manager_;
+
+ /// Cached deployment plan for the particular domain.
+ /// The plan will be initialized when init is called.
+ Deployment::DeploymentPlan plan_;
+
+ /// Cached child plans.
+ //Deployment::DeploymentPlan * child_plan_;
+
+ /// Total number of child deployment plans.
+ size_t num_child_plans_;
+
+ /// The list of node manager names, each of them
+ /// corresponds to one child plan.
+ ACE_Vector<ACE_CString> node_manager_names_;
+
+ /// Cached information for NodeManager, NodeApplicationManager,
+ /// NodeApplication, Connections, etc.
+ /// Key: NodeManager name with CString type.
+ /// Value: Chained_Artifacts struct type.
+ typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
+ Chained_Artifacts,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> Chained_Artifacts_Table;
+
+ Chained_Artifacts_Table artifact_map_;
+
+ /// The deployment information data file.
+ const char * deployment_file_;
+
+ /// Deployment Configuration info, which contains the deployment topology.
+ Deployment_Configuration deployment_config_;
+
+ /// UUID from the Plan
+ CORBA::String_var uuid_;
+
+ /// Maintain a list of <Connections>, each of which is obtained by
+ /// calling the startLaunch() method on the NodeApplicationManager object.
+ ::Deployment::Connections_var all_connections_;
+
+ };
+}
+
+#if defined (__ACE_INLINE__)
+# include "DomainApplicationManager_Impl.inl"
+#endif /* __ACE_INLINE__ */
+
+#include /**/ "ace/post.h"
+#endif /* CIAO_DOMAINAPPLICATIONMANAGER_IMPL_H */
diff --git a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.inl b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.inl
new file mode 100644
index 00000000000..b50adfbc712
--- /dev/null
+++ b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.inl
@@ -0,0 +1,16 @@
+// -*- C++ -*-
+//
+// $Id$
+
+ACE_INLINE const char *
+CIAO::DomainApplicationManager_Impl::get_uuid () const
+{
+ return this->uuid_;
+}
+
+ACE_INLINE void
+CIAO::DomainApplicationManager_Impl::set_uuid (const char * uuid)
+{
+ // Copy this uuid reference
+ this->uuid_ = CORBA::string_dup (uuid);
+}
diff --git a/TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager.idl b/TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager.idl
new file mode 100644
index 00000000000..cdd47c24d1b
--- /dev/null
+++ b/TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager.idl
@@ -0,0 +1,26 @@
+// $Id$
+
+/**
+ * @file ExecutionManager.idl
+ *
+ * @brief Simple interface to control the ExecutionManager. This
+ * interface currently provides an additional method called shutdown
+ * to terminate the process cleanly.
+ *
+ */
+
+#include "Deployment.idl"
+
+module CIAO
+{
+ /**
+ * @brief CIAO Execution Manager Program
+ *
+ * This feature addition is added using inheritance mechanism currently
+ */
+ interface ExecutionManagerDaemon : Deployment::ExecutionManager
+ {
+ // Shutdown the daemon process.
+ oneway void shutdown ();
+ };
+};
diff --git a/TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager.mpc b/TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager.mpc
new file mode 100644
index 00000000000..067cad1415d
--- /dev/null
+++ b/TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager.mpc
@@ -0,0 +1,31 @@
+// -*- MPC -*-
+// $Id$
+
+project (ExecutionManager_stub): ciao_deployment_stub, ciao_server_dnc {
+ sharedname = ExecutionManager_stub
+ idlflags += -Wb,stub_export_macro=ExecutionManager_stub_Export -Wb,stub_export_include=ExecutionManager_stub_export.h
+ dynamicflags = EXECUTIONMANAGER_STUB_BUILD_DLL
+
+ IDL_Files {
+ ExecutionManager.idl
+ }
+
+ Source_Files {
+ ExecutionManagerC.cpp
+ }
+}
+
+project(Execution_Manager): ciao_server_dnc, ciao_deployment_svnt, ciao_deployment_stub, iortable, naming {
+ exename = Execution_Manager
+ after += DomainApplicationManager ExecutionManager_stub
+ libs += DomainApplicationManager ExecutionManager_stub TAO_IFR_Client
+
+ IDL_Files {
+ }
+
+ Source_Files {
+ ExecutionManagerS.cpp
+ Execution_Manager.cpp
+ ExecutionManager_Impl.cpp
+ }
+}
diff --git a/TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager_Impl.cpp b/TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager_Impl.cpp
new file mode 100644
index 00000000000..65c3ccf99e9
--- /dev/null
+++ b/TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager_Impl.cpp
@@ -0,0 +1,154 @@
+/* -*- C++ -*- */
+// $Id$
+
+#include "ExecutionManager_Impl.h"
+
+CIAO::ExecutionManager_Impl::ExecutionManager_Impl (CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ const char * init_file
+ ACE_ENV_ARG_DECL)
+ : orb_ (CORBA::ORB::_duplicate (orb)),
+ poa_ (PortableServer::POA::_duplicate (poa)),
+ init_file_ (init_file),
+ dam_servant_ (0)
+{
+}
+
+CIAO::ExecutionManager_Impl::~ExecutionManager_Impl ()
+{
+ if (CIAO::debug_level () > 1)
+ ACE_DEBUG ((LM_DEBUG, "ExecutionManager Dtor\n"));
+}
+
+Deployment::DomainApplicationManager_ptr
+CIAO::ExecutionManager_Impl::
+preparePlan (const Deployment::DeploymentPlan &plan,
+ CORBA::Boolean
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Deployment::ResourceNotAvailable,
+ Deployment::PlanError,
+ Deployment::StartError
+ ))
+{
+ // As DAnCE currently supports only one domain for now, we return the same
+ // DomainApplicationManager for multiple calls to prepare plan
+
+ if (this->dam_servant_ == 0)
+ {
+ // Create a new DomainApplicationMananager servant
+ ACE_NEW_THROW_EX (this->dam_servant_,
+ CIAO::DomainApplicationManager_Impl
+ (this->orb_.in (),
+ this->poa_.in (),
+ Deployment::TargetManager::_nil (),
+ plan,
+ this->init_file_.c_str ()),
+ CORBA::NO_MEMORY ());
+
+ ACE_CHECK_RETURN (Deployment::DomainApplicationManager::_nil());
+
+ /**
+ *===================================================================
+ * MAIN STEP: This call parses the deployment plan, generates the Node
+ * specific plan and starts the deployment process
+ *===================================================================
+ */
+ this->dam_servant_->init (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_CHECK_RETURN (Deployment::DomainApplicationManager::_nil());
+
+ this->dam_servant_->set_uuid (plan.UUID.in ());
+
+ // Register with our POA and activate the object.
+ PortableServer::ObjectId_var oid
+ = this->poa_->activate_object (this->dam_servant_.in ()
+ ACE_ENV_ARG_PARAMETER);
+
+ ACE_CHECK_RETURN (Deployment::DomainApplicationManager::_nil ());
+
+ // Get the reference of the object.
+ CORBA::Object_var objref
+ = this->poa_->id_to_reference (oid.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (Deployment::DomainApplicationManager::_nil ());
+
+ this->dam_ =
+ Deployment::DomainApplicationManager::_narrow (objref.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (Deployment::DomainApplicationManager::_nil ());
+ }
+
+ // Return the ApplicationManager instance
+ return Deployment::DomainApplicationManager::_duplicate (this->dam_.in ());
+}
+
+Deployment::DomainApplicationManagers *
+CIAO::ExecutionManager_Impl::getManagers (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ // Initialize the list of DomainApplication Managers
+ Deployment::DomainApplicationManagers_var list;
+ ACE_NEW_THROW_EX (list,
+ Deployment::DomainApplicationManagers,
+ CORBA::NO_MEMORY());
+ ACE_CHECK_RETURN (0);
+
+ // Add the manager to the list
+ CORBA::ULong index = list->length ();
+ list->length (index + 1);
+ list [index] =
+ Deployment::DomainApplicationManager::_duplicate (this->dam_.in ());
+ return list._retn ();
+}
+
+void
+CIAO::ExecutionManager_Impl::destroyManager (Deployment::DomainApplicationManager_ptr manager
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Deployment::StopError))
+{
+ ACE_UNUSED_ARG (manager);
+ //if (CORBA::is_nil (manager))
+ // ACE_THROW (Deployment::StopError ());
+
+ ACE_TRY
+ {
+ PortableServer::ObjectId_var oid
+ = this->poa_->reference_to_id (this->dam_.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ this->dam_servant_->destroyManager (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ this->poa_->deactivate_object (oid.in ()
+ ACE_ENV_ARG_PARAMETER);
+
+ // set it to zero to force it to be in a consistent
+ // state.
+ this->dam_servant_ = 0;
+ this->dam_ = Deployment::DomainApplicationManager::_nil ();
+
+ ACE_TRY_CHECK;
+
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "ExecutionManager_Impl::destroyManager\t\n");
+ ACE_THROW (Deployment::StopError ());
+ }
+
+ ACE_ENDTRY;
+}
+
+void
+CIAO::ExecutionManager_Impl::shutdown (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ // @@ (OO) You're using the wrong emulated exception macro below.
+ // Please use ACE_ENV_ARG_PARAMETER instead.
+
+ // Shutdown the ORB on which it is runing
+ this->orb_->shutdown (0 ACE_ENV_ARG_PARAMETER);
+}
diff --git a/TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager_Impl.h b/TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager_Impl.h
new file mode 100644
index 00000000000..619d5d7f3ac
--- /dev/null
+++ b/TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager_Impl.h
@@ -0,0 +1,131 @@
+/*=======================================================================
+ *
+ * @file ExecutionManager_Impl.h
+ *
+ * $Id$
+ *
+ * @brief This file contains implementation for
+ * Deployment::ExecutionManager interface.
+ *
+ * @author Arvind S. Krishna <arvindk@dre.vanderbilt.edu>
+ * @auther Tao Lu <lu@dre.vanderbilt.edu>
+ *
+ *======================================================================*/
+
+#ifndef EXECUTIONMANAGER_IMPL_H
+#define EXECUTIONMANAGER_IMPL_H
+
+#include "ExecutionManagerS.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Synch.h"
+#include "ace/Hash_Map_Manager.h"
+#include "tao/Utils/Servant_Var.h"
+#include "DomainApplicationManager/DomainApplicationManager_Impl.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 is an 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.
+ *
+ */
+namespace CIAO
+{
+ class ExecutionManager_Impl
+ : public virtual POA_CIAO::ExecutionManagerDaemon,
+ public virtual PortableServer::RefCountServantBase
+ {
+
+ public:
+ /// Constructor.
+ ExecutionManager_Impl (CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ const char * init_file
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+
+ /// Generate an ApplicationManager factory.
+ virtual Deployment::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 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,
+ Deployment::StopError
+ ));
+
+ virtual void
+ shutdown (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ protected:
+ /*typedef
+ ACE_Hash_Map_Manager_Ex
+ < ACE_CString,
+ Deployment::DomainApplicationManager_var,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ TAO_SYNCH_MUTEX
+ >
+ Table;
+ typedef Table::iterator Iterator;
+ */
+
+ /// Destructor.
+ ~ExecutionManager_Impl ();
+
+ /// Cached ORB pointer
+ CORBA::ORB_var orb_;
+
+ /// Cached POA pointer
+ PortableServer::POA_var poa_;
+
+ // Internal Hashtable
+ // Table table_;
+
+ // Path to the initialization file
+ ACE_CString init_file_;
+
+ Deployment::DomainApplicationManager_var dam_;
+
+ /// Cached servant of the DomainApplicaitonmanager.
+ TAO::Utils::Servant_Var<CIAO::DomainApplicationManager_Impl> dam_servant_;
+ };
+
+};
+
+#include /**/ "ace/post.h"
+#endif /* EXECUTIONMANAGER_IMPL_H */
diff --git a/TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager_Impl.inl b/TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager_Impl.inl
new file mode 100644
index 00000000000..7325e38ec1d
--- /dev/null
+++ b/TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager_Impl.inl
@@ -0,0 +1,2 @@
+/* -*- C++ -*- */
+// $Id$
diff --git a/TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager_stub_export.h b/TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager_stub_export.h
new file mode 100644
index 00000000000..f32c91c5e6e
--- /dev/null
+++ b/TAO/CIAO/DAnCE/ExecutionManager/ExecutionManager_stub_export.h
@@ -0,0 +1,54 @@
+
+// -*- C++ -*-
+// $Id$
+// Definition for Win32 Export directives.
+// This file is generated automatically by generate_export_file.pl ExecutionManager_stub
+// ------------------------------
+#ifndef EXECUTIONMANAGER_STUB_EXPORT_H
+#define EXECUTIONMANAGER_STUB_EXPORT_H
+
+#include "ace/config-all.h"
+
+#if !defined (EXECUTIONMANAGER_STUB_HAS_DLL)
+# define EXECUTIONMANAGER_STUB_HAS_DLL 1
+#endif /* ! EXECUTIONMANAGER_STUB_HAS_DLL */
+
+#if defined (EXECUTIONMANAGER_STUB_HAS_DLL) && (EXECUTIONMANAGER_STUB_HAS_DLL == 1)
+# if defined (EXECUTIONMANAGER_STUB_BUILD_DLL)
+# define ExecutionManager_stub_Export ACE_Proper_Export_Flag
+# define EXECUTIONMANAGER_STUB_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T)
+# define EXECUTIONMANAGER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# else /* EXECUTIONMANAGER_STUB_BUILD_DLL */
+# define ExecutionManager_stub_Export ACE_Proper_Import_Flag
+# define EXECUTIONMANAGER_STUB_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T)
+# define EXECUTIONMANAGER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# endif /* EXECUTIONMANAGER_STUB_BUILD_DLL */
+#else /* EXECUTIONMANAGER_STUB_HAS_DLL == 1 */
+# define ExecutionManager_stub_Export
+# define EXECUTIONMANAGER_STUB_SINGLETON_DECLARATION(T)
+# define EXECUTIONMANAGER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+#endif /* EXECUTIONMANAGER_STUB_HAS_DLL == 1 */
+
+// Set EXECUTIONMANAGER_STUB_NTRACE = 0 to turn on library specific tracing even if
+// tracing is turned off for ACE.
+#if !defined (EXECUTIONMANAGER_STUB_NTRACE)
+# if (ACE_NTRACE == 1)
+# define EXECUTIONMANAGER_STUB_NTRACE 1
+# else /* (ACE_NTRACE == 1) */
+# define EXECUTIONMANAGER_STUB_NTRACE 0
+# endif /* (ACE_NTRACE == 1) */
+#endif /* !EXECUTIONMANAGER_STUB_NTRACE */
+
+#if (EXECUTIONMANAGER_STUB_NTRACE == 1)
+# define EXECUTIONMANAGER_STUB_TRACE(X)
+#else /* (EXECUTIONMANAGER_STUB_NTRACE == 1) */
+# if !defined (ACE_HAS_TRACE)
+# define ACE_HAS_TRACE
+# endif /* ACE_HAS_TRACE */
+# define EXECUTIONMANAGER_STUB_TRACE(X) ACE_TRACE_IMPL(X)
+# include "ace/Trace.h"
+#endif /* (EXECUTIONMANAGER_STUB_NTRACE == 1) */
+
+#endif /* EXECUTIONMANAGER_STUB_EXPORT_H */
+
+// End of auto generated file.
diff --git a/TAO/CIAO/DAnCE/ExecutionManager/Execution_Manager.cpp b/TAO/CIAO/DAnCE/ExecutionManager/Execution_Manager.cpp
new file mode 100644
index 00000000000..1815533921c
--- /dev/null
+++ b/TAO/CIAO/DAnCE/ExecutionManager/Execution_Manager.cpp
@@ -0,0 +1,230 @@
+//--*C++*--
+
+//==============================================================
+/**
+ * @file Execution_Manager.cpp
+ *
+ * @brief CIAO's Execution Manager implementation
+ *
+ * $Id$
+ *
+ * ExecutionManager is the DnC entity which is the starting point for
+ * the deployment process. This entity collaborates with other entities
+ * including Logging Facility, TargetManager, and
+ * DomainApplicationManager entities to facilitate the deployment and
+ * launching of components. In our current design, the ExecutionManager
+ * is started as an executable on a give host and registered with the
+ * name service. The Executor/client obtains this reference and starts
+ * the deployment process.
+ *
+ *
+ * @author Arvind S. Krishna <arvindk@dre.vanderbilt.edu>
+ * @author Tao Lu <lu@dre.vanderbilt.edu>
+ */
+//===============================================================
+
+#include "ExecutionManager_Impl.h"
+#include "Server_init.h"
+#include "tao/IORTable/IORTable.h"
+
+// Include Name Service header
+#include "orbsvcs/orbsvcs/CosNamingC.h"
+
+#include "ace/SString.h"
+#include "ace/Read_Buffer.h"
+#include "ace/Get_Opt.h"
+#include "ace/OS_NS_unistd.h"
+
+const char *ior_file_name_ = "executionManager.ior";
+char * default_svcconf_ = 0;
+char * svcconf_config_ = 0;
+char * name = "ExecutionManager";
+char * init_file_name = "deployment.dat";
+
+int write_to_ior_ = 0;
+int register_with_ns_ = 0;
+
+int
+parse_args (int argc, char *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "o:c:m:i:n");
+ 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 ();
+ write_to_ior_ = 1;
+ break;
+
+ case 'c': // get the default svc.conf filename
+ default_svcconf_ = get_opts.opt_arg ();
+ break;
+
+ case 'i': // get the svc.conf map configuration filename
+ init_file_name = get_opts.opt_arg ();
+ break;
+
+ case 'n':
+ register_with_ns_ = 1;
+ break;
+
+ case '?': // display help for use of the server.
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s\n"
+ "-o <ior_output_file>\n"
+ "-c <svc.conf file>\n"
+ "-i <installation data filename>\n"
+ "-n <use naming service>\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
+register_with_ns (const char * name_context,
+ CORBA::ORB_ptr orb,
+ CIAO::ExecutionManagerDaemon_ptr obj)
+{
+ // Naming Service related operations
+ CORBA::Object_var naming_context_object =
+ orb->resolve_initial_references ("NameService");
+
+ CosNaming::NamingContext_var naming_context =
+ CosNaming::NamingContext::_narrow (naming_context_object.in ());
+
+ // Initialize the Naming Sequence
+ CosNaming::Name name (1);
+ name.length (1);
+ // Register the name with the NS
+ name[0].id = CORBA::string_dup (name_context);
+
+ // Register the servant with the Naming Service
+ naming_context->bind (name, obj);
+
+ 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;
+
+ 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::ExecutionManager_Impl *daemon_servant = 0;
+ ACE_NEW_RETURN (daemon_servant,
+ CIAO::ExecutionManager_Impl(orb.in (),
+ poa.in (),
+ init_file_name),
+ -1);
+
+ // Implicit activation
+ PortableServer::ServantBase_var safe_daemon (daemon_servant);
+ CIAO::ExecutionManagerDaemon_var daemon = daemon_servant->_this ();
+
+ // Now register daemon with IOR table and write its IOR.
+ CORBA::String_var str = orb->object_to_string (daemon.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ adapter->bind ("ExecutionManager", str.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (write_to_ior_)
+ write_IOR (str.in ());
+ else if (register_with_ns_)
+ {
+ // Register this name with the Naming Service
+ register_with_ns (name, orb.in (), daemon.in ());
+ }
+
+ ACE_DEBUG ((LM_INFO, "CIAO_ExecutionMananger 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_ExecutionManager is running...\n"));
+
+ // Run the main event loop for the ORB.
+ orb->run (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK
+
+ poa->destroy (1, 1 ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "CIAO_ExecutionManager::main\t\n");
+ return 1;
+ }
+ ACE_ENDTRY;
+
+ ACE_DEBUG ((LM_DEBUG,
+ "CIAO_ExecutionManager has closed\n"));
+ return 0;
+}