From 91d124b16e975c774446b122bd3d76219925173a Mon Sep 17 00:00:00 2001 From: nshankar Date: Tue, 10 Oct 2006 23:15:24 +0000 Subject: Tue Oct 10 23:12:25 UTC 2006 Nishanth Shankaran --- .../Interactive_Input_Adapter/Converter.cpp | 160 +++++++++++++++++++++ .../Interactive_Input_Adapter/Converter.h | 39 +++++ .../Interactive_Input_Adapter.idl | 11 ++ .../Interactive_Input_Adapter.mpc | 22 +++ .../Interactive_Input_Adapter_exec.cpp | 75 +++++----- .../Interactive_Input_Adapter_exec.h | 36 +---- 6 files changed, 278 insertions(+), 65 deletions(-) create mode 100644 Input_Adapters/Interactive_Input_Adapter/Converter.cpp create mode 100644 Input_Adapters/Interactive_Input_Adapter/Converter.h diff --git a/Input_Adapters/Interactive_Input_Adapter/Converter.cpp b/Input_Adapters/Interactive_Input_Adapter/Converter.cpp new file mode 100644 index 00000000000..85c31648059 --- /dev/null +++ b/Input_Adapters/Interactive_Input_Adapter/Converter.cpp @@ -0,0 +1,160 @@ +#include "Converter.h" +namespace CIAO +{ + + namespace RACE + { + + Converter::Converter (int argc, char **argv) + : iia_name_ ("RACE::InteractiveInput"), + history_ (false) + { + try + { + this->orb_ = CORBA::ORB_init (argc, argv, ""); + // Resolve naming service + CORBA::Object_var ns_tmp = + this->orb_->resolve_initial_references ("NameService"); + ::CosNaming::NamingContext_var ns = + ::CosNaming::NamingContext::_narrow (ns_tmp.in ()); + ::CosNaming::Name ns_name; + CORBA::ULong i = 0; + ACE_Tokenizer tok (this->iia_name_.rep ()); + tok.delimiter_replace (':', 0); + tok.delimiter_replace ('/', 0); + char *name_element = 0; + while ((name_element = tok.next ()) != 0) + { + ns_name.length (ns_name.length () + 1); + ns_name[i].id = CORBA::string_dup (name_element); + ++i; + } + + /// now try to resolve the reference to the IIA. + CORBA::Object_var iia_tmp = ns->resolve (ns_name); + this->iia_ = + ::CIAO::RACE::Interactive_Input_Adapter::_narrow (iia_tmp.in ()); + + this->plan_gen_.init (this->orb_); + + } + catch (CORBA::Exception &ex) + { + ACE_PRINT_EXCEPTION (ex, "Error in initializing the Injector!\n"); + } + + } + + Converter::~Converter () + {} + + + int + Converter::convert (OperationalString &op_string, + ::Deployment::DeploymentPlan &plan) + { + plan.label = op_string.name; + + plan.UUID = op_string.UUID; + + plan.connection = op_string.dataLinks; + + plan.infoProperty = op_string.properties; + + int position; + + for (CORBA::ULong itr = 0; itr < op_string.instances.length (); ++itr) + { + ::CIAO::RACE::InstanceDescription op_instance = + op_string.instances [itr]; + if (this->plan_gen_.generate_plan + (plan, + op_instance.suggestedImpl.in (), + position)) + { + ::Deployment::InstanceDeploymentDescription instance; + instance.name = op_instance.name; + instance.node = CORBA::string_dup ("Satellite"); + instance.implementationRef = position; + instance.configProperty = op_instance.configProperty; + CORBA::ULong cur_len = plan.instance.length (); + plan.instance.length (cur_len+1); + plan.instance [cur_len] = instance; + + } + else + { + ACE_ERROR ((LM_ERROR, "Given suggested type is not available " + "in the Repoman!!\n Bailing out....\n")); + return -1; + } + } + + return 0; + } + + int + Converter::deploy_plan (::Deployment::DeploymentPlan &plan) + { + CIAO::RACE::Metadata_var metadata = new OBV_CIAO::RACE::Metadata; + + try + { + + if (this->history_) + { + metadata->command (::CIAO::RACE::TEARDOWN); + metadata->plan (this->previous_); + this->iia_->get_consumer_meta_data ()->push_Metadata (metadata.in ()); + } + + metadata->command (::CIAO::RACE::DEPLOY); + metadata->plan (plan); + this->iia_->get_consumer_meta_data ()->push_Metadata (metadata.in ()); + this->history_ = true; + this->previous_ = plan; + } + catch (CORBA::Exception &ex) + { + ACE_PRINT_EXCEPTION (ex, "Exception caught\n"); + return -1; + } + + catch (...) + { + ACE_ERROR ((LM_ERROR, "(%P|%t) Injector: Unknown exception\n")); + return -1; + } + + return 0; + } + + } +} + + +int main (int argc, char **argv) +{ + try + { + ::CIAO::RACE::Converter converter (argc, argv); + + ::CIAO::RACE::OperationalString op_string; + + ::Deployment::DeploymentPlan plan; + + if (converter.convert (op_string, plan) == 0) + { + converter.deploy_plan (plan); + } + else + { + return -1; + } + } + catch (...) + { + ACE_ERROR ((LM_ERROR, "(%P|%t) Unknown exception\n")); + return -1; + } +} diff --git a/Input_Adapters/Interactive_Input_Adapter/Converter.h b/Input_Adapters/Interactive_Input_Adapter/Converter.h new file mode 100644 index 00000000000..bb150884cd1 --- /dev/null +++ b/Input_Adapters/Interactive_Input_Adapter/Converter.h @@ -0,0 +1,39 @@ +#include "Interactive_Input_AdapterC.h" +#include "ace/OS.h" +#include "ace/SString.h" +#include "orbsvcs/CosNamingC.h" +#include "RACE/common/OpStringC.h" +#include "Plan_Generator_impl.h" +namespace CIAO +{ + namespace RACE + { + + class Converter + { + public: + Converter (int argc, char **argv); + + virtual ~Converter (); + + virtual int convert (OperationalString &op_string, + ::Deployment::DeploymentPlan &plan); + + virtual int deploy_plan (::Deployment::DeploymentPlan &plan); + + private: + ::CIAO::Plan_Generator::Plan_Generator_i plan_gen_; + + ACE_CString iia_name_; + + CORBA::ORB_var orb_; + + CIAO::RACE::Interactive_Input_Adapter_var iia_; + + bool history_; + + ::Deployment::DeploymentPlan previous_; + }; + + } +} diff --git a/Input_Adapters/Interactive_Input_Adapter/Interactive_Input_Adapter.idl b/Input_Adapters/Interactive_Input_Adapter/Interactive_Input_Adapter.idl index 289a2cfab08..987855a3703 100644 --- a/Input_Adapters/Interactive_Input_Adapter/Interactive_Input_Adapter.idl +++ b/Input_Adapters/Interactive_Input_Adapter/Interactive_Input_Adapter.idl @@ -5,6 +5,7 @@ #include #include "RACE/Input_Adapters/Base/Input_Adapter.idl" #include "RACE/common/RACE_common.idl" +#include "ciao/Packaging_Data.idl" module CIAO { @@ -17,9 +18,19 @@ module CIAO public Action command; }; + eventtype Metadata + { + public Action command; + public Deployment::DeploymentPlan plan; + public Deployment::PackageConfiguration package; + }; + component Interactive_Input_Adapter : Input_Adapter { consumes Deploy_Input deployment; + + consumes Metadata meta_data; + }; home Interactive_Input_Adapter_Home manages Interactive_Input_Adapter diff --git a/Input_Adapters/Interactive_Input_Adapter/Interactive_Input_Adapter.mpc b/Input_Adapters/Interactive_Input_Adapter/Interactive_Input_Adapter.mpc index 0b502e74c76..9037c14308e 100644 --- a/Input_Adapters/Interactive_Input_Adapter/Interactive_Input_Adapter.mpc +++ b/Input_Adapters/Interactive_Input_Adapter/Interactive_Input_Adapter.mpc @@ -107,3 +107,25 @@ project(Injector) : ciao_component_dnc, ciao_race_component, taoexe { Injector.cpp } } + +project(Converter) : ciao_component_dnc, ciao_race_component, taoexe, ciao_plan_generator { + after += Interactive_Input_Adapter_exec OpString_stub + exename = converter + libs += Interactive_Input_Adapter_stub \ + Input_Adapter_stub \ + Plan_Analyzer_Interface_stub\ + OpString_stub + + + + IDL_Files { + } + + Header_Files { + Converter.h + } + + Source_Files { + Converter.cpp + } +} diff --git a/Input_Adapters/Interactive_Input_Adapter/Interactive_Input_Adapter_exec.cpp b/Input_Adapters/Interactive_Input_Adapter/Interactive_Input_Adapter_exec.cpp index faabbf88c12..ac79a2c98c3 100644 --- a/Input_Adapters/Interactive_Input_Adapter/Interactive_Input_Adapter_exec.cpp +++ b/Input_Adapters/Interactive_Input_Adapter/Interactive_Input_Adapter_exec.cpp @@ -1,23 +1,4 @@ // $Id$ -// -// **** Code generated by the **** -// **** Component Integrated ACE ORB (CIAO) CIDL Compiler **** -// CIAO has been developed by: -// Center for Distributed Object Computing -// Washington University -// St. Louis, MO -// USA -// http://www.cs.wustl.edu/~schmidt/doc-center.html -// CIDL Compiler has been developed by: -// Institute for Software Integrated Systems -// Vanderbilt University -// Nashville, TN -// USA -// http://www.isis.vanderbilt.edu/ -// -// Information about CIAO is available at: -// http://www.dre.vanderbilt.edu/CIAO - #include "Interactive_Input_Adapter_exec.h" #include "ciao/CIAO_common.h" #include "Config_Handlers/XML_File_Intf.h" @@ -30,11 +11,6 @@ namespace CIAO { namespace CIDL_Interactive_Input_Adapter_Impl { - //================================================================== - // Component Executor Implementation Class: - // Interactive_Input_Adapter_exec_i - //================================================================== - Interactive_Input_Adapter_exec_i::Interactive_Input_Adapter_exec_i (void) { } @@ -43,24 +19,17 @@ namespace CIAO { } - // Supported or inherited operations. - - // Attribute operations. - - // Port operations. - void - Interactive_Input_Adapter_exec_i::push_deployment ( - ::CIAO::RACE::Deploy_Input * ev - ACE_ENV_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException)) + Interactive_Input_Adapter_exec_i::push_deployment + (::CIAO::RACE::Deploy_Input * ev) + throw (CORBA::SystemException) { try { ACE_Auto_Ptr < ::Deployment::DeploymentPlan > dp; ACE_Auto_Ptr < ::Deployment::PackageConfiguration > pcd; - if (ev->plan_uri () != 0) + if (ev->plan_uri () != 0 || ev->plan_uri () != "") { ACE_DEBUG ((LM_DEBUG, "Opening the plan\n")); @@ -111,6 +80,42 @@ namespace CIAO } } + void + Interactive_Input_Adapter_exec_i::push_meta_data + (::CIAO::RACE::Metadata * ev) + throw (CORBA::SystemException) + { + + ACE_DEBUG ((LM_DEBUG, "In push_meta_data\n")); + if (ACE_OS::strcmp (ev->plan ().UUID.in (), "") != 0) + { + /// Now populate the Plan_Action_seq structure. + ::CIAO::RACE::Plan_Actions plan_action_seq; + + /// Create a Plan_Action_seq structure of length 1. + plan_action_seq.length (1); + + plan_action_seq [0].command = ev->command (); + plan_action_seq [0].plan = ev->plan (); + try + { + /// Now invoke the plan_analyzer. + this->context_->get_connection_ingress () + ->analyze_plan (plan_action_seq); + } + catch (CORBA::Exception &ex) + { + ACE_PRINT_EXCEPTION + (ex, "Exception caught in " + "Interactive_Input_Adapter_exec_i::push_meta_data"); + } + catch (...) + { + ACE_ERROR ((LM_ERROR, "Exception caught in push_mata_data\n")); + } + } + } + // Operations from Components::SessionComponent void diff --git a/Input_Adapters/Interactive_Input_Adapter/Interactive_Input_Adapter_exec.h b/Input_Adapters/Interactive_Input_Adapter/Interactive_Input_Adapter_exec.h index 21e12cedad9..33977bcc275 100644 --- a/Input_Adapters/Interactive_Input_Adapter/Interactive_Input_Adapter_exec.h +++ b/Input_Adapters/Interactive_Input_Adapter/Interactive_Input_Adapter_exec.h @@ -1,23 +1,4 @@ // $Id$ -// -// **** Code generated by the **** -// **** Component Integrated ACE ORB (CIAO) CIDL Compiler **** -// CIAO has been developed by: -// Center for Distributed Object Computing -// Washington University -// St. Louis, MO -// USA -// http://www.cs.wustl.edu/~schmidt/doc-center.html -// CIDL Compiler has been developed by: -// Institute for Software Integrated Systems -// Vanderbilt University -// Nashville, TN -// USA -// http://www.isis.vanderbilt.edu/ -// -// Information about CIAO is available at: -// http://www.dre.vanderbilt.edu/CIAO - #ifndef CIAO_INTERACTIVE_INPUT_ADAPTER_EXEC_H #define CIAO_INTERACTIVE_INPUT_ADAPTER_EXEC_H @@ -44,21 +25,17 @@ namespace CIAO { public: Interactive_Input_Adapter_exec_i (void); - virtual ~Interactive_Input_Adapter_exec_i (void); - // Supported or inherited operations. - - // Attribute operations. + virtual ~Interactive_Input_Adapter_exec_i (void); - // Port operations. + virtual void + push_deployment (::CIAO::RACE::Deploy_Input *ev) + throw (CORBA::SystemException); virtual void - push_deployment ( - ::CIAO::RACE::Deploy_Input *ev - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException)); + push_meta_data (::CIAO::RACE::Metadata *mde) + throw (CORBA::SystemException); - // Operations from Components::SessionComponent virtual void set_session_context ( @@ -142,4 +119,3 @@ namespace CIAO #include /**/ "ace/post.h" #endif /* CIAO_INTERACTIVE_INPUT_ADAPTER_EXEC_H */ - -- cgit v1.2.1