summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam R. Otte <wotte@dre.vanderbilt.edu>2010-03-04 13:07:20 +0000
committerWilliam R. Otte <wotte@dre.vanderbilt.edu>2010-03-04 13:07:20 +0000
commite418bf63c70b5db9d3bb1aca98137641fd3f39a3 (patch)
treed6d910922d111eecfb127a878f7fe0d4be261c69
parent78010f53978b3fd49a5768aa934b3b992b77695f (diff)
downloadATCD-e418bf63c70b5db9d3bb1aca98137641fd3f39a3.tar.gz
Thu Mar 4 13:04:14 UTC 2010 William R. Otte <wotte@dre.vanderbilt.edu>
* DAnCE/Plan_Launcher/Deployment_Failure.h: * DAnCE/Plan_Launcher/EM_Launcher.h: * DAnCE/Plan_Launcher/EM_Launcher.cpp: * DAnCE/Plan_Launcher/NM_Launcher.h: * DAnCE/Plan_Launcher/NM_Launcher.cpp: * DAnCE/Plan_Launcher/Plan_Launcher.cpp: * DAnCE/Plan_Launcher/Plan_Launcher.mpc: * DAnCE/Plan_Launcher/Plan_Launcher_Base.h: * DAnCE/Plan_Launcher/Plan_Launcher_Base_Impl.h: * DAnCE/Plan_Launcher/Plan_Launcher_Base_Impl.cpp: Plan launcher re-factoring. Improves ability to handle CDR encoded deployment plans, adds ability to perform direct-to-NodeManager deployments, some command line options cleaned up. Main user visible change in behavior is the change of the teardown option from -q to -s.
-rw-r--r--CIAO/ChangeLog23
-rw-r--r--CIAO/DAnCE/Plan_Launcher/Deployment_Failure.h25
-rw-r--r--CIAO/DAnCE/Plan_Launcher/EM_Launcher.cpp67
-rw-r--r--CIAO/DAnCE/Plan_Launcher/EM_Launcher.h44
-rw-r--r--CIAO/DAnCE/Plan_Launcher/NM_Launcher.cpp19
-rw-r--r--CIAO/DAnCE/Plan_Launcher/NM_Launcher.h40
-rw-r--r--CIAO/DAnCE/Plan_Launcher/Plan_Launcher.cpp586
-rw-r--r--CIAO/DAnCE/Plan_Launcher/Plan_Launcher.mpc17
-rw-r--r--CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Base.h48
-rw-r--r--CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Base_Impl.cpp1187
-rw-r--r--CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Base_Impl.h164
-rw-r--r--CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.cpp114
-rw-r--r--CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.h35
13 files changed, 1399 insertions, 970 deletions
diff --git a/CIAO/ChangeLog b/CIAO/ChangeLog
index 01dcd325838..71bd6ada717 100644
--- a/CIAO/ChangeLog
+++ b/CIAO/ChangeLog
@@ -1,3 +1,22 @@
+Thu Mar 4 13:04:14 UTC 2010 William R. Otte <wotte@dre.vanderbilt.edu>
+
+ * DAnCE/Plan_Launcher/Deployment_Failure.h:
+ * DAnCE/Plan_Launcher/EM_Launcher.h:
+ * DAnCE/Plan_Launcher/EM_Launcher.cpp:
+ * DAnCE/Plan_Launcher/NM_Launcher.h:
+ * DAnCE/Plan_Launcher/NM_Launcher.cpp:
+ * DAnCE/Plan_Launcher/Plan_Launcher.cpp:
+ * DAnCE/Plan_Launcher/Plan_Launcher.mpc:
+ * DAnCE/Plan_Launcher/Plan_Launcher_Base.h:
+ * DAnCE/Plan_Launcher/Plan_Launcher_Base_Impl.h:
+ * DAnCE/Plan_Launcher/Plan_Launcher_Base_Impl.cpp:
+
+ Plan launcher re-factoring. Improves ability to handle CDR
+ encoded deployment plans, adds ability to perform
+ direct-to-NodeManager deployments, some command line options
+ cleaned up. Main user visible change in behavior is the change
+ of the teardown option from -q to -s.
+
Thu Mar 4 13:02:04 UTC 2010 William R. Otte <wotte@dre.vanderbilt.edu>
* DAnCE/tests/CIAO/Components/SimpleConsumer_exec.h:
@@ -6,8 +25,8 @@ Thu Mar 4 13:02:04 UTC 2010 William R. Otte <wotte@dre.vanderbilt.edu>
* DAnCE/tests/CIAO/Components/SimpleProvider_exec.cpp:
* DAnCE/tests/CIAO/Components/SimplePublisher_exec.cpp:
- Improved reporting of error conditions.
-
+ Improved reporting of error conditions.
+
Thu Mar 4 12:57:52 UTC 2010 William R. Otte <wotte@dre.vanderbilt.edu>
* DAnCE/tools/Convert_Plan/Convert_Plan.cpp:
diff --git a/CIAO/DAnCE/Plan_Launcher/Deployment_Failure.h b/CIAO/DAnCE/Plan_Launcher/Deployment_Failure.h
new file mode 100644
index 00000000000..bc073921794
--- /dev/null
+++ b/CIAO/DAnCE/Plan_Launcher/Deployment_Failure.h
@@ -0,0 +1,25 @@
+/**
+ * @file Deployment_Failure.h
+ * @author William R. Otte <wotte@dre.vanderbilt.edu>
+ *
+ * $Id$
+ *
+ * Defines exceptions used internally to the Plan Launcher
+ */
+
+#ifndef DANCE_DEPLOYMENT_FAILURE
+#define DANCE_DEPLOYMENT_FAILURE
+
+#include "ace/SString.h"
+
+namespace DAnCE
+{
+ struct Deployment_Failure
+ {
+ Deployment_Failure (const ACE_CString &ex) : ex_ (ex) {}
+
+ ACE_CString ex_;
+ };
+}
+
+#endif
diff --git a/CIAO/DAnCE/Plan_Launcher/EM_Launcher.cpp b/CIAO/DAnCE/Plan_Launcher/EM_Launcher.cpp
new file mode 100644
index 00000000000..3d683f42c2d
--- /dev/null
+++ b/CIAO/DAnCE/Plan_Launcher/EM_Launcher.cpp
@@ -0,0 +1,67 @@
+// $Id$
+
+#include "EM_Launcher.h"
+
+namespace DAnCE
+{
+ EM_Launcher::EM_Launcher (CORBA::ORB_ptr orb,
+ __Base::Manager_ptr manager)
+ : __Base (orb, manager)
+ {
+ }
+
+
+
+ EM_Launcher::~EM_Launcher (void)
+ {
+
+ }
+
+ bool
+ EM_Launcher::lookup_by_uuid (const char *uuid,
+ CORBA::Object_out am,
+ CORBA::Object_out app)
+ {
+ DANCE_TRACE ("EM_Launcher::lookup_by_uuid");
+
+ try
+ {
+ ::Deployment::DomainApplicationManagers_var managers = this->manager_->getManagers ();
+
+ for (CORBA::ULong i = 0; i < managers->length (); ++i)
+ {
+ ::Deployment::DeploymentPlan_var plan (managers[i]->getPlan ());
+ ACE_CString plan_uuid (plan->UUID.in ());
+ if (plan_uuid == uuid)
+ {
+ am = CORBA::Object::_duplicate (managers[i]);
+
+ ::Deployment::Applications_var apps = managers[i]->getApplications ();
+
+ if (apps->length () != 0)
+ {
+ app = CORBA::Object::_duplicate (apps[0]);
+ return true;
+ }
+ else return false;
+ }
+ }
+ }
+ catch (const CORBA::Exception &ex)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("EM_Launcher::lookup_by_uuid - ")
+ ACE_TEXT ("Caught CORBA Exception: %C\n"),
+ ex._info ().c_str ()));
+ throw Deployment_Failure (ex._info ());
+ }
+ catch (...)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("EM_Launcher::lookup_by_uuid - ")
+ ACE_TEXT ("Unknown C++ exception\n")));
+ throw Deployment_Failure ("Unknown C++ exception in lookup_by_uuid\n");
+ }
+
+ return false;
+ }
+
+}
diff --git a/CIAO/DAnCE/Plan_Launcher/EM_Launcher.h b/CIAO/DAnCE/Plan_Launcher/EM_Launcher.h
new file mode 100644
index 00000000000..0b052f7e5fd
--- /dev/null
+++ b/CIAO/DAnCE/Plan_Launcher/EM_Launcher.h
@@ -0,0 +1,44 @@
+/**
+ * @file Plan_Launcher_EM.h
+ * @author William R. Otte <wotte@dre.vanderbilt.edu>
+ *
+ * $Id$
+ *
+ * Plan Launcher bridge for the Execution Manager.
+ */
+
+#ifndef DANCE_PLAN_LAUNCHER_EM
+#define DANCE_PLAN_LAUNCHER_EM
+
+#include "Plan_Launcher_Base_Impl.h"
+
+#include "DAnCE/Deployment/Deployment_DomainApplicationC.h"
+#include "DAnCE/Deployment/Deployment_DomainApplicationManagerC.h"
+#include "DAnCE/Deployment/Deployment_ExecutionManagerC.h"
+
+namespace DAnCE
+{
+ class EM_Launcher :
+ public virtual Plan_Launcher_Base_Impl< ::Deployment::ExecutionManager,
+ ::Deployment::DomainApplicationManager,
+ ::Deployment::DomainApplication >
+ {
+ typedef Plan_Launcher_Base_Impl< ::Deployment::ExecutionManager,
+ ::Deployment::DomainApplicationManager,
+ ::Deployment::DomainApplication > __Base;
+
+ public:
+ EM_Launcher (CORBA::ORB_ptr orb,
+ __Base::Manager_ptr managerw);
+
+ ~EM_Launcher (void);
+
+
+ bool lookup_by_uuid (const char *uuid,
+ CORBA::Object_out am,
+ CORBA::Object_out app);
+
+ };
+}
+
+#endif
diff --git a/CIAO/DAnCE/Plan_Launcher/NM_Launcher.cpp b/CIAO/DAnCE/Plan_Launcher/NM_Launcher.cpp
new file mode 100644
index 00000000000..d95477b7c9f
--- /dev/null
+++ b/CIAO/DAnCE/Plan_Launcher/NM_Launcher.cpp
@@ -0,0 +1,19 @@
+// $Id$
+
+#include "NM_Launcher.h"
+
+namespace DAnCE
+{
+ NM_Launcher::NM_Launcher (CORBA::ORB_ptr orb,
+ __Base::Manager_ptr manager)
+ : __Base (orb, manager)
+ {
+ }
+
+
+
+ NM_Launcher::~NM_Launcher (void)
+ {
+
+ }
+}
diff --git a/CIAO/DAnCE/Plan_Launcher/NM_Launcher.h b/CIAO/DAnCE/Plan_Launcher/NM_Launcher.h
new file mode 100644
index 00000000000..60fdb77d1c0
--- /dev/null
+++ b/CIAO/DAnCE/Plan_Launcher/NM_Launcher.h
@@ -0,0 +1,40 @@
+/**
+ * @file NM_Launcher.h
+ * @author William R. Otte <wotte@dre.vanderbilt.edu>
+ *
+ * $Id$
+ *
+ * Plan Launcher bridge for the Node Manager.
+ */
+
+#ifndef DANCE_PLAN_LAUNCHER_NM
+#define DANCE_PLAN_LAUNCHER_NM
+
+#include "Plan_Launcher_Base_Impl.h"
+
+#include "DAnCE/Deployment/Deployment_NodeApplicationC.h"
+#include "DAnCE/Deployment/Deployment_NodeApplicationManagerC.h"
+#include "DAnCE/Deployment/Deployment_NodeManagerC.h"
+
+namespace DAnCE
+{
+ class NM_Launcher :
+ public virtual Plan_Launcher_Base_Impl< ::Deployment::NodeManager,
+ ::Deployment::NodeApplicationManager,
+ ::Deployment::NodeApplication >
+ {
+ typedef Plan_Launcher_Base_Impl< ::Deployment::NodeManager,
+ ::Deployment::NodeApplicationManager,
+ ::Deployment::NodeApplication > __Base;
+
+ public:
+ NM_Launcher (CORBA::ORB_ptr orb,
+ __Base::Manager_ptr managerw);
+
+ ~NM_Launcher (void);
+
+
+ };
+}
+
+#endif
diff --git a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.cpp b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.cpp
index d784f689507..a94b57f9c5a 100644
--- a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.cpp
+++ b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.cpp
@@ -1,11 +1,484 @@
// $Id$
#include "ace/Dynamic_Service.h"
+#include "ace/Env_Value_T.h"
+#include "ace/Get_Opt.h"
#include "tao/ORB.h"
#include "tao/Object.h"
#include "DAnCE/Logger/Log_Macros.h"
#include "DAnCE/Logger/Logger_Service.h"
-#include "Plan_Launcher_Impl.h"
+#include "DAnCE/tools/Convert_Plan/Convert_Plan_Impl.h"
+
+#include "EM_Launcher.h"
+#include "NM_Launcher.h"
+
+//#include "Plan_Launcher_Impl.h"
+
+ACE_CString
+expand_env_vars (const ACE_TCHAR * s)
+{
+ ACE_TString src(s);
+ ACE_TString res;
+ size_t pos_done = 0;
+ while (pos_done < (size_t) src.length())
+ {
+ size_t pos_start = src.find ('$', pos_done);
+ if (ACE_TString::npos == pos_start)
+ {
+ res += src.substring (pos_done);
+ pos_done = src.length();
+ }
+ else // take the substring before '$' and append value
+ {
+ if (pos_start > pos_done)
+ {
+ res += src.substring (pos_done, pos_start - pos_done);
+ pos_done = pos_start;
+ }
+
+ size_t pos_end = src.length();
+
+ size_t p;
+
+ p = src.find (ACE_TEXT(' '), pos_start + 1);
+ if (ACE_TString::npos != p && pos_end > p) pos_end = p;
+
+ p = src.find (ACE_TEXT('/'), pos_start + 1);
+ if (ACE_TString::npos != p && pos_end > p) pos_end = p;
+
+ p = src.find (ACE_TEXT('\\'), pos_start + 1);
+ if (ACE_TString::npos != p && pos_end > p) pos_end = p;
+
+ p = src.find (ACE_TEXT('$'), pos_start + 1);
+ if (ACE_TString::npos != p && pos_end > p) pos_end = p;
+
+ if (pos_end - pos_start > 1)
+ {
+ ACE_Env_Value<const ACE_TCHAR*> val (src.substring (pos_start + 1, pos_end - pos_start - 1).c_str(), 0);
+ res += val;
+ pos_done = pos_end;
+ }
+ else
+ {
+ DANCE_DEBUG (6, (LM_WARNING, DLINFO
+ ACE_TEXT("Plan_Launcher::expand_env_vars - ")
+ ACE_TEXT("Envvar can not be parsed out at %i in \"<%s>\""),
+ pos_start,
+ src.c_str()));
+ }
+ }
+ }
+ return res;
+}
+
+namespace
+{
+ struct Options
+ {
+ enum MODE
+ {
+ LAUNCH,
+ STARTLAUNCH,
+ FINISHLAUNCH,
+ START,
+ TEARDOWN,
+ INVALID
+ };
+
+ Options (void)
+ : em_ior_ (0),
+ nm_ior_ (0),
+ xml_plan_ (0),
+ cdr_plan_ (0),
+ uuid_ (0),
+ am_ior_ (0),
+ app_ior_ (0),
+ output_ (false),
+ output_prefix_ (0),
+ mode_ (LAUNCH)
+ {}
+
+ const ACE_TCHAR *em_ior_;
+ const ACE_TCHAR *nm_ior_;
+ const ACE_TCHAR *xml_plan_;
+ const ACE_TCHAR *cdr_plan_;
+ const ACE_TCHAR *uuid_;
+ const ACE_TCHAR *am_ior_;
+ const ACE_TCHAR *app_ior_;
+ bool output_;
+ const ACE_TCHAR *output_prefix_;
+ MODE mode_;
+ };
+}
+
+
+void
+usage(const ACE_TCHAR*)
+{
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Plan Launcher Options :\n")
+
+ ACE_TEXT ("\t-k|--em-ior <EM IOR>\t\t")
+ ACE_TEXT ("ExecutionManager IOR for EM based deployment.\n")
+ ACE_TEXT ("\t-n|--nm-ior <NodeManager IOR>\t")
+ ACE_TEXT ("NodeManager IOR for NM based deployment.\n")
+ /*
+ ACE_TEXT ("\nName Service Options\n")
+ ACE_TEXT ("\t--domain-nc [NC]\t\tDomain Naming Context (default will rir NameService)\n")
+ ACE_TEXT ("\t--instance-nc [NC]\t\tInstance Naming Context (default will rir NameService)\n")
+ */
+ ACE_TEXT ("\nPlan Identification Options:\n")
+ ACE_TEXT ("\t-c|--cdr-plan <CDR Deployment Plan>\n")
+ ACE_TEXT ("\t-x|--xml-plan <XML Deployment Plan>\n")
+ ACE_TEXT ("\t-u|--plan-uuid <PLAN UUID>\tOnly supported for EM-based deployments\n")
+ ACE_TEXT ("\t-a|--app-ior <APP IOR>\t\tIOR for ApplicationManager entity (Domain or Node)\n")
+ ACE_TEXT ("\t-m|--am-ior <AM IOR>\t\tIOR For Application entity (Domain or Node)\n")
+
+ ACE_TEXT ("\nPlan Control Options:\n")
+ ACE_TEXT ("The default action is to fully launch a plan. The following options may be used\n")
+ ACE_TEXT ("to arrive at a different state\n")
+ ACE_TEXT ("\t-l|--launch-plan\t\tLaunch the plan (Requires CDR/XML plan)\n")
+ ACE_TEXT ("\t-s|--stop-plan\t\t\tStop the plan\n (Requires Plan, UUID, or APP/AM references")
+
+ ACE_TEXT ("\nOther Options\n")
+ ACE_TEXT ("\t-o|--output[prefix]\t\tOutput IOR files that result from plan control action,")
+ ACE_TEXT ("if any. Optional prefix to filename defaults to plan UUID if plan is provided."
+ "Default is on for NM-based deployments.\n")
+
+ ACE_TEXT ("\t-h|--help\t\t\tShow this usage information\n")
+ ));
+}
+
+bool
+parse_args(int argc, ACE_TCHAR *argv[], Options &options)
+{
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("PL options : \"")));
+
+ for (int i = 0; i < argc; ++i)
+ {
+ DANCE_DEBUG (9, (LM_TRACE, "\t%s\n", argv[i]));
+ }
+
+ ACE_Get_Opt get_opt(argc, argv,
+ ACE_TEXT ("k:n:c:x:u:m:a:lso::h"));
+ get_opt.long_option(ACE_TEXT("em-ior"), 'k', ACE_Get_Opt::ARG_REQUIRED);
+ get_opt.long_option(ACE_TEXT("nm-ior"), 'n', ACE_Get_Opt::ARG_REQUIRED);
+ get_opt.long_option(ACE_TEXT("xml-plan"), 'x', ACE_Get_Opt::ARG_REQUIRED);
+ get_opt.long_option(ACE_TEXT("cdr-plan"), 'c', ACE_Get_Opt::ARG_REQUIRED);
+ get_opt.long_option(ACE_TEXT("plan-uuid"), 'u', ACE_Get_Opt::ARG_REQUIRED);
+ get_opt.long_option(ACE_TEXT("am-ior"), 'm', ACE_Get_Opt::ARG_REQUIRED);
+ get_opt.long_option(ACE_TEXT("app-ior"), 'a', ACE_Get_Opt::ARG_REQUIRED);
+ get_opt.long_option(ACE_TEXT("launch-plan"), 'l', ACE_Get_Opt::NO_ARG);
+ get_opt.long_option(ACE_TEXT("stop-plan"), 's', ACE_Get_Opt::NO_ARG);
+ get_opt.long_option(ACE_TEXT("output"), 'o', ACE_Get_Opt::ARG_OPTIONAL);
+ get_opt.long_option(ACE_TEXT("help"), 'h', ACE_Get_Opt::NO_ARG);
+
+ int c;
+ ACE_CString s;
+ while ( (c = get_opt ()) != EOF)
+ {
+ switch (c)
+ {
+ case 'k':
+ if (get_opt.opt_arg () == 0)
+ {
+ options.em_ior_ = "corbaname:rir:/NameService#ExecutionManager";
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT ("Plan_Launcher::parse_args - Defaulting to ")
+ ACE_TEXT ("NameService lookup of ExecutionManager\n")));
+ }
+ else
+ {
+ options.em_ior_ = get_opt.opt_arg ();
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT ("Plan_Launcher::parse_args -")
+ ACE_TEXT ("Using ExecutionManager IOR: %s\n"),
+ options.em_ior_));
+ }
+ break;
+
+ case 'n':
+ options.nm_ior_ = get_opt.opt_arg ();
+ options.output_ = true;
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT ("Plan_Launcher::parse_args -")
+ ACE_TEXT ("Using NodeManager IOR: %s\n"),
+ options.nm_ior_));
+ break;
+
+ case 'x':
+ options.xml_plan_ = get_opt.opt_arg ();
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT ("Plan_Launcher::parse_args -")
+ ACE_TEXT ("Using XML plan: %s\n"),
+ options.xml_plan_));
+ break;
+
+ case 'c':
+ options.cdr_plan_ = get_opt.opt_arg ();
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT ("Plan_Launcher::parse_args -")
+ ACE_TEXT ("Using CDR plan: %s\n"),
+ options.cdr_plan_));
+ break;
+
+ case 'u':
+ options.uuid_ = get_opt.opt_arg ();
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT ("Plan_Launcher::parse_args -")
+ ACE_TEXT ("Using UUID: %s\n"),
+ options.uuid_));
+ break;
+
+ case 'm':
+ options.am_ior_ = get_opt.opt_arg ();
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT ("Plan_Launcher::parse_args -")
+ ACE_TEXT ("Using ApplicationManager IOR %s\n"),
+ options.am_ior_));
+ break;
+
+ case 'a':
+ options.app_ior_ = get_opt.opt_arg ();
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT ("Plan_Launcher::parse_args -")
+ ACE_TEXT ("Application IOR: %s\n"),
+ options.app_ior_));
+ break;
+
+ case 'l':
+ options.mode_ = Options::LAUNCH;
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT ("Plan_Launcher::parse_args -")
+ ACE_TEXT ("Launching nominated plan\n")));
+ break;
+
+ case 's':
+ options.mode_ = Options::TEARDOWN;
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT ("Plan_Launcher::parse_args -")
+ ACE_TEXT ("Tearing down nominated plan\n")));
+ break;
+
+ case 'o':
+ options.output_ = true;
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT ("Plan_Launcher::parse_args - ")
+ ACE_TEXT ("IOR files will be output to the current working directory\n")));
+
+ if (get_opt.opt_arg () != 0)
+ {
+ options.output_prefix_ = get_opt.opt_arg ();
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT ("Plan_Launcher::parse_args - ")
+ ACE_TEXT ("Storing user-provided output postfix <%s>\n"),
+ options.output_prefix_));
+ }
+
+ break;
+
+ case 'h':
+ usage (argv[0]);
+ return false;
+ default:
+ usage (argv[0]);
+ return false;
+ }
+ }
+
+ /// Sanity checking on the options.
+
+ // In all cases, we need to have a EM/NM IOR specified, but only one.
+ if ((!options.em_ior_ && !options.nm_ior_) ||
+ (options.em_ior_ && options.nm_ior_))
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("Plan_launcher::parse_args - ")
+ ACE_TEXT ("Error: Must specify either EM IOR or NM IOR\n")));
+ return false;
+ }
+
+ // Launching plans requires a plan (duh), and only one plan
+ if ((options.mode_ == Options::LAUNCH) &&
+ ((!options.xml_plan_ && !options.cdr_plan_) ||
+ (options.xml_plan_ && options.cdr_plan_)))
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher::parse_args - ")
+ ACE_TEXT ("Error: Launching plans requires exactly one type of plan (CDR/XML) be ")
+ ACE_TEXT ("specified.\n")));
+ return false;
+ }
+
+ // tearing down plans requires a bit more complex set of options:
+ if ((options.mode_ == Options::TEARDOWN)
+ // Either way (EM/NM), we ca use a combination of a AM and a APP.
+ && !(
+ (options.am_ior_ && options.app_ior_) ||
+ // If we are tearing down from EM, we have more options, namely:
+ // A plan of some kind
+ (options.em_ior_ &&
+ (
+ ((!options.xml_plan_ && !options.cdr_plan_) ||
+ (options.xml_plan_ && options.cdr_plan_)) ||
+ // A UUID
+ (!options.uuid_)
+ )
+ )
+ )
+ )
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher::parse_args - ")
+ ACE_TEXT ("Invalid set of plan identification as required for teardown\n")));
+ return false;
+ }
+
+
+ return true;
+}
+
+bool
+write_IOR (const ACE_TCHAR * ior_file_name, const char* ior)
+{
+ FILE* ior_output_file_ = ACE_OS::fopen (ior_file_name, ACE_TEXT("w"));
+
+ if (ior_output_file_)
+ {
+ ACE_OS::fprintf (ior_output_file_, "%s", ior);
+ ACE_OS::fclose (ior_output_file_);
+ return true;
+ }
+ return false;
+}
+
+int launch_plan (const Options &opts,
+ DAnCE::Plan_Launcher_Base *pl_base,
+ const ::Deployment::DeploymentPlan *plan,
+ CORBA::ORB_ptr orb)
+{
+ DANCE_TRACE ("Plan_Launcher::launch_plan");
+
+ try
+ {
+ CORBA::Object_var app_mgr, app;
+
+ ACE_CString uuid (pl_base->launch_plan (*plan, app_mgr.out () , app.out ()));
+
+ DANCE_DEBUG (2, (LM_NOTICE, DLINFO ACE_TEXT ("Plan_Launcher::launch_plan - ")
+ ACE_TEXT ("Successfully deployed plan with UUID: <%C>\n"),
+ uuid.c_str ()));
+
+ if (!opts.output_)
+ return 0;
+
+ ACE_TString am_output, app_output;
+
+ if (opts.output_prefix_)
+ am_output = app_output = opts.output_prefix_;
+ else
+ am_output = app_output = ACE_TEXT_CHAR_TO_TCHAR (uuid.c_str ());
+
+ am_output += ACE_TEXT ("_AM.ior");
+ app_output += ACE_TEXT ("_APP.ior");
+
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT ("Plan_Launcher::launch_plan - ")
+ ACE_TEXT ("Writing Application Manager IOR to <%s>\n"),
+ am_output.c_str ()));
+ write_IOR (am_output.c_str (),
+ orb->object_to_string (app_mgr.in ()));
+
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT ("Plan_Launcher::launch_plan - ")
+ ACE_TEXT ("Writing Application IOR to <%s>\n"),
+ am_output.c_str ()));
+ write_IOR (app_output.c_str (),
+ orb->object_to_string (app.in ()));
+
+ }
+ catch (const DAnCE::Deployment_Failure &ex)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher::launch_plan - ")
+ ACE_TEXT ("Deployment failed, exception: %C\n"),
+ ex.ex_.c_str ()));
+ return -1;
+ }
+ catch (const CORBA::Exception &ex)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher::launch_plan - ")
+ ACE_TEXT ("Deployment failed, caught CORBA exception %C\n"),
+ ex._info ().c_str ()));
+ return -1;
+ }
+ catch (...)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher::launch_plan - ")
+ ACE_TEXT ("Deployment failed, caught unknown C++ exception\n")));
+ return -1;
+ }
+
+ return 0;
+}
+
+int teardown_plan (const Options &opts,
+ DAnCE::Plan_Launcher_Base *pl_base,
+ const ::Deployment::DeploymentPlan *plan,
+ CORBA::ORB_ptr orb)
+{
+ DANCE_TRACE ("Plan_Launcher::teardown_plan");
+
+ try
+ {
+ if (opts.am_ior_ && opts.app_ior_)
+ {
+ DANCE_DEBUG (3, (LM_DEBUG, DLINFO ACE_TEXT ("Plan_Launcher::teardown_plan - ")
+ ACE_TEXT ("Tearing down plan with explicitly nominated App and AM IORs.\n")));
+ CORBA::Object_var am (orb->string_to_object (opts.am_ior_));
+ CORBA::Object_var app (orb->string_to_object (opts.app_ior_));
+
+ pl_base->teardown_application (am, app);
+ }
+ else
+ {
+ ACE_CString uuid;
+ if (plan)
+ uuid = plan->UUID.in ();
+ else
+ uuid = opts.uuid_;
+
+ DAnCE::EM_Launcher *em_launcher = dynamic_cast <DAnCE::EM_Launcher *> (pl_base);
+
+ if (!pl_base)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher::teardown_plan - ")
+ ACE_TEXT ("Error: Attempting UUID lookup on non-EM managed plan not supported\n")));
+ return -1;
+ }
+
+ CORBA::Object_var am, app;
+ if (em_launcher->lookup_by_uuid (uuid.c_str (),
+ am.out (),
+ app.out ()))
+ {
+ DANCE_DEBUG (3, (LM_DEBUG, DLINFO ACE_TEXT ("Plan_Launcher::teardown_plan - ")
+ ACE_TEXT ("Tearing down plan with UUID %C\n"),
+ uuid.c_str ()));
+ pl_base->teardown_application (am, app);
+ }
+ else
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher::teardown_plan - ")
+ ACE_TEXT ("Error: Lookup by UUID failed\n")));
+ return -1;
+ }
+ }
+ }
+ catch (const DAnCE::Deployment_Failure &ex)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher::teardown_plan - ")
+ ACE_TEXT ("Teardown failed, exception: %C\n"),
+ ex.ex_.c_str ()));
+ return -1;
+ }
+ catch (const CORBA::Exception &ex)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher::teardown_plan - ")
+ ACE_TEXT ("Teardown failed, caught CORBA exception %C\n"),
+ ex._info ().c_str ()));
+ return -1;
+ }
+ catch (...)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher::teardown_plan - ")
+ ACE_TEXT ("Teardown failed, caught unknown C++ exception\n")));
+ return -1;
+ }
+
+ return 0;
+}
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
@@ -25,29 +498,120 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
}
DANCE_DEBUG (6, (LM_TRACE, DLINFO
- ACE_TEXT("PlanLauncher - initializing ORB\n")));
+ ACE_TEXT("PlanLauncher - initializing ORB\n")));
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
+
+ Options options;
+ if (!parse_args (argc, argv, options))
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher - ")
+ ACE_TEXT ("Failed to parse command line arguments, exiting.\n")));
+ return -1;
+ }
+
+
+ auto_ptr<DAnCE::Plan_Launcher_Base> pl_base (0);
+
+ if (options.em_ior_)
+ {
+ DAnCE::EM_Launcher *em_pl (0);
+
+ CORBA::Object_var obj = orb->string_to_object (options.em_ior_);
+ Deployment::ExecutionManager_var tmp_em = Deployment::ExecutionManager::_narrow (obj);
+
+ if (CORBA::is_nil (tmp_em))
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher - ")
+ ACE_TEXT ("Unable to resolve ExecutionManager reference <%s>\n"),
+ options.em_ior_));
+ return -1;
+ }
+
+ ACE_NEW_THROW_EX (em_pl,
+ DAnCE::EM_Launcher (orb.in (),
+ tmp_em.in ()),
+ CORBA::NO_MEMORY ());
+
+ pl_base.reset (em_pl);
+
+ }
+ else
+ {
+ DAnCE::NM_Launcher *nm_pl (0);
- DANCE_DEBUG (6, (LM_TRACE, DLINFO
- ACE_TEXT("PlanLauncher - initializing module instance\n")));
+ CORBA::Object_var obj = orb->string_to_object (options.nm_ior_);
+ Deployment::NodeManager_var tmp_em = Deployment::NodeManager::_narrow (obj);
+
+ if (CORBA::is_nil (tmp_em))
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher - ")
+ ACE_TEXT ("Unable to resolve NodeManager reference <%s>\n"),
+ options.em_ior_));
+ return -1;
+ }
+
+ ACE_NEW_THROW_EX (nm_pl,
+ DAnCE::NM_Launcher (orb.in (),
+ tmp_em.in ()),
+ CORBA::NO_MEMORY ());
+
+ pl_base.reset (nm_pl);
+ }
- Plan_Launcher_Impl pl (orb.in (), argc, argv);
- pl.execute();
+
+ Deployment::DeploymentPlan_var dp;
+
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT ("Plan_Launcher - ")
+ ACE_TEXT ("Parsing deployment plan\n")));
+ if (options.cdr_plan_)
+ {
+ dp = DAnCE::Convert_Plan::read_cdr_plan (options.cdr_plan_);
+ if (!dp.ptr ())
+ {
+ ACE_ERROR ((LM_ERROR, DLINFO ACE_TEXT ("PlanLauncher - Error: Unable to read in XML plan\n")));
+ return -1;
+ }
+ }
+ else if (options.xml_plan_)
+ {
+ dp = DAnCE::Convert_Plan::read_xml_plan (options.xml_plan_);
+
+ if (!dp.ptr ())
+ {
+ ACE_ERROR ((LM_ERROR, DLINFO ACE_TEXT ("PlanLauncher - Error: Unable to read in XML plan\n")));
+ return -1;
+ }
+ }
+
+ switch (options.mode_)
+ {
+ case Options::LAUNCH:
+ launch_plan (options, pl_base.get (), dp, orb.in ());
+
+ break;
+
+ case Options::TEARDOWN:
+ teardown_plan (options, pl_base.get (), dp, orb.in ());
+ break;
- DANCE_DEBUG (6, (LM_TRACE, DLINFO
- ACE_TEXT("PlanLauncher - destroying ORB\n")));
+ default:
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher -")
+ ACE_TEXT ("Mode not yet supported\n")));
+ break;
+
+ };
orb->destroy ();
}
- catch (const Plan_Launcher_Impl::Deployment_Failure& e)
+ catch (const DAnCE::Deployment_Failure& e)
{
- DANCE_ERROR (1, (LM_ERROR, DLINFO "PlanLauncher - Error: %C.\n", e.error_.c_str()));
+ ACE_ERROR ((LM_ERROR, DLINFO "PlanLauncher - Error: %C.\n", e.ex_.c_str()));
retval = -1;
}
catch (const CORBA::Exception& ex)
{
- ex._tao_print_exception ("PlanLauncher");
+ ACE_ERROR ((LM_ERROR, DLINFO "PlanLauncher - Error: %C\n", ex._info ().c_str ()));
retval = -1;
}
catch (...)
diff --git a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.mpc b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.mpc
index a838f6e2d68..800a6b3b219 100644
--- a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.mpc
+++ b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.mpc
@@ -1,11 +1,22 @@
// -*- MPC -*-
// $Id$
-project(Plan_Launcher_Exec) : dance_exe, dance_logger, xerces, dance_executionmanager_stub, dance_config_handlers {
+project(DAnCE_Plan_Launcher_Impl) : dance_lib, dance_logger, dance_convert_plan, \
+ dance_executionmanager_stub, \
+ dance_nodemanager_stub {
+ Source_Files {
+ EM_Launcher.cpp
+ NM_Launcher.cpp
+ }
+
+ Template_Files {
+ Plan_Launcher_Base_Impl.cpp
+ }
+}
+
+project(Plan_Launcher_Exec) : dance_exe, dance_plan_launcher {
exename = dance_plan_launcher
Source_Files {
Plan_Launcher.cpp
- Plan_Launcher_Base_Impl.cpp
- Plan_Launcher_Impl.cpp
}
}
diff --git a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Base.h b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Base.h
new file mode 100644
index 00000000000..3afb773e928
--- /dev/null
+++ b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Base.h
@@ -0,0 +1,48 @@
+/**
+ * @file Plan_Launcher_Base.h
+ * @author William R. Otte <wotte@dre.vanderbilt.edu>
+ *
+ * $Id$
+ *
+ * ABC for the EM/NM bridges.
+ */
+
+#ifndef DANCE_PLAN_LAUNCHER_BASE
+#define DANCE_PLAN_LAUNCHER_BASE
+
+#include "Deployment/Deployment_DeploymentPlanC.h"
+#include "Deployment/Deployment_ConnectionC.h"
+
+namespace DAnCE
+{
+ class Plan_Launcher_Base
+ {
+ public:
+ virtual const char * launch_plan (const ::Deployment::DeploymentPlan &plan,
+ CORBA::Object_out am,
+ CORBA::Object_out app) = 0;
+
+ virtual CORBA::Object_ptr prepare_plan (const ::Deployment::DeploymentPlan &plan) = 0;
+
+ virtual CORBA::Object_ptr start_launch (CORBA::Object_ptr app_mgr,
+ const ::Deployment::Properties &properties,
+ ::Deployment::Connections_out connections) = 0;
+
+ virtual void finish_launch (CORBA::Object_ptr application,
+ const ::Deployment::Connections &provided_connections,
+ bool start) = 0;
+
+ virtual void start (CORBA::Object_ptr application) = 0;
+
+ /// Tears down a plan given the UUID
+ virtual void teardown_application (CORBA::Object_ptr app_mgr,
+ CORBA::Object_ptr app) = 0;
+
+ virtual void destroy_app_manager (CORBA::Object_ptr app_mgr) = 0;
+
+ virtual void create_external_connections(const ::Deployment::DeploymentPlan &plan,
+ Deployment::Connections &conn) = 0;
+ };
+}
+
+#endif
diff --git a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Base_Impl.cpp b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Base_Impl.cpp
index 10fcf4083b6..679fece53ac 100644
--- a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Base_Impl.cpp
+++ b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Base_Impl.cpp
@@ -1,774 +1,529 @@
// $Id$
+#ifndef PLAN_LAUNCHER_BASE_IMPL_CPP
+#define PLAN_LAUNCHER_BASE_IMPL_CPP
+
#include "Plan_Launcher_Base_Impl.h"
-#include "DAnCE/Logger/Log_Macros.h"
+
#include "ace/Env_Value_T.h"
#include "ace/OS_NS_stdio.h"
#include "ace/Get_Opt.h"
-Plan_Launcher_Base_Impl::Plan_Launcher_Base_Impl(CORBA::ORB_ptr orb, int argc,
- ACE_TCHAR *argv[]) :
- orb_(CORBA::ORB::_duplicate (orb)),
- em_(Deployment::ExecutionManager::_nil()), em_ior_("file://em.ior") //default
- , mode_(0x0)
+#include "Deployment/Deployment_ApplicationManagerC.h"
+#include "DAnCE/Logger/Log_Macros.h"
+
+#include "Deployment_Failure.h"
+
+#ifdef GEN_OSTREAM_OPS
+#include <iostream>
+#include <sstream>
+#endif /* GEN_OSTREAM_OPS */
+
+namespace DAnCE
{
- DANCE_TRACE ("Plan_Launcher_Base_Impl::Plan_Launcher_Base_Impl");
- if (CORBA::is_nil (this->orb_))
- {
- DANCE_DEBUG (8, (LM_INFO, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::Plan_Launcher_Base_Impl - ")
- ACE_TEXT("Creating internal ORB.\n")));
- this->orb_ = CORBA::ORB_init (argc, argv);
- }
+ template <typename Manager, typename AppManager, typename Application>
+ Plan_Launcher_Base_Impl <Manager, AppManager, Application> ::
+ Plan_Launcher_Base_Impl(CORBA::ORB_ptr orb,
+ Manager_ptr manager)
+ : orb_ (CORBA::ORB::_duplicate (orb)),
+ manager_ (Manager::_duplicate (manager))
+ {
+ DANCE_TRACE ("Plan_Launcher_Base_Impl::Plan_Launcher_Base_Impl");
+ if (CORBA::is_nil (this->orb_))
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO "Plan_Launcher_Base_Impl::Plan_Launcher_Base_Impl - "
+ "Plan Launcher requires a valid ORB\n"));
+ throw Deployment_Failure ("Plan launcher requires a valid ORB\n");
+ }
- this->parse_args(argc, argv);
+ if (CORBA::is_nil (this->manager_))
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO "Plan_Launcher_Base_Impl::Plan_Launcher_Base_Impl - "
+ "Plan Launcher requires a valid Manager reference.\n"));
+ throw Deployment_Failure ("Plan launcher requires a valid Manager reference\n");
+ }
+ }
- DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("Plan_Launcher_i::init - em_ior = \"%C\"\n")
- , this->em_ior_.c_str()));
+ template <typename Manager, typename AppManager, typename Application>
+ Plan_Launcher_Base_Impl < Manager, AppManager, Application> ::~Plan_Launcher_Base_Impl()
+ {
+ }
- if (this->mode_ & (MODE_START_PLAN | MODE_STOP_PLAN))
+ template <typename Manager, typename AppManager, typename Application>
+ CORBA::Object_ptr
+ Plan_Launcher_Base_Impl< Manager, AppManager, Application>
+ ::prepare_plan (const ::Deployment::DeploymentPlan &plan)
+ {
+ DANCE_TRACE ("Plan_Launcher_Base_Impl::prepare_plan");
+
+
+#ifdef GEN_OSTREAM_OPS
{
- CORBA::Object_var obj;
- if (this->em_ior_.length() > 0)
- {
- obj = this->orb_->string_to_object(this->em_ior_.c_str());
- if (CORBA::is_nil(obj))
- {
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::Plan_Launcher_Base_Impl - ")
- ACE_TEXT("Failed to retrieve EM object from \"%C\"\n"), this->em_ior_.c_str()));
- throw Deployment_Failure ("Plan_Launcher_Base_Impl::Plan_Launcher_Base_Impl - "
- "failed to retrieve EM object");
- }
- }
- try
- {
- this->em_ = ::Deployment::ExecutionManager::_narrow (obj.in());
- }
- catch(const CORBA::Exception&)
- {
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::Plan_Launcher_Base_Impl - ")
- ACE_TEXT("Failed to retrieve EM object from \"%C\"\n"), this->em_ior_.c_str()));
- throw Deployment_Failure ("Plan_Launcher_Base_Impl::Plan_Launcher_Base_Impl - "
- "failed to retrieve EM object");
- }
-
- if (CORBA::is_nil (this->em_.in()))
- {
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::Plan_Launcher_Base_Impl - ")
- ACE_TEXT("failed to get an execution manager.\n")));
- throw Deployment_Failure ("Plan_Launcher_Base_Impl::Plan_Launcher_Base_Impl - "
- "failed to get an execution manager");
- }
+ std::ostringstream plan_stream;
+ plan_stream << plan << std::endl;
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO "Convert_Plan - Input plan: %C\n",
+ plan_stream.str ().c_str ()));
}
- DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::Plan_Launcher_Base_Impl - ")
- ACE_TEXT("Obtained Execution Manager ref\n")));
-}
+#endif /* GEN_OSTREAM_OPS */
-Plan_Launcher_Base_Impl::~Plan_Launcher_Base_Impl()
-{
-}
+ AppManager_var app_manager;
+ try
+ {
+ app_manager = this->manager_->preparePlan (plan, 0);
+ }
+ catch(...)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
+ ACE_TEXT("An exception was thrown during EM->preparePlan.\n")));
+ throw;
+ }
+
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO
+ ACE_TEXT ("Plan_Launcher_Base_Impl::launch_plan - ")
+ ACE_TEXT ("after to call preparePlan\n")));
+
+ if (CORBA::is_nil (app_manager.in ()))
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
+ ACE_TEXT("preparePlan call failed: ")
+ ACE_TEXT("nil ApplicationManager reference\n")));
+ return 0;
+ }
+ else
+ {
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
+ ACE_TEXT("ApplicationMAnager was received from preparePlan.\n")));
+ }
+
+ return app_manager._retn ();
+ }
-void Plan_Launcher_Base_Impl::execute()
-{
- DANCE_TRACE ("Plan_Launcher_Base_Impl::execute - ");
+ template <typename Manager, typename AppManager, typename Application>
+ CORBA::Object_ptr
+ Plan_Launcher_Base_Impl< Manager, AppManager, Application>
+ ::start_launch (CORBA::Object_ptr app_mgr,
+ const ::Deployment::Properties &properties,
+ ::Deployment::Connections_out connections)
+ {
+ DANCE_TRACE ("Plan_Launcher_Base_Impl::start_launch");
+
+ AppManager_var app_manager (AppManager::_narrow (app_mgr));
- if (this->mode_ & MODE_START_PLAN)
- {
- size_t sz = this->cdr_plan_urls_.size();
- for (size_t i= 0; i < sz; ++i)
- {
- DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::execute - ")
- ACE_TEXT("launching plan \"<%s>\"...\n"), this->cdr_plan_urls_[i].c_str()));
- ::Deployment::DeploymentPlan_var plan = this->read_cdr_plan_file(this->cdr_plan_urls_[i].c_str());
- try
- {
- CORBA::String_var uuid = this->launch_plan (plan.in());
- if (0 == uuid.in ())
- {
- throw Deployment_Failure ("Plan_Launcher_Base_Impl::execute - "
- "Error launching plan\n");
- }
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::execute - ")
- ACE_TEXT("returned plan UUID is \"%C\"\n"), uuid.in ()));
- }
- catch (...)
- {
- this->teardown_plan (plan->UUID.in());
- throw;
- }
- }
- }
- else if (this->mode_ & MODE_STOP_PLAN)
- {
- this->stop_plan();
- }
-}
+ if (CORBA::is_nil (app_manager))
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher_Base_Impl::start_launch - ")
+ ACE_TEXT ("Nil ApplicationManager reference\n")));
+ return 0;
+ }
-const char *
-Plan_Launcher_Base_Impl::launch_plan (const ::Deployment::DeploymentPlan &plan)
-{
- DANCE_TRACE ("Plan_Launcher_Base_Impl::launch_plan");
+ Deployment::Application_var da;
+ try
+ {
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::start_launch - ")
+ ACE_TEXT("before startLaunch...\n")));
+ da = app_manager->startLaunch (properties, connections);
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::start_launch - ")
+ ACE_TEXT("startLaunch completed...\n")));
+ }
+ catch(...)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
+ ACE_TEXT("An exception was thrown during DAM->startLaunch.\n")));
+ throw;
+ }
+
+ if (CORBA::is_nil (da.in()))
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
+ ACE_TEXT("CIAO_PlanLauncher:startLaunch call failed: ")
+ ACE_TEXT("nil DomainApplication reference\n")));
+ return 0;
+ }
+ else
+ {
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
+ ACE_TEXT("DomainApplication was received from startLaunch\n")));
+ }
+
+ return da._retn ();
+ }
- try
- {
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO
- ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - Starting...\n")));
- if (CORBA::is_nil (this->em_.in ()))
- {
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher_Base_Impl::launch_plan - ")
- ACE_TEXT ("launch_plan called witn an uninitialized EM.\n")));
- return 0;
- }
-
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO
- ACE_TEXT ("Plan_Launcher_Base_Impl::launch_plan - ")
- ACE_TEXT ("about to call this->em_->preparePlan\n")));
-
- ::Deployment::DomainApplicationManager_var dam;
- try
- {
- dam = this->em_->preparePlan (plan, 0);
- }
- catch(...)
- {
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
- ACE_TEXT("An exception was thrown during EM->preparePlan.\n")));
- throw;
- }
-
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO
- ACE_TEXT ("Plan_Launcher_Base_Impl::launch_plan - ")
- ACE_TEXT ("after to call this->em_->preparePlan\n")));
-
- if (CORBA::is_nil (dam.in ()))
- {
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
- ACE_TEXT("CIAO_PlanLauncher:preparePlan call failed: ")
- ACE_TEXT("nil DomainApplicationManager reference\n")));
- return 0;
- }
- else
- {
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
- ACE_TEXT("DAM was received from preparePlan.\n")));
- }
-
- this->write_dam_ior (dam.in());
-
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
- ACE_TEXT("Obtained DAM ref\n")));
-
- ::Deployment::Properties_var properties;
- ACE_NEW_RETURN (properties,
- Deployment::Properties,
- 0);
-
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
- ACE_TEXT("before startLaunch...\n")));
-
- ::Deployment::Connections_var conns;
- Deployment::Application_var da;
- try
- {
- da = dam->startLaunch (properties.in (), conns.out());
- }
- catch(...)
- {
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
- ACE_TEXT("An exception was thrown during DAM->startLaunch.\n")));
- throw;
- }
-
- if (CORBA::is_nil (da.in()))
- {
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
- ACE_TEXT("CIAO_PlanLauncher:startLaunch call failed: ")
- ACE_TEXT("nil DomainApplication reference\n")));
- return 0;
- }
- else
- {
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
- ACE_TEXT("DomainApplication was received from startLaunch\n")));
- }
-
- this->create_external_connections (plan, conns.inout());
-
- // Call finish Launch to complete the connections
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
- ACE_TEXT("before finishLaunch\n")));
- try
- {
- da->finishLaunch (conns.in(), false); // is_ReDAC by default is <false>
- }
- catch(...)
- {
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
- ACE_TEXT("An exception was thrown during DA->finishLaunch.\n")));
- throw;
- }
-
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
- ACE_TEXT("after finishLaunch\n")));
-
- // Call start to activate components
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
- ACE_TEXT("before start activating components...\n")));
-
- try
- {
- da->start ();
- }
- catch(...)
- {
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
- ACE_TEXT("An exception was thrown during DA->start.\n")));
- throw;
- }
-
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - [success]\n")));
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO
- ACE_TEXT ("Plan_Launcher_Base_Impl::launch_plan - ")
- ACE_TEXT ("Application Deployed successfully\n")));
+ template <typename Manager, typename AppManager, typename Application>
+ void
+ Plan_Launcher_Base_Impl< Manager, AppManager, Application>
+ ::finish_launch (CORBA::Object_ptr app,
+ const ::Deployment::Connections &provided_connections,
+ bool start)
+ {
+ DANCE_TRACE ("Plan_Launcher_Base_Impl::finish_launch");
+
+ Application_var application (Application::_narrow (app));
- }
- catch (const Deployment::ResourceNotAvailable& ex)
- {
- char buf[1024];
- ACE_OS::sprintf (buf, "Plan_Launcher_Base_Impl::launch_plan - EXCEPTION: ResourceNotAvaiable exception caught: <%s>,\n"
- "Type: <%s>\n"
- "Property: <%s>\n"
- "Element: <%s>\n"
- "Resource: <%s>\n",
- ex.name.in (),
- ex.resourceType.in (),
- ex.propertyName.in (),
- ex.elementName.in (),
- ex.resourceName.in ());
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("%C"), buf));
- throw Deployment_Failure (buf);
- }
- catch (const Deployment::StartError& ex)
- {
- char buf[1024];
- ACE_OS::sprintf (buf, "Plan_Launcher_Base_Impl::launch_plan - EXCEPTION: StartError exception caught: <%s>, <%s>\n",
- ex.name.in (),
- ex.reason.in ());
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("%C"), buf));
- throw Deployment_Failure (buf);
- }
- catch (const Deployment::InvalidProperty& ex)
- {
- char buf[1024];
- ACE_OS::sprintf (buf, "Plan_Launcher_Base_Impl::launch_plan - EXCEPTION: InvalidProperty exception caught: <%s>, <%s>\n",
- ex.name.in (),
- ex.reason.in ());
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("%C"), buf));
- throw Deployment_Failure (buf);
- }
- catch (const Deployment::InvalidConnection& ex)
- {
- char buf[1024];
- ACE_OS::sprintf (buf, "Plan_Launcher_Base_Impl::launch_plan - EXCEPTION: InvalidConnection exception caught: <%s>, <%s>\n",
- ex.name.in (),
- ex.reason.in ());
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("%C"), buf));
- throw Deployment_Failure (buf);
- }
- catch (const CORBA::Exception& ex)
- {
- char buf[1024];
- ACE_OS::sprintf (buf, "Plan_Launcher_Base_Impl::launch_plan - CORBA EXCEPTION: <%s>\n",
- ex._info().fast_rep());
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("%C"), buf));
- throw Deployment_Failure (buf);
- }
- catch (...)
- {
- char buf[1024];
- ACE_OS::sprintf (buf, "Plan_Launcher_Base_Impl::launch_plan - EXCEPTION: non-CORBA exception\n");
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("%C"), buf));
- throw Deployment_Failure (buf);
- }
+ if (CORBA::is_nil (application))
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
+ ACE_TEXT("Nil Application reference.\n")));
+ throw Deployment_Failure ("Nil Application reference");
+ }
- return CORBA::string_dup (plan.UUID.in());
-}
+ // Call finish Launch to complete the connections
+ try
+ {
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
+ ACE_TEXT("before finishLaunch\n")));
+ application->finishLaunch (provided_connections,
+ start);
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
+ ACE_TEXT("finishLaunch completed.\n")));
+ }
+ catch(...)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::launch_plan - ")
+ ACE_TEXT("An exception was thrown during DA->finishLaunch.\n")));
+ throw;
+ }
+ }
-bool Plan_Launcher_Base_Impl::teardown_plan(const char *uuid)
-{
- DANCE_TRACE ("Plan_Launcher_Base_Impl::teardown_plan");
+ template <typename Manager, typename AppManager, typename Application>
+ void
+ Plan_Launcher_Base_Impl< Manager, AppManager, Application>
+ ::start (CORBA::Object_ptr app)
+ {
+ DANCE_TRACE ("Plan_Launcher_Base_Impl::start");
+
+ Application_var application (Application::_narrow (app));
- try
- {
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::teardown_plan - looking for uuid=\"%C\"\n"), uuid));
- ::Deployment::DomainApplicationManagers_var mgrs = this->em_->getManagers();
- ::Deployment::DomainApplicationManager_var dapp_mgr;
- for (size_t i = 0; i < mgrs->length(); ++i)
- {
- ACE_CString s = (*mgrs) [i]->getPlan()->UUID.in();
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::teardown_plan - ")
- ACE_TEXT("comparing with existing uuid=\"%C\"\n"), s.c_str()));
- if (s == uuid)
- {
- dapp_mgr = ::Deployment::DomainApplicationManager::_duplicate ( (*mgrs) [i].in());
- break;
- }
- }
-
- if (!::CORBA::is_nil (dapp_mgr.in()))
- {
- this->teardown_plan (dapp_mgr.in());
- }
- else
- {
- throw Deployment_Failure ("Failed to find DAM by UUID");
- }
- }
- catch (const CORBA::Exception&)
- {
- // @todo the destroy_dam_by_plan could give a stoperror exception
- // we should handle
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::teardown_plan - ")
- ACE_TEXT("Unable to find DomainApplicationManager ")
- ACE_TEXT("for plan with uuid: %C\n"), uuid));
- throw;
- }
+ if (CORBA::is_nil (application))
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::start - ")
+ ACE_TEXT("Nil Application reference.\n")));
+ throw Deployment_Failure ("Nil Application reference");
+ }
- return true;
-}
+ try
+ {
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::start - ")
+ ACE_TEXT("before invoking start on application...\n")));
+ application->start ();
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::start - ")
+ ACE_TEXT("after invoking start on application...\n")));
+ }
+ catch(...)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::start - ")
+ ACE_TEXT("An exception was thrown during DA->start.\n")));
+ throw;
+ }
+ }
-void
-Plan_Launcher_Base_Impl::teardown_plan(::Deployment::DomainApplicationManager_ptr dam)
-{
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO
- ACE_TEXT("Plan_Launcher_Base_Impl::teardown_plan - destroy the application.....\n")));
- ::Deployment::Applications_var apps = dam->getApplications();
- if (0 == apps->length())
- {
- DANCE_DEBUG (6, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::teardown_plan - ")
- ACE_TEXT("DAM has no application.\n")));
- }
- for (CORBA::ULong i = 0; i < apps->length(); ++i)
- {
- dam->destroyApplication(apps[i]);
- }
- this->destroy_dam(dam);
+ template <typename Manager, typename AppManager, typename Application>
+ const char *
+ Plan_Launcher_Base_Impl< Manager, AppManager, Application>
+ ::launch_plan (const ::Deployment::DeploymentPlan &plan,
+ CORBA::Object_out am_out,
+ CORBA::Object_out app_out)
+ {
+ DANCE_TRACE ("Plan_Launcher_Base_Impl::launch_plan");
+
+ //this->create_external_connections (plan, conns.inout());
+
+ try
+ {
+ CORBA::Object_var app_mgr = this->prepare_plan (plan);
+
+ ::Deployment::Connections_var conns;
+
+ CORBA::Object_var app = this->start_launch (app_mgr.in (),
+ 0,
+ conns.out ());
+
+ this->create_external_connections (plan,
+ conns.inout ());
+
+ this->finish_launch (app.in (),
+ conns,
+ false);
+
+ this->start (app.in ());
+
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO
+ ACE_TEXT ("Plan_Launcher_Base_Impl::launch_plan - ")
+ ACE_TEXT ("Application Deployed successfully\n")));
+
+ am_out = app_mgr._retn ();
+ app_out = app._retn ();
+ }
+ catch (const Deployment::ResourceNotAvailable& ex)
+ {
+ char buf[1024];
+ ACE_OS::sprintf (buf, "Plan_Launcher_Base_Impl::launch_plan - EXCEPTION: ResourceNotAvaiable exception caught: <%s>,\n"
+ "Type: <%s>\n"
+ "Property: <%s>\n"
+ "Element: <%s>\n"
+ "Resource: <%s>\n",
+ ex.name.in (),
+ ex.resourceType.in (),
+ ex.propertyName.in (),
+ ex.elementName.in (),
+ ex.resourceName.in ());
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("%C"), buf));
+ throw Deployment_Failure (buf);
+ }
+ catch (const Deployment::StartError& ex)
+ {
+ char buf[1024];
+ ACE_OS::sprintf (buf, "Plan_Launcher_Base_Impl::launch_plan - EXCEPTION: StartError exception caught: <%s>, <%s>\n",
+ ex.name.in (),
+ ex.reason.in ());
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("%C"), buf));
+ throw Deployment_Failure (buf);
+ }
+ catch (const Deployment::InvalidProperty& ex)
+ {
+ char buf[1024];
+ ACE_OS::sprintf (buf, "Plan_Launcher_Base_Impl::launch_plan - EXCEPTION: InvalidProperty exception caught: <%s>, <%s>\n",
+ ex.name.in (),
+ ex.reason.in ());
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("%C"), buf));
+ throw Deployment_Failure (buf);
+ }
+ catch (const Deployment::InvalidConnection& ex)
+ {
+ char buf[1024];
+ ACE_OS::sprintf (buf, "Plan_Launcher_Base_Impl::launch_plan - EXCEPTION: InvalidConnection exception caught: <%s>, <%s>\n",
+ ex.name.in (),
+ ex.reason.in ());
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("%C"), buf));
+ throw Deployment_Failure (buf);
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ char buf[1024];
+ ACE_OS::sprintf (buf, "Plan_Launcher_Base_Impl::launch_plan - CORBA EXCEPTION: <%s>\n",
+ ex._info().fast_rep());
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("%C"), buf));
+ throw Deployment_Failure (buf);
+ }
+ catch (...)
+ {
+ char buf[1024];
+ ACE_OS::sprintf (buf, "Plan_Launcher_Base_Impl::launch_plan - EXCEPTION: non-CORBA exception\n");
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("%C"), buf));
+ throw Deployment_Failure (buf);
+ }
+
+ return CORBA::string_dup (plan.UUID.in());
+ }
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::teardown_plan - [success]\n")));
-}
+ template <typename Manager, typename AppManager, typename Application>
+ void
+ Plan_Launcher_Base_Impl< Manager, AppManager, Application>
+ ::teardown_application (CORBA::Object_ptr am_obj,
+ CORBA::Object_ptr app_obj)
+ {
+ DANCE_TRACE ("Plan_Launcher_Base_Impl::teardown_application");
+
+ AppManager_var am (AppManager::_narrow (am_obj));
+
+ if (CORBA::is_nil (am))
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::teardown_application - ")
+ ACE_TEXT("Nil ApplicationManager reference.\n")));
+ throw Deployment_Failure ("Nil ApplicationManager reference");
+ }
+
+ Application_var app (Application::_narrow (app_obj));
-void
-Plan_Launcher_Base_Impl::destroy_dam(
- ::Deployment::DomainApplicationManager_ptr dam)
-{
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO
- ACE_TEXT("Plan_Launcher_Base_Impl::destroy_dam - destroy the manager.....\n")));
- this->em_->destroyManager(dam);
+ if (CORBA::is_nil (app))
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::teardown_appliocation - ")
+ ACE_TEXT("Nil Application reference.\n")));
+ throw Deployment_Failure ("Nil Application reference");
+ }
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::destroy_dam - [success]\n")));
-}
+ try
+ {
+ am->destroyApplication (app.in ());
+ }
+ catch (const ::Deployment::StopError &ex)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::teardown_appliocation - ")
+ ACE_TEXT ("Caught StopError exception\n")));
+ throw Deployment_Failure ("StopError Exception\n");
+ }
+ catch (const CORBA::Exception &ex)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::teardown_appliocation - ")
+ ACE_TEXT ("Caught CORBA exception: %s\n"),
+ ex._info ().c_str ()));
+ throw Deployment_Failure (ex._info ().c_str ());
+ }
+ catch (...)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::teardown_appliocation - ")
+ ACE_TEXT ("Caught unknown C++ exception\n")));
+ throw Deployment_Failure ("Unknown C++ exception\n");
+ }
+ }
-void
-Plan_Launcher_Base_Impl::usage(const ACE_TCHAR*)
-{
- ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Plan Launcher Options :\n")
- ACE_TEXT ("-k|--em-ior <EXECUTION_MANAGER_IOR>")
- ACE_TEXT (" : Default file://em.ior\n")
- ACE_TEXT ("-d|--read-cdr-plan <CDR_DEPLOYMENT_PLAN_URL>\n")
- ACE_TEXT ("-w|--write-cdr-plan <CDR_DEPLOYMENT_PLAN_URL>\n")
- ACE_TEXT ("-t|--plan-uuid <PLAN_UUID>\n")
- // ACE_TEXT ("-a|dam-ior <DOMAIN_APPLICATION_MANAGER_IOR>\n")
- ACE_TEXT ("-q|--stop-plan : Stop the plan\n")
- ACE_TEXT ("-h|--help : Show this usage information\n")
- ACE_TEXT ("-x|--read-plan <XML_DEPLOYMENT_PLAN_URL>\n\n")));
-}
+ template <typename Manager, typename AppManager, typename Application>
+ void
+ Plan_Launcher_Base_Impl< Manager, AppManager, Application>
+ ::destroy_app_manager(CORBA::Object_ptr am_obj)
+ {
+ DANCE_TRACE ("Plan_Launcher_Base_Impl::destroy_app_manager");
+
+ AppManager_var am (AppManager::_narrow (am_obj));
-void
-Plan_Launcher_Base_Impl::parse_args(int argc, ACE_TCHAR *argv[])
-{
- DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("PL options : \"")));
+ if (CORBA::is_nil (am))
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::destroy_app_manager - ")
+ ACE_TEXT("Nil ApplicationManager reference.\n")));
+ throw Deployment_Failure ("Nil ApplicationManager reference");
+ }
- for (int i = 0; i < argc; ++i)
- {
- DANCE_DEBUG (9, (LM_TRACE, "\t%s\n", argv[i]));
- }
+ try
+ {
+ DANCE_ERROR (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::destroy_app_manager - ")
+ ACE_TEXT ("Destroying ApplicationManager\n")));
+ this->manager_->destroyManager (am.in ());
+ DANCE_ERROR (6, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::destroy_app_manager - ")
+ ACE_TEXT ("ApplicationManager destroyed.\n")));
+ }
+ catch (const ::Deployment::StopError &ex)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::destroy_app_manager - ")
+ ACE_TEXT ("Caught StopError exception\n")));
+ throw Deployment_Failure ("StopError Exception\n");
+ }
+ catch (const CORBA::Exception &ex)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::destroy_app_manager - ")
+ ACE_TEXT ("Caught CORBA exception: %s\n"),
+ ex._info ().c_str ()));
+ throw Deployment_Failure (ex._info ().c_str ());
+ }
+ catch (...)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::destroy_app_manager - ")
+ ACE_TEXT ("Caught unknown C++ exception\n")));
+ throw Deployment_Failure ("Unknown C++ exception\n");
+ }
+ }
- ACE_Get_Opt get_opt(argc, argv,
- ACE_TEXT ("k:d:w:t:a:qx:h"), 0);
- get_opt.long_option(ACE_TEXT("em-ior"), 'k', ACE_Get_Opt::ARG_REQUIRED);
- get_opt.long_option(ACE_TEXT("read-cdr-plan"), 'd', ACE_Get_Opt::ARG_REQUIRED);
- get_opt.long_option(ACE_TEXT("write-cdr-plan"), 'w', ACE_Get_Opt::ARG_REQUIRED);
- get_opt.long_option(ACE_TEXT("plan-uuid"), 't', ACE_Get_Opt::ARG_REQUIRED);
- get_opt.long_option(ACE_TEXT("dam-ior"), 'a', ACE_Get_Opt::ARG_REQUIRED);
- get_opt.long_option(ACE_TEXT("stop-plan"), 'q', ACE_Get_Opt::NO_ARG);
- get_opt.long_option(ACE_TEXT("read-plan"), 'x', ACE_Get_Opt::ARG_REQUIRED);
- get_opt.long_option(ACE_TEXT("help"), 'h', ACE_Get_Opt::NO_ARG);
-
- int c;
- ACE_CString s;
- while ( (c = get_opt ()) != EOF)
- {
- switch (c)
- {
- case 'k':
- this->em_ior_ = expand_env_vars (get_opt.opt_arg());
- break;
- case 'd':
- s = expand_env_vars (get_opt.opt_arg());
- // trim leading file://
- if (0 < s.length())
+
+ template <typename Manager, typename AppManager, typename Application>
+ void
+ Plan_Launcher_Base_Impl< Manager, AppManager, Application>
+ ::create_external_connections(const ::Deployment::DeploymentPlan &plan,
+ Deployment::Connections &conn)
+ {
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("create_external_connections - start\n")));
+
+ for (CORBA::ULong i = 0; i < plan.connection.length(); i++)
+ {
+ if (plan.connection[i].externalReference.length() > 0
+ && plan.connection[i].externalReference[0].provider)
+ {
+ DANCE_DEBUG (6, (LM_DEBUG,
+ "Plan_Launcher_i::create_external_connections - create connection %C from IOR %C\n",
+ plan.connection[i].name.in(),
+ plan.connection[i].externalReference[0].location.in()));
+
+ try
{
- ssize_t const pos = s.find("file://");
- if (0 == pos)
+ CORBA::Object_ptr
+ obj = this->orb_->string_to_object(plan.connection[i].externalReference[0].location.in());
+ if (!CORBA::is_nil (obj))
{
- s = s.substring(7);
+ CORBA::ULong const indx = conn.length();
+ conn.length(indx + 1);
+ conn[indx].name= CORBA::string_dup (plan.connection[i].name.in());
+ conn[indx].endpoint.length(1L);
+ conn[indx].endpoint[0] = obj;
+ }
+ else
+ {
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO
+ ACE_TEXT("Plan_Launcher_i::create_external_connections - can't create object for IOR %C\n"),
+ plan.connection[i].externalReference[0].location.in()));
}
- this->cdr_plan_urls_.push_back(s);
}
- break;
- case 'w':
- if (0 < this->cdr_dest_url_.length())
+ catch (CORBA::Exception &ex)
{
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Ambiguity: more then one --write-cdr-plan option.\n")));
- throw Deployment_Failure("Ambiguity: more then one --write-cdr-plan option.");
+ DANCE_ERROR (1, (LM_ERROR, DLINFO
+ ACE_TEXT("Plan_Launcher_i::create_external_connections - ")
+ ACE_TEXT("Caught CORBA Exception while resolving endpoint for connection %C\n"),
+ plan.connection[i].name.in ()));
}
- this->cdr_dest_url_ = expand_env_vars (get_opt.opt_arg());
- this->mode_ |= MODE_WRITE_CDR;
- // trim leading file://
- if (0 < this->cdr_dest_url_.length())
+ catch (...)
{
- ssize_t pos = this->cdr_dest_url_.find("file://");
- if (0 == pos)
- {
- this->cdr_dest_url_= this->cdr_dest_url_.substring(7);
- }
+ DANCE_ERROR (1, (LM_ERROR, DLINFO
+ ACE_TEXT("Plan_Launcher_i::create_external_connections - ")
+ ACE_TEXT("Caught C++ Exception while resolving endpoint for connection\n")));
}
- break;
- case 't':
- this->plan_uuid_ = ACE_TEXT_ALWAYS_CHAR (get_opt.opt_arg());
- break;
- case 'a':
- this->dam_ior_ = expand_env_vars (get_opt.opt_arg());
- DANCE_DEBUG (9, (LM_TRACE, "Parsed DAM IOR : %s\n", this->dam_ior_.c_str()));
- break;
- case 'q':
- this->mode_ |= MODE_STOP_PLAN;
- break;
- case 'x':
- this->xml_plan_urls_.push_back(expand_env_vars (get_opt.opt_arg()));
- break;
- case 'h':
- usage (argv[0]);
- throw Help_Issued ();
- break;
- default:
- usage (argv[0]);
- throw Deployment_Failure ("parse_args : invalid arguments");
- }
- }
- if (0 == (this->mode_ & (MODE_STOP_PLAN | MODE_WRITE_CDR)))
- {
- this->mode_ |= MODE_START_PLAN;
- }
- // Post-check
- this->check_mode_consistentness();
-}
-
-void
-Plan_Launcher_Base_Impl::write_dam_ior(
- ::Deployment::DomainApplicationManager_ptr dam)
-{
- if (this->dam_ior_.length () == 0)
- return;
-
- CORBA::String_var ior = this->orb_->object_to_string(dam);
-
- FILE* ior_output_file = ACE_OS::fopen (this->dam_ior_.c_str(), "w");
+ }
+ }
+ }
+ /*
- if (ior_output_file)
+ ACE_CString
+ Plan_Launcher_Base_Impl::expand_env_vars (const ACE_TCHAR * s)
{
- ACE_OS::fprintf (ior_output_file, "%s", ior.in());
- ACE_OS::fclose (ior_output_file);
- }
- else
+ ACE_TString src(s);
+ ACE_TString res;
+ size_t pos_done = 0;
+ while (pos_done < (size_t) src.length())
{
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("PlanLauncher.cpp::write_dap_ior - Error in opening file <%s> to write DAM IOR: %m"),
- this->dam_ior_.c_str()));
- throw Deployment_Failure (ACE_CString ("write_dap_ior - Error in opening file <%s> to write DAM IOR: %m") +
- this->dam_ior_);
- }
-}
-
-void
-Plan_Launcher_Base_Impl::stop_plan(void)
-{
- bool stopped = false;
- if (!is_empty (this->plan_uuid_))
+ size_t pos_start = src.find ('$', pos_done);
+ if (ACE_TString::npos == pos_start)
{
- stopped = true;
- DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::stop_plan - ")
- ACE_TEXT("Stopping plan \"%C\"\n"), this->plan_uuid_.c_str ()));
-
- if (!this->teardown_plan(this->plan_uuid_.c_str ()))
- {
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::stop_plan - ")
- ACE_TEXT("tear down assembly failed: unknown plan uuid.\n")));
- }
+ res += src.substring (pos_done);
+ pos_done = src.length();
}
-
- if (!is_empty (this->dam_ior_))
+ else // take the substring before '$' and append value
{
- stopped = true;
- DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::stop_plan - ")
- ACE_TEXT("Stopping plan by DAM IOR.\n")));
- CORBA::Object_var
- obj = this->orb_->string_to_object(this->dam_ior_.c_str());
- if (CORBA::is_nil (obj.in ()))
- {
- DANCE_ERROR (1, (LM_ERROR, DLINFO
- ACE_TEXT("Plan_Launcher_Base_Impl::stop_plan - ")
- ACE_TEXT("tear down assembly failed: DAM IOR is invalid.\n")));
- }
- else
- {
- Deployment::DomainApplicationManager_var
- dam = Deployment::DomainApplicationManager::_narrow (obj.in());
- this->teardown_plan(dam.in());
- }
- }
-
- if (0 < this->cdr_plan_urls_.size())
+ if (pos_start > pos_done)
{
- stopped = true;
- size_t const sz = this->cdr_plan_urls_.size();
- for (size_t i = 0; i < sz; ++i)
- {
- DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::stop_plan - ")
- ACE_TEXT("Stopping plan by plan file : <%s>\n"), this->cdr_plan_urls_[i].c_str()));
- ::Deployment::DeploymentPlan_var plan = this->read_cdr_plan_file(this->cdr_plan_urls_[i].c_str());
- if (!this->teardown_plan(plan->UUID.in()))
- {
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::stop_plan - ")
- ACE_TEXT("tear down assembly failed: unknown plan uuid.\n")));
- }
- }
+ res += src.substring (pos_done, pos_start - pos_done);
+ pos_done = pos_start;
}
- if (!stopped && 0 == this->xml_plan_urls_.size())
- {
- DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::stop_plan - ")
- ACE_TEXT("Stopping plan all running plans.\n")));
- ::Deployment::DomainApplicationManagers_var
- mgrs = this->em_->getManagers();
- ::Deployment::DomainApplicationManager_var dapp_mgr;
- for (size_t i = 0; i < mgrs->length(); ++i)
- {
- this->teardown_plan((*mgrs) [i]);
- }
- }
-}
+ size_t pos_end = src.length();
-void
-Plan_Launcher_Base_Impl::create_external_connections(
- const ::Deployment::DeploymentPlan &plan, Deployment::Connections& conn)
-{
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("create_external_connections - start\n")));
- for (CORBA::ULong i = 0; i < plan.connection.length(); i++)
- {
- if (plan.connection[i].externalReference.length() > 0
- && plan.connection[i].externalReference[0].provider)
- {
- DANCE_DEBUG (6, (LM_DEBUG,
- "Plan_Launcher_i::create_external_connections - create connection %C from IOR %C\n",
- plan.connection[i].name.in(),
- plan.connection[i].externalReference[0].location.in()));
- CORBA::ULong const indx = conn.length();
- conn.length(indx + 1);
- conn[indx].name= CORBA::string_dup (plan.connection[i].name.in());
- conn[indx].endpoint.length(1L);
- CORBA::Object_ptr
- obj = this->orb_->string_to_object(plan.connection[i].externalReference[0].location.in());
- if (!CORBA::is_nil (obj))
- {
- //Components::CCMObject_ptr ccmobj = Components::CCMObject::_narrow (obj);
- conn[indx].endpoint[0] = obj;
- }
- else
- {
- DANCE_DEBUG (6, (LM_DEBUG,
- ACE_TEXT("Plan_Launcher_i::create_external_connections - can't create object for IOR %C\n"),
- plan.connection[i].externalReference[0].location.in()));
- throw 0;
- }
- }
- }
-}
+ size_t p;
-Deployment::DeploymentPlan*
-Plan_Launcher_Base_Impl::read_cdr_plan_file(const char *cdr_plan_uri)
-{
- Deployment::DeploymentPlan* res = 0;
- try
+ p = src.find (ACE_TEXT(' '), pos_start + 1);
+ if (ACE_TString::npos != p && pos_end > p) pos_end = p;
+
+ p = src.find (ACE_TEXT('/'), pos_start + 1);
+ if (ACE_TString::npos != p && pos_end > p) pos_end = p;
+
+ p = src.find (ACE_TEXT('\\'), pos_start + 1);
+ if (ACE_TString::npos != p && pos_end > p) pos_end = p;
+
+ p = src.find (ACE_TEXT('$'), pos_start + 1);
+ if (ACE_TString::npos != p && pos_end > p) pos_end = p;
+
+ if (pos_end - pos_start > 1)
{
- FILE* file = ACE_OS::fopen (cdr_plan_uri, "r");
- if (0 == file)
- {
- ACE_CString s = "read_cdr_plan_file : failed to open file \"";
- s += cdr_plan_uri;
- s += "\"";
- throw Deployment_Failure (s.c_str());
- }
-
- size_t buf_size = 0;
- ACE_OS::fread (&buf_size, sizeof (buf_size), 1, file);
-
- char * buf = new char[buf_size];
- ACE_OS::fread (buf, 1, buf_size, file);
- {
- TAO_InputCDR cdr (buf, buf_size);
- ACE_NEW_THROW_EX (res,
- Deployment::DeploymentPlan (),
- CORBA::NO_MEMORY ());
- cdr >> *res;
- }
- delete [] buf;
- ACE_OS::fclose (file);
+ ACE_Env_Value<const ACE_TCHAR*> val (src.substring (pos_start + 1, pos_end - pos_start - 1).c_str(), 0);
+ res += val;
+ pos_done = pos_end;
}
- catch(...)
+ else
{
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Failed to read CDR plan file.\n")));
- throw Deployment_Failure("Failed to read CDR plan file.");
+ DANCE_DEBUG (6, (LM_WARNING, DLINFO
+ ACE_TEXT("Plan_Launcher_Base_Impl::expand_env_vars - ")
+ ACE_TEXT("Envvar can not be parsed out at %i in \"<%s>\""),
+ pos_start,
+ src.c_str()));
}
- return res;
-}
-
-void
-Plan_Launcher_Base_Impl::write_cdr_plan_file(const char * filename,
- const Deployment::DeploymentPlan & plan)
-{
- try
- {
- FILE * file = ACE_OS::fopen (filename, "w");
- if (0 == file)
- {
- throw Deployment_Failure ("write_cdr_plan_file : failed to open file.");
- }
- TAO_OutputCDR cdr;
- if (cdr << plan)
- {
- size_t buf_size = cdr.total_length();
- ACE_OS::fwrite (&buf_size, sizeof (buf_size), 1, file);
- for (const ACE_Message_Block *i = cdr.begin ();
- i != 0;
- i = i->cont ())
- {
- ACE_OS::fwrite (i->rd_ptr (), 1, i->length (), file);
- }
- ACE_OS::fclose (file);
- }
- else
- {
- throw Deployment_Failure ("write_cdr_plan_file : failed marshal plan.");
- }
}
- catch(...)
- {
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::write_cdr_plan_file - ")
- ACE_TEXT("Failed to write CDR plan file.\n")));
- throw Deployment_Failure("Failed to write CDR plan file.");
}
-}
-
-void
-Plan_Launcher_Base_Impl::check_mode_consistentness()
-{
- if (this->mode_ & MODE_START_PLAN)
- {
- if (0 == this->cdr_plan_urls_.size() && 0 == this->xml_plan_urls_.size())
- {
- throw Deployment_Failure ("check_mode_consistentness : no plan to start");
- }
- }
- else if (this->mode_ & MODE_STOP_PLAN)
- {
- // if (is_empty (this->cdr_plan_url_)
- // && is_empty (this->xml_plan_url_)
- // && is_empty (this->plan_uuid_)
- // && is_empty (this->dam_ior_))
- // {
- // throw Deployment_Failure ("check_mode_consistentness : no plan to stop");
- // }
- }
- else if (this->mode_ & MODE_WRITE_CDR)
- {
- if (is_empty (this->cdr_dest_url_))
- {
- throw Deployment_Failure ("check_mode_consistentness : no cdr url for writing plan.");
- }
- if (1 != this->xml_plan_urls_.size())
- {
- throw Deployment_Failure ("check_mode_consistentness : not one source url for writing plan.");
- }
- }
- else
- {
- throw Deployment_Failure ("check_mode_consistentness : no action specified");
- }
- }
-
-ACE_CString
-Plan_Launcher_Base_Impl::expand_env_vars (const ACE_TCHAR * s)
- {
- ACE_TString src(s);
- ACE_TString res;
- size_t pos_done = 0;
- while (pos_done < (size_t) src.length())
- {
- size_t pos_start = src.find ('$', pos_done);
- if (ACE_TString::npos == pos_start)
- {
- res += src.substring (pos_done);
- pos_done = src.length();
- }
- else // take the substring before '$' and append value
- {
- if (pos_start > pos_done)
- {
- res += src.substring (pos_done, pos_start - pos_done);
- pos_done = pos_start;
- }
-
- size_t pos_end = src.length();
-
- size_t p;
-
- p = src.find (ACE_TEXT(' '), pos_start + 1);
- if (ACE_TString::npos != p && pos_end > p) pos_end = p;
-
- p = src.find (ACE_TEXT('/'), pos_start + 1);
- if (ACE_TString::npos != p && pos_end > p) pos_end = p;
-
- p = src.find (ACE_TEXT('\\'), pos_start + 1);
- if (ACE_TString::npos != p && pos_end > p) pos_end = p;
-
- p = src.find (ACE_TEXT('$'), pos_start + 1);
- if (ACE_TString::npos != p && pos_end > p) pos_end = p;
-
- if (pos_end - pos_start > 1)
- {
- ACE_Env_Value<const ACE_TCHAR*> val (src.substring (pos_start + 1, pos_end - pos_start - 1).c_str(), 0);
- res += val;
- pos_done = pos_end;
- }
- else
- {
- DANCE_DEBUG (6, (LM_WARNING, DLINFO
- ACE_TEXT("Plan_Launcher_Base_Impl::expand_env_vars - ")
- ACE_TEXT("Envvar can not be parsed out at %i in \"<%s>\""),
- pos_start,
- src.c_str()));
- }
- }
- }
return res;
- }
+ }
+ */
+}
+#endif
diff --git a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Base_Impl.h b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Base_Impl.h
index e48fdb3997b..7c2fd8a94b7 100644
--- a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Base_Impl.h
+++ b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Base_Impl.h
@@ -1,106 +1,92 @@
/**
* $Id$
* @file Plan_Launcher_Base_Impl.h
- * @author Will Otte <wotte@dre.vanderbilt.edu>
+ * @author William R. Otte <wotte@dre.vanderbilt.edu>
*
- * Contains the Plan_Launcher_i class, which can be used by
- * applications to launch component assemblies.
+ * Contains the generic implementation of plan launcher logic for both EM and NM deployments.
+ *
*/
+
#ifndef PLAN_LAUNCHER_BASE_IMPL_H
#define PLAN_LAUNCHER_BASE_IMPL_H
-#include "DAnCE/Deployment/Deployment_DomainApplicationManagerC.h"
-#include "DAnCE/Deployment/Deployment_ExecutionManagerC.h"
#include "DAnCE/Deployment/Deployment_ConnectionC.h"
-#include "ace/Map_Manager.h"
#include "DAnCE/Deployment/Deployment_DeploymentPlanC.h"
-#include "ace/Vector_T.h"
-/**
- * @class Plan_Launcher_Impl
- * @brief This class launches and manages deployment plans.
- */
-class Plan_Launcher_Base_Impl
-{
-public:
- struct Deployment_Failure
- {
- Deployment_Failure(const ACE_CString &error) :
- error_(error)
- {}
- ACE_CString error_;
- };
-
- struct Help_Issued
- {
- Help_Issued() {}
- };
+#include "Plan_Launcher_Base.h"
- Plan_Launcher_Base_Impl(CORBA::ORB_ptr orb, int argc, ACE_TCHAR *argv[]);
-
- virtual ~Plan_Launcher_Base_Impl();
-
- void execute();
-
- static Deployment::DeploymentPlan* read_cdr_plan_file(
- const char *deployment_plan_uri);
- static void write_cdr_plan_file(const char * filename,
- const Deployment::DeploymentPlan & plan);
-
-protected:
+namespace DAnCE
+{
/**
- * @brief Launch a plan, given an IDL deployment plan
- * @param plan A valid IDL deployment plan
- * @returns a string containing the UUID of the plan. Null indicates failure.
+ * @class Plan_Launcher_Base_Impl
+ * @brief This class launches and manages deployment plans.
*/
- virtual const char * launch_plan(const ::Deployment::DeploymentPlan &plan);
-
- /// Returns the DAM associated with a given plan URI
- ::Deployment::DomainApplicationManager_ptr get_dam(const char *uuid);
-
- /// Tears down a plan given the UUID
- bool teardown_plan(const char *uuid);
-
- void teardown_plan(::Deployment::DomainApplicationManager_ptr dam);
-
- void destroy_dam(::Deployment::DomainApplicationManager_ptr dam);
-
- virtual void stop_plan();
- void usage(const ACE_TCHAR* program = 0);
- void parse_args(int argc, ACE_TCHAR *argv[]);
-
- static bool is_empty(const ACE_CString & s)
+ template<typename Manager, typename AppManager, typename Application>
+ class Plan_Launcher_Base_Impl : public virtual Plan_Launcher_Base
{
- return 0 == s.length();
- }
-
- void write_dam_ior(::Deployment::DomainApplicationManager_ptr dam);
-
- void create_external_connections(const ::Deployment::DeploymentPlan &plan,
- Deployment::Connections& conn);
-
- virtual void check_mode_consistentness();
- static ACE_CString expand_env_vars(const ACE_TCHAR * src);
-
- /// Cached ORB pointer
- CORBA::ORB_var orb_;
-
- /// Object reference of the ExecutionManager
- ::Deployment::ExecutionManager_var em_;
-
- ACE_Vector<ACE_CString> cdr_plan_urls_;
- ACE_CString plan_uuid_;
- ACE_CString em_ior_;
- ACE_CString dam_ior_;
- ACE_Vector<ACE_CString> xml_plan_urls_;
- ACE_CString cdr_dest_url_;
-
- unsigned long mode_;
- static const unsigned long MODE_START_PLAN = 0x0001;
- static const unsigned long MODE_STOP_PLAN = 0x0002;
- static const unsigned long MODE_USE_NAMING = 0x0004;
- static const unsigned long MODE_WRITE_CDR = 0x0008;
-
-}; // class Plan_Launcher_Impl
+ protected:
+
+ typedef typename Manager::_ptr_type Manager_ptr;
+ typedef typename Manager::_var_type Manager_var;
+
+ typedef typename AppManager::_ptr_type AppManager_ptr;
+ typedef typename AppManager::_var_type AppManager_var;
+
+ typedef typename Application::_ptr_type Application_ptr;
+ typedef typename Application::_var_type Application_var;
+
+ public:
+ Plan_Launcher_Base_Impl (CORBA::ORB_ptr orb,
+ Manager_ptr manager);
+
+ virtual ~Plan_Launcher_Base_Impl ();
+
+ /**
+ * @brief Launch a plan, given an IDL deployment plan
+ * @param plan A valid IDL deployment plan
+ * @returns a string containing the UUID of the plan. Null indicates failure.
+ */
+ virtual const char * launch_plan (const ::Deployment::DeploymentPlan &plan,
+ CORBA::Object_out am,
+ CORBA::Object_out app);
+
+ virtual CORBA::Object_ptr prepare_plan (const ::Deployment::DeploymentPlan &plan);
+
+ virtual CORBA::Object_ptr start_launch (CORBA::Object_ptr app_mgr,
+ const ::Deployment::Properties &properties,
+ ::Deployment::Connections_out connections);
+
+ virtual void finish_launch (CORBA::Object_ptr app,
+ const ::Deployment::Connections &provided_connections,
+ bool start);
+
+ virtual void start (CORBA::Object_ptr application);
+
+ /// Tears down a plan given the UUID
+ virtual void teardown_application (CORBA::Object_ptr app_mgr,
+ CORBA::Object_ptr app);
+
+ virtual void destroy_app_manager (CORBA::Object_ptr);
+
+ virtual void create_external_connections(const ::Deployment::DeploymentPlan &plan,
+ Deployment::Connections &conn);
+
+ // static ACE_CString expand_env_vars(const ACE_TCHAR * src);
+ protected:
+ /// Cached ORB pointer
+ CORBA::ORB_var orb_;
+
+ /// Object reference of the Manager
+ Manager_var manager_;
+ }; // class Plan_Launcher_Impl
+
+}
+#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
+#include "Plan_Launcher/Plan_Launcher_Base_Impl.cpp"
+#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
+
+#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
+#pragma implementation ("Plan_Launcher_Base_Impl.cpp")
+#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
#endif /* PLAN_LAUNCHER_BASE_IMPL_H */
diff --git a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.cpp b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.cpp
deleted file mode 100644
index a6835efce70..00000000000
--- a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-// $Id$
-
-#include "Plan_Launcher_Impl.h"
-#include "DAnCE/Logger/Log_Macros.h"
-#include "Config_Handlers/XML_File_Intf.h"
-#include "Config_Handlers/DnC_Dump.h"
-#include "ace/SString.h"
-#include "ace/Get_Opt.h"
-
-Plan_Launcher_Impl::~Plan_Launcher_Impl (void)
-{
-}
-
-::Deployment::DeploymentPlan *
-Plan_Launcher_Impl::load_xml_plan(const ACE_TCHAR *deployment_plan_uri)
-{
- DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("Plan_Launcher_Impl::load_xml_plan - ")
- ACE_TEXT("Parsing plan \"%C\"...\n"), deployment_plan_uri));
-
- ::Deployment::DeploymentPlan * plan = 0;
- try
- {
- CIAO::Config_Handlers::XML_File_Intf intf (deployment_plan_uri);
- intf.add_search_path (ACE_TEXT("DANCE_ROOT"), ACE_TEXT("/docs/schema/"));
- intf.add_search_path (ACE_TEXT("CIAO_ROOT"), ACE_TEXT("/docs/schema/"));
- intf.add_search_path (ACE_TEXT("TAO_ROOT"), ACE_TEXT("/docs/schema/"));
- plan = intf.release_plan ();
- if (0 == plan)
- {
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Impl::load_xml_plan - ")
- ACE_TEXT("Failed to parse plan \"%C\".\n"), deployment_plan_uri));
- throw Deployment_Failure("Failed to parse plan.");
- }
- }
- catch (...)
- {
- ACE_TString s = ACE_TEXT ("failed to parse deployment plan \"");
- s += deployment_plan_uri;
- s += ACE_TEXT ("\"");
- DANCE_DEBUG (6, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Impl::load_xml_plan - %s\n"), s.c_str()));
- throw Deployment_Failure (ACE_TEXT_ALWAYS_CHAR (s.c_str()));
- }
-
- DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("Plan_Launcher_Impl::load_xml_plan - Parsing complete....\n")));
- return plan;
-}
-
-void Plan_Launcher_Impl::execute()
-{
- DANCE_TRACE ("Plan_Launcher_Impl::execute()");
-
- if (this->mode_ & MODE_START_PLAN)
- {
- size_t const sz = this->xml_plan_urls_.size();
- for (size_t i= 0; i < sz; ++i)
- {
- DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("Plan_Launcher_Impl::execute - ")
- ACE_TEXT("launching plan \"%C\"...\n"), this->xml_plan_urls_[i].c_str()));
- ::Deployment::DeploymentPlan_var plan =
- this->load_xml_plan(ACE_TEXT_CHAR_TO_TCHAR (this->xml_plan_urls_[i].c_str()));
- try
- {
- CORBA::String_var uuid = this->launch_plan (plan.in());
- if (0 == uuid.in ())
- {
- throw Deployment_Failure ("execute - Error launching plan\n");
- }
- DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("Plan_Launcher_Impl::execute - ")
- ACE_TEXT("returned plan UUID is \"%C\"\n"), uuid.in ()));
- }
- catch (...)
- {
- this->teardown_plan (plan->UUID.in());
- throw;
- }
- }
- this->Plan_Launcher_Base_Impl::execute();
- }
-
- if (this->mode_ & MODE_STOP_PLAN)
- {
- this->stop_plan();
- }
-
- if (this->mode_ & MODE_WRITE_CDR)
- {
- ::Deployment::DeploymentPlan_var plan = this->load_xml_plan(ACE_TEXT_CHAR_TO_TCHAR (this->xml_plan_urls_[0].c_str()));
- this->write_cdr_plan_file(this->cdr_dest_url_.c_str(), plan);
- }
-}
-
-void Plan_Launcher_Impl::stop_plan()
-{
- DANCE_TRACE ("Plan_Launcher_Impl::stop_plan");
-
- if (0 < this->xml_plan_urls_.size())
- {
- size_t const sz = this->xml_plan_urls_.size();
- for (size_t i= 0; i < sz; ++i)
- {
- DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("Plan_Launcher_Impl::stop_plan - ")
- ACE_TEXT("Stopping plan by plan file: %C\n"), this->xml_plan_urls_[i].c_str()));
- ::Deployment::DeploymentPlan_var plan =
- this->load_xml_plan(ACE_TEXT_CHAR_TO_TCHAR (this->xml_plan_urls_[i].c_str()));
- if (!this->teardown_plan(plan->UUID.in()))
- {
- DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Impl::stop_plan - ")
- ACE_TEXT("tear down assembly failed: unknown plan uuid.\n")));
- }
- }
- }
- this->Plan_Launcher_Base_Impl::stop_plan();
-}
-
diff --git a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.h b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.h
deleted file mode 100644
index 6fe7c43f027..00000000000
--- a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * $Id$
- * @file Plan_Launcher_Impl.h
- * @author Will Otte <wotte@dre.vanderbilt.edu>
- *
- * Contains the Plan_Launcher_i class, which can be used by
- * applications to launch component assemblies.
- */
-#ifndef PLAN_LAUNCHER_IMPL_H
-#define PLAN_LAUNCHER_IMPL_H
-
-#include "Plan_Launcher_Base_Impl.h"
-
-/**
-* @class Plan_Launcher_Impl
-* @brief This class launches and manages deployment plans.
-*/
-class Plan_Launcher_Impl : public Plan_Launcher_Base_Impl
- {
- public:
- Plan_Launcher_Impl (CORBA::ORB_ptr orb, int argc, ACE_TCHAR *argv[])
- : Plan_Launcher_Base_Impl (orb, argc, argv) {};
-
- virtual ~Plan_Launcher_Impl(void);
-
- void execute(void);
-
- static ::Deployment::DeploymentPlan* load_xml_plan (
- const ACE_TCHAR *deployment_plan_uri);
-
- protected:
- virtual void stop_plan();
- }; // class Plan_Launcher_Impl
-
-#endif /* PLAN_LAUNCHER_IMPL_H */