From: caremoli Date: Wed, 15 Apr 2009 10:33:04 +0000 (+0000) Subject: CCAR: X-Git-Tag: CCAR_rm_end X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f464a8dab4fb05a38720c3fb6790117e9d5bb7b7;p=modules%2Fkernel.git CCAR: 1- add a new type MachineDefinition in ContainerManager idl to separate machine definition parameters and machine parameters for requests to container manager (MachineParameters) 2- in Resource manager replace module by component. Selection of a resource is now done with a component name and no more with a module name. Now in CatalogResource.xml, we can specify for a resource that it supports a list of components or modules. Syntax for a component is: Syntax for a module is: When a module is added, a component with the same name is also added. --- diff --git a/idl/SALOME_ContainerManager.idl b/idl/SALOME_ContainerManager.idl index 32b8e364e..392f56519 100644 --- a/idl/SALOME_ContainerManager.idl +++ b/idl/SALOME_ContainerManager.idl @@ -40,24 +40,38 @@ module Engines //! modules list typedef sequence ModulesList; -//! Type to describe properties of a resource. +//! Type to describe required properties of a container. struct MachineParameters { + //! container name if given else automatic string container_name; + //! host name if given else automatic string hostname; + //! if given alias name to use ?? string alias; + //! protocol to use to start a remote container (ssh or rsh) string protocol; + //! login name to use to start a remote container string username; + //! salome application to use to start a remote container string applipath; ModulesList modList; string OS; + //! required memory size long mem_mb; + //! required frequency long cpu_clock; + //! required number of proc per node long nb_proc_per_node; + //! required number of node long nb_node; + //! if true start a MPI container ?? boolean isMPI; + //! required MPI implementation to use string mpiImpl; + //! required batch system to use string batch; + //! container working directory string workingdir; // PaCO specific informations @@ -65,6 +79,36 @@ struct MachineParameters long nb_component_nodes; }; +//! Type to describe properties of a resource. +struct MachineDefinition +{ + //! host name + string hostname; + string alias; + //! protocol to use to start a remote container (ssh or rsh) + string protocol; + //! login name to use to start a remote container + string username; + //! salome application to use to start a remote container + string applipath; + //! list of available components + CompoList componentList; + //! operating system + string OS; + //! memory size + long mem_mb; + //! frequency + long cpu_clock; + //! number of proc per node + long nb_proc_per_node; + //! number of node + long nb_node; + //! MPI implementation + string mpiImpl; + //! batch system + string batch; + long nb_component_nodes; +}; //! exception thrown if a computer is not found in the catalog exception NotFound {}; @@ -178,7 +222,7 @@ struct BatchParameters raises (SALOME::SALOME_Exception); //! Get the current machine parameters of a computer - MachineParameters GetMachineParameters( in string hostname ); + MachineDefinition GetMachineParameters( in string hostname ); } ; }; diff --git a/src/Launcher/BatchTest.cxx b/src/Launcher/BatchTest.cxx index a320ecedc..727cedc5f 100644 --- a/src/Launcher/BatchTest.cxx +++ b/src/Launcher/BatchTest.cxx @@ -31,7 +31,7 @@ #ifdef WIN32 # include #endif -BatchTest::BatchTest(const Engines::MachineParameters& batch_descr) +BatchTest::BatchTest(const Engines::MachineDefinition& batch_descr) { _batch_descr = batch_descr; diff --git a/src/Launcher/BatchTest.hxx b/src/Launcher/BatchTest.hxx index 8ccd5a550..8fdf3736c 100644 --- a/src/Launcher/BatchTest.hxx +++ b/src/Launcher/BatchTest.hxx @@ -32,7 +32,7 @@ class SALOMELAUNCHER_EXPORT BatchTest { public: - BatchTest(const Engines::MachineParameters& batch_descr); + BatchTest(const Engines::MachineDefinition& batch_descr); virtual ~BatchTest(); bool test(); @@ -48,7 +48,7 @@ class SALOMELAUNCHER_EXPORT BatchTest std::string get_home(std::string * home); private: - Engines::MachineParameters _batch_descr; + Engines::MachineDefinition _batch_descr; std::string _test_filename; std::string _base_filename; std::string _date; diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index 00869eec8..817fa0f50 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -92,7 +92,6 @@ void SALOME_Launcher::Shutdown() _ResManager->Shutdown(); PortableServer::ObjectId_var oid = _poa->servant_to_id(this); _poa->deactivate_object(oid); - //_remove_ref(); if(!CORBA::is_nil(_orb)) _orb->shutdown(0); } @@ -204,7 +203,7 @@ SALOME_Launcher::testBatch(const Engines::MachineParameters& params) if (aMachineList->length() == 0) throw SALOME_Exception("No resources have been found with your parameters"); - const Engines::MachineParameters* p = _ResManager->GetMachineParameters((*aMachineList)[0]); + const Engines::MachineDefinition* p = _ResManager->GetMachineParameters((*aMachineList)[0]); string clustername(p->alias); INFOS("Choose cluster" << clustername); diff --git a/src/LifeCycleCORBA/TestContainerManager.cxx b/src/LifeCycleCORBA/TestContainerManager.cxx index fc09b92e6..c5fc4ef06 100644 --- a/src/LifeCycleCORBA/TestContainerManager.cxx +++ b/src/LifeCycleCORBA/TestContainerManager.cxx @@ -139,7 +139,7 @@ int main (int argc, char * argv[]) int nbpmax; for(std::map::iterator iter=cycle.begin();iter!=cycle.end();iter++){ if(strcmp((*iter).first.c_str(),"localhost")!=0){ - Engines::MachineParameters *p = _ResManager->GetMachineParameters((*iter).first.c_str()); + Engines::MachineDefinition *p = _ResManager->GetMachineParameters((*iter).first.c_str()); int nbproc = p->nb_node * p->nb_proc_per_node; if(cycle[(*iter).first]/nbproccmax) cmax=cycle[(*iter).first]/nbproc; diff --git a/src/ResourcesManager/ResourcesManager.cxx b/src/ResourcesManager/ResourcesManager.cxx index 5bcf6d843..7a68eb2bc 100644 --- a/src/ResourcesManager/ResourcesManager.cxx +++ b/src/ResourcesManager/ResourcesManager.cxx @@ -108,15 +108,15 @@ ResourcesManager_cpp::~ResourcesManager_cpp() //============================================================================= /*! - * get the list of name of ressources fitting for the specified module. + * get the list of name of ressources fitting for the specified component. * If hostname specified, check it is local or known in resources catalog. * * Else * - select first machines with corresponding OS (all machines if * parameter OS empty), - * - then select the sublist of machines on witch the module is known + * - then select the sublist of machines on witch the component is known * (if the result is empty, that probably means that the inventory of - * modules is probably not done, so give complete list from previous step) + * components is probably not done, so give complete list from previous step) */ //============================================================================= @@ -185,7 +185,7 @@ ResourcesManager_cpp::GetFittingResources(const machineParams& params, // --- Search for available resources sorted by priority SelectOnlyResourcesWithOS(vec, params.OS.c_str()); - KeepOnlyResourcesWithModule(vec, componentList); + KeepOnlyResourcesWithComponent(vec, componentList); if (vec.size() == 0) SelectOnlyResourcesWithOS(vec, params.OS.c_str()); @@ -225,25 +225,25 @@ ResourcesManager_cpp::GetFittingResources(const machineParams& params, //============================================================================= /*! * add an entry in the ressources catalog xml file. - * Return 0 if OK (KERNEL found in new resources modules) else throw exception + * Return 0 if OK (KERNEL found in new resources components) else throw exception */ //============================================================================= int ResourcesManager_cpp:: AddResourceInCatalog(const machineParams& paramsOfNewResources, - const vector& modulesOnNewResources, + const vector& componentsOnNewResources, const char *alias, const char *userName, AccessModeType mode, AccessProtocolType prot) throw(ResourcesException) { - vector::const_iterator iter = find(modulesOnNewResources.begin(), - modulesOnNewResources.end(), + vector::const_iterator iter = find(componentsOnNewResources.begin(), + componentsOnNewResources.end(), "KERNEL"); - if (iter != modulesOnNewResources.end()) + if (iter != componentsOnNewResources.end()) { ParserResourcesType newElt; newElt.DataForSort._hostName = paramsOfNewResources.hostname; @@ -251,7 +251,7 @@ throw(ResourcesException) newElt.Protocol = prot; newElt.Mode = mode; newElt.UserName = userName; - newElt.ModulesList = modulesOnNewResources; + newElt.ComponentsList = componentsOnNewResources; newElt.OS = paramsOfNewResources.OS; newElt.DataForSort._memInMB = paramsOfNewResources.mem_mb; newElt.DataForSort._CPUFreqMHz = paramsOfNewResources.cpu_clock; @@ -369,9 +369,9 @@ const MapOfParserResourcesType& ResourcesManager_cpp::ParseXmlFile() //============================================================================= const MapOfParserResourcesType& ResourcesManager_cpp::GetList() const - { - return _resourcesList; - } +{ + return _resourcesList; +} //============================================================================= @@ -432,28 +432,28 @@ throw(ResourcesException) //============================================================================= /*! - * Gives a sublist of machines on which the module is known. + * Gives a sublist of machines on which the component is known. */ //============================================================================= //Warning need an updated parsed list : _resourcesList -void ResourcesManager_cpp::KeepOnlyResourcesWithModule( vector& hosts, const vector& componentList) const +void ResourcesManager_cpp::KeepOnlyResourcesWithComponent( vector& hosts, const vector& componentList) const throw(ResourcesException) { for (vector::iterator iter = hosts.begin(); iter != hosts.end();) { MapOfParserResourcesType::const_iterator it = _resourcesList.find(*iter); - const vector& mapOfModulesOfCurrentHost = (((*it).second).ModulesList); + const vector& mapOfComponentsOfCurrentHost = (((*it).second).ComponentsList); bool erasedHost = false; - if( mapOfModulesOfCurrentHost.size() > 0 ){ + if( mapOfComponentsOfCurrentHost.size() > 0 ){ for(unsigned int i=0;i::const_iterator itt = find(mapOfModulesOfCurrentHost.begin(), - mapOfModulesOfCurrentHost.end(), + vector::const_iterator itt = find(mapOfComponentsOfCurrentHost.begin(), + mapOfComponentsOfCurrentHost.end(), compoi); // componentList[i]); - if (itt == mapOfModulesOfCurrentHost.end()){ + if (itt == mapOfComponentsOfCurrentHost.end()){ erasedHost = true; break; } diff --git a/src/ResourcesManager/ResourcesManager.hxx b/src/ResourcesManager/ResourcesManager.hxx index cc065929c..839faccf0 100644 --- a/src/ResourcesManager/ResourcesManager.hxx +++ b/src/ResourcesManager/ResourcesManager.hxx @@ -74,7 +74,7 @@ class RESOURCESMANAGER_EXPORT ResourcesManager_cpp int AddResourceInCatalog (const machineParams& paramsOfNewResources, - const std::vector& modulesOnNewResources, + const std::vector& componentsOnNewResources, const char *alias, const char *userName, AccessModeType mode, @@ -96,7 +96,7 @@ class RESOURCESMANAGER_EXPORT ResourcesManager_cpp const char *OS) const throw(ResourcesException); - void KeepOnlyResourcesWithModule(std::vector& hosts, + void KeepOnlyResourcesWithComponent(std::vector& hosts, const std::vector& componentList) const throw(ResourcesException); diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx index a80bc83bf..e990944c0 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx @@ -59,6 +59,8 @@ SALOME_ResourcesCatalog_Handler(MapOfParserResourcesType& resources_list, test_appli_path = "appliPath"; test_modules = "modules"; test_module_name = "moduleName"; + test_components = "component"; + test_component_name = "name"; test_os = "OS"; test_mem_in_mb = "memInMB"; test_cpu_freq_mhz = "CPUFreqMHz"; @@ -277,18 +279,42 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) xmlFree(nb_of_proc_per_node); } - // Process modules + // Process components xmlNodePtr aCurSubNode = aCurNode->xmlChildrenNode; while(aCurSubNode != NULL) { - if ( !xmlStrcmp(aCurSubNode->name, (const xmlChar*)test_modules) ) + if ( !xmlStrcmp(aCurSubNode->name, (const xmlChar*)test_components) ) { + //If a component is given, it is in a module with the same name + //except if the module name is given + if (xmlHasProp(aCurSubNode, (const xmlChar*)test_component_name)) + { + xmlChar* component_name = xmlGetProp(aCurSubNode, (const xmlChar*)test_component_name); + std::string aComponentName = (const char*)component_name; + _resource.ComponentsList.push_back(aComponentName); + if (xmlHasProp(aCurSubNode, (const xmlChar*)test_module_name)) + { + xmlChar* module_name = xmlGetProp(aCurSubNode, (const xmlChar*)test_module_name); + std::string aModuleName = (const char*)module_name; + _resource.ModulesList.push_back(aModuleName); + xmlFree(module_name); + } + else + _resource.ModulesList.push_back(aComponentName); + xmlFree(component_name); + } + } + else if ( !xmlStrcmp(aCurSubNode->name, (const xmlChar*)test_modules) ) + { + // If a module is given, we create an entry in componentsList and modulesList + // with the same name (module == component) if (xmlHasProp(aCurSubNode, (const xmlChar*)test_module_name)) { - xmlChar* module_name = xmlGetProp(aCurSubNode, (const xmlChar*)test_module_name); - std::string aModuleName = (const char*)module_name; - _resource.ModulesList.push_back(aModuleName); - xmlFree(module_name); + xmlChar* component_name = xmlGetProp(aCurSubNode, (const xmlChar*)test_module_name); + std::string aComponentName = (const char*)component_name; + _resource.ComponentsList.push_back(aComponentName); + _resource.ModulesList.push_back(aComponentName); + xmlFree(component_name); } } aCurSubNode = aCurSubNode->next; @@ -315,13 +341,14 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) } else { - _resources_list[_resource.HostName] = _resource; if(_resource.HostName == "localhost") { _resource.HostName = Kernel_Utils::GetHostname(); _resource.DataForSort._hostName = Kernel_Utils::GetHostname(); _resources_list[Kernel_Utils::GetHostname()] = _resource; } + else + _resources_list[_resource.HostName] = _resource; } } else @@ -443,12 +470,12 @@ void SALOME_ResourcesCatalog_Handler::PrepareDocToXmlFile(xmlDocPtr theDoc) xmlNewProp(node, BAD_CAST test_user_name, BAD_CAST (*iter).second.UserName.c_str()); for (vector::const_iterator iter2 = - (*iter).second.ModulesList.begin(); - iter2 != (*iter).second.ModulesList.end(); + (*iter).second.ComponentsList.begin(); + iter2 != (*iter).second.ComponentsList.end(); iter2++) { - node1 = xmlNewChild(node, NULL, BAD_CAST test_modules, NULL); - xmlNewProp(node1, BAD_CAST test_module_name, BAD_CAST (*iter2).c_str()); + node1 = xmlNewChild(node, NULL, BAD_CAST test_components, NULL); + xmlNewProp(node1, BAD_CAST test_component_name, BAD_CAST (*iter2).c_str()); } xmlNewProp(node, BAD_CAST test_os, BAD_CAST (*iter).second.OS.c_str()); @@ -532,12 +559,12 @@ void SALOME_ResourcesCatalog_Handler::PrepareDocToXmlFile(xmlDocPtr theDoc) xmlNewProp(node, BAD_CAST test_user_name, BAD_CAST (*iter).second.UserName.c_str()); for (vector::const_iterator iter2 = - (*iter).second.ModulesList.begin(); - iter2 != (*iter).second.ModulesList.end(); + (*iter).second.ComponentsList.begin(); + iter2 != (*iter).second.ComponentsList.end(); iter2++) { - node1 = xmlNewChild(node, NULL, BAD_CAST test_modules, NULL); - xmlNewProp(node1, BAD_CAST test_module_name, BAD_CAST (*iter2).c_str()); + node1 = xmlNewChild(node, NULL, BAD_CAST test_components, NULL); + xmlNewProp(node1, BAD_CAST test_component_name, BAD_CAST (*iter2).c_str()); } xmlNewProp(node, BAD_CAST test_os, BAD_CAST (*iter).second.OS.c_str()); diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx index 35cd21296..a48dded3c 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx @@ -54,7 +54,7 @@ class RESOURCESMANAGER_EXPORT SALOME_ResourcesCatalog_Handler void PrepareDocToXmlFile(xmlDocPtr theDoc); private : - std::string previous_module_name; + std::string previous_component_name; ParserResourcesType _resource; MapOfParserResourcesType& _resources_list; @@ -71,8 +71,11 @@ class RESOURCESMANAGER_EXPORT SALOME_ResourcesCatalog_Handler const char *test_mpi; const char *test_user_name; const char *test_appli_path; + // for compatibility const char *test_modules; const char *test_module_name; + const char *test_components; + const char *test_component_name; const char *test_os; const char *test_mem_in_mb; const char *test_cpu_freq_mhz; diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx index fff95034a..510a00437 100644 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx @@ -133,10 +133,10 @@ void ParserResourcesType::Print() const "OS : " << OS << endl << "batchQueue : " << batchQueue << endl << "userCommands : " << userCommands << endl << - "Modules : " << endl; + "Components : " << endl; - for(int i=0;i ComponentsList; std::vector ModulesList; std::string OS; std::string batchQueue; diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index 408c2250a..1817edc86 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -66,9 +66,7 @@ SALOME_ResourcesManager(CORBA::ORB_ptr orb, _poa = PortableServer::POA::_duplicate(poa) ; PortableServer::ObjectId_var id = _poa->activate_object(this); CORBA::Object_var obj = _poa->id_to_reference(id); - Engines::SalomeLauncher_var refContMan = - Engines::SalomeLauncher::_narrow(obj); - + Engines::ResourcesManager_var refContMan = Engines::ResourcesManager::_narrow(obj); _NS->Register(refContMan,_ResourcesManagerNameInNS); MESSAGE("SALOME_ResourcesManager constructor end"); } @@ -124,20 +122,19 @@ void SALOME_ResourcesManager::Shutdown() _NS->Destroy_Name(_ResourcesManagerNameInNS); PortableServer::ObjectId_var oid = _poa->servant_to_id(this); _poa->deactivate_object(oid); - //_remove_ref(); } //============================================================================= /*! - * get the list of name of ressources fitting for the specified module. + * get the list of name of ressources fitting for the specified component. * If hostname specified, check it is local or known in resources catalog. * * Else * - select first machines with corresponding OS (all machines if * parameter OS empty), - * - then select the sublist of machines on witch the module is known + * - then select the sublist of machines on witch the component is known * (if the result is empty, that probably means that the inventory of - * modules is probably not done, so give complete list from previous step) + * components is probably not done, so give complete list from previous step) */ //============================================================================= @@ -189,11 +186,10 @@ SALOME_ResourcesManager::FindFirst(const Engines::MachineList& listOfMachines) return CORBA::string_dup(_rm.FindFirst(ml).c_str()); } -Engines::MachineParameters* SALOME_ResourcesManager::GetMachineParameters(const char *hostname) +Engines::MachineDefinition* SALOME_ResourcesManager::GetMachineParameters(const char *hostname) { ParserResourcesType resource = _rm.GetResourcesList(string(hostname)); - Engines::MachineParameters *p_ptr = new Engines::MachineParameters; - p_ptr->container_name = CORBA::string_dup(""); + Engines::MachineDefinition *p_ptr = new Engines::MachineDefinition; p_ptr->hostname = CORBA::string_dup(resource.HostName.c_str()); p_ptr->alias = CORBA::string_dup(resource.Alias.c_str()); if( resource.Protocol == rsh ) @@ -202,9 +198,9 @@ Engines::MachineParameters* SALOME_ResourcesManager::GetMachineParameters(const p_ptr->protocol = "ssh"; p_ptr->username = CORBA::string_dup(resource.UserName.c_str()); p_ptr->applipath = CORBA::string_dup(resource.AppliPath.c_str()); - p_ptr->modList.length(resource.ModulesList.size()); - for(unsigned int i=0;imodList[i] = CORBA::string_dup(resource.ModulesList[i].c_str()); + p_ptr->componentList.length(resource.ComponentsList.size()); + for(unsigned int i=0;icomponentList[i] = CORBA::string_dup(resource.ComponentsList[i].c_str()); p_ptr->OS = CORBA::string_dup(resource.OS.c_str()); p_ptr->mem_mb = resource.DataForSort._memInMB; p_ptr->cpu_clock = resource.DataForSort._CPUFreqMHz; diff --git a/src/ResourcesManager/SALOME_ResourcesManager.hxx b/src/ResourcesManager/SALOME_ResourcesManager.hxx index 9fcf8a1c6..1ef841757 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.hxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.hxx @@ -69,7 +69,7 @@ class SALOMERESOURCESMANAGER_EXPORT SALOME_ResourcesManager: char* FindFirst(const Engines::MachineList& listOfMachines); - Engines::MachineParameters* GetMachineParameters(const char *hostname); + Engines::MachineDefinition* GetMachineParameters(const char *hostname); void Shutdown();