From 29a5a6eb62b0a5c2df6d23d58039b10d7aba9989 Mon Sep 17 00:00:00 2001 From: nilabjar Date: Fri, 21 Sep 2007 22:19:58 +0000 Subject: Fri Sep 21 22:18:53 UTC 2007 Nishanth Shanakran --- CIAO/ChangeLog | 23 ++ CIAO/DAnCE/TM_Daemon/DomainDataManager.cpp | 548 +++++++++++++---------------- CIAO/DAnCE/TM_Daemon/DomainDataManager.h | 153 +++----- CIAO/DAnCE/TM_Daemon/Handler_i.cpp | 10 +- CIAO/DAnCE/TM_Daemon/MonitorManager.h | 14 - CIAO/DAnCE/TM_Daemon/Profile_Code.cpp | 49 --- CIAO/DAnCE/TM_Daemon/Profile_Code.h | 41 --- CIAO/DAnCE/TM_Daemon/TM_Daemon.cpp | 39 +- CIAO/DAnCE/TM_Daemon/TM_Daemon.mpc | 10 +- CIAO/DAnCE/TM_Daemon/utils/Exceptions.h | 17 + CIAO/DAnCE/TM_Daemon/utils/RT.cpp | 37 ++ CIAO/DAnCE/TM_Daemon/utils/RT.h | 14 + CIAO/DAnCE/TM_Daemon/utils/Timer.cpp | 88 +++++ CIAO/DAnCE/TM_Daemon/utils/Timer.h | 48 +++ 14 files changed, 540 insertions(+), 551 deletions(-) delete mode 100644 CIAO/DAnCE/TM_Daemon/MonitorManager.h delete mode 100644 CIAO/DAnCE/TM_Daemon/Profile_Code.cpp delete mode 100644 CIAO/DAnCE/TM_Daemon/Profile_Code.h create mode 100644 CIAO/DAnCE/TM_Daemon/utils/Exceptions.h create mode 100644 CIAO/DAnCE/TM_Daemon/utils/RT.cpp create mode 100644 CIAO/DAnCE/TM_Daemon/utils/RT.h create mode 100644 CIAO/DAnCE/TM_Daemon/utils/Timer.cpp create mode 100644 CIAO/DAnCE/TM_Daemon/utils/Timer.h diff --git a/CIAO/ChangeLog b/CIAO/ChangeLog index 91e3d6f6c21..b887060a0f3 100644 --- a/CIAO/ChangeLog +++ b/CIAO/ChangeLog @@ -1,3 +1,26 @@ +Fri Sep 21 22:18:53 UTC 2007 Nishanth Shanakran + + * DAnCE/TM_Daemon/DomainDataManager.h: + * DAnCE/TM_Daemon/DomainDataManager.cpp: + * DAnCE/TM_Daemon/Handler_i.cpp: + * DAnCE/TM_Daemon/TM_Daemon.cpp: + * DAnCE/TM_Daemon/TM_Daemon.mpc: + * DAnCE/TM_Daemon/utils: + + * DAnCE/TM_Daemon/utils/Exceptions.h: + * DAnCE/TM_Daemon/utils/RT.h: + * DAnCE/TM_Daemon/utils/RT.cpp: + * DAnCE/TM_Daemon/utils/Timer.h: + * DAnCE/TM_Daemon/utils/Timer.cpp: + + Cleaned up the implementation. + + * DAnCE/TM_Daemon/MonitorManager.h: + * DAnCE/TM_Daemon/Profile_Code.h: + * DAnCE/TM_Daemon/Profile_Code.cpp: + + Removed these files. + Tue Sep 18 22:41:16 UTC 2007 Nilabja R * DAnCE/NodeApplicationManager/NodeApplicationManager.mpc: diff --git a/CIAO/DAnCE/TM_Daemon/DomainDataManager.cpp b/CIAO/DAnCE/TM_Daemon/DomainDataManager.cpp index 8482e036a32..14bae91a2b9 100644 --- a/CIAO/DAnCE/TM_Daemon/DomainDataManager.cpp +++ b/CIAO/DAnCE/TM_Daemon/DomainDataManager.cpp @@ -4,376 +4,298 @@ #include "tools/Config_Handlers/DD_Handler.h" #include "tools/Config_Handlers/DnC_Dump.h" #include "ciao/CIAO_common.h" - -#include "Profile_Code.h" - #include +#include "utils/Exceptions.h" -const char * domain_file_name = "Domain.cdd"; - -CIAO::DomainDataManager* CIAO::DomainDataManager::global_data_manager_ = 0; - -CIAO::DomainDataManager * -CIAO::DomainDataManager::create (CORBA::ORB_ptr orb, - ::Deployment::TargetManager_ptr target, - const char* dat_file) +namespace CIAO { - if (global_data_manager_ == 0) + DomainDataManager::DomainDataManager (CORBA::ORB_ptr orb, + const char* dat_file) + : orb_ (CORBA::ORB::_duplicate (orb)), + deployment_config_ (orb_.in()), + delay_ (utils::Timer ("delay")), + dat_file_ (dat_file) { - global_data_manager_ = new DomainDataManager (orb , target, dat_file); - } - return global_data_manager_; -} - -// Returns the pointer to the static variable -CIAO::DomainDataManager* -CIAO::DomainDataManager::get_data_manager () -{ - return global_data_manager_; -} - - -void -CIAO::DomainDataManager::delete_data_manger () -{ - if (global_data_manager_) - delete global_data_manager_; -} - -int CIAO::DomainDataManager::update_domain ( - const ::CORBA::StringSeq &, - const ::Deployment::Domain & domainSubset, - ::Deployment::DomainUpdateKind update_kind) -{ - // Update the subset of the domain which the above - // parameter corresponds to - - // ACE_DEBUG ((LM_DEBUG, "[TM] Update domain called\n")); - - //check the type of update .. - - this->update_dynamic (domainSubset); + // @@ TODO need to make the domain filename as a command param. + CIAO::Config_Handlers::DD_Handler dd ("Domain.cdd"); + ::Deployment::Domain* dmn = dd.domain_idl (); + current_domain_ = *dmn; + initial_domain_ = current_domain_; -// switch (update_kind) -// { -// case ::Deployment::UpdateAll: -// case ::Deployment::UpdateDynamic: -// this->update_dynamic (domainSubset); -// break; + //this->current_domain_ = *dd.domain_idl (); + //this->initial_domain_ = *dd.domain_idl (); -// case ::Deployment::Add: -// ex_occur = true; -// break; -// default: -// return 1; -// } - return 0; - -} - -int -CIAO::DomainDataManager::update_dynamic (const ::Deployment::Domain - &domainSubset) -{ - CORBA::ULong const size = current_domain_.node.length (); - this->node_info_map_ [domainSubset.node[0].name.in ()] = domainSubset.node[0]; - - int temp_count; + // set up the profile timers for each node + for (CORBA::ULong i = 0; i < this->current_domain_.node.length (); ++i) + { - this->mutex_.acquire (); - this->response_count_++; - temp_count = this->response_count_; - this->mutex_.release (); +// utils::Timer temp (this->current_domain_.node[i].name.in ()); +// std::pair pair; +// pair.first = this->current_domain_.node[i].name.in (); +// pair.second = temp; +// this->node_timers_.insert (pair); - if (temp_count == current_domain_.node.length ()) - { - // all responses have come in .... now time stamp the event - this->profile_->stop (); - this->profile_->dump (); - for (std::map::iterator itr = this->profile_nodes_.begin (); - itr != this->profile_nodes_.end (); - itr++) + this->node_timers_ [this->current_domain_.node[i].name.in ()] = + new utils::Timer (this->current_domain_.node[i].name.in ()); + } + if (this->call_all_node_managers () != 0) { - (*itr).second->dump (); + throw new utils::Initialization_Exception (); } - this->got_all_response_ = true; + // Wait for all the monitors to upload their obj. refs + sleep (10); + this->get_monitor_obj_ref (); } -// CORBA::Double load; -// domainSubset.node[0].resource[0].property[0].value >>= load; -// ACE_DEBUG ((LM_DEBUG, "The current load is %f\n", load)); - - - profile_nodes_[domainSubset.node[0].name.in ()]->stop (); - - -// CORBA::ULong response_time; - -// domainSubset.node[0].qos_seq[0].value >>= response_time; - -// ACE_DEBUG ((LM_DEBUG, "The response time is %u\n", response_time)); - - return 0; -} - -CIAO::DomainDataManager:: -DomainDataManager (CORBA::ORB_ptr orb, - ::Deployment::TargetManager_ptr target, - const char* dat_file) - : orb_ (CORBA::ORB::_duplicate (orb)), - deployment_config_ (orb_.in()), - dat_file_ (dat_file), - profile_ (new Profile_Code ("Tst")) -{ - CIAO::Config_Handlers::DD_Handler dd (domain_file_name); - ::Deployment::Domain* dmn = dd.domain_idl (); - - if (CIAO::debug_level () > 9) - ::Deployment::DnC_Dump::dump (*dmn); - - current_domain_ = *dmn; - initial_domain_ = current_domain_; - - // update_node_status (); - - // set up the profile timers for each node - - for (int i = 0;i < current_domain_.node.length ();i++) - { - profile_nodes_[current_domain_.node[i].name.in ()] = - new Profile_Code (current_domain_.node[i].name.in ()); - } - - call_all_node_managers (); -} - -int CIAO::DomainDataManager::readin_domain_data () -{ - // here read in Domain data ... - // - return 0; -} - -int CIAO::DomainDataManager::call_all_node_managers () -{ - if ( this->deployment_config_.init (this->dat_file_.c_str ()) == -1 ) + int + DomainDataManager::call_all_node_managers () { - ACE_ERROR ((LM_ERROR, - "TargetM (%P|%t) DomainDataManager.cpp -" - "CIAO::DomainDataManager::call_all_node_managers -" - "ERROR while trying to initialize after reading " - "node details DAT file \n")); - return 0; - } - - CORBA::ULong const length = initial_domain_.node.length (); - - for (CORBA::ULong i=0;i < length;i++) - { - - ::Deployment::NodeManager_var node_manager; - - try - { - node_manager = - deployment_config_.get_node_manager - (initial_domain_.node[i].name.in ()); - } - catch (CORBA::Exception&) + if (this->deployment_config_.init (this->dat_file_.c_str ()) == -1 ) { - ACE_ERROR ((LM_ERROR, "DANCE::TM (%P|%t) DomainDataManager.cpp: " - "Error trying to contact NodeManager %s\n", - initial_domain_.node[i].name.in ())); - continue; + ACE_ERROR ((LM_ERROR, + "TM::DomainDataManager.cpp:" + "call_all_node_managers(): " + "ERROR while trying to initialize after reading " + "node details DAT file \n")); + return -1; } - - if (!CORBA::is_nil (node_manager.in ())) + for (CORBA::ULong i = 0; i < this->initial_domain_.node.length (); ++i) { - Deployment::Logger_ptr log = - Deployment::Logger::_nil (); - ::Deployment::Domain sub_domain; - sub_domain.UUID = CORBA::string_dup("Node-Level-domain"); - sub_domain.label = CORBA::string_dup("Node-level-domain"); - sub_domain.sharedResource.length(0); - sub_domain.interconnect.length(0); - sub_domain.bridge.length(0); - sub_domain.infoProperty.length(0); - sub_domain.node.length (1); - sub_domain.node[0] = initial_domain_.node[i]; + ::Deployment::NodeManager_var node_manager; try { - ACE_DEBUG ((LM_DEBUG, "CAlling Join DOmain\n")); - node_manager->joinDomain (sub_domain, - NULL, - log); + node_manager = + deployment_config_.get_node_manager (this->initial_domain_.node[i].name.in ()); } catch (CORBA::Exception& ex) { - ACE_ERROR ((LM_ERROR , "TM::Error in calling Join Domain==\n")); - ex._tao_print_exception ( - "Exception caught in ""DomainDataManager::joinDomain"); + std::string msg = "TM::DomainDataManager.cpp:call_all_node_managers(): " + "Error trying to contact nodemanager "; + msg += this->initial_domain_.node[i].name.in (); + msg += "\n"; + ACE_PRINT_EXCEPTION (ex, msg.c_str ()); + return -1; } - } - } - return 0; -} + if (!CORBA::is_nil (node_manager.in ())) + { + Deployment::Logger_ptr log = + Deployment::Logger::_nil (); + ::Deployment::Domain sub_domain; + sub_domain.UUID = CORBA::string_dup("Node-Level-domain"); + sub_domain.label = CORBA::string_dup("Node-level-domain"); + sub_domain.sharedResource.length(0); + sub_domain.interconnect.length(0); + sub_domain.bridge.length(0); + sub_domain.infoProperty.length(0); + sub_domain.node.length (1); + sub_domain.node[0] = initial_domain_.node[i]; + try + { + node_manager->joinDomain (sub_domain, NULL, log); + } + catch (CORBA::Exception& ex) + { + std::string msg = "TM::DomainDataManager.cpp:call_all_node_managers(): " + "Error in invoking join domaintrying on "; + msg += this->initial_domain_.node[i].name.in (); + msg += "\n"; + ACE_PRINT_EXCEPTION (ex, msg.c_str ()); + return -1; + } + } + else + { + ACE_ERROR ((LM_ERROR, + "TM::DomainDataManager.cpp:" + "call_all_node_managers(): " + "Object ref. for %s is nil!\n", + this->initial_domain_.node[i].name.in ())); + return -1; + } + } + return 0; + } -void CIAO::DomainDataManager::stop_monitors () -{ - - CORBA::ULong length = initial_domain_.node.length (); - for (CORBA::ULong i=0;i < length;i++) + int + DomainDataManager::update_domain (const ::CORBA::StringSeq &, + const ::Deployment::Domain & domainSubset, + ::Deployment::DomainUpdateKind /*update_kind*/) { - ::Deployment::NodeManager_var node_manager; + // Update the subset of the domain which the above + // parameter corresponds to + // ACE_DEBUG ((LM_DEBUG, "[TM] Update domain called\n")); + + //check the type of update .. + + return this->update_dynamic (domainSubset); + + // switch (update_kind) + // { + // case ::Deployment::UpdateAll: + // case ::Deployment::UpdateDynamic: + // this->update_dynamic (domainSubset); + // break; + + // case ::Deployment::Add: + // ex_occur = true; + // break; + // default: + // return 1; + // } + } - try - { - node_manager = - deployment_config_.get_node_manager - (initial_domain_.node[i].name.in ()); - } - catch (CORBA::Exception&) - { - ACE_ERROR ((LM_ERROR, "DANCE::TM (%P|%t) DomainDataManager.cpp: " - "Error in get Node Manager from Deployment Config %s\n", - initial_domain_.node[i].name.in ())); - continue; - } + int + DomainDataManager::update_dynamic (const ::Deployment::Domain &domainSubset) + { + // CORBA::ULong const size = current_domain_.node.length (); + this->node_info_map_ [domainSubset.node[0].name.in ()] = domainSubset.node[0]; + this->mutex_.acquire (); + this->response_count_++; + CORBA::ULong temp_count = this->response_count_; + this->mutex_.release (); - if (!CORBA::is_nil (node_manager.in ())) + if (temp_count == this->current_domain_.node.length ()) { - try + // all responses have come in .... now timestamp the event + this->delay_.stop (); + this->delay_.dump (); + for (std::map::iterator itr = this->node_timers_.begin (); + itr != this->node_timers_.end (); + itr++) { - node_manager->leaveDomain (); - } - catch (CORBA::Exception& ex) - { - ACE_ERROR ((LM_ERROR , "TM::Error in calling Leave Domain\n")); - ex._tao_print_exception ( - "Exception caught in ""DomainDataManager::leaveDomain"); + (*itr).second->dump (); + } } - } - return; - -} - -int CIAO::DomainDataManager::get_monitor_obj_ref () -{ - // here we have to extract the monitors from the NS - CORBA::Object_var naming_context_object = - orb_->resolve_initial_references ("NameService"); - - CosNaming::NamingContext_var naming_context = - CosNaming::NamingContext::_narrow (naming_context_object.in ()); - - for (CORBA::ULong i = 0;i < initial_domain_.node.length ();i++) - { - CosNaming::Name name (2); - name.length (2); - name[0].id = CORBA::string_dup ("Node_Monitor"); - name[1].id = CORBA::string_dup (initial_domain_.node[i].name); - - CORBA::Object_var object = - naming_context->resolve (name); - node_monitors_.push_back (Onl_Monitor::NM_Monitor::_narrow (object.in ())); - } - return 0; + // CORBA::Double load; + // domainSubset.node[0].resource[0].property[0].value >>= load; + // ACE_DEBUG ((LM_DEBUG, "The current load is %f\n", load)); + this->node_timers_[domainSubset.node[0].name.in ()]->stop (); + // CORBA::ULong response_time; + // domainSubset.node[0].qos_seq[0].value >>= response_time; + // ACE_DEBUG ((LM_DEBUG, "The response time is %u\n", response_time)); -} + return 0; + } -void -CIAO::DomainDataManager::get_all_data (Onl_Monitor::AMI_NM_MonitorHandler_ptr - handler) -{ - this->got_all_response_ = false; - this->mutex_.acquire (); - this->response_count_ = 0; - this->mutex_.release (); - this->profile_->start (); + void + CIAO::DomainDataManager::stop_monitors () + { - for (int i = 0;i < node_monitors_.size ();i++) - { + for (CORBA::ULong i = 0; i < this->initial_domain_.node.length (); i++) + { + ::Deployment::NodeManager_var node_manager; + try + { + node_manager = + this->deployment_config_.get_node_manager + (this->initial_domain_.node[i].name.in ()); + } + catch (CORBA::Exception& ex) + { + std::string msg = "TM::DomainDataManager.cpp:call_all_node_managers(): " + "Error trying to contact nodemanager "; + msg += this->initial_domain_.node[i].name.in (); + msg += "\n"; + ACE_PRINT_EXCEPTION (ex, msg.c_str ()); + continue; + } + + + if (!CORBA::is_nil (node_manager.in ())) + { + try + { + node_manager->leaveDomain (); + } + catch (CORBA::Exception& ex) + { + std::string msg = "TM::DomainDataManager.cpp:call_all_node_managers(): " + "Error in invoking leavedomain on "; + msg += this->initial_domain_.node[i].name.in (); + msg += "\n"; + ACE_PRINT_EXCEPTION (ex, msg.c_str ()); + } + } + } + return; + } - profile_nodes_[current_domain_.node[i].name.in ()]->start (); - node_monitors_[i]->sendc_get_resource_data (handler); - } -} -bool CIAO::DomainDataManager::got_all_response () -{ - return got_all_response_; -} + int + CIAO::DomainDataManager::get_monitor_obj_ref () + { + try + { -int -CIAO::DomainDataManager:: -start_monitor_qos (Onl_Monitor::AMI_NM_MonitorHandler_ptr handler, - ::Deployment::DeploymentPlan& plan) -{ - for (int i = 0;i < node_monitors_.size ();i++) - { - node_monitors_[i]->sendc_monitor_app_QoS (handler, plan); - } - return 0; + // here we have to extract the monitors from the NS + CORBA::Object_var naming_context_object = + this->orb_->resolve_initial_references ("NameService"); -} + CosNaming::NamingContext_var naming_context = + CosNaming::NamingContext::_narrow (naming_context_object.in ()); -void -CIAO::DomainDataManager:: -write_snapshot () -{ + for (CORBA::ULong i = 0; i < this->initial_domain_.node.length (); ++i) + { + CosNaming::Name name (2); + name.length (2); + name[0].id = CORBA::string_dup ("Node_Monitor"); + name[1].id = CORBA::string_dup (initial_domain_.node[i].name); + CORBA::Object_var object = + naming_context->resolve (name); + this->node_monitors_.push_back (Onl_Monitor::NM_Monitor::_narrow (object.in ())); + } + return 0; + } + catch (CORBA::Exception &ex) + { - if (ex_occur) - return; - std::ofstream out ("Snapshot", std::ios::app); + ACE_PRINT_EXCEPTION (ex, "TM::DomainDataManager.cpp:get_monitor_obj_ref(): " + "Exception caught."); + return -1; + } + } - out << "----------------------------------------------------" - << std::endl; - for (CORBA::ULong i = 0; - i < this->current_domain_.node.length (); - i++) + void + CIAO::DomainDataManager::get_all_data (Onl_Monitor::AMI_NM_MonitorHandler_ptr + handler) { - out << "Node" - << "\t" - << this->current_domain_.node[i].name.in () - << std::endl; + this->mutex_.acquire (); + this->response_count_ = 0; + this->mutex_.release (); - CORBA::ULong response_time; + this->delay_.start (); - current_domain_.node[i].qos_seq[0].value >>= response_time; + for (CORBA::ULong i = 0; i < this->node_monitors_.size (); ++i) + { - CORBA::Double cpu_load; - CORBA::Double na_load; + this->node_timers_[this->current_domain_.node[i].name.in ()]->start (); + this->node_monitors_[i]->sendc_get_resource_data (handler); + } + } - for (CORBA::ULong j =0; - j < current_domain_.node[i].resource.length (); - j++) - { - if (!strcmp (current_domain_.node[0].resource[j].name.in (), "NA_Monitor")) - current_domain_.node[i].resource[j].property[0].value >>= na_load; - if (!strcmp (current_domain_.node[0].resource[j].name.in (), "Processor")) - current_domain_.node[i].resource[j].property[0].value >>= cpu_load; + int + CIAO::DomainDataManager:: + start_monitor_qos (Onl_Monitor::AMI_NM_MonitorHandler_ptr handler, + ::Deployment::DeploymentPlan& plan) + { + for (CORBA::ULong i = 0; i < this->node_monitors_.size (); ++i) + { + this->node_monitors_[i]->sendc_monitor_app_QoS (handler, plan); } + return 0; - out << cpu_load - << "\t" - << na_load - << "\t" - << response_time - << std::endl; } - - out.close (); -} + } diff --git a/CIAO/DAnCE/TM_Daemon/DomainDataManager.h b/CIAO/DAnCE/TM_Daemon/DomainDataManager.h index 48ed329e928..1a274cc3790 100644 --- a/CIAO/DAnCE/TM_Daemon/DomainDataManager.h +++ b/CIAO/DAnCE/TM_Daemon/DomainDataManager.h @@ -8,23 +8,25 @@ * It contains the entire Domain information. Both the * initial domain as well as the current available domain. * - * @author Nilabja Roy nilabjar@dre.vanderbilt.edu + * @author Nilabja Roy + * @quthor Nishanth Shanakran */ //=============================================================== #ifndef DOMAIN_DATA_MGRH #define DOMAIN_DATA_MGRH #include "DAnCE/DomainApplicationManager/Deployment_Configuration.h" -//#include "DAnCE/Deployment/Deployment_ResourceCommitmentManagerC.h" #include "NM_MonitorC.h" #include #include #include -#include "Profile_Code.h" +#include "utils/Timer.h" #include "ace/Mutex.h" +using namespace ::CIAO::TM_Daemon; + /** * @namespace CIAO * @@ -33,67 +35,47 @@ */ namespace CIAO { - /** - * @class DomainDataManager - * - * @brief Responsible for maintaining the Domain Information - * - * It maintains both the Current Domain Information as well - * as the Initial domain at full capacity. - */ - class DomainDataManager + /** + * @class DomainDataManager + * + * @brief Responsible for maintaining the Domain Information + * + * It maintains both the Current Domain Information as well + * as the Initial domain at full capacity. + */ + class DomainDataManager { - public : - /** - * @brief This function is called by the other classes to update - * current domain data. - * @param elements The string sequence of elements - * being updated - * @param domainSubset The subset of the actual Domain to - * be updated - * @param updateKind Specifies the update type eg. add, - * delete, update - * - */ - int update_domain (const ::CORBA::StringSeq & elements, - const ::Deployment::Domain & domainSubset, - ::Deployment::DomainUpdateKind updateKind); + public : + /** - * This function calls the constructor of the - * class Domain Data Manager - * @brief This function is called to create the Datamanager - * @param orb The orb pointer - * @param target The Target Manager Object Reference + * Constructor + * + * @param orb the orb pointer. * + * @param dat_file file that contains the objec references to the + * node managers. */ - static DomainDataManager * create (CORBA::ORB_ptr orb, - ::Deployment::TargetManager_ptr target, - const char* dat_file); + DomainDataManager (CORBA::ORB_ptr orb, + const char* dat_file); - /** - * @brief Returns the static pointer to the - * data manager. - * @return DomainDataManager* - * The staic get_data_manger function returning - * the data_manager pointer - */ - static DomainDataManager* get_data_manager (); + ~DomainDataManager (); - /** - * @brief deletes the data manager - */ - static void delete_data_manger (); /** - * @brief Extracts the Obj Refs from the NS - */ - int get_monitor_obj_ref (); - - /** - * @brief checks if all the responses have reached or not + * @brief This function is called by the other classes to update + * current domain data. + * @param elements The string sequence of elements + * being updated + * @param domainSubset The subset of the actual Domain to + * be updated + * @param updateKind Specifies the update type eg. add, + * delete, update + * */ - bool got_all_response (); + int update_domain (const ::CORBA::StringSeq & elements, + const ::Deployment::Domain & domainSubset, + ::Deployment::DomainUpdateKind updateKind); /** * @brief signals all the nodes to send in data @@ -108,62 +90,45 @@ namespace CIAO void stop_monitors (); + private: /** - * @brief Writes snapshot of the application + * Extracts the Obj Refs from the NS */ - void write_snapshot (); - - private: + int get_monitor_obj_ref (); - /** - * The constructor made protected so that no one can create - * it. - * @param orb The orb pointer - * @param target The Target Manager Object Reference - */ - DomainDataManager (CORBA::ORB_ptr orb, - ::Deployment::TargetManager_ptr target, - const char* dat_file - ); /** - * @brief It will read the initial Domain data from - * XML files. + * Read the initial Domain data from XML files. */ int readin_domain_data (); /** - * @brief This function calls all NM and gives them - * the sub-domain + * Invokes all NMs giving them the sub-domain. */ int call_all_node_managers (); /** - * @brief updates the node status by reading it from a file + * Updates the node status by reading it from a file */ bool update_node_status (); /** - * @brief updates the snapshot of the system. + * updates the snapshot of the system. */ int update_dynamic (const ::Deployment::Domain &domainSubset); + /// The ORB pointer CORBA::ORB_var orb_; /// The Deployment Configuration CIAO::Deployment_Configuration deployment_config_; - /// The Initial Domain - contains resources - /// at total capacity + /// The Initial Domain - contains resources at total capacity ::Deployment::Domain initial_domain_; - /// The staic data member , replacing a global variable - static DomainDataManager* global_data_manager_; - - /// The Current Domain - contains resources - /// at current capacity + /// The Current Domain - contains resourcesat current capacity ::Deployment::Domain current_domain_; /// The monitor obj references @@ -172,32 +137,30 @@ namespace CIAO /// The count of responses returned int response_count_; - /// denotes if all responses are there or not - bool got_all_response_; - - /// The profiler class to time code - Profile_Code * profile_; + /// Stores the time taken to obtain the snapshot of the entire domain. + utils::Timer delay_; /// Exception occured - bool ex_occur; + bool ex_occur_; - /// guard - ACE_Thread_Mutex lock; + // /// guard + // ACE_Thread_Mutex lock_; - /// profiles for each node to measure end-to-end for each node - std::map profile_nodes_; + /// Timers for each node to measure data collection delay latency for + /// each node + std::map node_timers_; /// Map used to store "dynamic information" of each node. - std::map node_info_map_; + std::map node_info_map_; - /// the Data file which contains the Node Manager references - std::string dat_file_; + /// the Data file which contains the Node Manager references + std::string dat_file_; /// Thread mutex. ACE_Mutex mutex_; }; -} // CIAO + } #endif /* DOMAIN_DATA_MGRH */ diff --git a/CIAO/DAnCE/TM_Daemon/Handler_i.cpp b/CIAO/DAnCE/TM_Daemon/Handler_i.cpp index bb400cdbb80..352dd250db9 100644 --- a/CIAO/DAnCE/TM_Daemon/Handler_i.cpp +++ b/CIAO/DAnCE/TM_Daemon/Handler_i.cpp @@ -18,15 +18,15 @@ void Monitor_Handler_I::get_resource_data (const ::Deployment::Domain } void Monitor_Handler_I::get_resource_data_excep (::Messaging::ExceptionHolder - * excep_holder) + * /*excep_holder */) { // handle the exception here .... ACE_DEBUG ((LM_DEBUG, "getresource exception occured \n")); - ::Deployment::Domain ami_return_val; + // ::Deployment::Domain ami_return_val; - ::CORBA::StringSeq elements; - ::Deployment::DomainUpdateKind kind = ::Deployment::Add; + // ::CORBA::StringSeq elements; + // ::Deployment::DomainUpdateKind kind = ::Deployment::Add; // manager_->update_domain (elements, ami_return_val, kind); } @@ -36,7 +36,7 @@ void Monitor_Handler_I::monitor_app_QoS (void) // ACE_DEBUG ((LM_DEBUG, "Monitor app QoS returned\n")); } -void Monitor_Handler_I::monitor_app_QoS_excep (::Messaging::ExceptionHolder * excep_holder) +void Monitor_Handler_I::monitor_app_QoS_excep (::Messaging::ExceptionHolder * /*excep_holder*/) { ACE_DEBUG ((LM_DEBUG, "Monitor app QoS exception\n")); } diff --git a/CIAO/DAnCE/TM_Daemon/MonitorManager.h b/CIAO/DAnCE/TM_Daemon/MonitorManager.h deleted file mode 100644 index 45700e8708f..00000000000 --- a/CIAO/DAnCE/TM_Daemon/MonitorManager.h +++ /dev/null @@ -1,14 +0,0 @@ - -#ifndef MONITORMANAGERH -#define MONITORMANAGERH - -class MonitorManager -{ - - /** - * @brief This function calls all NM and gives them - * the sub-domain - */ - int call_all_node_managers (); -}; -#endif diff --git a/CIAO/DAnCE/TM_Daemon/Profile_Code.cpp b/CIAO/DAnCE/TM_Daemon/Profile_Code.cpp deleted file mode 100644 index 05707c37399..00000000000 --- a/CIAO/DAnCE/TM_Daemon/Profile_Code.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "Profile_Code.h" -#include "ace/Time_Value.h" - -Profile_Code::Profile_Code (const std::string& file) - :running_(false) -{ - // open the file ... - this->file_.open (file.c_str (), std::ios::app); -} - - -Profile_Code::~Profile_Code () -{ - this->file_.close (); -} - - -void Profile_Code::start () -{ - - // if still running ... stop it and then run again ... - if (this->running_) - { - this->timer_.stop (); - } - - - // start the timer .... - this->timer_.start (); - - this->running_ = true; -} - - -void Profile_Code::stop () -{ - this->timer_.stop (); - this->timer_.elapsed_microseconds (this->elapsed_time_); - // reset the state - this->running_ = false; - -} - -void -Profile_Code::dump () -{ - this->file_ << this->elapsed_time_ << std::endl; - -} diff --git a/CIAO/DAnCE/TM_Daemon/Profile_Code.h b/CIAO/DAnCE/TM_Daemon/Profile_Code.h deleted file mode 100644 index 8c80a7ce49c..00000000000 --- a/CIAO/DAnCE/TM_Daemon/Profile_Code.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef PROFILE_CODEH -#define PROFILE_CODEH - -#include "ace/High_Res_Timer.h" -#include - -class ACE_High_Res_Timer; - -class Profile_Code -{ -public: - Profile_Code (const std::string &file); - - Profile_Code (){}; - - ~Profile_Code (); - - void start (); - - void stop (); - - void dump (); - - -private: - - /// The high resolution Timer ... - ACE_High_Res_Timer timer_; - - /// Elapsed time. - ACE_hrtime_t elapsed_time_; - - std::ofstream file_; - - /// state of the timer - bool running_; -}; - - - -#endif diff --git a/CIAO/DAnCE/TM_Daemon/TM_Daemon.cpp b/CIAO/DAnCE/TM_Daemon/TM_Daemon.cpp index 7ca1423ecd9..119ace76683 100644 --- a/CIAO/DAnCE/TM_Daemon/TM_Daemon.cpp +++ b/CIAO/DAnCE/TM_Daemon/TM_Daemon.cpp @@ -3,42 +3,16 @@ #include "Config_Handlers/XML_File_Intf.h" #include "Config_Handlers/DnC_Dump.h" #include "Client_Task.h" -// To set RT Sched params. -#include "ace/Sched_Params.h" -#include "ace/OS_NS_errno.h" +#include "utils/RT.h" namespace CIAO { namespace TM_Daemon { - int run_main (int argc, char *argv[]) { - - int priority = - (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO) - + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2; - priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO, - priority); - // Enable FIFO scheduling, e.g., RT scheduling class on Solaris. - - if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO, - priority, - ACE_SCOPE_PROCESS)) != 0) - { - if (ACE_OS::last_error () == EPERM) - { - ACE_DEBUG ((LM_DEBUG, - "server (%P|%t): user is not superuser, " - "test runs in time-shared class\n")); - } - else - ACE_ERROR ((LM_ERROR, - "server (%P|%t): sched_params failed\n")); - } - - + utils::set_priority (); try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); @@ -55,13 +29,12 @@ namespace CIAO poa_manager->activate (); // create the Domain data Manager - DomainDataManager* manager = - DomainDataManager::create (orb, NULL, argv[2]); + DomainDataManager* manager = new DomainDataManager (orb, argv[2]); - // Wait for all the monitors to upload their obj. refs - sleep (10); +// // Wait for all the monitors to upload their obj. refs +// sleep (10); - manager->get_monitor_obj_ref (); +// manager->get_monitor_obj_ref (); ACE_DEBUG ((LM_DEBUG, "After get_monitor_obj_ref\n")); diff --git a/CIAO/DAnCE/TM_Daemon/TM_Daemon.mpc b/CIAO/DAnCE/TM_Daemon/TM_Daemon.mpc index d407cd1c8c0..134b532c384 100644 --- a/CIAO/DAnCE/TM_Daemon/TM_Daemon.mpc +++ b/CIAO/DAnCE/TM_Daemon/TM_Daemon.mpc @@ -6,6 +6,12 @@ project(TM_Daemon): ciao_server_dnc, dance_extension_stub, ciaoexe , ciao_domain IDL_Files { } + Header_Files { + utils/RT.h + utils/Timer.h + utils/Exceptions.h + } + Source_Files { TM_Daemon.cpp Client_Task.cpp @@ -14,6 +20,8 @@ project(TM_Daemon): ciao_server_dnc, dance_extension_stub, ciaoexe , ciao_domain ../NodeManager/NM_MonitorC.cpp $(CIAO_ROOT)/DAnCE/NodeApplication/App_MonitorC.cpp Handler_i.cpp - Profile_Code.cpp + utils/RT.cpp + utils/Timer.cpp + } } diff --git a/CIAO/DAnCE/TM_Daemon/utils/Exceptions.h b/CIAO/DAnCE/TM_Daemon/utils/Exceptions.h new file mode 100644 index 00000000000..582c42d15dc --- /dev/null +++ b/CIAO/DAnCE/TM_Daemon/utils/Exceptions.h @@ -0,0 +1,17 @@ +#ifndef EXCEPTION_H +#define EXCEPTION_H + +namespace CIAO +{ + namespace TM_Daemon + { + namespace utils + { + class Initialization_Exception + {}; + + } + } +} + +#endif diff --git a/CIAO/DAnCE/TM_Daemon/utils/RT.cpp b/CIAO/DAnCE/TM_Daemon/utils/RT.cpp new file mode 100644 index 00000000000..3eeceba7af8 --- /dev/null +++ b/CIAO/DAnCE/TM_Daemon/utils/RT.cpp @@ -0,0 +1,37 @@ +#include "RT.h" + +namespace CIAO +{ + namespace TM_Daemon + { + namespace utils + { + int set_priority () + { + int priority = + (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO) + + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2; + priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO, + priority); + + // Enable FIFO scheduling. + + if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO, + priority, + ACE_SCOPE_PROCESS)) != 0) + { + if (ACE_OS::last_error () == EPERM) + ACE_DEBUG ((LM_DEBUG, + "Utils (%P|%t): user is not superuser, " + "processes runs in time-shared class\n")); + else + ACE_ERROR ((LM_ERROR, + "Utils(%P|%t): set_priority failed\n")); + return -1; + } + return 0; + + } + } + } +} diff --git a/CIAO/DAnCE/TM_Daemon/utils/RT.h b/CIAO/DAnCE/TM_Daemon/utils/RT.h new file mode 100644 index 00000000000..7b4dffcdfba --- /dev/null +++ b/CIAO/DAnCE/TM_Daemon/utils/RT.h @@ -0,0 +1,14 @@ +#include "ace/Sched_Params.h" +#include "ace/OS_NS_errno.h" +#include "ace/Log_Msg.h" + +namespace CIAO +{ + namespace TM_Daemon + { + namespace utils + { + int set_priority (); + } + } +} diff --git a/CIAO/DAnCE/TM_Daemon/utils/Timer.cpp b/CIAO/DAnCE/TM_Daemon/utils/Timer.cpp new file mode 100644 index 00000000000..8ffe09d42d9 --- /dev/null +++ b/CIAO/DAnCE/TM_Daemon/utils/Timer.cpp @@ -0,0 +1,88 @@ +#include "Timer.h" +#include "Exceptions.h" +#include "ace/Time_Value.h" +#include "ace/OS.h" +#include "ace/Log_Msg.h" + +namespace CIAO +{ + namespace TM_Daemon + { + namespace utils + { + + Timer::Timer () + : running_ (false) + {} + + Timer::Timer (const char* file_name) + :running_(false) + { + + // open the file . + this->file_ = ACE_OS::fopen (file_name, "w"); + if (this->file_ == 0) + { + ACE_ERROR ((LM_ERROR, + "TM_Timer::Cannot open output file %s for writing.\n", + this->file_)); + throw new Initialization_Exception (); + } + } + + Timer::Timer (const Timer &timer) + : timer_ (timer.timer_), + elapsed_time_ (timer.elapsed_time_), + file_ (timer.file_), + running_ (timer.running_) + {} + + void + Timer::operator = (const Timer &timer) + { + this->timer_ = timer.timer_; + this->elapsed_time_ = timer.elapsed_time_; + this->file_ = timer.file_; + this->running_ = timer.running_; + } + + + Timer::~Timer () + { + ACE_OS::fclose (this->file_); + } + + + void Timer::start () + { + + // if already running, restart it. + if (this->running_) + { + this->timer_.stop (); + } + + // start the timer. + this->timer_.start (); + + this->running_ = true; + } + + + void Timer::stop () + { + this->timer_.stop (); + this->timer_.elapsed_microseconds (this->elapsed_time_); + // reset the state + this->running_ = false; + + } + + void Timer::dump () + { + ACE_OS::fprintf (this->file_, "%u\n", this->elapsed_time_); + ACE_OS::fflush (this->file_); + } + } + } +} diff --git a/CIAO/DAnCE/TM_Daemon/utils/Timer.h b/CIAO/DAnCE/TM_Daemon/utils/Timer.h new file mode 100644 index 00000000000..aae06bf2085 --- /dev/null +++ b/CIAO/DAnCE/TM_Daemon/utils/Timer.h @@ -0,0 +1,48 @@ +#ifndef TIMER_H +#define TIMER_H +#include "ace/High_Res_Timer.h" + +namespace CIAO +{ + namespace TM_Daemon + { + namespace utils + { + + class Timer + { + public: + Timer (const char* file); + + Timer (const Timer &timer); + + Timer (); + + virtual void operator = (const Timer &timer); + + virtual ~Timer (); + + virtual void start (); + + virtual void stop (); + + virtual void dump (); + + + private: + /// The high resolution timer. + ACE_High_Res_Timer timer_; + + /// Elapsed time. + ACE_hrtime_t elapsed_time_; + + /// output file. + FILE * file_; + + /// state of the timer + bool running_; + }; + } + } +} +#endif -- cgit v1.2.1