diff options
author | William R. Otte <wotte@dre.vanderbilt.edu> | 2011-11-25 20:53:21 +0000 |
---|---|---|
committer | William R. Otte <wotte@dre.vanderbilt.edu> | 2011-11-25 20:53:21 +0000 |
commit | 384c0c61aca518936ef2199d374856a8becbeffa (patch) | |
tree | a32bbef5fbb5e454b78c086fbb7b602a635e0b2b | |
parent | f395ed4c974efe71c40d03c55105d7641280a0e9 (diff) | |
download | ATCD-384c0c61aca518936ef2199d374856a8becbeffa.tar.gz |
-rw-r--r-- | DAnCE/dance/Plan_Launcher/Plan_Launcher.cpp | 129 | ||||
-rw-r--r-- | DAnCE/dance/Plan_Launcher/Plan_Launcher_Base.h | 5 | ||||
-rw-r--r-- | DAnCE/dance/Plan_Launcher/Plan_Launcher_Base_Impl_T.cpp | 69 | ||||
-rw-r--r-- | DAnCE/dance/Plan_Launcher/Plan_Launcher_Base_Impl_T.h | 3 |
4 files changed, 206 insertions, 0 deletions
diff --git a/DAnCE/dance/Plan_Launcher/Plan_Launcher.cpp b/DAnCE/dance/Plan_Launcher/Plan_Launcher.cpp index 68b0a676ca1..a822e8faea8 100644 --- a/DAnCE/dance/Plan_Launcher/Plan_Launcher.cpp +++ b/DAnCE/dance/Plan_Launcher/Plan_Launcher.cpp @@ -31,6 +31,7 @@ namespace FINISHLAUNCH, START, STOPAPP, + STARTAPP, TEARDOWN, INVALID }; @@ -121,6 +122,7 @@ usage(const ACE_TCHAR*) ACE_TEXT ("(Requires Plan, UUID, or APP/AM references\n") ACE_TEXT ("\t--stop-application\t\t\tStop an application, but not destroy DAM\n") + ACE_TEXT ("\t--start-application\t\t\t Start an application from existing DAM\n") ACE_TEXT ("\t-f|--force\t\t\tDo not stop teardown on errors") @@ -168,6 +170,7 @@ parse_args(int argc, ACE_TCHAR *argv[], Options &options) get_opt.long_option(ACE_TEXT("domain-timeout"), ACE_Get_Opt::ARG_REQUIRED); get_opt.long_option(ACE_TEXT("domain-file"), ACE_Get_Opt::ARG_REQUIRED); get_opt.long_option(ACE_TEXT("stop-application"), ACE_Get_Opt::NO_ARG); + get_opt.long_option(ACE_TEXT("start-application"), ACE_Get_Opt::NO_ARG); int c; ACE_CString s; @@ -342,6 +345,17 @@ parse_args(int argc, ACE_TCHAR *argv[], Options &options) break; } if ((ACE_OS::strcmp (get_opt.long_option (), + ACE_TEXT ("start-application")) == 0)) + { + DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, + (LM_DEBUG, DLINFO + ACE_TEXT ("Plan_Launcher::parse_args - ") + ACE_TEXT ("Setting mode for starting app from existing AM: %C\n"), + get_opt.opt_arg ())); + options.mode_ = Options::STARTAPP; + break; + } + if ((ACE_OS::strcmp (get_opt.long_option (), ACE_TEXT ("domain-timeout")) == 0)) { DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, @@ -395,6 +409,17 @@ parse_args(int argc, ACE_TCHAR *argv[], Options &options) return false; } + if ((options.mode_ == Options::STARTAPP) + // Either way (EM/NM), we ca use a combination of a AM and a APP. + && !(options.am_ior_)) + { + DANCE_ERROR (DANCE_LOG_EMERGENCY, + (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher::parse_args - ") + ACE_TEXT ("Invalid set of plan identification ") + ACE_TEXT ("as required for start application\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. @@ -644,6 +669,106 @@ stop_plan (const Options &opts, } int +start_application (const Options &opts, + DAnCE::Plan_Launcher_Base *pl_base, + const ::Deployment::DeploymentPlan *plan, + CORBA::ORB_ptr orb) +{ + CORBA::Object_var am; + CORBA::Object_var app; + + int rc = 0; + + if (opts.am_ior_) + { + DANCE_DEBUG (DANCE_LOG_MAJOR_EVENT, + (LM_DEBUG, DLINFO + ACE_TEXT ("Plan_Launcher::teardown_plan - ") + ACE_TEXT ("Starting application with explicitly ") + ACE_TEXT ("nominated AM IOR.\n"))); + am = orb->string_to_object (opts.am_ior_); + } + else + { + DANCE_ERROR (DANCE_LOG_EMERGENCY, + (LM_DEBUG, DLINFO + ACE_TEXT ("Plan_Launcher::stop_plan - ") + ACE_TEXT ("Start application curently requires an AM reference\n"))); + return -1; + } + + try + { + pl_base->start_application (am.in (), app.out ()); + + + DANCE_DEBUG (DANCE_LOG_MAJOR_EVENT, + (LM_NOTICE, DLINFO + ACE_TEXT ("Plan_Launcher::launch_plan - ") + ACE_TEXT ("Successfully deployed application\n"))); + + if (!opts.output_) + return 0; + + ACE_TString app_output; + + if (opts.output_prefix_) + app_output = opts.output_prefix_; + else + app_output = ACE_TEXT_CHAR_TO_TCHAR (opts.uuid_); + + app_output += ACE_TEXT ("_APP.ior"); + + DANCE_DEBUG (DANCE_LOG_MINOR_EVENT, + (LM_DEBUG, DLINFO + ACE_TEXT ("Plan_Launcher::start_application - ") + ACE_TEXT ("Writing Application IOR to <%s>\n"), + app_output.c_str ())); + + CORBA::String_var tmp = orb->object_to_string (app.in ()); + write_IOR (app_output.c_str (), + tmp.in ()); + + } + catch (const DAnCE::Deployment_Failure &ex) + { + if (!opts.quiet_) + { + DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO + ACE_TEXT ("Plan_Launcher::teardown_plan - ") + ACE_TEXT ("Application Teardown failed, exception: %C\n"), + ex.ex_.c_str ())); + } + rc = 1; + } + catch (const CORBA::Exception &ex) + { + if (!opts.quiet_) + { + DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO + ACE_TEXT ("Plan_Launcher::teardown_plan - ") + ACE_TEXT ("Application Teardown failed, ") + ACE_TEXT ("caught CORBA exception %C\n"), + ex._info ().c_str ())); + } + rc = 1; + } + catch (...) + { + if (!opts.quiet_) + { + DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO + ACE_TEXT ("Plan_Launcher::teardown_plan - ") + ACE_TEXT ("Application Teardown failed, ") + ACE_TEXT ("caught unknown C++ exception\n"))); + } + rc = 1; + } + + return rc; +} + +int teardown_plan (const Options &opts, DAnCE::Plan_Launcher_Base *pl_base, const ::Deployment::DeploymentPlan *plan, @@ -1092,6 +1217,10 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[]) retval = stop_plan (options, pl_base.get (), dp, orb.in ()); break; + case Options::STARTAPP: + retval = start_application (options, pl_base.get (), dp, orb.in ()); + break; + default: if (!options.quiet_) { diff --git a/DAnCE/dance/Plan_Launcher/Plan_Launcher_Base.h b/DAnCE/dance/Plan_Launcher/Plan_Launcher_Base.h index e0a00edee7b..34187cfc231 100644 --- a/DAnCE/dance/Plan_Launcher/Plan_Launcher_Base.h +++ b/DAnCE/dance/Plan_Launcher/Plan_Launcher_Base.h @@ -15,6 +15,7 @@ #include "dance/Deployment/Deployment_DeploymentPlanC.h" #include "dance/Deployment/Deployment_ConnectionC.h" +#include "dance/Deployment/Deployment_ApplicationManagerC.h" #include "dance/Plan_Launcher/Plan_Launcher_Export.h" namespace DAnCE @@ -29,6 +30,10 @@ namespace DAnCE virtual const char * launch_plan (const ::Deployment::DeploymentPlan &plan, CORBA::Object_out am, CORBA::Object_out app) = 0; + + /// Starts a new instance of a plan from an existing ApplicationManager reference. + virtual void start_application (CORBA::Object_ptr am, + CORBA::Object_out app) = 0; /// Invokes prepareplan for the provided plan, returning a reference to /// the ApplicationManager. diff --git a/DAnCE/dance/Plan_Launcher/Plan_Launcher_Base_Impl_T.cpp b/DAnCE/dance/Plan_Launcher/Plan_Launcher_Base_Impl_T.cpp index add10f5c1a9..3c765b61416 100644 --- a/DAnCE/dance/Plan_Launcher/Plan_Launcher_Base_Impl_T.cpp +++ b/DAnCE/dance/Plan_Launcher/Plan_Launcher_Base_Impl_T.cpp @@ -565,6 +565,75 @@ Plan_Launcher_Base_Impl< Manager, AppManager, Application> template <typename Manager, typename AppManager, typename Application> void Plan_Launcher_Base_Impl< Manager, AppManager, Application> +::start_application (CORBA::Object_ptr am, + CORBA::Object_out app) +{ + DANCE_TRACE ("Plan_Launcher_Base_Impl::start_application"); + + try + { + std::string filename = "Redeployment"; + filename += ".timing"; + outfile_.open (filename.c_str ()); + + ACE_High_Res_Timer timer; + timer.reset (); + timer.start (); + + ::Deployment::Connections_var conns; + + CORBA::Object_var app = this->start_launch (am, + 0, + conns.out ()); + + this->finish_launch (app.in (), + conns, + false); + + this->start (app.in ()); + + + timer.stop (); + + ACE_hrtime_t elapsed (0); + timer.elapsed_microseconds (elapsed); + outfile_ << "Total plan deployment time: " << elapsed << '\n'; + + outfile_.close (); + + DANCE_DEBUG (DANCE_LOG_MAJOR_EVENT, + (LM_DEBUG, DLINFO + ACE_TEXT ("Plan_Launcher_Base_Impl::start_application - ") + ACE_TEXT ("Application Deployed successfully\n"))); + + app = app._retn (); + } + catch (const CORBA::Exception& ex) + { + char buf[1024]; + ACE_OS::sprintf (buf, "Plan_Launcher_Base_Impl::start_application - CORBA EXCEPTION: <%s>\n", + ex._info().fast_rep()); + DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, + (LM_ERROR, DLINFO ACE_TEXT("%C"), buf)); + throw Deployment_Failure (buf); + } + catch (const Deployment_Failure &) + { + throw; + } + catch (...) + { + char buf[1024]; + ACE_OS::sprintf (buf, "Plan_Launcher_Base_Impl::start_application - EXCEPTION: non-CORBA exception\n"); + DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, + (LM_ERROR, DLINFO ACE_TEXT("%C"), buf)); + throw Deployment_Failure (buf); + } +} + +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) { diff --git a/DAnCE/dance/Plan_Launcher/Plan_Launcher_Base_Impl_T.h b/DAnCE/dance/Plan_Launcher/Plan_Launcher_Base_Impl_T.h index 9b8bbb0abf4..a331a4c5bcf 100644 --- a/DAnCE/dance/Plan_Launcher/Plan_Launcher_Base_Impl_T.h +++ b/DAnCE/dance/Plan_Launcher/Plan_Launcher_Base_Impl_T.h @@ -54,6 +54,9 @@ namespace DAnCE CORBA::Object_out am, CORBA::Object_out app); + virtual void start_application (CORBA::Object_ptr 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, |