From 8651e8d670f0f190bc2c68f78a352f01dc1792f9 Mon Sep 17 00:00:00 2001 From: ribes Date: Wed, 14 May 2008 14:14:29 +0000 Subject: [PATCH] Patch for bach clusters --- .../SALOME_ResourcesCatalog_Handler.cxx | 127 +++++++++++++++--- .../SALOME_ResourcesCatalog_Handler.hxx | 4 +- .../SALOME_ResourcesManager.cxx | 26 ++-- .../SALOME_ResourcesManager.hxx | 3 + 4 files changed, 134 insertions(+), 26 deletions(-) diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx index 659b3162a..181e40374 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx @@ -47,8 +47,10 @@ static int MYDEBUG = 0; //============================================================================= SALOME_ResourcesCatalog_Handler:: -SALOME_ResourcesCatalog_Handler(MapOfParserResourcesType& listOfResources): - _resources_list(listOfResources) +SALOME_ResourcesCatalog_Handler(MapOfParserResourcesType& resources_list, + MapOfParserResourcesType& resources_batch_list): + _resources_list(resources_list), + _resources_batch_list(resources_batch_list) { MESSAGE("SALOME_ResourcesCatalog_Handler creation"); //XML tags initialisation @@ -277,23 +279,32 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) } aCurSubNode = aCurSubNode->next; } - - int aNbNodes = _resource.DataForSort._nbOfNodes; - if( aNbNodes > 1 ){ - string clusterNode = _resource.DataForSort._hostName ; - for( int i=0; i < aNbNodes; i++ ){ - char inode[64]; - inode[0] = '\0' ; - sprintf(inode,"%s%d",clusterNode.c_str(),i+1); - std::string nodeName(inode); - _resource.DataForSort._hostName = nodeName ; - _resources_list[nodeName] = _resource; + + // There is two lists + // _resources_list for interactive resources + // _resources_batch_list for batch resources + // This choice is done with Mode parameter + if (_resource.Mode == interactive) + { + int aNbNodes = _resource.DataForSort._nbOfNodes; + if( aNbNodes > 1 ){ + string clusterNode = _resource.DataForSort._hostName ; + for( int i=0; i < aNbNodes; i++ ){ + char inode[64]; + inode[0] = '\0' ; + sprintf(inode,"%s%d",clusterNode.c_str(),i+1); + std::string nodeName(inode); + _resource.DataForSort._hostName = nodeName ; + _resource.HostName = nodeName ; + _resources_list[nodeName] = _resource; + } } + else + _resources_list[_resource.HostName] = _resource; } else - _resources_list[_resource.DataForSort._hostName] = _resource; + _resources_batch_list[_resource.HostName] = _resource; } - aCurNode = aCurNode->next; } @@ -305,6 +316,7 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) iter != _resources_list.end(); iter++) { + SCRUTE((*iter).second.HostName); SCRUTE((*iter).second.Alias); SCRUTE((*iter).second.UserName); SCRUTE((*iter).second.AppliPath); @@ -340,7 +352,90 @@ void SALOME_ResourcesCatalog_Handler::PrepareDocToXmlFile(xmlDocPtr theDoc) iter++) { node = xmlNewChild(root_node, NULL, BAD_CAST test_machine, NULL); - xmlNewProp(node, BAD_CAST test_hostname, BAD_CAST (*iter).first.c_str()); + xmlNewProp(node, BAD_CAST test_hostname, BAD_CAST (*iter).second.HostName.c_str()); + xmlNewProp(node, BAD_CAST test_alias, BAD_CAST (*iter).second.Alias.c_str()); + + switch ((*iter).second.Protocol) + { + case rsh: + xmlNewProp(node, BAD_CAST test_protocol, BAD_CAST "rsh"); + break; + case ssh: + xmlNewProp(node, BAD_CAST test_protocol, BAD_CAST "ssh"); + break; + default: + xmlNewProp(node, BAD_CAST test_protocol, BAD_CAST "rsh"); + } + + switch ((*iter).second.Mode) + { + case interactive: + xmlNewProp(node, BAD_CAST test_mode, BAD_CAST "interactive"); + break; + case batch: + xmlNewProp(node, BAD_CAST test_mode, BAD_CAST "batch"); + break; + default: + xmlNewProp(node, BAD_CAST test_mode, BAD_CAST "interactive"); + } + + switch ((*iter).second.Batch) + { + case pbs: + xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "pbs"); + break; + case lsf: + xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "lsf"); + break; + case slurm: + xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "slurm"); + break; + default: + xmlNewProp(node, BAD_CAST test_batch, BAD_CAST ""); + } + + switch ((*iter).second.mpi) + { + case lam: + xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "lam"); + break; + case mpich1: + xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "mpich1"); + break; + case mpich2: + xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "mpich2"); + break; + case openmpi: + xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "openmpi"); + break; + default: + xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST ""); + } + + 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(); + iter2++) + { + node1 = xmlNewChild(node, NULL, BAD_CAST test_modules, NULL); + xmlNewProp(node1, BAD_CAST test_module_name, BAD_CAST (*iter2).c_str()); + } + + xmlNewProp(node, BAD_CAST test_os, BAD_CAST (*iter).second.OS.c_str()); + xmlNewProp(node, BAD_CAST test_mem_in_mb, BAD_CAST sprintf(string_buf, "%u", (*iter).second.DataForSort._memInMB)); + xmlNewProp(node, BAD_CAST test_cpu_freq_mhz, BAD_CAST sprintf(string_buf, "%u", (*iter).second.DataForSort._CPUFreqMHz)); + xmlNewProp(node, BAD_CAST test_nb_of_nodes, BAD_CAST sprintf(string_buf, "%u", (*iter).second.DataForSort._nbOfNodes)); + xmlNewProp(node, BAD_CAST test_nb_of_proc_per_node, BAD_CAST sprintf(string_buf, "%u", (*iter).second.DataForSort._nbOfProcPerNode)); + } + for (map::iterator iter = + _resources_batch_list.begin(); + iter != _resources_batch_list.end(); + iter++) + { + node = xmlNewChild(root_node, NULL, BAD_CAST test_machine, NULL); + xmlNewProp(node, BAD_CAST test_hostname, BAD_CAST (*iter).second.HostName.c_str()); xmlNewProp(node, BAD_CAST test_alias, BAD_CAST (*iter).second.Alias.c_str()); switch ((*iter).second.Protocol) diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx index d636ff22f..9422c7bd1 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx @@ -40,7 +40,8 @@ class SALOME_ResourcesCatalog_Handler { public : - SALOME_ResourcesCatalog_Handler(MapOfParserResourcesType& listOfResources); + SALOME_ResourcesCatalog_Handler(MapOfParserResourcesType& resources_list, + MapOfParserResourcesType& resources_batch_list); const MapOfParserResourcesType& GetResourcesAfterParsing() const; @@ -55,6 +56,7 @@ class SALOME_ResourcesCatalog_Handler ParserResourcesType _resource; MapOfParserResourcesType& _resources_list; + MapOfParserResourcesType& _resources_batch_list; const char *test_machine; const char *test_resources; diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index cb8412a08..2ce747a50 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -162,15 +162,12 @@ void SALOME_ResourcesManager::Shutdown() Engines::MachineList * SALOME_ResourcesManager::GetFittingResources(const Engines::MachineParameters& params, const Engines::CompoList& componentList) -//throw(SALOME_Exception) { -// MESSAGE("ResourcesManager::GetFittingResources"); vector vec; Engines::MachineList *ret=new Engines::MachineList; - try{ // --- To be sure that we search in a correct list. - ParseXmlFile(); + // ParseXmlFile(); const char *hostname = (const char *)params.hostname; MESSAGE("GetFittingResources " << hostname << " " << GetHostname().c_str()); @@ -192,10 +189,14 @@ SALOME_ResourcesManager::GetFittingResources(const Engines::MachineParameters& p // --- params.hostname is in the list of resources so return it. vec.push_back(hostname); } - + else if (_resourcesBatchList.find(hostname) != _resourcesBatchList.end()) + { + // --- params.hostname is in the list of resources so return it. + vec.push_back(hostname); + } else { - // Cas d'un cluster: nombre de noeuds > 1 + // Cas d'un cluster interactif: nombre de noeuds > 1 int cpt=0; for (map::const_iterator iter = _resourcesList.begin(); iter != _resourcesList.end(); iter++){ if( (*iter).second.DataForSort._nbOfNodes > 1 ){ @@ -294,6 +295,7 @@ throw(SALOME_Exception) { ParserResourcesType newElt; newElt.DataForSort._hostName = paramsOfNewResources.hostname; + newElt.HostName = paramsOfNewResources.hostname; newElt.Alias = alias; newElt.Protocol = prot; newElt.Mode = mode; @@ -346,7 +348,7 @@ void SALOME_ResourcesManager::WriteInXmlFile() xmlNewDocComment(aDoc, BAD_CAST "ResourcesCatalog"); SALOME_ResourcesCatalog_Handler* handler = - new SALOME_ResourcesCatalog_Handler(_resourcesList); + new SALOME_ResourcesCatalog_Handler(_resourcesList, _resourcesBatchList); handler->PrepareDocToXmlFile(aDoc); delete handler; @@ -372,7 +374,7 @@ void SALOME_ResourcesManager::WriteInXmlFile() const MapOfParserResourcesType& SALOME_ResourcesManager::ParseXmlFile() { SALOME_ResourcesCatalog_Handler* handler = - new SALOME_ResourcesCatalog_Handler(_resourcesList); + new SALOME_ResourcesCatalog_Handler(_resourcesList, _resourcesBatchList); const char* aFilePath = _path_resources.c_str(); FILE* aFile = fopen(aFilePath, "r"); @@ -1155,7 +1157,12 @@ void SALOME_ResourcesManager::startMPI() Engines::MachineParameters* SALOME_ResourcesManager::GetMachineParameters(const char *hostname) { - ParserResourcesType resource = _resourcesList[string(hostname)]; + ParserResourcesType resource; + if (_resourcesList.find(hostname) != _resourcesList.end()) + resource = _resourcesList[string(hostname)]; + else + resource = _resourcesBatchList[string(hostname)]; + Engines::MachineParameters *p_ptr = new Engines::MachineParameters; p_ptr->container_name = CORBA::string_dup(""); p_ptr->hostname = CORBA::string_dup(resource.HostName.c_str()); @@ -1190,5 +1197,6 @@ Engines::MachineParameters* SALOME_ResourcesManager::GetMachineParameters(const p_ptr->batch = "lsf"; else if( resource.Batch == slurm ) p_ptr->batch = "slurm"; + return p_ptr; } diff --git a/src/ResourcesManager/SALOME_ResourcesManager.hxx b/src/ResourcesManager/SALOME_ResourcesManager.hxx index 23c7bd647..af258b807 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.hxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.hxx @@ -151,6 +151,9 @@ class RESOURCESMANAGER_EXPORT SALOME_ResourcesManager: //! will contain the informations on the data type catalog(after parsing) MapOfParserResourcesType _resourcesList; + // + //! will contain the informations on the data type catalog(after parsing) + MapOfParserResourcesType _resourcesBatchList; SALOME_LoadRateManager _dynamicResourcesSelecter; -- 2.39.2