diff options
author | Abdullah Sowayan <sowayan@users.noreply.github.com> | 2007-03-18 22:23:37 +0000 |
---|---|---|
committer | Abdullah Sowayan <sowayan@users.noreply.github.com> | 2007-03-18 22:23:37 +0000 |
commit | 06a34455bd98b1379cc69bbc5b2cf085e0fc0d9b (patch) | |
tree | 8815ce3b3a85c3c4285429295f338e00ea4497f4 /CIAO/DAnCE/Plan_Launcher | |
parent | d66fcc9b4aaec8e88eeb83fc578fdf8a3cc963de (diff) | |
download | ATCD-Static_RT_DAnCE.tar.gz |
Diffstat (limited to 'CIAO/DAnCE/Plan_Launcher')
-rw-r--r-- | CIAO/DAnCE/Plan_Launcher/Plan_Launcher.cpp | 327 | ||||
-rw-r--r-- | CIAO/DAnCE/Plan_Launcher/Plan_Launcher.mpc | 33 | ||||
-rw-r--r-- | CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.cpp | 411 | ||||
-rw-r--r-- | CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.h | 97 | ||||
-rw-r--r-- | CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl_Export.h | 58 |
5 files changed, 926 insertions, 0 deletions
diff --git a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.cpp b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.cpp new file mode 100644 index 00000000000..d5233cf870c --- /dev/null +++ b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.cpp @@ -0,0 +1,327 @@ +// $Id$ + +#include "Plan_Launcher_Impl.h" + +#include "ace/OS.h" +#include "ace/Get_Opt.h" +#include <iostream> + +#include "DAnCE/Interfaces/ExecutionManagerDaemonC.h" + +namespace CIAO +{ + namespace Plan_Launcher + { + // deployment plan URL + const char* deployment_plan_url = 0; + bool use_package_name = true; + const char* package_names = 0; + const char* package_types = 0; + const char* new_deployment_plan_url = 0; + const char* plan_uuid = 0; + bool em_use_naming = false; + const char* em_ior_file = "file://em.ior"; + bool rm_use_naming = false; + bool use_repoman = false; + const char* rm_ior_file = "file://rm.ior"; + const char* repoman_name_ = "RepositoryManager"; + const char* dap_ior_filename = 0; + const char* dap_ior = 0; + + enum mode_type { + pl_mode_start, + pl_mode_interactive, + pl_mode_stop_by_dam, + pl_mode_stop_by_uuid, + pl_mode_redeployment + }; + + // default mode + mode_type mode = pl_mode_interactive; + + static void + usage (const ACE_TCHAR* program) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("[(%P|%t) Executor] Usage: %s\n") + ACE_TEXT ("-a <PACKAGE_NAMES>\n") + ACE_TEXT ("-e <PACKAGE_TYPES>\n") + ACE_TEXT ("-p <DEPLOYMENT_PLAN_URL>\n") + ACE_TEXT ("-n : Use naming service to fetch EM") + ACE_TEXT ("-k <EXECUTION_MANAGER_IOR>") + ACE_TEXT (" : Default file://em.ior\n") + ACE_TEXT ("-l <REPOSITORY_MANAGER_IOR>") + ACE_TEXT (" : Default file://rm.ior\n") + ACE_TEXT ("-v <REPOSITORY_MANAGER_NAME>: Use naming service to fetch RM with the given name") + ACE_TEXT (" : Default RepositoryManager\n") + ACE_TEXT ("-t <PLAN_UUID>\n") + ACE_TEXT ("-o <DOMAIN_APPLICATION_MANAGER_IOR_OUTPUT_FILE>\n") + ACE_TEXT ("-i <DOMAIN_APPLICATION_MANAGER_IOR_FOR_INPUT>\n") + ACE_TEXT ("-r <NEW_PLAN_DESCRIPTOR_FOR_REDEPLOYMENT>\n") + ACE_TEXT ("-h : Show this usage information\n"), + program)); + } + + static bool + parse_args (int argc, + ACE_TCHAR *argv[]) + { + ACE_Get_Opt get_opt (argc, + argv, + ACE_TEXT ("a:e:p:nk:l:v:t:o:i:r:h")); + int c; + + while ((c = get_opt ()) != EOF) + { + switch (c) + { + case 'a': + package_names = get_opt.opt_arg (); + use_package_name = true; + break; + case 'e': + package_types = get_opt.opt_arg (); + use_package_name = false; + break; + case 'p': + deployment_plan_url = get_opt.opt_arg (); + break; + case 'n': + em_use_naming = true; + break; + case 'k': + em_ior_file = get_opt.opt_arg (); + break; + case 'l': + use_repoman = true; + rm_ior_file = get_opt.opt_arg (); + break; + case 'v': + use_repoman = true; + rm_use_naming = true; + repoman_name_ = get_opt.opt_arg (); + break; + case 'o': + dap_ior_filename = get_opt.opt_arg (); + mode = pl_mode_start; + break; + case 'i': + dap_ior = get_opt.opt_arg (); + mode = pl_mode_stop_by_dam; + break; + case 't': + plan_uuid = get_opt.opt_arg (); + mode = pl_mode_stop_by_uuid; + break; + case 'r': + new_deployment_plan_url = get_opt.opt_arg (); + mode = pl_mode_redeployment; + break; + case 'h': + default: + usage(argv[0]); + return false; + } + } + + if ((mode != pl_mode_stop_by_dam) && + (mode != pl_mode_stop_by_uuid) && + (package_names == 0) && + (package_types == 0) && + (deployment_plan_url == 0) && + (new_deployment_plan_url == 0)) + { + usage (argv[0]); + return false; + } + + return true; + } + + static ::Deployment::DomainApplicationManager_ptr + read_dap_ior (CORBA::ORB_ptr orb) + { + CORBA::Object_var obj = orb->string_to_object (dap_ior); + return + Deployment::DomainApplicationManager::_narrow (obj.in ()); + } + + static int + write_dap_ior (CORBA::ORB_ptr orb, + ::Deployment::DomainApplicationManager_ptr dap) + { + CORBA::String_var ior = orb->object_to_string (dap); + + FILE* ior_output_file = ACE_OS::fopen (dap_ior_filename, "w"); + + if (ior_output_file) + { + ACE_OS::fprintf (ior_output_file, "%s", ior.in ()); + ACE_OS::fclose (ior_output_file); + + return 0; + } + + return -1; + } + + static int + run_main_implementation (int argc, char *argv[]) + { + + try + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, + argv, + ""); + + if (parse_args (argc, argv) == false) + return -1; + + Plan_Launcher_i launcher; + + if (!launcher.init (em_use_naming ? 0 : em_ior_file, + orb.in (), + use_repoman, + rm_use_naming, + rm_use_naming ? repoman_name_ : rm_ior_file)) + { + ACE_ERROR ((LM_ERROR, "(%P|%t) Plan_Launcher: Error initializing the EM.\n")); + return -1; + } + + ::Deployment::DomainApplicationManager_var dapp_mgr; + + if (mode == pl_mode_start || mode == pl_mode_interactive) // initial deployment + { + CORBA::String_var uuid; + + if (package_names != 0) + uuid = launcher.launch_plan (deployment_plan_url, + package_names, + use_package_name, + use_repoman); + else + uuid = launcher.launch_plan (deployment_plan_url, + package_types, + use_package_name, + use_repoman); + + if (uuid.in () == 0) + { + ACE_ERROR ((LM_ERROR, "(%P|%t) Plan_Launcher: Error launching plan\n")); + return -1; + } + + ACE_DEBUG ((LM_DEBUG, "Plan_Launcher returned UUID is %s\n", uuid.in ())); + dapp_mgr = launcher.get_dam (uuid.in ()); + + // Write out DAM ior if requested + if (mode == pl_mode_start) + { + write_dap_ior (orb.in (), dapp_mgr.in ()); + } + else // if (pl_mode_interactive) + { + ACE_DEBUG ((LM_DEBUG, + "Press <Enter> to tear down application\n")); + char dummy [256]; + std::cin.getline (dummy, 256); + + // Tear down the assembly + ACE_DEBUG ((LM_DEBUG, + "Plan_Launcher: destroy the application.....\n")); + if (! launcher.teardown_plan (uuid)) + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) CIAO_PlanLauncher:tear down assembly failed: " + "unkonw plan uuid.\n")); + } + } + else if (mode == pl_mode_redeployment && new_deployment_plan_url != 0) // do redeployment + { + ACE_DEBUG ((LM_DEBUG, + "Plan_Launcher: reconfigure application assembly.....\n")); + + CORBA::String_var uuid; + + if (package_names != 0) + uuid = launcher.re_launch_plan (new_deployment_plan_url, + package_names, + use_package_name, + use_repoman); + else + uuid = launcher.re_launch_plan (new_deployment_plan_url, + package_types, + use_package_name, + use_repoman); + + if (uuid.in () == 0) + { + ACE_ERROR ((LM_ERROR, "(%P|%t) Plan_Launcher: Error re-launching plan\n")); + return -1; + } + } + else if (mode == pl_mode_stop_by_dam) // tear down by DAM + { + dapp_mgr = read_dap_ior (orb.in ()); + + if (CORBA::is_nil (dapp_mgr.in ())) + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) CIAO_PlanLauncher:tear down assembly failed: " + "nil DomainApplicationManager reference\n")); + return -1; + } + + // Tear down the assembly + ACE_DEBUG ((LM_DEBUG, + "Plan_Launcher: destroy the application.....\n")); + launcher.teardown_plan (dapp_mgr.in ()); + } + else if (mode == pl_mode_stop_by_uuid) // tear down by plan_uuid + { + // Tear down the assembly + ACE_DEBUG ((LM_DEBUG, + "Plan_Launcher: destroy the application.....\n")); + if (! launcher.teardown_plan (plan_uuid)) + { + ACE_ERROR ((LM_ERROR, + "(%P|%t) CIAO_PlanLauncher:tear down assembly failed: " + "unkown plan uuid.\n")); + } + } + + orb->destroy (); + } + catch (const Plan_Launcher_i::Deployment_Failure&) + { + ACE_ERROR ((LM_ERROR, + "Deployment failed. Plan_Launcher exiting.\n")); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("(%P|%t) Plan_Launcher: "); + + return -1; + } + catch (...) + { + ACE_ERROR ((LM_ERROR, + "(%P|%t) Plan_Launcher: Unknown exception.\n")); + return -1; + } + + return 0; + } + } +} + +using namespace CIAO::Plan_Launcher; + +int +ACE_TMAIN (int argc, + ACE_TCHAR *argv[]) +{ + return run_main_implementation (argc, argv); +} diff --git a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.mpc b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.mpc new file mode 100644 index 00000000000..4c86092d6b2 --- /dev/null +++ b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.mpc @@ -0,0 +1,33 @@ +// -*- MPC -*- +// $Id$ + +project(Plan_Launcher_Impl) : ciao_servant_dnc, ciao_config_handlers, ciao_executionmanager_stub, ciao_plan_generator { + sharedname = Plan_Launcher_Impl + + dynamicflags = PLAN_LAUNCHER_IMPL_BUILD_DLL + + Source_Files { + ../ExecutionManager/DAM_Map.cpp + Plan_Launcher_Impl.cpp + } + + Header_Files { + ../ExecutionManager/DAM_Map.h + Plan_Launcher_Impl.h + Plan_Launcher_Impl_Export.h + } +} + +project(Plan_Launcher) : ciao_server_dnc, ciao_config_handlers, ciao_executionmanager_stub, ciao_plan_generator, ciaoexe { + exename = plan_launcher + + after += Plan_Launcher_Impl + libs += Plan_Launcher_Impl + + Source_Files { + Plan_Launcher.cpp + } + + Header_Files { + } +} diff --git a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.cpp b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.cpp new file mode 100644 index 00000000000..237ede72b1a --- /dev/null +++ b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.cpp @@ -0,0 +1,411 @@ +// $Id$ +#include "Plan_Launcher_Impl.h" +#include "orbsvcs/CosNamingC.h" +#include "Config_Handlers/XML_File_Intf.h" +#include "Config_Handlers/DnC_Dump.h" + +namespace CIAO +{ + namespace Plan_Launcher + { + // @todo make this a private method + static CORBA::Object_ptr + fetch_reference_naming (CORBA::ORB_ptr orb) + { + CORBA::Object_var tmp = orb->resolve_initial_references ("NameService"); + + CosNaming::NamingContext_var pns = + CosNaming::NamingContext::_narrow (tmp.in ()); + + if (CORBA::is_nil (pns.in ())) + { + return CORBA::Object::_nil (); + } + + CosNaming::Name name (1); + name.length (1); + + name[0].id = CORBA::string_dup ("ExecutionManager"); + + return pns->resolve (name); + } + + Plan_Launcher_i::Plan_Launcher_i () + : em_ (), pg_ () + { + } + + bool + Plan_Launcher_i::init (const char *em_ior, + CORBA::ORB_ptr orb, + bool use_repoman, + bool rm_use_naming, + const char *rm_name) + { + CORBA::Object_var obj; + + // EM + if (em_ior == 0) + { + obj = fetch_reference_naming (orb); + } + else + { + obj = orb->string_to_object (em_ior); + } + + this->em_ = ::CIAO::ExecutionManagerDaemon::_narrow (obj.in ()); + + if (CORBA::is_nil (this->em_.in ())) + { + ACE_ERROR ((LM_ERROR, + "(%P|%t) CIAO_PlanLauncher: nil Execution" + " Manager reference, narrow failed\n")); + return false; + } + + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) CIAO_PlanLauncher: Obtained Execution" + " Manager ref \n")); + } + + if (use_repoman) + { + return pg_.init (orb, rm_use_naming, rm_name); + } + else + { + return true; + } + } + + + const char * + Plan_Launcher_i::launch_plan (const char *deployment_plan_uri, + const char *package_uri, + bool use_package_name, + bool use_repoman) + { + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG, "Parsing plan...\n")); + } + + CIAO::Config_Handlers::XML_File_Intf intf (deployment_plan_uri); + + ::Deployment::DeploymentPlan_var plan = intf.get_plan (); + + // Use the package name(s) or type(s) to modify the location of all the + // artifacts in DeploymentPlan. + if (use_repoman) + { + // @todo check return value + pg_.generate_plan (plan, package_uri, use_package_name); + } + + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG, "Parsing complete....\n")); + } + + return this->launch_plan (plan.in ()); + } + + const char * + Plan_Launcher_i::launch_plan (const ::Deployment::DeploymentPlan &plan) + { + try + { + if (CORBA::is_nil (this->em_.in ())) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("CIAO::Plan_Launcher_i: ") + ACE_TEXT ("launch_plan called witn an uninitialized EM.\n"))); + return 0; + } + + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("CIAO::Plan_Launcher_i: " ) + ACE_TEXT ("about to call this->em_->preparePlan\n"))); + } + + ::Deployment::DomainApplicationManager_var dam (this->em_->preparePlan (plan, 1)); + + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("CIAO::Plan_Launcher_i: " ) + ACE_TEXT ("after to call this->em_->preparePlan\n"))); + } + + if (CORBA::is_nil (dam.in ())) + { + ACE_ERROR ((LM_ERROR, + "(%P|%t) CIAO_PlanLauncher:preparePlan call failed: " + "nil DomainApplicationManager reference\n")); + return 0; + } + + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG, + "CIAO_PlanLauncher: Obtained DAM ref \n")); + } + + ::Deployment::Properties_var properties; + ACE_NEW_RETURN (properties, + Deployment::Properties, + 0); + + if (CIAO::debug_level ()) + { + ACE_DEBUG ((LM_DEBUG, + "CIAO_PlanLauncher: start Launch application...\n")); + } + + // Dont not start the Application immediately since it violates + // the semantics of component activation sequence + int start = 0; + + dam->startLaunch (properties.in (), 0); + + if (CIAO::debug_level ()) + ACE_DEBUG ((LM_DEBUG, "[success]\n")); + + // Call finish Launch to complete the connections + if (CIAO::debug_level ()) + ACE_DEBUG ((LM_DEBUG, + "CIAO_PlanLauncher: finish Launch application...\n")); + dam->finishLaunch (start, false); // is_ReDAC by default is <false> + + if (CIAO::debug_level ()) + ACE_DEBUG ((LM_DEBUG, "[success]\n")); + + // Call start to activate components + if (CIAO::debug_level ()) + ACE_DEBUG ((LM_DEBUG, + "CIAO_PlanLauncher: start activating components...\n")); + dam->start (); + + if (CIAO::debug_level ()) + ACE_DEBUG ((LM_DEBUG, "[success]\n")); + + if (CIAO::debug_level ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("CIAO_PlanLauncher: ") + ACE_TEXT ("Application Deployed successfully\n"))); + + map_.bind_dam_reference (plan.UUID.in (), + Deployment::DomainApplicationManager::_duplicate (dam.in ())); + } + catch (const Deployment::ResourceNotAvailable& ex) + { + ACE_ERROR ((LM_ERROR, + "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 ())); + throw Deployment_Failure (""); + } + catch (const Deployment::StartError& ex) + { + ACE_ERROR ((LM_ERROR, + "EXCEPTION: StartError exception caught: %s, %s\n", + ex.name.in (), + ex.reason.in ())); + throw Deployment_Failure (""); + } + catch (const Deployment::InvalidProperty& ex) + { + ACE_ERROR ((LM_ERROR, + "EXCEPTION: InvalidProperty exception caught: %s, %s\n", + ex.name.in (), + ex.reason.in ())); + throw Deployment_Failure (""); + } + catch (const Deployment::InvalidConnection& ex) + { + ACE_ERROR ((LM_ERROR, + "EXCEPTION: InvalidConnection exception caught: %s, %s\n", + ex.name.in (), + ex.reason.in ())); + throw Deployment_Failure (""); + } + catch (const CORBA::Exception& ex) + { + ACE_ERROR ((LM_ERROR, + "CORBA EXCEPTION: %s\n", + ex._info().fast_rep())); + throw Deployment_Failure (""); + } + catch (...) + { + ACE_ERROR ((LM_ERROR, + "EXCEPTION: non-CORBA exception\n")); + throw Deployment_Failure (""); + } + + return CORBA::string_dup (plan.UUID.in ()); + } + + ::Deployment::DomainApplicationManager_ptr + Plan_Launcher_i::get_dam (const char *uuid) + { + if (!this->map_.is_plan_available (uuid)) + { + // Note: we could do an exhaustive (and expensive!) search of the DAMS + // on our EM at this point, if we wanted. In most cases, though, this + // would not produce a different result. + return Deployment::DomainApplicationManager::_nil (); + } + return this->map_.fetch_dam_reference (uuid); + } + + bool + Plan_Launcher_i::teardown_plan (const char *uuid) + { + // Since people could always run another instance of the Plan_Launcher + // executable to tear down a plan, so we could NOT rely on the local + // DAM_Map to fetch DAM obj reference. Instead, we make a remote call + // on ExecutionManager to fetch it. + try + { + ::Deployment::DomainApplicationManager_var dapp_mgr = + this->em_->getManager (uuid); + + if (!::CORBA::is_nil (dapp_mgr.in ())) + { + dapp_mgr->destroyApplication (); + + if (CIAO::debug_level ()) + { + ACE_DEBUG ((LM_DEBUG, "[success]\n")); + } + + // Note that we should ask the DAM to tell EM whether the DAM should + // be destroyed + this->destroy_dam_by_plan (uuid); + } + } + catch (const CORBA::Exception&) + { + // @todo the destroy_dam_by_plan could give a stoperror exception + // we should handle + ACE_ERROR ((LM_ERROR, "Unable to find DomainApplicationManager " + "for plan with uuid: %s\n", uuid)); + return false; + } + + return true; + } + + bool + Plan_Launcher_i::teardown_plan (::Deployment::DomainApplicationManager_ptr dam) + { + if (CIAO::debug_level ()) + { + ACE_DEBUG ((LM_DEBUG, + "CIAO_PlanLauncher: destroy the application.....\n")); + } + + dam->destroyApplication (); + + if (CIAO::debug_level ()) + { + ACE_DEBUG ((LM_DEBUG, "[success]\n")); + } + + this->destroy_dam (dam); + + return true; + } + + void + Plan_Launcher_i::destroy_dam (::Deployment::DomainApplicationManager_ptr dam) + { + if (CIAO::debug_level ()) + { + ACE_DEBUG ((LM_DEBUG, + "CIAO_PlanLauncher: destroy the manager.....\n")); + } + + this->em_->destroyManager (dam); + + if (CIAO::debug_level ()) + { + ACE_DEBUG ((LM_DEBUG, "[success]\n")); + } + } + + void + Plan_Launcher_i::destroy_dam_by_plan (const char* plan_uuid) + { + if (CIAO::debug_level ()) + { + ACE_DEBUG ((LM_DEBUG, + "CIAO_PlanLauncher: destroy the manager.....\n")); + } + + this->em_->destroyManagerByPlan (plan_uuid); + + if (CIAO::debug_level ()) + { + ACE_DEBUG ((LM_DEBUG, "[success]\n")); + } + } + + const char * + Plan_Launcher_i::re_launch_plan (const char *deployment_plan_uri, + const char *package_uri, + bool use_package_name, + bool use_repoman) + { + CIAO::Config_Handlers::XML_File_Intf intf (deployment_plan_uri); + + ::Deployment::DeploymentPlan_var plan = intf.get_plan (); + + // Use the package name(s) or type(s) to modify the location of all the + // artifacts in DeploymentPlan. + if (use_repoman) + { + // @todo use return value + pg_.generate_plan (plan, package_uri, use_package_name); + } + + return this->re_launch_plan (plan.in ()); + } + + const char * + Plan_Launcher_i::re_launch_plan (const ::Deployment::DeploymentPlan &plan) + { + + if (CORBA::is_nil (this->em_.in ())) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("CIAO::Plan_Launcher_i: ") + ACE_TEXT ("re_launch_plan called witn an uninitialized EM.\n"))); + return 0; + } + + this->em_->perform_redeployment (plan); + + if (CIAO::debug_level ()) + { + ACE_DEBUG ((LM_DEBUG, + "CIAO_PlanLauncher: new plan redeployed ...\n")); + } + + return CORBA::string_dup (plan.UUID.in ()); + } + } +} diff --git a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.h b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.h new file mode 100644 index 00000000000..72d46ce68cf --- /dev/null +++ b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.h @@ -0,0 +1,97 @@ +/** + * $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_Impl_Export.h" +#include "ciao/CIAO_common.h" +#include "DAnCE/ExecutionManager/DAM_Map.h" +#include "DAnCE/Interfaces/ExecutionManagerDaemonC.h" +#include "DAnCE/Plan_Generator/Plan_Generator_Impl.h" + +namespace CIAO +{ + namespace Plan_Launcher + { + /** + * @class Plan_Launcher_i + * @brief This class launches and manages deployment plans. + */ + class Plan_Launcher_Impl_Export Plan_Launcher_i + { + public: + class Deployment_Failure { + public: + Deployment_Failure (const ACE_CString &error) + : error_ (error) + { + } + + ACE_CString error_; + }; + + Plan_Launcher_i (); + + + bool init (const char *em_ior, + CORBA::ORB_ptr orb, + bool use_repoman = false, + bool rm_use_naming = false, + const char *rm_name = 0); + + /** + * @brief Launch a plan, given a deployment plan URI + * @param deployment_plan_uri A uri that points ot a valid deployment plan + * @returns a string containing the UUID of the plan. Null indicates failure. + */ + const char * launch_plan (const char *deployment_plan_uri, + const char *package_uri = 0, + bool use_package_name = true, + bool use_repoman = false); + + const char * re_launch_plan (const char *deployment_plan_uri, + const char *package_uri = 0, + bool use_package_name = true, + bool use_repoman = false); + + /** + * @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. + */ + const char * launch_plan (const ::Deployment::DeploymentPlan &plan); + + const char * re_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); + + bool teardown_plan (::Deployment::DomainApplicationManager_ptr dam); + + void destroy_dam (::Deployment::DomainApplicationManager_ptr dam); + + void destroy_dam_by_plan (const char * plan_uuid); + + private: + ::CIAO::ExecutionManagerDaemon_var em_; + + /// Local map for DAMs, to save expensive UUID lookups. + Execution_Manager::DAM_Map map_; + + CIAO::Plan_Generator::Plan_Generator_i pg_; + }; + + } +} + + +#endif /* PLAN_LAUNCHER_IMPL_H */ diff --git a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl_Export.h b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl_Export.h new file mode 100644 index 00000000000..1c85d1b98c9 --- /dev/null +++ b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl_Export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl -s Config_Handlers +// ------------------------------ +#ifndef PLAN_LAUNCHER_IMPL_EXPORT_H +#define PLAN_LAUNCHER_IMPL_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (PLAN_LAUNCHER_IMPL_HAS_DLL) +# define PLAN_LAUNCHER_IMPL_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && PLAN_LAUNCHER_IMPL_HAS_DLL */ + +#if !defined (PLAN_LAUNCHER_IMPL_HAS_DLL) +# define PLAN_LAUNCHER_IMPL_HAS_DLL 1 +#endif /* ! PLAN_LAUNCHER_IMPL_HAS_DLL */ + +#if defined (PLAN_LAUNCHER_IMPL_HAS_DLL) && (PLAN_LAUNCHER_IMPL_HAS_DLL == 1) +# if defined (PLAN_LAUNCHER_IMPL_BUILD_DLL) +# define Plan_Launcher_Impl_Export ACE_Proper_Export_Flag +# define PLAN_LAUNCHER_IMPL_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define PLAN_LAUNCHER_IMPL_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* PLAN_LAUNCHER_IMPL_BUILD_DLL */ +# define Plan_Launcher_Impl_Export ACE_Proper_Import_Flag +# define PLAN_LAUNCHER_IMPL_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define PLAN_LAUNCHER_IMPL_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* PLAN_LAUNCHER_IMPL_BUILD_DLL */ +#else /* PLAN_LAUNCHER_IMPL_HAS_DLL == 1 */ +# define Plan_Launcher_Impl_Export +# define PLAN_LAUNCHER_IMPL_SINGLETON_DECLARATION(T) +# define PLAN_LAUNCHER_IMPL_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* PLAN_LAUNCHER_IMPL_HAS_DLL == 1 */ + +// Set PLAN_LAUNCHER_IMPL_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (PLAN_LAUNCHER_IMPL_NTRACE) +# if (ACE_NTRACE == 1) +# define PLAN_LAUNCHER_IMPL_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define PLAN_LAUNCHER_IMPL_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !PLAN_LAUNCHER_IMPL_NTRACE */ + +#if (PLAN_LAUNCHER_IMPL_NTRACE == 1) +# define PLAN_LAUNCHER_IMPL_TRACE(X) +#else /* (PLAN_LAUNCHER_IMPL_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define PLAN_LAUNCHER_IMPL_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (PLAN_LAUNCHER_IMPL_NTRACE == 1) */ + +#endif /* PLAN_LAUNCHER_IMPL_EXPORT_H */ + +// End of auto generated file. |