diff options
Diffstat (limited to 'TAO/CIAO/DAnCE/NodeManager')
-rw-r--r-- | TAO/CIAO/DAnCE/NodeManager/CIAO_Monitor.cpp | 102 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/NodeManager/CIAO_Monitor.h | 13 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/NodeManager/Monitor.mpc | 6 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/NodeManager/MonitorCB.cpp | 14 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/NodeManager/MonitorController.cpp | 110 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/NodeManager/MonitorController.h | 41 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/NodeManager/NodeManager.mpc | 4 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp | 216 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.h | 27 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/NodeManager/Node_Manager.cpp | 79 | ||||
-rw-r--r-- | TAO/CIAO/DAnCE/NodeManager/README | 4 |
11 files changed, 469 insertions, 147 deletions
diff --git a/TAO/CIAO/DAnCE/NodeManager/CIAO_Monitor.cpp b/TAO/CIAO/DAnCE/NodeManager/CIAO_Monitor.cpp index 7c5485adf82..cbd494ac776 100644 --- a/TAO/CIAO/DAnCE/NodeManager/CIAO_Monitor.cpp +++ b/TAO/CIAO/DAnCE/NodeManager/CIAO_Monitor.cpp @@ -56,15 +56,24 @@ int CIAO::CIAO_Monitor::stop () { if (CIAO::debug_level () > 9) { - ACE_DEBUG ((LM_DEBUG , "Inside the get_current_data")); + // ACE_DEBUG ((LM_DEBUG , + // "CIAO_Monitor::Inside the get_current_data of[%s]\n", + // current_domain_->node[0].name.in ())); } - float current_load; + CORBA::Double current_load = 0; + + long user_cpu; + long user_cpu_low; + long sys_cpu; + long idle_time; // get the load average value from the /proc/loadavg - FILE *load_file = ACE_OS::fopen ("/proc/loadavg", "r"); - + FILE *load_file = 0; + + load_file = ACE_OS::fopen ("/proc/stat", "r"); + if (load_file == 0) { // load file cannot be opened .. @@ -72,25 +81,90 @@ int CIAO::CIAO_Monitor::stop () } else { - fscanf (load_file, "%f", ¤t_load); + char buffer [99]; + + // read in the cpu label + fscanf (load_file, "%s", buffer); + + //read the user_cpu + fscanf (load_file, "%ld", &user_cpu); + + //read the user cpu low priority + fscanf (load_file, "%ld", &user_cpu_low); + + //read the system cpu + fscanf (load_file, "%ld", &sys_cpu); + + //read the cpu in idle time .. + fscanf (load_file, "%ld", &idle_time); + + if (CIAO::debug_level () > 9) { - ACE_DEBUG ((LM_DEBUG , "Current load is %d\n",current_load)); + // ACE_DEBUG ((LM_DEBUG , "Current load is %d\n",current_load)); } + + ACE_OS::fclose (load_file); + + + // Calculate the percent CPU + + long current_user_cpu = user_cpu - prev_user_cpu_; + long total_cpu_usage = user_cpu + user_cpu_low + sys_cpu + + idle_time - prev_user_cpu_ - prev_idle_time_ - prev_sys_cpu_ + - prev_user_cpu_low_; + + current_load = (current_user_cpu * 100)/total_cpu_usage; + + // Save the current cpu values in the previous variables + + prev_user_cpu_ = user_cpu; + + prev_user_cpu_low_ = user_cpu_low; + + prev_sys_cpu_ = sys_cpu; + + prev_idle_time_ = idle_time; + } - ACE_OS::fclose (load_file); - CORBA::Any any; - any <<= current_load; + CORBA::Any any; + any <<= current_load; + + // here insert the util value, in the right position + + for (unsigned int i = 0; + i < current_domain_->node[0].resource.length (); + i++) + { + if (!strcmp (current_domain_->node[0].resource[i].name, "Processor")) + { + // ACE_DEBUG ((LM_DEBUG , "CIAO::Monitor::The Resource found\n")); + for (unsigned int j = 0; + j < current_domain_->node[0].resource[i].property.length (); + j++) + { + if (!strcmp ( + current_domain_ + ->node[0].resource[i].property[j].name.in (), + "LoadAverage")) + { + //ACE_DEBUG ((LM_DEBUG , "CIAO::Monitor::The property found\n")); + current_domain_->node[0].resource[i].property[j].kind = + ::Deployment::Quantity; + current_domain_->node[0].resource[i].property[j].value = + any; + } + } + } + } - current_domain_->node[0].resource[0].property[0].kind = ::Deployment::Quantity; - current_domain_->node[0].resource[0].property[0].value = any; - if (CIAO::debug_level () > 9) + if (CIAO::debug_level () > 9) { - ACE_DEBUG ((LM_DEBUG , "Exiting from the get_current_data function\n")); + //ACE_DEBUG ((LM_DEBUG , "CIAO::Monitor::Exiting from the get_current_data function\n")); } - return current_domain_.get (); + return current_domain_.get (); } diff --git a/TAO/CIAO/DAnCE/NodeManager/CIAO_Monitor.h b/TAO/CIAO/DAnCE/NodeManager/CIAO_Monitor.h index d6f15d06802..62fd78da735 100644 --- a/TAO/CIAO/DAnCE/NodeManager/CIAO_Monitor.h +++ b/TAO/CIAO/DAnCE/NodeManager/CIAO_Monitor.h @@ -100,6 +100,19 @@ namespace CIAO /// The Domain data structure auto_ptr <Deployment::Domain> current_domain_; + + ///The previous user cpu + long prev_user_cpu_; + + ///The previous user cpu low priority + long prev_user_cpu_low_; + + ///The previous system cpu + long prev_sys_cpu_; + + ///The previous idle time + long prev_idle_time_; + }; } // CIAO diff --git a/TAO/CIAO/DAnCE/NodeManager/Monitor.mpc b/TAO/CIAO/DAnCE/NodeManager/Monitor.mpc index 911b8bc9ce8..d082a5ecd3c 100644 --- a/TAO/CIAO/DAnCE/NodeManager/Monitor.mpc +++ b/TAO/CIAO/DAnCE/NodeManager/Monitor.mpc @@ -1,12 +1,12 @@ // $Id$ -// MPC file for the Monitor +// MPC file for the Monitor project(*monitorlib): ciao_client_dnc{ after += CIAO_TargetManager_stub includes += $(CIAO_ROOT)/DAnCE/TargetManager - sharedname = ciaomonlib + sharedname = ciaomonlib libs += TargetManager_stub CIAO_Deployment_stub @@ -15,7 +15,7 @@ project(*monitorlib): ciao_client_dnc{ Header_Files { } - + Inline_Files { } diff --git a/TAO/CIAO/DAnCE/NodeManager/MonitorCB.cpp b/TAO/CIAO/DAnCE/NodeManager/MonitorCB.cpp index 5bd59627d2e..c5333d60a77 100644 --- a/TAO/CIAO/DAnCE/NodeManager/MonitorCB.cpp +++ b/TAO/CIAO/DAnCE/NodeManager/MonitorCB.cpp @@ -39,16 +39,20 @@ int CIAO::MonitorCB::update_data (::Deployment::Domain& data) try { - if (CIAO::debug_level () > 9) + if (CIAO::debug_level () > 20) { - ACE_DEBUG ((LM_DEBUG , "---Making a call to update\n")); + ACE_DEBUG ((LM_DEBUG , "CIAO::NM::MonitorCB::Making a call to update\n")); } target_mgr_->updateDomain (elements , domain , update_kind); } - catch (CORBA::Exception&) + catch (CORBA::Exception& ex) { - ACE_DEBUG ((LM_DEBUG, "Unknown Exception")); + //ACE_DEBUG ((LM_DEBUG, "CIAO::NM::MonitorCB::Unknown Exception\n")); + //ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "NM::MonitorCB::updateDomain"); + } + catch (...) + { + // ignore } - return 0; } diff --git a/TAO/CIAO/DAnCE/NodeManager/MonitorController.cpp b/TAO/CIAO/DAnCE/NodeManager/MonitorController.cpp index fc009f1b3fe..dd1c987a434 100644 --- a/TAO/CIAO/DAnCE/NodeManager/MonitorController.cpp +++ b/TAO/CIAO/DAnCE/NodeManager/MonitorController.cpp @@ -16,10 +16,15 @@ #include "MonitorCB.h" #include "CIAO_common.h" + #include "ace/Log_Msg.h" #include "ace/DLL.h" #include "ace/SString.h" +#include "NodeManager_Impl.h" + + + namespace CIAO { typedef MonitorBase* (*MonitorFactory) (void); @@ -36,18 +41,22 @@ namespace CIAO CIAO::MonitorController::MonitorController (CORBA::ORB_ptr orb, ::Deployment::Domain& domain, - ::Deployment::TargetManager_ptr target + ::Deployment::TargetManager_ptr target, + ::CIAO::NodeManager_Impl_Base* node_mgr ) : target_facet_i_ (::Deployment::TargetManager::_duplicate (target)), terminate_flag_ (0), orb_ (orb), - initial_domain_ (domain) + initial_domain_ (domain), + node_mgr_ (node_mgr), + monitor_cpu_usage_ (0), + add_component_pid_ (1) { } int CIAO::MonitorController::svc (void) { - ACE_DLL dll; + ACE_DLL dll; // forming the library name ACE_CString lib_name = ACE_DLL_PREFIX; @@ -74,6 +83,7 @@ int CIAO::MonitorController::svc (void) { ACE_TRACE ((LM_DEBUG "Inside the init call\n")); + // here creating the monitor object monitor_.reset ((MonitorBase*) factory ()); monitor_->initialize_params (initial_domain_, target_facet_i_.in (), @@ -83,30 +93,108 @@ int CIAO::MonitorController::svc (void) // Start the Monitor monitor_->start (orb_); auto_ptr <CIAO::MonitorCB> monitor_callback (new CIAO::MonitorCB (orb_, - target_facet_i_.in (), - interval)); + target_facet_i_.in (), + interval)); + + // check if cpu needs to be monitored or not + for (unsigned int i = 0;i < initial_domain_.node[0].resource.length ();i++) + { + if (!strcmp (initial_domain_.node[0].resource[i].name, "Processor")) + monitor_cpu_usage_ = 1; + } + + // Wait for system to stabilize itself + ACE_OS::sleep (interval); + // The loop in which UpdateData is called while (!terminating ()) { + + //ACE_DEBUG ((LM_DEBUG , "=The Terminate is %d\n", terminate_flag_)); + + + // if monitoring of cpu is enable , monitor , else dont do + // anything + ::Deployment::Domain* domain; + + if (monitor_cpu_usage_) + domain = monitor_->get_current_data (); + else + domain = &initial_domain_; + + + + // ****** add component data ******************* + + NodeManager_Impl_Base::Component_Ids cids = + node_mgr_->get_component_detail (); + + // Here save the old resource length + int counter = domain->node[0].resource.length (); + + // if pid is already added , dont add + if (add_component_pid_) + { + // then add more resource element to the + // domain structure + // ACE_DEBUG ((LM_DEBUG , "Going to add CID/PID data\n")); + int new_res_size = domain->node[0].resource.length () + + cids.cid_seq_.size (); + + domain->node[0].resource.length (new_res_size); + + ACE_Unbounded_Set_Iterator<ACE_CString> iter (cids.cid_seq_); + + for (iter = cids.cid_seq_.begin (); + iter != cids.cid_seq_.end (); + iter++,counter++) + { + domain->node[0].resource[counter].name = + CORBA::string_dup ("Component"); + domain->node[0].resource[counter].resourceType.length (0); + + // Have one property for now + domain->node[0].resource[counter].property.length (1); + domain->node[0].resource[counter].property[0].name = + CORBA::string_dup ((*iter).c_str ()); + domain->node[0].resource[counter].property[0].kind = + ::Deployment::Quantity; + domain->node[0].resource[counter].property[0].dynamic = + 0; + domain->node[0].resource[counter].property[0].value <<= + CORBA::Long (cids.process_id_); + + // ACE_DEBUG ((LM_DEBUG , "The process id is [%d]\n", + // CORBA::Long (cids.process_id_))); + } + // set the add_component_pid_ to 0 + add_component_pid_ = 0; + } + + //******add compoennt data + + monitor_callback->update_data (*domain); + // data will be updated in intervals of 10 secs. // in the latest version of spec , this value will // come from Execution Manager ACE_OS::sleep (interval); - // ACE_DEBUG ((LM_DEBUG , "=The Terminate is %d\n", terminate_flag_)); - ::Deployment::Domain* domain = - monitor_->get_current_data (); - monitor_callback->update_data (*domain); } monitor_->stop (); } + // here delete the monitor object before + // unloading the library + monitor_.reset (); + + // unload the library dll.close (); if (CIAO::debug_level () > 9) { - ACE_DEBUG ((LM_DEBUG , "Terminating Monitor\n")); + ACE_DEBUG ((LM_DEBUG , "CIAO::Monitor::Terminating Monitor\n")); } return 0; } @@ -124,7 +212,7 @@ void CIAO::MonitorController::terminate () guard, lock_ ); - ACE_DEBUG ((LM_DEBUG , "WITHIN TERMINATE CALL ......")); + //ACE_DEBUG ((LM_DEBUG , "WITHIN TERMINATE CALL ......\n")); terminate_flag_=1; } diff --git a/TAO/CIAO/DAnCE/NodeManager/MonitorController.h b/TAO/CIAO/DAnCE/NodeManager/MonitorController.h index 9fc62beed8b..9a02042022b 100644 --- a/TAO/CIAO/DAnCE/NodeManager/MonitorController.h +++ b/TAO/CIAO/DAnCE/NodeManager/MonitorController.h @@ -15,6 +15,8 @@ #define MONITOR_CONTROLLER_H #include "NodeManager_svnt_export.h" +#include "Deployment_BaseC.h" + #include "TargetManager/TargetManagerC.h" #include "ace/Task.h" #include "ace/Auto_Ptr.h" @@ -23,7 +25,6 @@ #include "ace/Synch.h" - /** * @namespace CIAO * @@ -36,6 +37,8 @@ namespace CIAO class MonitorBase; + class NodeManager_Impl_Base; + /** * @class MonitorController * @@ -66,46 +69,56 @@ namespace CIAO * thread */ void terminate (); - - + + /// The Constructor. MonitorController (CORBA::ORB_ptr orb, ::Deployment::Domain& domain, - ::Deployment::TargetManager_ptr target + ::Deployment::TargetManager_ptr target, + ::CIAO::NodeManager_Impl_Base* node_mgr ); - + ~MonitorController (); protected: - + /** * @function terminating. * @brief returns the terminating flag * @return bool The terminting state of the thread */ bool terminating (); - + /// The monitor object auto_ptr <MonitorBase> monitor_; - + /// The TargetManagerImpl object CIAO::TargetManagerImpl_var target_impl_cmp_; - + /// The TargetManager Facet .... Deployment::TargetManager_var target_facet_i_; - + /// The terminate flag_ bool terminate_flag_; - + //Thread Mutex for synchronizing call ACE_SYNCH_MUTEX lock_; - + // the ORB pointer .. CORBA::ORB_ptr orb_; - + /// The initial domain ::Deployment::Domain initial_domain_; + + /// The Node Manager + ::CIAO::NodeManager_Impl_Base* node_mgr_; + + /// flag tells ; what to monitor + bool monitor_cpu_usage_; + + /// TO add component pid or not .. + bool add_component_pid_; }; } // CIAO - + #endif diff --git a/TAO/CIAO/DAnCE/NodeManager/NodeManager.mpc b/TAO/CIAO/DAnCE/NodeManager/NodeManager.mpc index ec5eabcca8a..192fe6f31f0 100644 --- a/TAO/CIAO/DAnCE/NodeManager/NodeManager.mpc +++ b/TAO/CIAO/DAnCE/NodeManager/NodeManager.mpc @@ -8,10 +8,10 @@ project(NodeManager_svnt): ciao_component_dnc, iortable, ifr_client, dance_exten libs += NodeManager_stub NodeApplicationManager TargetManager_stub CIAO_NoOp_Configurator includes += $(CIAO_ROOT)/ciao $(CIAO_ROOT)/DAnCE/Interfaces $(CIAO_ROOT)/DAnCE/TargetManager dynamicflags = NODEMANAGER_SVNT_BUILD_DLL - + IDL_Files { } - + Source_Files { ../Interfaces/NodeManagerS.cpp NodeManager_Impl.cpp diff --git a/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp b/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp index db1c0883454..052b5bdbfc0 100644 --- a/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp +++ b/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.cpp @@ -3,21 +3,22 @@ #include "NodeManager_Impl.h" #include "../NodeApplicationManager/NodeApplicationManager_Impl.h" #include "ace/Log_Msg.h" +#include <errno.h> CIAO::NodeManager_Impl_Base::NodeManager_Impl_Base (const char *name, - CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - const char * nodeapp_loc, - const char * nodeapp_options, - int spawn_delay) + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + const char * nodeapp_loc, + const char * nodeapp_options, + int spawn_delay) ACE_THROW_SPEC ((CORBA::SystemException)) - : orb_ (CORBA::ORB::_duplicate (orb)), - poa_ (PortableServer::POA::_duplicate (poa)), - name_ (CORBA::string_dup (name)), - nodeapp_location_ (CORBA::string_dup (nodeapp_loc)), - nodeapp_options_ (CORBA::string_dup (nodeapp_options)), - callback_poa_ (PortableServer::POA::_nil ()), - spawn_delay_ (spawn_delay) + : orb_ (CORBA::ORB::_duplicate (orb)), + poa_ (PortableServer::POA::_duplicate (poa)), + name_ (CORBA::string_dup (name)), + nodeapp_location_ (CORBA::string_dup (nodeapp_loc)), + nodeapp_options_ (CORBA::string_dup (nodeapp_options)), + callback_poa_ (PortableServer::POA::_nil ()), + spawn_delay_ (spawn_delay) { } @@ -71,48 +72,88 @@ void CIAO::NodeManager_Impl_Base::shutdown (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { + this->orb_->shutdown (0 ACE_ENV_ARG_PARAMETER); ACE_CHECK; } void CIAO::NodeManager_Impl_Base::joinDomain (const Deployment::Domain & domain, - Deployment::TargetManager_ptr target, - Deployment::Logger_ptr - ACE_ENV_ARG_DECL) + Deployment::TargetManager_ptr target, + Deployment::Logger_ptr + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { -// ACE_THROW (CORBA::NO_IMPLEMENT ()); -// Here start the Monitor - CIAO_TRACE("CIAO::NodeManager_Impl_Base::joinDomain"); - - ::Deployment::Domain this_domain = domain; -// MonitorController* monitor_controller - monitor_controller_.reset ( - new MonitorController (orb_.in (), - this_domain, - target)); - - if (CIAO::debug_level () > 9) - { - ACE_DEBUG ((LM_DEBUG , "Before Activate")); - } + // ACE_THROW (CORBA::NO_IMPLEMENT ()); + // Here start the Monitor + CIAO_TRACE("CIAO::NodeManager_Impl_Base::joinDomain"); + + ::Deployment::Domain this_domain = domain; + + monitor_controller_.reset ( + new MonitorController (orb_.in (), + this_domain, + target, + this)); + + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG , "Before Activate\n")); + } /// Activate the Monitor Controller to //start the monitoring - monitor_controller_->activate (); + monitor_controller_->activate (); - if (CIAO::debug_level () > 9) - { - ACE_DEBUG ((LM_DEBUG , "After Activate")); - } + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG , "Monitor Activated\n")); + } } void CIAO::NodeManager_Impl_Base::leaveDomain (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { - //Implementation undefined. - ACE_THROW (CORBA::NO_IMPLEMENT ()); + // Delete the monitor , this will also terminate the thread + monitor_controller_.reset (); +} + +CORBA::Long +CIAO::NodeManager_Impl_Base::set_priority ( + const char * plan_id, + const char * cid, + const ::Deployment::Sched_Params & nm_params + ACE_ENV_ARG_DECL_WITH_DEFAULTS + ) + ACE_THROW_SPEC ((::CORBA::SystemException)) + +{ + ACE_CString key (plan_id); + key += "@"; + key += this->name_.in (); + + if (CIAO::debug_level () > 10) + { + ACE_DEBUG ((LM_DEBUG , "Inside the set_priority\n")); + ACE_DEBUG ((LM_DEBUG , "pid = [%s] , cid = [%s]\n", key.c_str () , cid)); + } + + try { + CORBA::Object_var obj = + this->poa_->id_to_reference (this->map_.get_nam (key)); + + Deployment::NodeApplicationManager_var nam = + Deployment::NodeApplicationManager::_narrow (obj.in ()); + + return nam->set_priority (cid, nm_params); + } + catch (CORBA::Exception& ex) + { + + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "(%P|%t) NodeManager_Impl::set_priority ()\t\n"); + ACE_RE_THROW; + } } ::Components::FacetDescriptions * @@ -123,7 +164,7 @@ get_all_facets (ACE_CString & name) if (this->comp_facets_map_.find (name.c_str (), entry) != 0) ACE_DEBUG ((LM_ERROR, "(%P|%t) - NodeManager_Impl_Base::get_all_facets - " - "No component with name [%s] was found in the NodeManager\n", name.c_str ())); + "No component with name [%s] was found in the NodeManager\n", name.c_str ())); CORBA::ULong facet_len = entry->int_id_->length (); @@ -150,7 +191,7 @@ get_all_consumers (ACE_CString & name) if (this->comp_consumers_map_.find (name.c_str (), entry) != 0) ACE_DEBUG ((LM_ERROR, "(%P|%t) - NodeManager_Impl_Base::get_all_facets - " - "Component [%s] was not found in the NodeManager\n", name.c_str ())); + "Component [%s] was not found in the NodeManager\n", name.c_str ())); CORBA::ULong consumer_len = entry->int_id_->length (); @@ -197,10 +238,10 @@ CIAO::NodeManager_Impl_Base::preparePlan (const Deployment::DeploymentPlan &plan if (! this->validate_plan (plan)) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) NodeManager <%s>:prepare_plan:Plan_Error.\n", - plan.instance[0].node.in ())); + plan.instance[0].node.in ())); ACE_DEBUG ((LM_DEBUG, "(%P|%t) All component instances hosted in the " - "same component server must have the " - "same \"resourceName\" defined.\n")); + "same component server must have the " + "same \"resourceName\" defined.\n")); ACE_THROW_RETURN (Deployment::PlanError (), Deployment::NodeApplicationManager::_nil ()); @@ -329,8 +370,8 @@ CIAO::NodeManager_Impl_Base::preparePlan (const Deployment::DeploymentPlan &plan void CIAO::NodeManager_Impl_Base::destroyManager - (Deployment::NodeApplicationManager_ptr manager - ACE_ENV_ARG_DECL) +(Deployment::NodeApplicationManager_ptr manager + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Deployment::StopError, Deployment::InvalidReference)) @@ -338,7 +379,6 @@ CIAO::NodeManager_Impl_Base::destroyManager CIAO_TRACE("CIAO::NodeManager_Impl::destroyManager"); ACE_TRY { - printf("Entering NM_Impl::destroyManager\n"); // Deactivate this object PortableServer::ObjectId_var id = this->poa_->reference_to_id (manager @@ -355,7 +395,6 @@ CIAO::NodeManager_Impl_Base::destroyManager this->poa_->deactivate_object (id.in () ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - printf("Exiting NM_Impl::destroyManager\n"); } ACE_CATCH (PortableServer::POA::WrongAdapter, ex) { @@ -398,6 +437,9 @@ destroyPlan (const Deployment::DeploymentPlan & plan CORBA::ULong const length = plan.instance.length (); for (CORBA::ULong i = 0; i < length; ++i) { + ACE_DEBUG ((LM_DEBUG, "NM_DP - forloop instance %s\n", + plan.instance[i].name.in ())); + Reference_Count_Map::ENTRY *entry = 0; if (this->ref_count_map_.find (plan.instance[i].name.in (), entry) == 0) { @@ -406,23 +448,25 @@ destroyPlan (const Deployment::DeploymentPlan & plan if (entry->int_id_.count_ == 0) { // Remove this component from the shared set + ACE_DEBUG ((LM_DEBUG, "\tremoving shared...\n")); this->shared_components_.remove (plan.instance[i].name.in ()); - + ACE_DEBUG ((LM_DEBUG, "\tunbinding from the ref count map\n")); // Unbind this component from the ref_count_map_ this->ref_count_map_.unbind (plan.instance[i].name.in ()); + ACE_DEBUG ((LM_DEBUG, "\tunbinding from the facet/consumer maps\n")); // Unbind this component from the facet/consumer maps if (this->comp_facets_map_.unbind ( - plan.instance[i].name.in ()) != 0 || + plan.instance[i].name.in ()) != 0 || this->comp_consumers_map_.unbind ( - plan.instance[i].name.in ()) != 0) + plan.instance[i].name.in ()) != 0) { ACE_TRY_THROW (Deployment::StopError ("NodeManager_Impl_Base::destroyPlan ", "Unable to find component instance")); } } - } + } } // Find the NAM from the map and invoke the destroyPlan() operation on @@ -434,10 +478,12 @@ destroyPlan (const Deployment::DeploymentPlan & plan Deployment::NodeApplicationManager_var nam = Deployment::NodeApplicationManager::_narrow (obj.in ()); + // Reset each NAM about the shared components information Deployment::ComponentPlans_var shared = this->get_shared_components_i (); + ACE_DEBUG ((LM_DEBUG, "contacting the nams - set shared components\n")); nam->set_shared_components (shared.inout ()); - + ACE_DEBUG ((LM_DEBUG, "contacting the nams destroyApplication\n")); nam->destroyApplication (0); @@ -486,8 +532,8 @@ CIAO::NodeManager_Impl_Base::get_shared_components_i (void) { // should never happen ACE_DEBUG ((LM_ERROR, "Component [%s] in the list of shared component, " - "was not found in the NodeManager ref count map.\n", - (*iter).c_str ())); + "was not found in the NodeManager ref count map.\n", + (*iter).c_str ())); } } @@ -523,6 +569,9 @@ validate_plan (const Deployment::DeploymentPlan &plan) const char * resource_id = 0; CORBA::ULong i = 0; + // Update the name of ourself + this->name_ = plan.instance[0].node.in (); + for (i = 0; i < plan.instance.length (); ++i) { if (plan.instance[i].deployedResource.length () != 0) @@ -531,9 +580,10 @@ validate_plan (const Deployment::DeploymentPlan &plan) // the "resourceValue" field represents the policy_set_id, so we // are checking to make sure that all component instances have // the same server_resource_id. - resource_id = - plan.instance[i].deployedResource[0].resourceName.in (); - break; + + //resource_id = + // plan.instance[i].deployedResource[0].resourceName.in (); + //break; } } if (i == plan.instance.length ()) // No server resource id has been set for any instance @@ -542,7 +592,7 @@ validate_plan (const Deployment::DeploymentPlan &plan) for (i = 0; i < plan.instance.length (); ++i) { const char * my_resource_id; - if (plan.instance[i].deployedResource.length () == 0) + if (true || plan.instance[i].deployedResource.length () == 0) { continue; } @@ -560,17 +610,31 @@ validate_plan (const Deployment::DeploymentPlan &plan) return true; } + +void CIAO::NodeManager_Impl_Base:: +push_component_id_info (Component_Ids comps) +{ + components_ = comps; +} + +CIAO::NodeManager_Impl_Base::Component_Ids +CIAO::NodeManager_Impl_Base:: +get_component_detail () +{ + return components_; +} + CIAO::NodeManager_Impl::~NodeManager_Impl () { } CIAO::NodeManager_Impl:: NodeManager_Impl (const char *name, - CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - const char * nodeapp_loc, - const char * nodeapp_options, - int spawn_delay) + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + const char * nodeapp_loc, + const char * nodeapp_options, + int spawn_delay) : NodeManager_Impl_Base (name, orb, poa, nodeapp_loc, nodeapp_options, spawn_delay) {} @@ -596,12 +660,12 @@ CIAO::Static_NodeManager_Impl::~Static_NodeManager_Impl () CIAO::Static_NodeManager_Impl:: Static_NodeManager_Impl (const char *name, - CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - const char * nodeapp_loc, - const char * nodeapp_options, - int spawn_delay, - Static_Config_EntryPoints_Maps* static_config_entrypoints_maps) + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + const char * nodeapp_loc, + const char * nodeapp_options, + int spawn_delay, + Static_Config_EntryPoints_Maps* static_config_entrypoints_maps) : NodeManager_Impl_Base (name, orb, poa, nodeapp_loc, nodeapp_options, spawn_delay), static_config_entrypoints_maps_ (static_config_entrypoints_maps) {} @@ -613,20 +677,22 @@ create_node_app_manager (CORBA::ORB_ptr orb, ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { - ACE_DEBUG ((LM_DEBUG, "creating static_node_app_manager\n")); + if (CIAO::debug_level () > 10) + ACE_DEBUG ((LM_DEBUG, "creating static_node_app_manager\n")); + CIAO::NodeApplicationManager_Impl_Base *app_mgr; ACE_NEW_THROW_EX (app_mgr, - CIAO::Static_NodeApplicationManager_Impl (orb, - poa, - this->static_config_entrypoints_maps_), - CORBA::NO_MEMORY ()); + CIAO::Static_NodeApplicationManager_Impl (orb, + poa, + this->static_config_entrypoints_maps_), + CORBA::NO_MEMORY ()); return app_mgr; } void CIAO::Static_NodeManager_Impl::destroyManager - (Deployment::NodeApplicationManager_ptr manager - ACE_ENV_ARG_DECL) +(Deployment::NodeApplicationManager_ptr manager + ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, Deployment::StopError, Deployment::InvalidReference)) diff --git a/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.h b/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.h index bae08351a45..1003f18327e 100644 --- a/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.h +++ b/TAO/CIAO/DAnCE/NodeManager/NodeManager_Impl.h @@ -123,6 +123,17 @@ namespace CIAO get_shared_components (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((::CORBA::SystemException)); + /// RACE specific extension. Modify the priority of a node application + /// process. + + virtual ::CORBA::Long + set_priority ( + const char * plan_id, + const char * cid, + const ::Deployment::Sched_Params & nm_params + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((::CORBA::SystemException)); + // ********* CIAO Specific Helper functions ************ virtual ::Components::FacetDescriptions * @@ -139,6 +150,19 @@ namespace CIAO set_all_consumers (ACE_CString &name, const ::Components::ConsumerDescriptions_var & consumers); + // ********* Function added for getting component ids... + + struct Component_Ids + { + ACE_Unbounded_Set <ACE_CString> cid_seq_; + pid_t process_id_; + }; + + virtual void push_component_id_info (Component_Ids comps); + + + Component_Ids get_component_detail (); + private: /// Validate the child deployment plan. In particular, we are /// trying to verify that all the component instances within this @@ -232,6 +256,9 @@ namespace CIAO /// The MonitorController pointer auto_ptr <MonitorController> monitor_controller_; + + /// The set of Components + Component_Ids components_; }; diff --git a/TAO/CIAO/DAnCE/NodeManager/Node_Manager.cpp b/TAO/CIAO/DAnCE/NodeManager/Node_Manager.cpp index 7318939fe16..4c3684f5d3c 100644 --- a/TAO/CIAO/DAnCE/NodeManager/Node_Manager.cpp +++ b/TAO/CIAO/DAnCE/NodeManager/Node_Manager.cpp @@ -17,6 +17,7 @@ char *default_svcconf_ = 0; char *svcconf_config_ = 0; char *nodeapp_location_ = 0; char *nodeapp_options_ = 0; +const char *pid_file_name_ = 0; int write_to_ior_ = 0; int register_with_ns_ = 0; int nodeapp_loc_ = 0; @@ -25,29 +26,33 @@ int spawn_delay = 1; int parse_args (int argc, char *argv[]) { - ACE_Get_Opt get_opts (argc, argv, "o:c:m:s:d:na:"); + ACE_Get_Opt get_opts (argc, argv, "o:c:m:s:d:na:p:z:"); int c; while ((c = get_opts ()) != -1) switch (c) { + case 'z': + nodeapp_options_ = "-ORBDebugLevel 10"; + break; + case 'o': // get the file name to write to - ior_file_name_ = get_opts.opt_arg (); - write_to_ior_ = 1; - break; + ior_file_name_ = get_opts.opt_arg (); + write_to_ior_ = 1; + break; case 'c': // get the default svc.conf filename default_svcconf_ = get_opts.opt_arg (); - break; + break; case 'm': // get the svc.conf map configuration filename svcconf_config_ = get_opts.opt_arg (); - break; + break; case 's': //get the location to spawn the NodeApplication nodeapp_location_ = get_opts.opt_arg (); nodeapp_loc_ = 1; - break; + break; case 'a': // Nodeapplication arguments nodeapp_options_ = get_opts.opt_arg (); @@ -55,11 +60,15 @@ parse_args (int argc, char *argv[]) case 'd': //get the spawn delay argument spawn_delay = ACE_OS::atoi (get_opts.opt_arg ()); - break; + break; case 'n': register_with_ns_ = 1; - break; + break; + + case 'p': + pid_file_name_ = get_opts.opt_arg (); + break; case '?': // display help for use of the server. default: @@ -71,6 +80,7 @@ parse_args (int argc, char *argv[]) "-s <NodeApplication executable path>\n" "-a <arguments to NodeApplication>\n" "-d <spawn delay for nodeapplication>\n" + "-p <pid file>\n" "\n", argv [0]), -1); @@ -96,6 +106,23 @@ write_IOR(const char* ior) return 0; } +void +write_pid (void) +{ + if (pid_file_name_ == 0) + return; + + FILE* pid_file = ACE_OS::fopen (pid_file_name_, "w"); + + if (pid_file) + { + ACE_OS::fprintf (pid_file, + "%i", + ACE_OS::getpid ()); + ACE_OS::fclose (pid_file); + } +} + bool register_with_ns (const char * name_context, CORBA::ORB_ptr orb, @@ -116,8 +143,16 @@ register_with_ns (const char * name_context, name.length (1); name[0].id = name_context; - // Register the servant with the Naming Service - naming_context->bind (name, obj); + try + { + // Register the servant with the Naming Service + naming_context->bind (name, obj); + } + catch (CosNaming::NamingContext::AlreadyBound &) + { + ACE_DEBUG ((LM_DEBUG, "Node_Manager.cpp: Name already bound, rebinding....\n")); + naming_context->rebind (name, obj); + } return true; } @@ -170,7 +205,7 @@ main (int argc, char *argv[]) ACE_TRY_CHECK; if (CORBA::is_nil (adapter.in ())) - ACE_ERROR_RETURN ((LM_ERROR, "Nil IORTable\n"), -1); + ACE_ERROR_RETURN ((LM_ERROR, "Nil IORTable\n"), -1); // Create and install the CIAO NodeManager servant CIAO::NodeManager_Impl *node_manager_servant = 0; @@ -184,9 +219,9 @@ main (int argc, char *argv[]) -1); PortableServer::ServantBase_var safe_daemon (node_manager_servant); - + node_manager_servant->init (); - + // Implicit activation CIAO::NodeManager_var node_manager = node_manager_servant->_this (); @@ -232,19 +267,21 @@ main (int argc, char *argv[]) ACE_TRY_CHECK; // Here start the Monitor -/* - MonitorController* monitor_controller - = new MonitorController (orb); + /* + MonitorController* monitor_controller + = new MonitorController (orb); - ACE_DEBUG ((LM_DEBUG , "Before Activate")); - monitor_controller->activate (); - ACE_DEBUG ((LM_DEBUG , "After Activate")); -*/ + ACE_DEBUG ((LM_DEBUG , "Before Activate")); + monitor_controller->activate (); + ACE_DEBUG ((LM_DEBUG , "After Activate")); + */ // Finishing Deployment part ACE_DEBUG ((LM_DEBUG, "CIAO_NodeManager is running...\n")); + write_pid (); + // Run the main event loop for the ORB. orb->run (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; diff --git a/TAO/CIAO/DAnCE/NodeManager/README b/TAO/CIAO/DAnCE/NodeManager/README index 2b6553863eb..09f407f6a65 100644 --- a/TAO/CIAO/DAnCE/NodeManager/README +++ b/TAO/CIAO/DAnCE/NodeManager/README @@ -9,5 +9,5 @@ some port of all the hosts that have NodeApplication install to function properly. The port to run this daemon can be set by using the TAO ORB options command of -ORBEndpoint <port>. This replaces the earlier CIAO_Daemon implementation of CIAO as defined in the CCM -specification. -*/
\ No newline at end of file +specification. +*/ |