diff options
Diffstat (limited to 'modules/CIAO/DAnCE/TargetManager')
19 files changed, 2684 insertions, 0 deletions
diff --git a/modules/CIAO/DAnCE/TargetManager/CmpClient.cpp b/modules/CIAO/DAnCE/TargetManager/CmpClient.cpp new file mode 100644 index 00000000000..12deaa5ac80 --- /dev/null +++ b/modules/CIAO/DAnCE/TargetManager/CmpClient.cpp @@ -0,0 +1,271 @@ +// $Id$ +/** + * @file CmpClient.cpp + * + * @brief This file contains a client of TargetManager. + * + * It picks up the TM ior from the Targetmanager.ior file + * present in the current directory, and makes the calls on the + * TM to getAllResources and getAvailable resources + */ + +#include "ciao/Deployment_DataC.h" +#include "DAnCE/TargetManager/TargetManagerImplC.h" +#include "ace/streams.h" +#include "Config_Handlers/DnC_Dump.h" + +void write_to_file (::Deployment::Domain domain); + +int main (int argc, char* argv[]) +{ + try { + // First initialize the ORB, that will remove some arguments... + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, + "" /* the ORB name, it can be anything! */); + + // There must be at least two arguments, the first is the factory + // name, the rest are the names of the stock symbols we want to + // get quotes for. + if (argc < 2) { + cerr << "Usage: " << argv[0] + << " Factory_IOR ..." << endl; + return 1; + } + + // Use the first argument to create the factory object reference, + // in real applications we use the naming service, but let's do + // the easy part first! + CORBA::Object_var factory_object = + orb->string_to_object (argv[1]); + + // Now downcast the object reference to the appropriate type + CIAO::TargetManagerImpl_var targetCmp = + CIAO::TargetManagerImpl::_narrow (factory_object.in ()); + + // Now get the facet reference from the target Manager Component + ACE_DEBUG((LM_DEBUG, "Making a Call to provide_targetMgr ()\n")); + Deployment::TargetManager_ptr targetI = targetCmp->provide_targetMgr (); + + // Now make calls on the Target Manager facet + + try + { + Deployment::Domain_var domainV = targetI->getAllResources (); + ACE_DEBUG ((LM_DEBUG , "\n\nGetAllResources Returned \n")); + ::Deployment::DnC_Dump::dump (domainV); + } + catch(CORBA::NO_IMPLEMENT &) + { + ACE_DEBUG((LM_DEBUG ,"Error:TargetManager:CORBA::NO_IMPLEMENT thrown\n")); + } + catch(CORBA::Exception &) + { + ACE_DEBUG((LM_DEBUG ,"Error:TargetManager:CORBA Generic Exception \n")); + ACE_DEBUG((LM_DEBUG ,"Error:TargetManager:Exception in TargetManager call\n")); + } + + + // make a call to the commit resources ..... + + + Deployment::DeploymentPlan plan; + + plan.instance.length (2); + + ::Deployment::InstanceDeploymentDescription instance_; + instance_.node = CORBA::string_dup ("foil"); + instance_.deployedResource.length (1); + instance_.deployedResource[0].requirementName = + CORBA::string_dup ("Processor"); + instance_.deployedResource[0].resourceName = + CORBA::string_dup ("CPULoad"); + + instance_.deployedResource[0].property.length (1); + instance_.deployedResource[0].property[0].name = + CORBA::string_dup ("LoadAverage"); + CORBA::Long d = 20; + instance_.deployedResource[0].property[0].value <<= d; + + plan.instance[0] = instance_; + + instance_.node = CORBA::string_dup ("blade30"); + instance_.deployedResource.length (1); + instance_.deployedResource[0].requirementName = + CORBA::string_dup ("Processor"); + instance_.deployedResource[0].resourceName = + CORBA::string_dup ("CPULoad"); + + instance_.deployedResource[0].property.length (1); + instance_.deployedResource[0].property[0].name = + CORBA::string_dup ("LoadAverage"); + d = 50; + + instance_.deployedResource[0].property[0].value <<= d; + + plan.instance[1] = instance_; + + bool resource_available = true; + + try + { + targetI->commitResources(plan); + ACE_DEBUG ((LM_DEBUG , "\n\ncommitResources Returned \n")); + } + catch(CORBA::NO_IMPLEMENT &) + { + cerr << "Error:TargetManager:CORBA::NO_IMPLEMENT thrown" << endl; + } + catch (Deployment::ResourceNotAvailable & e) + { + resource_available = 0; + cout << "TargetManager commitResources ResourceNotAvailable Exception" <<endl; + + ACE_DEBUG ((LM_DEBUG , + "ResourceNotAvailable\n name=[%s]\n elementName=[%s]\n resourceName=[%s]\n \ + resourceType= [%s]\n propertyName=[%s]\n", + e.name.in (), + e.elementName.in (), + e.resourceName.in (), + e.resourceType.in (), + e.propertyName.in ())); + } + catch(CORBA::Exception & ex) + { + cout << "Error:TargetManager:commitResources Exception" <<endl; + cout << "Error:TargetManager:CORBA Generic Exception " << endl; + cerr << "Error:TargetManager:Exception in TargetManager call" << ex << endl; + } + + + // Make a call to release resources , if resource < 0 + try + { + if (!resource_available) + { + targetI->releaseResources(plan); + ACE_DEBUG ((LM_DEBUG , "\n\nreleaseResources Returned \n")); + } + } + catch(CORBA::NO_IMPLEMENT &) + { + cerr << "Error:TargetManager:CORBA::NO_IMPLEMENT thrown" << endl; + } + catch (Deployment::ResourceNotAvailable &) + { + cout << "Error:TargetManager releaseResources ResourceNotAvailable Exception" <<endl; + } + catch(CORBA::Exception & ex) + { + cout << "Error:TargetManager:releaseResources Exception" <<endl; + cout << "Error:TargetManager:CORBA Generic Exception " << endl; + cerr << "Error:TargetManager:Exception in TargetManager call" << ex << endl; + } + + // Here make a call on the TM with update domain and node deletion + + ::Deployment::Domain updated; + updated.node.length (1); + updated.node[0].name = CORBA::string_dup (argv[2]); + + ::CORBA::StringSeq elements; + elements.length (0); + + bool Add = true; + Add = ACE_OS::atoi (argv[3]); + + if (Add) + { + try + { + targetI->updateDomain (elements , updated, ::Deployment::Add); + } + catch(CORBA::NO_IMPLEMENT &) + { + cerr << "Error:TargetManager:CORBA::NO_IMPLEMENT thrown" << endl; + } + catch(CORBA::Exception & ex) + { + cout << "Error:TargetManager:CORBA Generic Exception " << endl; + cerr << "Error:TargetManager:Exception in UpdateDomain call" << ex << endl; + } + } + else + { + try + { + targetI->updateDomain (elements , updated, ::Deployment::Delete); + } + catch(CORBA::NO_IMPLEMENT &) + { + cerr << "Error:TargetManager:CORBA::NO_IMPLEMENT thrown" << endl; + } + catch(CORBA::Exception & ex) + { + cout << "Error:TargetManager:CORBA Generic Exception " << endl; + cerr << "Error:TargetManager:Exception in UpdateDomain call" << ex << endl; + } + } + // Now make a call of getAvailableResources on the TargetManager ... + try + { + Deployment::Domain_var domainV = targetI->getAvailableResources(); + + // here write things to file ... + write_to_file (domainV.in()); + + ACE_DEBUG ((LM_DEBUG , "\n\nGetAvailableResources Returned \n")); + ::Deployment::DnC_Dump::dump (domainV); + } + catch(CORBA::NO_IMPLEMENT &) + { + cerr << "Error:TargetManager:CORBA::NO_IMPLEMENT thrown" << endl; + } + catch(CORBA::Exception & ex) + { + cout << "Error:TargetManager:CORBA Generic Exception " << endl; + cerr << "Error:TargetManager:Exception in TargetManager call" << ex << endl; + } + + // Finally destroy the ORB + orb->destroy (); + } + catch (CORBA::Exception & ex) { + cerr << "Error:TargetManager:CORBA exception raised!" << ex << endl; + } + return 0; +} + +void write_to_file (::Deployment::Domain domain) +{ + for (size_t i = 0;i < domain.node.length ();i++) + { + std::ofstream out (domain.node[i].name.in ()); + + + // write in the node usage ... + for (size_t j = 0;j < domain.node[i].resource.length ();j++) + { + + if (!strcmp (domain.node[i].resource[j].name.in (), "Processor")) + { + CORBA::Double node_cpu; + domain.node[i].resource[j].property[0].value >>= node_cpu; + out << node_cpu << std::endl; + } + if (!strcmp (domain.node[i].resource[j].name.in (), "NA_Monitor")) + { + std::string file_name = "NA_"; + file_name += domain.node[i].name.in (); + std::ofstream na_out (file_name.c_str ()); + CORBA::Double na_node_cpu; + domain.node[i].resource[j].property[0].value >>= na_node_cpu; + na_out << na_node_cpu << std::endl; + na_out.close (); + } + } + + out.close (); + } + +} diff --git a/modules/CIAO/DAnCE/TargetManager/DomainDataManager.cpp b/modules/CIAO/DAnCE/TargetManager/DomainDataManager.cpp new file mode 100644 index 00000000000..da7f59a3b86 --- /dev/null +++ b/modules/CIAO/DAnCE/TargetManager/DomainDataManager.cpp @@ -0,0 +1,738 @@ +// $Id$ +//=============================================================== +/** + * @file DomainDataManager.cpp + * + * @brief Maintains the Domain Information + * + * It contains the entire Domain information.Both the + * initial domain as well as the current available domain. + * + * @author Nilabja Roy nilabjar@dre.vanderbilt.edu + */ +//=============================================================== +#include "DomainDataManager.h" + +#include "Config_Handlers/DD_Handler.h" +#include "Config_Handlers/DnC_Dump.h" +#include "ciao/CIAO_common.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 + ) +{ + if (global_data_manager_ == 0) + { + global_data_manager_ = new DomainDataManager (orb , target); + } + return global_data_manager_; +} + + +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 + + + //check the type of update .. + + switch (update_kind) + { + case ::Deployment::UpdateAll: + case ::Deployment::UpdateAvailable: + break; + case ::Deployment::Add: + add_to_domain (domainSubset); + break; + case ::Deployment::Delete: + delete_from_domain (domainSubset); + break; + default: + break; + } + + int size = current_domain_.node.length (); + + int i; + for (i=0;i < size;i++) + { + if (!strcmp (domainSubset.node[0].name , + current_domain_.node[i].name)) + { + // found a match + // for now overwrite the entire Node info ... + // but later , this has to be changed to overwrite + // only the specific part ... + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG , "TM::Changed the cpu Value\n")); + } + current_domain_.node[i] = domainSubset.node[0]; + break; // finished job ...break + } + } + + if (i == size) + { + // thus the node is new .. add it to current_domain_ + // later change it ... + current_domain_.node.length (size+1); + current_domain_.node[size]=domainSubset.node[0]; + } + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG , + "TM::Inside The update Domain of Manager\n")); + } + return 0; +} + +CIAO::DomainDataManager:: +DomainDataManager (CORBA::ORB_ptr orb, + ::Deployment::TargetManager_ptr target) + : orb_ (CORBA::ORB::_duplicate (orb)), + deployment_config_ (orb_.in()), + target_mgr_ (::Deployment::TargetManager::_duplicate(target)) +{ + // ACE_DEBUG((LM_DEBUG , "Calling DD_HANDLER\n")); + CIAO::Config_Handlers::DD_Handler dd (domain_file_name); + // ACE_DEBUG((LM_DEBUG , "After DD_HANDLER Constructor\n")); + ::Deployment::Domain* dmn = dd.domain_idl (); + // ACE_DEBUG((LM_DEBUG , "After DD_HANDLER domain_idl\n")); + + if (CIAO::debug_level () > 9) + ::Deployment::DnC_Dump::dump (*dmn); + + current_domain_ = *dmn; + initial_domain_ = current_domain_; + + // initialize the provisioning domain + provisioned_data_ = initial_domain_; + + update_node_status (); + + call_all_node_managers (); +} + +::Deployment::Domain* CIAO::DomainDataManager::get_current_domain () +{ + return new ::Deployment::Domain (provisioned_data_); +} + +::Deployment::Domain* CIAO::DomainDataManager::get_initial_domain () +{ + return new ::Deployment::Domain (initial_domain_); +} + +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 ("NodeDetails.dat") == -1 ) + { + 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 (); + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG, "Number of nodes in domain.cdd is : %d\n", 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&) + { + ACE_ERROR ((LM_ERROR, "DANCE::TM (%P|%t) DomainDataManager.cpp: " + "Error trying to contact NodeManager %s\n", + initial_domain_.node[i].name.in ())); + continue; + } + + + if (!CORBA::is_nil (node_manager.in ())) + { + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG, "Trying to contact nodemanager on %s\n", + initial_domain_.node[i].name.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, + target_mgr_.in (), + log); + } + catch (CORBA::Exception& ex) + { + ACE_DEBUG ((LM_DEBUG , "TM::Error in calling Join Domain==\n")); + ex._tao_print_exception ( + "Exception caught in ""DomainDataManager::joinDomain"); + } + } + } + return 0; + +} + +CIAO::Host_NodeManager_seq * CIAO::DomainDataManager::get_node_managers () +{ + ::CIAO::Host_NodeManager_seq* node_mgr_seq = + new ::CIAO::Host_NodeManager_seq (); + node_mgr_seq->length (initial_domain_.node.length ()); + for (unsigned int i=0;i < initial_domain_.node.length ();i++) + { + (*node_mgr_seq)[i].host_ = + CORBA::string_dup (initial_domain_.node[i].name); + ::Deployment::NodeManager_var node_manager = + deployment_config_.get_node_manager (initial_domain_.node[i].name); + // if (node_manager.in () != 0) + { + (*node_mgr_seq)[i].node_mgr_ = ::CIAO::NodeManagerDaemon::_narrow (node_manager.in ()); + } + } + return node_mgr_seq; +} + +CIAO::Host_Infos* CIAO::DomainDataManager::get_cpu_info () +{ + CIAO::Host_Infos* host_info_seq = new CIAO::Host_Infos (); + host_info_seq->length (current_domain_.node.length ()); + + if (CIAO::debug_level () > 9) + ACE_DEBUG ((LM_DEBUG , "TM:: The node length is [%d]", + current_domain_.node.length ())); + + for (unsigned int i=0;i < current_domain_.node.length ();i++) + { + (*host_info_seq)[i].hostname = + CORBA::string_dup (current_domain_.node[i].name); + // ACE_DEBUG ((LM_DEBUG , "The resource length is [%d]", + // current_domain_.node[i].resource.length ())); + + for (unsigned int j = 0;j < current_domain_.node[i].resource.length ();j++) + { + if (!strcmp( + current_domain_.node[i].resource[j].name, + "Processor")) + { + current_domain_.node[i].resource[j].property[0].value + >>= (*host_info_seq)[i].cpu_util; + CORBA::Double d; + current_domain_.node[i].resource[j].property[0].value + >>= d; + // ACE_DEBUG ((LM_DEBUG, "TM::The current cpu util is [%f]\n", d)); + } + } + } + + if (CIAO::debug_level () > 9) + ACE_DEBUG ((LM_DEBUG , "TM::Returning from get_cpu_info")); + + return host_info_seq; +} + +CORBA::Long CIAO::DomainDataManager::get_pid (ACE_CString cmp) +{ + CORBA::Long pid; + + // This is really ineffiecient this is O(n) ; searching all the nodes + // all the resources for a particular component. + // It needs to be stored in some other data structure + + for (unsigned int i=0;i < current_domain_.node.length ();i++) + { + if (CIAO::debug_level () > 9) + ACE_DEBUG ((LM_DEBUG , "TM::The resource length is [%d]", + current_domain_.node[i].resource.length ())); + + for (unsigned int j = 0;j < current_domain_.node[i].resource.length ();j++) + { + // The resource + if (!ACE_OS::strcmp( + current_domain_.node[i].resource[j].name, + "Component") && + ACE_CString (current_domain_.node[i].resource[j].property[0].name) == + cmp) + { + current_domain_.node[i].resource[j].property[0].value + >>= pid; + if (CIAO::debug_level () > 9) + ACE_DEBUG ((LM_DEBUG, + "TM::getpid::The current pid is [%d]\n", pid)); + + } + } // resources + }// nodes + + return pid; +} + +void CIAO::DomainDataManager +::commitResources ( + const ::Deployment::DeploymentPlan & plan) +{ + // commit the resources + // parse into the plan and commit resources ... + + // set the action value + current_action_ = commit; + + // temporary created to guard against exceptions + ::Deployment::Domain temp_provisioned_data = + provisioned_data_; + + for (unsigned int i = 0;i < plan.instance.length ();i++) + { + for (unsigned int j = 0;j < temp_provisioned_data.node.length ();j++) + { + if (!strcmp (plan.instance[i].node.in () , + temp_provisioned_data.node[j].name.in ())) + { + if (CIAO::debug_level () > 9) + ACE_DEBUG ((LM_DEBUG , + "TM::commitResource::Host name matched\n")); + try { + match_requirement_resource ( + plan.instance[i].deployedResource, + temp_provisioned_data.node[j].resource); + } + catch (::Deployment::ResourceNotAvailable& ex) + { + // catch the exception and add parameters + ex.elementName = + CORBA::string_dup (temp_provisioned_data.node[j].name); + + throw ex; + } + } + } + } + + // here commit the commitresources + provisioned_data_ = temp_provisioned_data; +} + + +void CIAO::DomainDataManager:: +releaseResources ( + const ::Deployment::DeploymentPlan& plan) +{ + // release the resources + + + // set the action value + current_action_ = release; + + for (unsigned int i = 0;i < plan.instance.length ();i++) + { + for (unsigned int j = 0;j < provisioned_data_.node.length ();j++) + { + if (!ACE_OS::strcmp (plan.instance[i].node.in () , + provisioned_data_.node[j].name.in ())) + { + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG , + "TM::commitResource::Host name matched\n")); + } + + match_requirement_resource ( + plan.instance[i].deployedResource, + provisioned_data_.node[j].resource); + + } + } + } + +} + + +void CIAO::DomainDataManager:: +match_requirement_resource ( + ::Deployment::InstanceResourceDeploymentDescriptions deployed, + ::Deployment::Resources & available + ) +{ + // here match the deployed to the available + + for (CORBA::ULong i = 0;i < deployed.length ();i++) + { + // for each deployed resource ....search the corresponding + // available resource + for (CORBA::ULong j = 0;j < available.length ();j++) + { + if (!strcmp (deployed[i].requirementName, available[j].name)) + { + if (CIAO::debug_level () > 9) + ACE_DEBUG ((LM_DEBUG , + "TM::commitResource::Requirement name matched\n")); + // search for the resourcename in the resourceType + for (CORBA::ULong k = 0;k < available[j].resourceType.length ();k++) + { + if (!strcmp (deployed[i].resourceName, + available[j].resourceType[k])) + { + if (CIAO::debug_level () > 9) + ACE_DEBUG ((LM_DEBUG , + "TM::commitResource::Resource name matched\n")); + + try { + match_properties (deployed[i].property, + available[j].property); + } + catch (::Deployment::ResourceNotAvailable& ex) + { + // catch the exception and add parameters + ex.resourceType = + CORBA::string_dup (available[j].resourceType[k]); + ex.resourceName = + CORBA::string_dup (available[j].name); + throw ex; + } + } + } + } + } + } + +} + +void CIAO::DomainDataManager:: +match_properties ( + ::Deployment::Properties deployed, + ::Deployment::SatisfierProperties & available) +{ + for (CORBA::ULong i = 0;i < deployed.length ();i++) + { + for (CORBA::ULong j = 0;j < available.length ();j++) + if (!ACE_OS::strcmp (deployed[i].name , available[j].name)) + { + // check kind here ....and then subtract .... + // accordingly , ..this is complex ... better to write + // some specialised algo + // for now assuming Capacity .... + // and tk_double .... + if (CIAO::debug_level () > 9) + ACE_DEBUG ((LM_DEBUG , + "TM::commitResource::Property name matched\n")); + + commit_release_resource (deployed[i] , available[j]); + + } + } +} + +void CIAO::DomainDataManager::commit_release_resource ( + ::Deployment::Property & deployed, + ::Deployment::SatisfierProperty & available) +{ + if (current_action_ == commit) + { + + CORBA::Long required_d; + + if ((deployed.value >>= required_d) == false) + ACE_ERROR ((LM_ERROR, "Failed to extract required amount\n")); + + CORBA::Long available_d; + + if ((available.value >>= available_d) == false) + ACE_ERROR ((LM_ERROR, "failed to extract available amount\n")); + + if (available_d >= required_d) + { + available_d = available_d - required_d; + if (CIAO::debug_level () > 9) + ACE_DEBUG ((LM_DEBUG, "TM::The available is [%f]", + available_d)); + + available.value <<= available_d; + } + else + { + ACE_DEBUG ((LM_DEBUG, "Insufficient resources! Available: %d, Required %d\n", + available_d, required_d)); + throw ::Deployment::ResourceNotAvailable ("", + "", + deployed.name.in (), + "", + ""); + } + + + } + else + { + //must be release + // @todo check return value of >>= + CORBA::Long required_d; + deployed.value >>= required_d; + CORBA::Long available_d; + available.value >>= available_d; + + available_d = available_d + required_d; + + // Should we check for bin > 100 ?????? + + if (CIAO::debug_level () > 9) + ACE_DEBUG ((LM_DEBUG, "TM::The available is [%f]", + available_d)); + + available.value <<= available_d; + } +} + +void CIAO::DomainDataManager::stop_monitors () +{ + + CORBA::ULong length = initial_domain_.node.length (); + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG, "Number of nodes in domain.cdd is : %d\n", 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&) + { + 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; + } + + + if (!CORBA::is_nil (node_manager.in ())) + { + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG, "Trying to contact nodemanager on %s\n", + initial_domain_.node[i].name.in ())); + } + try + { + node_manager->leaveDomain (); + } + catch (CORBA::Exception& ex) + { + ACE_DEBUG ((LM_DEBUG , "TM::Error in calling Leave Domain\n")); + ex._tao_print_exception ( + "Exception caught in ""DomainDataManager::leaveDomain"); + } + } + } + return; + +} + +int CIAO::DomainDataManager::add_to_domain ( + const ::Deployment::Domain& domain) +{ + // here add the domain to the Domain + // right now use only a node + + // got to take care of the fact , that a node can be added , + // while it is still in the domain + + //iterate through the supplied domain + //for each node + // find it in the pristine domain + // and copy it back to the provisioned_domain + + for (CORBA::ULong i = 0;i < domain.node.length ();i++) + { + //find in the pristine domain + ::Deployment::Node a_node; + + if (!this->find_in_initial_domain (domain.node[i].name.in (), + a_node)) + continue; // dont know this node + + //check if already present + if (!this->find_in_provisioned_domain (domain.node[i].name.in (), + a_node)) + { + // add the node to the domain ... + provisioned_data_.node.length (provisioned_data_.node.length () + 1); + provisioned_data_.node[provisioned_data_.node.length () - 1] = + a_node; + } + } + +// ::Deployment::DnC_Dump::dump (this->provisioned_data_); + + ACE_DEBUG ((LM_DEBUG, "TM::Node Up Message Processed\n")); + + return 0; +} + +bool CIAO::DomainDataManager:: +find_in_initial_domain (const char* node_name, + ::Deployment::Node& node) +{ + for (CORBA::ULong i =0; + i < this->initial_domain_.node.length (); + i++) + { + if (ACE_OS::strcmp (node_name, this->initial_domain_.node[i].name.in ()) == 0) + { + node = this->initial_domain_.node[i]; + return true; + } + } + + // not found the node , return a node with an empty name + return false; +} + + +bool CIAO::DomainDataManager:: +find_in_provisioned_domain (const char* node_name, + ::Deployment::Node& node) +{ + for (CORBA::ULong i =0; + i < this->provisioned_data_.node.length (); + i++) + { + if (ACE_OS::strcmp (node_name, this->provisioned_data_.node[i].name.in ()) == 0) + { + node = this->provisioned_data_.node[i]; + return true; + } + } + + // not found the node , return a node with an empty name + return false; +} + +int CIAO::DomainDataManager::delete_from_domain ( + const ::Deployment::Domain& domain) +{ + // validate input + if (domain.node.length () == 0) + return 1; + + if (domain.node.length () > + this->provisioned_data_.node.length ()) + return 0; + + //algo : parse through the provisioned_data + // for each node , find in the deleted domain list + // if not found add it to the updated nodes list + + ::Deployment::Nodes updated_nodes; + bool found = false; + + for (CORBA::ULong j = 0; + j < this->provisioned_data_.node.length (); + j++) + { + found = false; + + for (CORBA::ULong i = 0;i < domain.node.length ();i++) + { + if (strcmp (domain.node[i].name.in (), + this->provisioned_data_.node[j].name.in ()) == 0) + { + found = true; + break; // found the node + } + } + if (found) + continue; + + // not found in the deleted list + + // update the length of the list + updated_nodes.length (updated_nodes.length () + 1); + + // copy the node info + updated_nodes[updated_nodes.length () - 1] = + this->provisioned_data_.node[j]; + + } // for provisioned_data + + // here update the provisioned data + this->provisioned_data_.node = updated_nodes; + + return 1; +} + +int CIAO::DomainDataManager::intimate_planner ( + const ::Deployment::Domain& domain) +{ + // use the connection with the planner and get a reference to the planner + // make a call top the planner + Deployment::Domain d = domain; + return 0; + +} + +bool CIAO::DomainDataManager::update_node_status () +{ + // update the node status here ... + return 0; +} diff --git a/modules/CIAO/DAnCE/TargetManager/DomainDataManager.h b/modules/CIAO/DAnCE/TargetManager/DomainDataManager.h new file mode 100644 index 00000000000..d75e314606d --- /dev/null +++ b/modules/CIAO/DAnCE/TargetManager/DomainDataManager.h @@ -0,0 +1,290 @@ +// $Id$ +//=============================================================== +/** + * @file DomainDataManager.h + * + * @brief Maintains the Domain Information + * + * It contains the entire Domain information. Both the + * initial domain as well as the current available domain. + * + * @author Nilabja Roy nilabjar@dre.vanderbilt.edu + */ +//=============================================================== +#ifndef DOMAIN_DATA_MGRH +#define DOMAIN_DATA_MGRH + +#include "TargetManagerImplC.h" +#include "DAnCE/DomainApplicationManager/Deployment_Configuration.h" + +/** + * @namespace CIAO + * + * @brief The main CIAO namespace + * + */ +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 + { + + 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 + ); + /** + * @brief This function is called the Executor code + * to get the Original Domain data. + * @return Domain* The Initial Domain + * + */ + ::Deployment::Domain* get_initial_domain (); + + /** + * @brief This function is called the Executor code + * to get the Current Domain data. + * @return Domain* The Current Domain + */ + ::Deployment::Domain* get_current_domain (); + + + /** + * 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 + * + */ + static DomainDataManager * create (CORBA::ORB_ptr orb, + ::Deployment::TargetManager_ptr target + ); + + /** + * @brief Returns the static pointer to the + * data manager. + * @return DomainDataManager* + * @description The staic get_data_manger function returning + * the data_manager pointer + */ + static DomainDataManager* get_data_manager (); + + /** + * @brief deletes the data manager + */ + static void delete_data_manger (); + + /** + * @brief returns the sequence of node managers + * object reference + */ + CIAO::Host_NodeManager_seq * + get_node_managers (); + + /** + * @brief returns the node specific cpu utilization + * + * @return CIAO::Host_Infos* + */ + + CIAO::Host_Infos* get_cpu_info (); + + /** + * @brief returns the pid of the component id submitted + * @param cmp The component id + * + * @return process id + */ + CORBA::Long get_pid (ACE_CString cmp); + + /** + * @brief commits the resources that are specified + * in the plan. + * @param plan ::Deployment::DeploymentPlan + * @exception ::Deployment::ResourceNotAvailable thrown + * when the resources mentioned in the plan exceeds + * the current resource. + * @exception ::Deployment::PlanError thrown if the plan has any + * error + * + */ + void commitResources ( + const ::Deployment::DeploymentPlan & plan); + + /** + * @brief The function releases the resources held by a plan + * @param plan ::Deployment::DeploymentPlan the plan whose + * resources are to be released + */ + void releaseResources ( + const ::Deployment::DeploymentPlan& plan); + + /** + * The node manager in turn stops the monitor + * @brief The function makes a call on the leaveDomain on the + * NodeManager + */ + void stop_monitors (); + + protected: + + /** + * 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 + ); + + /** + * @brief It will read the initial Domain data from + * XML files. + */ + int readin_domain_data (); + + /** + * @brief Match the deployed resources to the + * available resource + */ + void match_requirement_resource ( + ::Deployment::InstanceResourceDeploymentDescriptions deployed, + ::Deployment::Resources& available + ); + + /** + * @brief Match the properties of a Requirement to the + * properties of available resource + * @param deployed The deployed Properties + * @param available The available Properties + */ + void match_properties ( + ::Deployment::Properties deployed, + ::Deployment::SatisfierProperties& available); + + + /// The different actiona that can take place + enum Action {commit , release}; + + /** + * @brief Either commits or releases the given resource + * based on the current Action set. + * @param deployed ::Deployment::Property is the resource + * to be commited/released + * @param available ::Deployment::SatisfierProperty is the + * available resource from which committed/released. + * @exception ::Deployment::ResourceNotAvailable thrown + * when the deployed resources exceeds + * the available resource. + */ + void commit_release_resource ( ::Deployment::Property & deployed, + ::Deployment::SatisfierProperty & available); + + /** + * @brief This function calls all NM and gives them + * the sub-domain + */ + int call_all_node_managers (); + + /** + * @brief This function add new elements to the + * already existing domain + * + * @param domain Deployment::Domain contians the new + * elements + */ + int add_to_domain (const ::Deployment::Domain& domain); + + /** + * @brief This function deletes elements from the domain + * + * @param domain ::Deployment::Domain contains the new elements + * in the domain + */ + int delete_from_domain (const ::Deployment::Domain& domain); + + /** + * @brief This function intimates the planner about a domain + * change + * + * @param domain ::Deployment::Domain contains the new elements + * in the domain + */ + int intimate_planner (const ::Deployment::Domain& domain); + + /** + * @brief This function finds a new node in the initial_domain + * + * @param node The name of the node which is to be searched + */ + + bool find_in_initial_domain (const char* node_name, + ::Deployment::Node& node); + /** + * @brief This function finds a new node in the proviosiond_domain + * + * @param node The name of the node which is to be searched + */ + bool find_in_provisioned_domain (const char* node_name, + ::Deployment::Node& node); + + /** + * @brief updates the node status by reading it from a file + */ + bool update_node_status (); + + /// The ORB pointer + CORBA::ORB_var orb_; + + /// The Deployment Configuration + CIAO::Deployment_Configuration deployment_config_; + + /// The Initial Domain - contains resources + /// at total capacity + ::Deployment::Domain initial_domain_; + + + /// The Current Domain - contains resources + /// at current capacity + ::Deployment::Domain current_domain_; + + /// The Target Manager Context + ::Deployment::TargetManager_var target_mgr_; + + /** + * The staic data manager pointer implementing + * singleton pattern + */ + static DomainDataManager* global_data_manager_; + + /** + * The static provisioned Domain data + */ + ::Deployment::Domain provisioned_data_; + + /// The current action + Action current_action_; + }; + +} // CIAO + +#endif /* DOMAIN_DATA_MGRH */ diff --git a/modules/CIAO/DAnCE/TargetManager/DomainEvents.idl b/modules/CIAO/DAnCE/TargetManager/DomainEvents.idl new file mode 100644 index 00000000000..4fe089a86a6 --- /dev/null +++ b/modules/CIAO/DAnCE/TargetManager/DomainEvents.idl @@ -0,0 +1,25 @@ +/** + * @file DomainEvents.idl + * @brief Contains Events in the Domain + * + * @author Nilabja R <nilabjar@dre.vanderbilt.edu> + * + * $Id$ + */ + +#ifndef DOMAIN_CHANGE_IDL +#define DOMAIN_CHANGE_IDL + +#include "ciao/Deployment_TargetManager.idl" +#include "ciao/CCM_Events.idl" + +module CIAO +{ + eventtype Domain_Changed_Event + { + public ::Deployment::Domain changes; + public ::Deployment::DomainUpdateKind change_kind; + }; +}; + +#endif diff --git a/modules/CIAO/DAnCE/TargetManager/TM_Client.mpc b/modules/CIAO/DAnCE/TargetManager/TM_Client.mpc new file mode 100644 index 00000000000..0a203ab1476 --- /dev/null +++ b/modules/CIAO/DAnCE/TargetManager/TM_Client.mpc @@ -0,0 +1,21 @@ +// $Id$ + +// Client.mpc,v 1.6 2005/02/18 09:07:06 jwillemsen Exp + +project(TMClient): ciao_client_dnc,ciao_deployment_stub, ciao_config_handlers, ciao_events_dnc, ciao_targetmanager_stub { + IDL_Files { + } + + Source_Files { + CmpClient.cpp + } + + Header_Files { + } + + Inline_Files { + } + + Template_Files { + } +} diff --git a/modules/CIAO/DAnCE/TargetManager/TargetManager.cidl b/modules/CIAO/DAnCE/TargetManager/TargetManager.cidl new file mode 100644 index 00000000000..6e880c069e9 --- /dev/null +++ b/modules/CIAO/DAnCE/TargetManager/TargetManager.cidl @@ -0,0 +1,27 @@ +// $Id$ + +/* + * @file TargetManager.cidl + * @brief The file contains the TargetManager component + * defination + */ + +#ifndef TARGETMANAGER_CIDL +#define TARGETMANAGER_CIDL + +#include "TargetManagerImpl.idl" + +/* + * @composition TargetManager_i + */ + +composition session TargetManager_i +{ + home executor TargetManagerHome_Exec + { + implements CIAO::TargetManagerHome; + manages TargetManagerImpl_Exec; + }; +}; + +#endif diff --git a/modules/CIAO/DAnCE/TargetManager/TargetManager.mpc b/modules/CIAO/DAnCE/TargetManager/TargetManager.mpc new file mode 100644 index 00000000000..11d1bd518b9 --- /dev/null +++ b/modules/CIAO/DAnCE/TargetManager/TargetManager.mpc @@ -0,0 +1,62 @@ +// $Id$ + +project(CIAO_TargetManager_stub): ciao_client_dnc, ciao_deployment_stub, ciao_nodemanager_stub { + sharedname = TargetManager_stub + idlflags += -Wb,stub_export_macro=TARGETMANAGER_STUB_Export \ + -Wb,stub_export_include=TargetManager_stub_export.h \ + -Wb,skel_export_macro=TARGETMANAGER_SVNT_Export \ + -Wb,skel_export_include=TargetManager_svnt_export.h + dynamicflags = TARGETMANAGER_STUB_BUILD_DLL + + IDL_Files { + TargetManagerImpl.idl + TargetManagerExt.idl + DomainEvents.idl + } + + Source_Files { + TargetManagerImplC.cpp + TargetManagerExtC.cpp + DomainEventsC.cpp + } +} + +project(CIAO_TargetManager_svnt) : ciao_servant_dnc, ciao_targetmanager_stub { + sharedname = TargetManager_svnt + + idlflags += -Wb,export_macro=TARGETMANAGER_SVNT_Export \ + -Wb,export_include=TargetManager_svnt_export.h + + dynamicflags = TARGETMANAGER_SVNT_BUILD_DLL + + CIDL_Files { + TargetManager.cidl + } + + IDL_Files { + TargetManagerE.idl + } + + Source_Files { + TargetManagerEC.cpp + TargetManagerImplS.cpp + TargetManagerExtS.cpp + TargetManager_svnt.cpp + DomainEventsS.cpp + } +} + + +project(CIAO_TargetManager_exec) : ciao_component_dnc, ciao_config_handlers, ciao_domainapplicationmanager_dnc, ciao_targetmanager_svnt { + sharedname = TargetManager_exec + + dynamicflags = TARGETMANAGER_EXEC_BUILD_DLL + + Source_Files { + DomainDataManager.cpp + TargetManager_exec.cpp + } + + IDL_Files { + } +} diff --git a/modules/CIAO/DAnCE/TargetManager/TargetManagerExt.idl b/modules/CIAO/DAnCE/TargetManager/TargetManagerExt.idl new file mode 100644 index 00000000000..025d8188e39 --- /dev/null +++ b/modules/CIAO/DAnCE/TargetManager/TargetManagerExt.idl @@ -0,0 +1,79 @@ +// $Id$ + +/** + * @file TargetManagerExt.idl + * + * @brief The Extensions to the TM interface for ARMS demo + * + * @author Nilabja R <nilabjar@dre.vanderbilt.edu> + * @author Nishanth Shankaran <nshankar@dre.vanderbilt.edu> + * + * This file declares a interface which will be implemented as + * a facet by the TargetManager component + */ + +/** + * @module CIAO + * + * @brief The CIAO module + */ + +#include "DAnCE/Interfaces/NodeManagerDaemon.idl" + +module CIAO +{ + /** + * @struct Cpu_Info + * @brief Consists of individual host-cpu info + */ + struct Host_Info + { + string hostname; + double cpu_util; + }; + + /// The sequence of CPU infos + typedef sequence<Host_Info> Host_Infos; + + /** + * @struct Component_Cpu_Util + * @brief Contains a component CPU Util + */ + struct Component_Info + { + string component_name; + double cpu_util; + }; + + /// The sequence of component cpu utilization + typedef sequence <Component_Info> Component_Infos; + + + /** + * @struct Host_NodeManager + * @brief Contains the node manager to host reference + */ + struct Host_NodeManager + { + string host_; + ::CIAO::NodeManagerDaemon node_mgr_; + }; + + /// Sequence of NodeManager. + typedef sequence <Host_NodeManager> Host_NodeManager_seq; + + /** + * @interface TargetManagerExt + * @brief The Target Manager Extension + * + * Contains the interface used by the RACE + * controller. + */ + interface TargetManagerExt + { + long get_pid (in string component_uuid); + Host_Infos get_host_cpu (); + Component_Infos get_component_cpu (); + Host_NodeManager_seq get_all_node_managers (); + }; +}; diff --git a/modules/CIAO/DAnCE/TargetManager/TargetManagerImpl.idl b/modules/CIAO/DAnCE/TargetManager/TargetManagerImpl.idl new file mode 100644 index 00000000000..705a3146a75 --- /dev/null +++ b/modules/CIAO/DAnCE/TargetManager/TargetManagerImpl.idl @@ -0,0 +1,39 @@ +// $Id$ + +/** + * @file TargetManagerImpl.idl + * @brief TargetManager interface defintion + * + * @author Nilabja R <nilabjar@dre.vanderbilt.edu> + */ + +#ifndef TARGETMGR_IDL +#define TARGETMGR_IDL + +#include "ciao/Components.idl" +#include "ciao/Deployment_Target_Data.idl" +#include "TargetManagerExt.idl" +#include "DomainEvents.idl" + +/** + * @module CIAO + * + * @brief TargetManagenr interface defintion + * + */ +module CIAO +{ + component TargetManagerImpl + { + provides ::Deployment::TargetManager targetMgr; + provides CIAO::TargetManagerExt target_manager_ext; + + publishes Domain_Changed_Event changes; + }; + + home TargetManagerHome manages TargetManagerImpl + { + }; +}; + +#endif diff --git a/modules/CIAO/DAnCE/TargetManager/TargetManager_exec.cpp b/modules/CIAO/DAnCE/TargetManager/TargetManager_exec.cpp new file mode 100644 index 00000000000..a39446e7273 --- /dev/null +++ b/modules/CIAO/DAnCE/TargetManager/TargetManager_exec.cpp @@ -0,0 +1,395 @@ +// $Id$ +//=============================================================== +/** + * @file TargetManager_exec.cpp + * + * @brief TargetManager Executor code + * + * @author Nilabja Roy nilabjar@dre.vanderbilt.edu + */ +//=============================================================== +#include "TargetManager_exec.h" +#include "ciao/CIAO_common.h" +#include <orbsvcs/CosNamingC.h> +#include "Config_Handlers/DD_Handler.h" +#include "Config_Handlers/DnC_Dump.h" + +#include "DomainEventsC.h" + +namespace CIDL_TargetManager_i +{ + //================================================================== + // Facet Executor Implementation Class: TargetManager_exec_i + //================================================================== + + TargetManager_exec_i:: + TargetManager_exec_i (TargetManagerImpl_exec_i* exec , + CORBA::ORB_ptr orb, + TargetManagerImpl_Context *context + ) + : _exec (exec), + orb_ (CORBA::ORB::_duplicate (orb)), + context_ (context) + { + // The DomainDataManager created here ... + + // get its own obj ref , then call + + ACE_DEBUG ((LM_DEBUG, "TM_Exec: getting ccm object\n")); + CORBA::Object_var object = context_->get_CCM_object (); + ACE_DEBUG ((LM_DEBUG, "TM_Exec: narrowing target_impl\n")); + CIAO::TargetManagerImpl_var target_impl = + CIAO::TargetManagerImpl::_narrow (object.in ()); + ACE_DEBUG ((LM_DEBUG, "TM_Exec: provide target manager\n")); + ::Deployment::TargetManager_var target = + target_impl->provide_targetMgr (); + // dataManager_.reset (new CIAO::DomainDataManager (orb, target.in ())); + ACE_DEBUG ((LM_DEBUG, "TM_Exec: creating domain data manager\n")); + CIAO::DomainDataManager::create (orb, target.in()); + ACE_DEBUG ((LM_DEBUG, "TM_Exec: DDD created!\n")); + } + + TargetManager_exec_i::~TargetManager_exec_i (void) + { + } + + // Operations from ::Deployment::TargetManager + + ::Deployment::Domain * + TargetManager_exec_i::getAllResources () + ACE_THROW_SPEC ((CORBA::SystemException)) + { + return CIAO::DomainDataManager:: + get_data_manager ()->get_initial_domain (); + } + + ::Deployment::Domain * + TargetManager_exec_i::getAvailableResources () + ACE_THROW_SPEC ((CORBA::SystemException)) + { + return CIAO::DomainDataManager:: + get_data_manager ()->get_current_domain (); + } + + void + TargetManager_exec_i::commitResources ( + const ::Deployment::DeploymentPlan & plan) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Deployment::ResourceNotAvailable, + ::Deployment::PlanError)) + { + return CIAO::DomainDataManager:: + get_data_manager ()->commitResources (plan); + } + + void + TargetManager_exec_i::releaseResources ( + const ::Deployment::DeploymentPlan & plan) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + return CIAO::DomainDataManager:: + get_data_manager ()->releaseResources (plan); + } + + void + TargetManager_exec_i::updateDomain ( + const ::CORBA::StringSeq & elements , + const ::Deployment::Domain & domainSubset , + ::Deployment::DomainUpdateKind updateKind) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + // Your code here. + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG , ".. Update Domain called ...\n")); + } + + CIAO::DomainDataManager:: + get_data_manager ()->update_domain ( + elements, + domainSubset, + updateKind + ); + + // here tell the planner about the changes + + // first get the node names which have failed ... + // assuming nodes to only fail , for now + + if (updateKind == ::Deployment::Delete || + updateKind == ::Deployment::Add) + { + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG , "TM::Creating the changed event\n")); + } + + CIAO::Domain_Changed_Event_var changed_event = + new OBV_CIAO::Domain_Changed_Event (); + + ::Deployment::Domain_var temp_domain = + new ::Deployment::Domain (domainSubset); + + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG , "TM::After getting the current domain\n")); + } + + changed_event->changes (temp_domain); + changed_event->change_kind (updateKind); + + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG , "TM::Sending the event to the Planner_Manager\n")); + } + + context_->push_changes (changed_event); + + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG , "TM::After Sending the event to the Planner_Manager\n")); + } + } + + } + + //================================================================== + // Facet Executor Implementation Class: TargetManagerExt_exec_i + // required for RACE + //================================================================== + + TargetManagerExt_exec_i::TargetManagerExt_exec_i (void) + { + } + + TargetManagerExt_exec_i::~TargetManagerExt_exec_i (void) + { + } + + // Operations from ::CIAO::TargetManagerExt + + ::CORBA::Long + TargetManagerExt_exec_i::get_pid ( + const char * component_uuid) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + // Your code here. + ACE_DEBUG ((LM_DEBUG, "Get PID :: Skeleton Impl")); + return CIAO::DomainDataManager:: + get_data_manager ()->get_pid (component_uuid); + } + + ::CIAO::Host_Infos * + TargetManagerExt_exec_i::get_host_cpu () + ACE_THROW_SPEC ((CORBA::SystemException)) + { + // Your code here. + ACE_DEBUG ((LM_DEBUG, "Get host cpu :: Skeleton Impl entering\n")); + return CIAO::DomainDataManager:: + get_data_manager ()->get_cpu_info (); + } + + ::CIAO::Component_Infos * + TargetManagerExt_exec_i::get_component_cpu () + ACE_THROW_SPEC ((CORBA::SystemException)) + { + // Your code here. + ACE_DEBUG ((LM_DEBUG, "Get component cpu :: Skeleton Impl")); + + // todo + + return 0; + } + + ::CIAO::Host_NodeManager_seq * + TargetManagerExt_exec_i::get_all_node_managers + () + ACE_THROW_SPEC ((CORBA::SystemException)) + { + return CIAO::DomainDataManager:: + get_data_manager ()->get_node_managers (); + } + + //================================================================== + // Component Executor Implementation Class: TargetManagerImpl_exec_i + //================================================================== + + TargetManagerImpl_exec_i::TargetManagerImpl_exec_i (void) + : exec_object_ (0) + { + } + + TargetManagerImpl_exec_i::~TargetManagerImpl_exec_i (void) + { + } + + // Supported or inherited operations. + + // Attribute operations. + + // Port operations. + + ::Deployment::CCM_TargetManager_ptr + TargetManagerImpl_exec_i::get_targetMgr () + ACE_THROW_SPEC ((CORBA::SystemException)) + { + // Your code here. + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG , "Calling TM constructor")); + } + + if (CORBA::is_nil (this->exec_ext_object_.in ())) + { + this->exec_object_ = new TargetManager_exec_i(this, + context_->_ciao_the_Container()->the_ORB(), + context_ + ); + } + + return ::Deployment::CCM_TargetManager::_duplicate (this->exec_object_.in ()); + } + + ::CIAO::CCM_TargetManagerExt_ptr TargetManagerImpl_exec_i + ::get_target_manager_ext ( + ) ACE_THROW_SPEC ((CORBA::SystemException)) + { + if (CORBA::is_nil (this->exec_ext_object_.in ())) + { + this->exec_ext_object_ = new TargetManagerExt_exec_i(); + } + + return ::CIAO::CCM_TargetManagerExt::_duplicate (this->exec_ext_object_.in ()); + } + + // Operations from Components::SessionComponent + + void + TargetManagerImpl_exec_i::set_session_context ( + ::Components::SessionContext_ptr ctx) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::CCMException)) + { + this->context_ = + TargetManagerImpl_Context::_narrow ( + ctx); + + if (this->context_ == 0) + { + throw CORBA::INTERNAL (); + } + } + + void + TargetManagerImpl_exec_i::ciao_preactivate () + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::CCMException)) + { + // Your code here. + } + + void + TargetManagerImpl_exec_i::ciao_postactivate () + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::CCMException)) + { + // Your code here. + } + + + void + TargetManagerImpl_exec_i::ccm_activate () + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::CCMException)) + { + // Your code here. + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG , "Inside CCM_ACTIVATE\n")); + } + this->get_targetMgr (); + } + + void + TargetManagerImpl_exec_i::ccm_passivate () + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::CCMException)) + { + // Your code here. + } + + void + TargetManagerImpl_exec_i::ccm_remove () + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::CCMException)) + { + // Your code here. + ACE_DEBUG ((LM_DEBUG , "TM::ccm_remove , calling LeaveDomain\n")); + + //CIAO::DomainDataManager::get_data_manager ()->stop_monitors (); + + ACE_DEBUG ((LM_DEBUG , "TM::ccm_remove , After calling LeaveDomain\n")); + return; + } + + + //================================================================== + // Home Executor Implementation Class: TargetManagerHome_exec_i + //================================================================== + + TargetManagerHome_exec_i::TargetManagerHome_exec_i (void) + { + } + + TargetManagerHome_exec_i::~TargetManagerHome_exec_i (void) + { + } + + // Supported or inherited operations. + + // Home operations. + + // Factory and finder operations. + + // Attribute operations. + + // Implicit operations. + + ::Components::EnterpriseComponent_ptr + TargetManagerHome_exec_i::create () + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::CCMException)) + { + ::Components::EnterpriseComponent_ptr retval = + ::Components::EnterpriseComponent::_nil (); + + ACE_NEW_THROW_EX ( + retval, + TargetManagerImpl_exec_i, + CORBA::NO_MEMORY ()); + + return retval; + } + + extern "C" TARGETMANAGER_EXEC_Export ::Components::HomeExecutorBase_ptr + create_CIAO_TargetManagerHome_Impl (void) + { + ::Components::HomeExecutorBase_ptr retval = + ::Components::HomeExecutorBase::_nil (); + + ACE_NEW_RETURN ( + retval, + TargetManagerHome_exec_i, + ::Components::HomeExecutorBase::_nil ()); + + return retval; + } +} diff --git a/modules/CIAO/DAnCE/TargetManager/TargetManager_exec.h b/modules/CIAO/DAnCE/TargetManager/TargetManager_exec.h new file mode 100644 index 00000000000..fe419bdab8b --- /dev/null +++ b/modules/CIAO/DAnCE/TargetManager/TargetManager_exec.h @@ -0,0 +1,218 @@ +// $Id$ +//=============================================================== +/** + * @file TargetManager_exec.h + * + * @brief TargetManager Executor code + * + * @author Nilabja Roy nilabjar@dre.vanderbilt.edu + */ +//=============================================================== + +#ifndef CIAO_TARGETMANAGER_EXEC_H +#define CIAO_TARGETMANAGER_EXEC_H + +#include /**/ "ace/pre.h" + +#include "TargetManager_svnt.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "TargetManager_exec_export.h" +#include "tao/LocalObject.h" +#include "DomainDataManager.h" + +namespace CIDL_TargetManager_i +{ + class TargetManager_exec_i; + + class TARGETMANAGER_EXEC_Export TargetManagerImpl_exec_i + : public virtual TargetManagerImpl_Exec, + public virtual TAO_Local_RefCounted_Object + { + public: + TargetManagerImpl_exec_i (void); + virtual ~TargetManagerImpl_exec_i (void); + + // Supported or inherited operations. + + // Attribute operations. + + // Port operations. + + virtual ::Deployment::CCM_TargetManager_ptr + get_targetMgr () + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::CIAO::CCM_TargetManagerExt_ptr + get_target_manager_ext ( + ) + ACE_THROW_SPEC ((::CORBA::SystemException)); + + // Operations from Components::SessionComponent + + virtual void + set_session_context ( + ::Components::SessionContext_ptr ctx) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::CCMException)); + + virtual void + ciao_preactivate () + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::CCMException)); + + virtual void + ciao_postactivate () + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::CCMException)); + + virtual void + ccm_activate () + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::CCMException)); + + virtual void + ccm_passivate () + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::CCMException)); + + virtual void + ccm_remove () + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::CCMException)); + + protected: + /// The service context pointer + TargetManagerImpl_Context *context_; + + /// The exec Object + ::Deployment::CCM_TargetManager_var exec_object_; + + ::CIAO::CCM_TargetManagerExt_var exec_ext_object_; + }; + + class TARGETMANAGER_EXEC_Export TargetManagerExt_exec_i + : public virtual ::CIAO::CCM_TargetManagerExt, + public virtual TAO_Local_RefCounted_Object + { + public: + TargetManagerExt_exec_i (void); + virtual ~TargetManagerExt_exec_i (void); + + // Operations from ::CIAO::TargetManagerExt + + virtual ::CORBA::Long + get_pid ( + const char * component_uuid) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::CIAO::Host_Infos * + get_host_cpu () + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::CIAO::Component_Infos * + get_component_cpu () + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::CIAO::Host_NodeManager_seq * + get_all_node_managers () + ACE_THROW_SPEC ((CORBA::SystemException)); + }; + + class TARGETMANAGER_EXEC_Export TargetManager_exec_i + : public virtual ::Deployment::CCM_TargetManager, + public virtual TAO_Local_RefCounted_Object + { + public: + TargetManager_exec_i (TargetManagerImpl_exec_i* exec, + CORBA::ORB_ptr orb, + TargetManagerImpl_Context *context + ); + virtual ~TargetManager_exec_i (void); + + // Operations from ::Deployment::TargetManager + + virtual ::Deployment::Domain * + getAllResources () + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual ::Deployment::Domain * + getAvailableResources () + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void + commitResources ( + const ::Deployment::DeploymentPlan & plan) + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Deployment::ResourceNotAvailable, + ::Deployment::PlanError)); + + virtual void + releaseResources ( + const ::Deployment::DeploymentPlan & argname) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void + updateDomain ( + const ::CORBA::StringSeq & elements, + const ::Deployment::Domain & domainSubset, + ::Deployment::DomainUpdateKind updateKind) + ACE_THROW_SPEC ((CORBA::SystemException)); + + private: + TargetManagerImpl_exec_i * _exec; + + ///The pointer to the Domain Manager + auto_ptr<CIAO::DomainDataManager> dataManager_; + + /// The CORBA ORB ... + CORBA::ORB_var orb_; + + /// The context object ... + TargetManagerImpl_Context *context_; + }; + + + + class TARGETMANAGER_EXEC_Export TargetManagerHome_exec_i + : public virtual TargetManagerHome_Exec, + public virtual TAO_Local_RefCounted_Object + { + public: + TargetManagerHome_exec_i (void); + virtual ~TargetManagerHome_exec_i (void); + + // Supported or inherited operations. + + // Home operations. + + // Factory and finder operations. + + // Attribute operations. + + // Implicit operations. + + virtual ::Components::EnterpriseComponent_ptr + create () + ACE_THROW_SPEC (( + ::CORBA::SystemException, + ::Components::CCMException)); + }; + + extern "C" TARGETMANAGER_EXEC_Export ::Components::HomeExecutorBase_ptr + create_CIAO_TargetManagerHome_Impl (void); +} + +#include /**/ "ace/post.h" + +#endif /* CIAO_TARGETMANAGER_EXEC_H */ diff --git a/modules/CIAO/DAnCE/TargetManager/TargetManager_exec_export.h b/modules/CIAO/DAnCE/TargetManager/TargetManager_exec_export.h new file mode 100644 index 00000000000..690e5b6136e --- /dev/null +++ b/modules/CIAO/DAnCE/TargetManager/TargetManager_exec_export.h @@ -0,0 +1,54 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl TARGETMANAGER_EXEC +// ------------------------------ +#ifndef TARGETMANAGER_EXEC_EXPORT_H +#define TARGETMANAGER_EXEC_EXPORT_H + +#include "ace/config-all.h" + +#if !defined (TARGETMANAGER_EXEC_HAS_DLL) +# define TARGETMANAGER_EXEC_HAS_DLL 1 +#endif /* ! TARGETMANAGER_EXEC_HAS_DLL */ + +#if defined (TARGETMANAGER_EXEC_HAS_DLL) && (TARGETMANAGER_EXEC_HAS_DLL == 1) +# if defined (TARGETMANAGER_EXEC_BUILD_DLL) +# define TARGETMANAGER_EXEC_Export ACE_Proper_Export_Flag +# define TARGETMANAGER_EXEC_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define TARGETMANAGER_EXEC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* TARGETMANAGER_EXEC_BUILD_DLL */ +# define TARGETMANAGER_EXEC_Export ACE_Proper_Import_Flag +# define TARGETMANAGER_EXEC_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define TARGETMANAGER_EXEC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* TARGETMANAGER_EXEC_BUILD_DLL */ +#else /* TARGETMANAGER_EXEC_HAS_DLL == 1 */ +# define TARGETMANAGER_EXEC_Export +# define TARGETMANAGER_EXEC_SINGLETON_DECLARATION(T) +# define TARGETMANAGER_EXEC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* TARGETMANAGER_EXEC_HAS_DLL == 1 */ + +// Set TARGETMANAGER_EXEC_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (TARGETMANAGER_EXEC_NTRACE) +# if (ACE_NTRACE == 1) +# define TARGETMANAGER_EXEC_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define TARGETMANAGER_EXEC_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !TARGETMANAGER_EXEC_NTRACE */ + +#if (TARGETMANAGER_EXEC_NTRACE == 1) +# define TARGETMANAGER_EXEC_TRACE(X) +#else /* (TARGETMANAGER_EXEC_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define TARGETMANAGER_EXEC_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (TARGETMANAGER_EXEC_NTRACE == 1) */ + +#endif /* TARGETMANAGER_EXEC_EXPORT_H */ + +// End of auto generated file. diff --git a/modules/CIAO/DAnCE/TargetManager/TargetManager_stub_export.h b/modules/CIAO/DAnCE/TargetManager/TargetManager_stub_export.h new file mode 100644 index 00000000000..d362f4f4ac8 --- /dev/null +++ b/modules/CIAO/DAnCE/TargetManager/TargetManager_stub_export.h @@ -0,0 +1,54 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl TARGETMANAGER_STUB +// ------------------------------ +#ifndef TARGETMANAGER_STUB_EXPORT_H +#define TARGETMANAGER_STUB_EXPORT_H + +#include "ace/config-all.h" + +#if !defined (TARGETMANAGER_STUB_HAS_DLL) +# define TARGETMANAGER_STUB_HAS_DLL 1 +#endif /* ! TARGETMANAGER_STUB_HAS_DLL */ + +#if defined (TARGETMANAGER_STUB_HAS_DLL) && (TARGETMANAGER_STUB_HAS_DLL == 1) +# if defined (TARGETMANAGER_STUB_BUILD_DLL) +# define TARGETMANAGER_STUB_Export ACE_Proper_Export_Flag +# define TARGETMANAGER_STUB_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define TARGETMANAGER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* TARGETMANAGER_STUB_BUILD_DLL */ +# define TARGETMANAGER_STUB_Export ACE_Proper_Import_Flag +# define TARGETMANAGER_STUB_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define TARGETMANAGER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* TARGETMANAGER_STUB_BUILD_DLL */ +#else /* TARGETMANAGER_STUB_HAS_DLL == 1 */ +# define TARGETMANAGER_STUB_Export +# define TARGETMANAGER_STUB_SINGLETON_DECLARATION(T) +# define TARGETMANAGER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* TARGETMANAGER_STUB_HAS_DLL == 1 */ + +// Set TARGETMANAGER_STUB_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (TARGETMANAGER_STUB_NTRACE) +# if (ACE_NTRACE == 1) +# define TARGETMANAGER_STUB_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define TARGETMANAGER_STUB_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !TARGETMANAGER_STUB_NTRACE */ + +#if (TARGETMANAGER_STUB_NTRACE == 1) +# define TARGETMANAGER_STUB_TRACE(X) +#else /* (TARGETMANAGER_STUB_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define TARGETMANAGER_STUB_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (TARGETMANAGER_STUB_NTRACE == 1) */ + +#endif /* TARGETMANAGER_STUB_EXPORT_H */ + +// End of auto generated file. diff --git a/modules/CIAO/DAnCE/TargetManager/TargetManager_svnt_export.h b/modules/CIAO/DAnCE/TargetManager/TargetManager_svnt_export.h new file mode 100644 index 00000000000..f57ce799949 --- /dev/null +++ b/modules/CIAO/DAnCE/TargetManager/TargetManager_svnt_export.h @@ -0,0 +1,54 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl TARGETMANAGER_SVNT +// ------------------------------ +#ifndef TARGETMANAGER_SVNT_EXPORT_H +#define TARGETMANAGER_SVNT_EXPORT_H + +#include "ace/config-all.h" + +#if !defined (TARGETMANAGER_SVNT_HAS_DLL) +# define TARGETMANAGER_SVNT_HAS_DLL 1 +#endif /* ! TARGETMANAGER_SVNT_HAS_DLL */ + +#if defined (TARGETMANAGER_SVNT_HAS_DLL) && (TARGETMANAGER_SVNT_HAS_DLL == 1) +# if defined (TARGETMANAGER_SVNT_BUILD_DLL) +# define TARGETMANAGER_SVNT_Export ACE_Proper_Export_Flag +# define TARGETMANAGER_SVNT_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define TARGETMANAGER_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* TARGETMANAGER_SVNT_BUILD_DLL */ +# define TARGETMANAGER_SVNT_Export ACE_Proper_Import_Flag +# define TARGETMANAGER_SVNT_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define TARGETMANAGER_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* TARGETMANAGER_SVNT_BUILD_DLL */ +#else /* TARGETMANAGER_SVNT_HAS_DLL == 1 */ +# define TARGETMANAGER_SVNT_Export +# define TARGETMANAGER_SVNT_SINGLETON_DECLARATION(T) +# define TARGETMANAGER_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* TARGETMANAGER_SVNT_HAS_DLL == 1 */ + +// Set TARGETMANAGER_SVNT_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (TARGETMANAGER_SVNT_NTRACE) +# if (ACE_NTRACE == 1) +# define TARGETMANAGER_SVNT_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define TARGETMANAGER_SVNT_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !TARGETMANAGER_SVNT_NTRACE */ + +#if (TARGETMANAGER_SVNT_NTRACE == 1) +# define TARGETMANAGER_SVNT_TRACE(X) +#else /* (TARGETMANAGER_SVNT_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define TARGETMANAGER_SVNT_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (TARGETMANAGER_SVNT_NTRACE == 1) */ + +#endif /* TARGETMANAGER_SVNT_EXPORT_H */ + +// End of auto generated file. diff --git a/modules/CIAO/DAnCE/TargetManager/descriptors/Domain.cdd b/modules/CIAO/DAnCE/TargetManager/descriptors/Domain.cdd new file mode 100644 index 00000000000..fe21a4b48f5 --- /dev/null +++ b/modules/CIAO/DAnCE/TargetManager/descriptors/Domain.cdd @@ -0,0 +1,101 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<Deployment:domain + xmlns:Deployment="http://www.omg.org/Deployment" + xmlns:xmi="http://www.omg.org/XMI" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.omg.org/Deployment Deployment.xsd"> + +<UUID>effd4bd0-6db0-4c50-9bb7-db9decebae1c</UUID> +<label>Hello Domain</label> + + +<node> + <name>TargetManagerNode_1</name> + <label>Sender's Node</label> + <resource> + <name>Processor</name> + <resourceType>CPULoad</resourceType> + <property> + <name>LoadAverage</name> + <kind>Quantity</kind> + <dynamic>true</dynamic> + <value> + <type> + <kind>tk_long</kind> + </type> + <value><long>99</long></value> + </value> + </property> + </resource> +</node> +<node> + <name>TargetManagerNode_2</name> + <label>Receiver's Node</label> + <resource> + <name>Processor</name> + <resourceType>CPULoad</resourceType> + <property> + <name>LoadAverage</name> + <kind>Quantity</kind> + <dynamic>true</dynamic> + <value> + <type> + <kind>tk_long</kind> + </type> + <value><long>99</long></value> + </value> + </property> + </resource> +</node> + + +<interconnect> + <name>NoBridgeInterConnect</name> + <connect> + <name>Receiver</name> + <resource> + <name>Processor</name> + <resourceType>CPULoad</resourceType> + <property> + <name>LoadAverage</name> + <kind>Quantity</kind> + <dynamic>true</dynamic> + <value> + <type> + <kind>tk_long</kind> + </type> + <value><long>99</long></value> + </value> + </property> + </resource> + </connect> +</interconnect> + + +<bridge> + <name>NoBridge</name> + <connect> + <name>NoBridgeInterConnect</name> + <connect> + <name>Receiver</name> + <resource> + <name>Processor</name> + <resourceType>CPULoad</resourceType> + <property> + <name>LoadAverage</name> + <kind>Quantity</kind> + <dynamic>true</dynamic> + <value> + <type> + <kind>tk_long</kind> + </type> + <value><long>99</long></value> + </value> + </property> + </resource> + </connect> + </connect> +</bridge> + + +</Deployment:domain> diff --git a/modules/CIAO/DAnCE/TargetManager/descriptors/NodeDetails.dat b/modules/CIAO/DAnCE/TargetManager/descriptors/NodeDetails.dat new file mode 100644 index 00000000000..0ca8bfefd8b --- /dev/null +++ b/modules/CIAO/DAnCE/TargetManager/descriptors/NodeDetails.dat @@ -0,0 +1,2 @@ +TargetManagerNode_1 corbaloc:iiop:localhost:40000/NodeManager +TargetManagerNode_2 corbaloc:iiop:localhost:30000/NodeManager diff --git a/modules/CIAO/DAnCE/TargetManager/descriptors/NodeManagerMap.dat b/modules/CIAO/DAnCE/TargetManager/descriptors/NodeManagerMap.dat new file mode 100644 index 00000000000..0ca8bfefd8b --- /dev/null +++ b/modules/CIAO/DAnCE/TargetManager/descriptors/NodeManagerMap.dat @@ -0,0 +1,2 @@ +TargetManagerNode_1 corbaloc:iiop:localhost:40000/NodeManager +TargetManagerNode_2 corbaloc:iiop:localhost:30000/NodeManager diff --git a/modules/CIAO/DAnCE/TargetManager/descriptors/flattened_deploymentplan.cdp b/modules/CIAO/DAnCE/TargetManager/descriptors/flattened_deploymentplan.cdp new file mode 100644 index 00000000000..fae71c39fa1 --- /dev/null +++ b/modules/CIAO/DAnCE/TargetManager/descriptors/flattened_deploymentplan.cdp @@ -0,0 +1,92 @@ +<Deployment:deploymentPlan + xmlns:Deployment="http://www.omg.org/Deployment" + xmlns:xmi="http://www.omg.org/XMI" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.omg.org/Deployment Modified_Deployment.xsd"> + + <label>Hello-DeploymentPlan</label> + <!-- Could be ZERO --> + <realizes> + <label>BasicSP-realizes-cid</label> + <UUID>c0965470-7b83-11d9-9669-0800200c9a66</UUID> + <specificType><!-- @@ What does here? --></specificType> + <supportedType>IDL:BasicSP/EC:1.0</supportedType> + <port> + <name>read_message</name> + <specificType>IDL:Hello/ReadMessage:1.0</specificType> + <supportedType>IDL:Hello/ReadMessage:1.0</supportedType> + <provider>false></provider> + <exclusiveProvider>false</exclusiveProvider> + <exclusiveUser>true</exclusiveUser> + <optional>false</optional> + <kind>SimplexReceptacle</kind> + </port> + </realizes> + + <implementation id="TargetManager-mdd"> + <name>TargetManager-mdd</name> + <source><!-- @@ Don't know what goes here --></source> + <artifact>TargetManager_exec</artifact> + <artifact>TargetManager_svnt</artifact> + <!-- + <execParameter></execParameter> + <deployRequirement></deployRequirement> + --> + </implementation> + + <instance id="TargetManager-idd"> + <name>TargetManager-idd</name> + <node>TargetManagerNode_1</node> + <source><!-- @@ What goes here --></source> + <implementation>TargetManager-mdd</implementation> + <configProperty> + <name>ComponentIOR</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>TargetManager.ior</string> + </value> + </value> + </configProperty> + </instance> + + <!-- @@ Runtime library name must match exactly in "location" tag --> + + <artifact id="TargetManager_exec"> + <name>TargetManager_exec</name> + <source><!-- @@ Not sure about this--></source> + <node><!-- blank --></node> + <location>TargetManager_exec</location> + <execParameter> + <name>entryPoint</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>create_CIAO_TargetManagerHome_Impl</string> + </value> + </value> + </execParameter> + </artifact> + + <artifact id="TargetManager_svnt"> + <name>TargetManager_svnt</name> + <source><!-- @@ Not sure --></source> + <node><!-- blank --></node> + <location>TargetManager_svnt</location> + <execParameter> + <name>entryPoint</name> + <value> + <type> + <kind>tk_string</kind> + </type> + <value> + <string>create_CIAO_TargetManagerHome_Servant</string> + </value> + </value> + </execParameter> + </artifact> +</Deployment:deploymentPlan> diff --git a/modules/CIAO/DAnCE/TargetManager/descriptors/run_test_TargetManager.pl b/modules/CIAO/DAnCE/TargetManager/descriptors/run_test_TargetManager.pl new file mode 100644 index 00000000000..a98401ef296 --- /dev/null +++ b/modules/CIAO/DAnCE/TargetManager/descriptors/run_test_TargetManager.pl @@ -0,0 +1,160 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "$ENV{'ACE_ROOT'}/bin"; +use PerlACE::Run_Test; +$CIAO_ROOT = "$ENV{'CIAO_ROOT'}"; +$DAnCE = "$ENV{'CIAO_ROOT'}/DAnCE"; + +$daemons_running = 0; +$em_running = 0; +$daemons = 2; +@ports = ( 40000, 30000 ); +@iorfiles = ( "NodeApp1.ior", "NodeApp2.ior" ); +$status = 0; +$dat_file = "NodeDetails.dat"; +$cdp_file = "flattened_DeploymentPlan.cdp"; + +$E = 0; +$EM = 0; + +# Delete if there are any .ior files. +sub delete_ior_files { + for ($i = 0; $i < $daemons; ++$i) { + unlink $iorfiles[$i]; + } + unlink PerlACE::LocalFile ("EM.ior"); + unlink PerlACE::LocalFile ("TargetManager.ior"); + unlink PerlACE::LocalFile ("DAM.ior"); +} + +sub kill_node_daemons { + for ($i = 0; $i < $daemons; ++$i) { + $Daemons[$i]->Kill (); $Daemons[$i]->TimedWait (1); + } +} + +sub kill_open_processes { + if ($daemons_running == 1) { + kill_node_daemons (); + } + + if ($em_running == 1) { + $EM->Kill (); + $EM->TimedWait (1); + } +} + +sub run_node_daemons { + for ($i = 0; $i < $daemons; ++$i) + { + $iorfile = $iorfiles[$i]; + $port = $ports[$i]; + + $iiop = "iiop://localhost:$port"; + $node_app = "$DAnCE/NodeApplication/NodeApplication"; + + $d_cmd = "$DAnCE/NodeManager/NodeManager"; + $d_param = "-ORBEndpoint $iiop -s $node_app -o $iorfile"; + + $Daemons[$i] = new PerlACE::Process ($d_cmd, $d_param); + $result = $Daemons[$i]->Spawn (); + push(@processes, $Daemons[$i]); + + if (PerlACE::waitforfile_timed ($iorfile, + $PerlACE::wait_interval_for_process_creation) == -1) { + print STDERR + "ERROR: The ior file of node daemon $i could not be found\n"; + for (; $i > 0; --$i) { + $Daemons[$i]->Kill (); $Daemons[$i]->TimedWait (1); + } + return -1; + } + } + $daemons_running = 1; + return 0; +} + +delete_ior_files (); + +# Invoke node daemons. +print "Invoking node daemons\n"; +$status = run_node_daemons (); + +if ($status != 0) { + print STDERR "ERROR: Unable to execute the node daemons\n"; + exit 1; +} + +$ns_running = 1; + +# Invoke execution manager. +print "Invoking execution manager\n"; +$EM = new PerlACE::Process ("$DAnCE/ExecutionManager/Execution_Manager", + "-o EM.ior -i $dat_file"); +$EM->Spawn (); + +if (PerlACE::waitforfile_timed ("EM.ior", + $PerlACE::wait_interval_for_process_creation) == -1) { + print STDERR + "ERROR: The ior file of execution manager could not be found\n"; + kill_open_processes (); + exit 1; +} + +$em_running = 1; + +# Invoke executor - start the application -. +print "Invoking executor - start the application -\n"; +$E = + new PerlACE::Process ("$DAnCE/Plan_Launcher/plan_launcher", + "-p flattened_deploymentplan.cdp -k file://EM.ior -o DAM.ior"); + +$E->SpawnWaitKill (5000); + +if (PerlACE::waitforfile_timed ( + "TargetManager.ior", + $PerlACE::wait_interval_for_process_creation) == -1) { + print STDERR "ERROR: The ior file of receiver could not be found\n"; + kill_open_processes (); + exit 1; +} + +print "Waiting for 15 secs then invoking client ===\n"; +sleep (15); + +print "Making 5 such calls \n"; + +$call_num = 5; + +for ($i = 0; $i < $call_num; ++$i) +{ + print "Invoking the client\n"; + $tmclient = new PerlACE::Process ("../CmpClient", "file://TargetManager.ior"); + $result = $tmclient->SpawnWaitKill (3000); + + if ($result != 0) { + print STDERR "ERROR: The client returned $result\n"; + $status = 1; + } + sleep (15); +} + +# Invoke executor - stop the application -. +print "Invoking executor - stop the application -\n"; +$E = + new PerlACE::Process ("$DAnCE/Plan_Launcher/plan_launcher", + "-k file://EM.ior -i file://DAM.ior"); +$E->SpawnWaitKill (3000); + +print "Executor returned.\n"; +print "Shutting down rest of the processes.\n"; + +delete_ior_files (); +kill_open_processes (); + +exit $status; |