diff options
Diffstat (limited to 'TAO/CIAO/DAnCE/DomainApplicationManager')
4 files changed, 206 insertions, 45 deletions
diff --git a/TAO/CIAO/DAnCE/DomainApplicationManager/Deployment_Configuration.cpp b/TAO/CIAO/DAnCE/DomainApplicationManager/Deployment_Configuration.cpp index 394369b12c7..a7123da88b4 100644 --- a/TAO/CIAO/DAnCE/DomainApplicationManager/Deployment_Configuration.cpp +++ b/TAO/CIAO/DAnCE/DomainApplicationManager/Deployment_Configuration.cpp @@ -23,7 +23,7 @@ CIAO::Deployment_Configuration::init (const char *filename) if (filename == 0) { - ACE_ERROR ((LM_ERROR, "CIAO (%P|%t) Deployment_Configuration.cpp" + ACE_ERROR ((LM_ERROR, "DANCE (%P|%t) Deployment_Configuration.cpp" ": Unable to identify the file name \n")); return -1; } @@ -118,14 +118,25 @@ CIAO::Deployment_Configuration::get_node_manager (const char *name if (CORBA::is_nil (entry->int_id_.node_manager_.in ())) { - CORBA::Object_var temp = this->orb_->string_to_object - (entry->int_id_.IOR_.c_str () - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (0); + ACE_TRY + { - entry->int_id_.node_manager_ = - ::Deployment::NodeManager::_narrow (temp.in () - ACE_ENV_ARG_PARAMETER); + CORBA::Object_var temp = this->orb_->string_to_object + (entry->int_id_.IOR_.c_str () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + entry->int_id_.node_manager_ = + ::Deployment::NodeManager::_narrow (temp.in () + ACE_ENV_ARG_PARAMETER); + } + ACE_CATCHANY + { + ACE_ERROR ((LM_ERROR, "DANCE (%P|%t) Deployment_Configuration.cpp: " + "Error while contacting NodeManager %s\n", name)); + ACE_RE_THROW; + } + ACE_ENDTRY; ACE_CHECK_RETURN (0); } return ::Deployment::NodeManager::_duplicate diff --git a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager.mpc b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager.mpc index ed69dfe37e9..263fb68e16e 100644 --- a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager.mpc +++ b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager.mpc @@ -6,7 +6,7 @@ project (DomainApplicationManager): ciao_deployment_svnt { after += ExecutionManager_stub dynamicflags = DOMAINAPPLICATIONMANAGER_BUILD_DLL - + Source_Files { DomainApplicationManager_Impl.cpp Deployment_Configuration.cpp diff --git a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp index 729c5eab0ac..26b4776290a 100644 --- a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp +++ b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp @@ -618,6 +618,12 @@ startLaunch (const ::Deployment::Properties & configProperty, this->synchronize_shared_components_with_node_managers (); } + ACE_CATCH (Deployment::StartError,ex) + { + ACE_DEBUG ((LM_DEBUG, "DAM_Impl:StartError: %s, %s\n", + ex.name.in (), + ex.reason.in ())); + } ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, @@ -798,6 +804,12 @@ finishLaunch (CORBA::Boolean start, // Establish bindings on external/shared components of this deployment plan. this->post_finishLaunch (); } + ACE_CATCH (Deployment::StartError, ex) + { + ACE_ERROR ((LM_ERROR, "DAM_Impl::finishLaunch - StartError: %s, %s\n", + ex.name.in (), + ex.reason.in ())); + } ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, @@ -1024,7 +1036,7 @@ get_outgoing_connections (const Deployment::DeploymentPlan &plan, connections.inout (), is_getting_all_connections, is_search_new_plan - ACE_ENV_ARG_PARAMETER)) + ACE_ENV_ARG_PARAMETER)) return 0; } return connections._retn (); @@ -1093,9 +1105,12 @@ get_outgoing_connections_i (const char * instname, ACE_CString port_name = curr_conn.internalEndpoint[index].portName.in (); - ACE_DEBUG ((LM_ERROR, "Looking: %s,%s \n", - name.c_str (), - port_name.c_str ())); + if (CIAO::debug_level () > 10) + { + ACE_DEBUG ((LM_ERROR, "Looking: %s,%s \n", + name.c_str (), + port_name.c_str ())); + } bool found = false; // Now we have to search in the received @@ -1115,7 +1130,6 @@ get_outgoing_connections_i (const char * instname, ACE_OS::strcmp (curr_rev_conn.portName.in (), port_name.c_str ()) == 0) { - //ACE_DEBUG ((LM_DEBUG, "step5\n")); retv.length (len+1); retv[len].instanceName = instname; retv[len].portName = endpoint.portName.in (); @@ -1277,6 +1291,10 @@ destroyApplication (ACE_ENV_SINGLE_ARG_DECL) CIAO_TRACE("CIAO::DomainApplicationManager_Impl::destroyApplication"); ACE_TRY { + // Passivate shared components also, which should delegate to EM to handle + this->passivate_shared_components (); + + // Passivate all components associated with the plan for (CORBA::ULong i = 0; i < this->num_child_plans_; ++i) { ACE_Hash_Map_Entry <ACE_CString, Chained_Artifacts> *entry = 0; @@ -1300,17 +1318,31 @@ destroyApplication (ACE_ENV_SINGLE_ARG_DECL) ("DomainApplicationManager_Impl::destroyApplication", error.c_str ())); } + ACE_DEBUG ((LM_DEBUG, "DAM_Impl: Invoking passivate on %s\n", + this->node_manager_names_[i].c_str ())); // Invoke ciao_passivate () operation on each cached NodeApplication object. ::Deployment::NodeApplication_ptr my_na = (entry->int_id_).node_application_.in (); my_na->ciao_passivate (); + } + + + // Remove all connections associated with the plan + for (CORBA::ULong i = 0; i < this->num_child_plans_; ++i) + { + ACE_DEBUG ((LM_DEBUG, "DAM:DA Second for loop %s\n", + this->node_manager_names_[i].c_str ())); + + ACE_Hash_Map_Entry <ACE_CString, Chained_Artifacts> *entry = 0; + + this->artifact_map_.find (this->node_manager_names_[i], entry); Deployment::Connections_var connections = this->get_outgoing_connections ( (entry->int_id_).child_plan_.in (), - true, // yes, get *all* the connections + true, // yes, get *all* the connections true, // yes, we search the current plan DomainApplicationManager_Impl::External_Connections ACE_ENV_ARG_PARAMETER); @@ -1332,35 +1364,36 @@ destroyApplication (ACE_ENV_SINGLE_ARG_DECL) if (this->is_shared_component (connections[j].instanceName.in ())) { // ask EM to remove the binding for us + ACE_CString inst_name = connections[j].instanceName.in (); CIAO::Component_Binding_Info * - binding = this->populate_binding_info ( - connections[j].instanceName.in ()); + binding = this->populate_binding_info (inst_name.c_str ()); this->execution_manager_->finalize_global_binding ( *binding, false); - // If this element is the last one in the sequence - if (j == connections->length () - 1) - { - connections->length (connections->length () - 1); - break; - } - - // otherwise, remove this element from the list - for (CORBA::ULong k = j; k < connections->length (); ++k) - { - connections[k] = connections [k + 1]; - connections->length (connections->length () - 1); - } + // Remove all the connections whose "source" component + // is this component instance from the <connections> list + this->purge_connections (connections, + inst_name.c_str ()); } } - entry->int_id_.node_application_->finishLaunch - (connections.in (), - true, // "true" ==> start the components - false // "false" => remove connections - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + if (connections->length () > 0) + { + entry->int_id_.node_application_->finishLaunch + (connections.in (), + true, // "true" ==> start the components + false // "false" => remove connections + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + } + + for (CORBA::ULong i = 0; i < this->num_child_plans_; ++i) + { + ACE_Hash_Map_Entry <ACE_CString, Chained_Artifacts> *entry = 0; + + this->artifact_map_.find (this->node_manager_names_[i], entry); // To invoke <destroy> operations on NodeManagers is the way to go. @@ -1377,6 +1410,8 @@ destroyApplication (ACE_ENV_SINGLE_ARG_DECL) // to clean up all the NodeApplicationManagers associated with this deployment // plan (one NodeApplicationManager per Node per plan). + // We should again activate those shared components + this->activate_shared_components (); } ACE_CATCHANY { @@ -1614,3 +1649,105 @@ subtract_connections (const Deployment::Connections & left, } return retv._retn (); } + +void +CIAO::DomainApplicationManager_Impl:: +purge_connections (Deployment::Connections_var & connections, + const char * inst) +{ + CORBA::ULong total_len = connections->length (); + + for (CORBA::ULong i = 0; i < total_len; ++i) + { + bool found = false; + + // Remove all the connections whose "source" component + // name is <inst> + if (ACE_OS::strcmp (connections[i].instanceName.in (), + inst) == 0) + { + found = true; + + for (CORBA::ULong j = i; j < total_len - 1; ++j) + { + connections[j] = connections[j + 1]; + } + connections->length (total_len - 1); + } + + if (found) + this->purge_connections (connections, inst); + } +} + +void +CIAO::DomainApplicationManager_Impl:: +passivate_shared_components (void) + ACE_THROW_SPEC ((CORBA::SystemException, + Deployment::StartError)) +{ + ACE_TRY + { + // For each "external" component... + CORBA::ULong length = this->shared_->length (); + for (CORBA::ULong j = 0; j < length; ++j) + { + // Construct <Component_Binding_Info> struct for the component + CIAO::Component_Binding_Info * + binding = this->populate_binding_info ( + this->shared_[j].name.in (), + this->shared_[j].plan_uuid.in ()); + + // Invoke <finalize_global_binding> on ExecutionManager + this->execution_manager_->passivate_shared_components ( + *binding); + + delete binding; + } + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "DomainApplicationManager_Impl::passivate_shared_components.\n"); + ACE_RE_THROW; + } + ACE_ENDTRY; + + ACE_CHECK; +} + +void +CIAO::DomainApplicationManager_Impl:: +activate_shared_components (void) + ACE_THROW_SPEC ((CORBA::SystemException, + Deployment::StartError)) +{ + ACE_TRY + { + // For each "external" component... + CORBA::ULong length = this->shared_->length (); + for (CORBA::ULong j = 0; j < length; ++j) + { + // Construct <Component_Binding_Info> struct for the component + CIAO::Component_Binding_Info * + binding = this->populate_binding_info ( + this->shared_[j].name.in (), + this->shared_[j].plan_uuid.in ()); + + // Invoke <finalize_global_binding> on ExecutionManager + this->execution_manager_->activate_shared_components ( + *binding); + + delete binding; + } + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "DomainApplicationManager_Impl::activate_shared_components.\n"); + ACE_RE_THROW; + } + ACE_ENDTRY; + + ACE_CHECK; +} diff --git a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h index 837c6b4291d..f18e5b6206e 100644 --- a/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h +++ b/TAO/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h @@ -58,7 +58,7 @@ namespace CIAO // port objrefs of components within this plan enum Connection_Search_Type { - External_Connections, + External_Connections, Internal_Connections }; @@ -183,6 +183,15 @@ namespace CIAO ACE_THROW_SPEC ((CORBA::SystemException, Deployment::StartError)); + virtual void passivate_shared_components (void) + ACE_THROW_SPEC ((CORBA::SystemException, + Deployment::StartError)); + + virtual void activate_shared_components (void) + ACE_THROW_SPEC ((CORBA::SystemException, + Deployment::StartError)); + + /** * Starts the application. Raises the StartError exception if * starting the application fails. @@ -220,7 +229,7 @@ namespace CIAO // The input parameter is a *new_plan* which has the // same UUID of the existing running plan. - virtual void + virtual void perform_redeployment ( const Deployment::DeploymentPlan & plan ACE_ENV_ARG_DECL_WITH_DEFAULTS) @@ -256,12 +265,12 @@ namespace CIAO /** * Construct <Component_Binding_Info> struct for the component instance. - * + * * @para name component instance name * @para child_uuid child plan uuid string */ CIAO::Component_Binding_Info * - populate_binding_info (const ACE_CString& name, + populate_binding_info (const ACE_CString& name, const ACE_CString& child_uuid); /** @@ -281,9 +290,9 @@ namespace CIAO void synchronize_shared_components_with_node_managers (void); /** - * A helper function to add a list of shared components into + * A helper function to add a list of shared components into * the cached shared component list. - * + * * @para shared A list of shared components to be added. */ void add_shared_components (const Deployment::ComponentPlans & shared); @@ -291,7 +300,7 @@ namespace CIAO /** * A private function to check whether a component is in the shared * component list. - * + * * @para name The name of a component instance. */ bool is_shared_component (const char * name); @@ -313,7 +322,7 @@ namespace CIAO bool is_getting_all_connections = true, bool is_search_new_plan = true, Connection_Search_Type t = Internal_Connections - ACE_ENV_ARG_DECL_WITH_DEFAULTS); + ACE_ENV_ARG_DECL_WITH_DEFAULTS); /// This is a helper function to find the connection for a component. bool @@ -321,7 +330,7 @@ namespace CIAO Deployment::Connections & retv, bool is_ReDAC, bool is_search_new_plan - ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_ENV_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((Deployment::StartError)); /// Dump connections, a static method @@ -335,6 +344,10 @@ namespace CIAO subtract_connections (const Deployment::Connections & left, const Deployment::Connections & right); + void + purge_connections (Deployment::Connections_var & connections, + const char * inst); + protected: /// location of the Domainapplication CORBA::String_var domainapp_path_; |