From f8cf81e318541aad6d28d3ae38841b0689a16612 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Thu, 4 Jan 2024 18:08:01 +0100 Subject: [PATCH] [EDF29150] : Add relevant traces in resource manager + dump of logmanager service --- idl/SALOME_LogManager.idl | 1 + src/Container/SALOME_ContainerHelper.py | 32 ++- src/KERNEL_PY/__init__.py | 2 +- src/Launcher/SALOME_LogManager.cxx | 183 +++++++++++++++++- src/Launcher/SALOME_LogManager.hxx | 37 ++++ src/ResourcesManager/ResourcesManager.cxx | 36 ++-- .../SALOME_ResourcesCatalog_Handler.cxx | 7 +- .../SALOME_ResourcesCatalog_Parser.cxx | 61 +++--- .../SALOME_ResourcesCatalog_Parser.hxx | 1 + 9 files changed, 301 insertions(+), 59 deletions(-) diff --git a/idl/SALOME_LogManager.idl b/idl/SALOME_LogManager.idl index 23415c700..c461c66d7 100644 --- a/idl/SALOME_LogManager.idl +++ b/idl/SALOME_LogManager.idl @@ -57,6 +57,7 @@ module Engines { ContainerPerfLog declareContainer(in string contInNS, in string logfile); ListOfContainerPerfLog listOfContainerLogs(); + SALOME::vectorOfByte getAllStruct(); }; }; diff --git a/src/Container/SALOME_ContainerHelper.py b/src/Container/SALOME_ContainerHelper.py index c0dce572c..2d3562846 100644 --- a/src/Container/SALOME_ContainerHelper.py +++ b/src/Container/SALOME_ContainerHelper.py @@ -250,7 +250,7 @@ class ScriptExecInfoDeco: cont = f.read() return cont[self._eff.tracePosStart:self._eff.tracePosStop].decode() -class ScriptInfo: +class ScriptInfoAbstract: def __init__(self, scriptPtr): self._node_name = scriptPtr.getName() self._code = scriptPtr.getCode() @@ -283,6 +283,18 @@ class ScriptInfo: def __repr__(self): return """ScriptInfo \"{self.nodeName}\"""".format(**locals()) + +class ScriptInfoClt(ScriptInfoAbstract): + def __init__(self, scriptPtr): + self._node_name = scriptPtr.getName() + self._code = scriptPtr.getCode() + self._exec = [pickle.loads(elt.getObj()) for elt in scriptPtr.listOfExecs()] + +class ScriptInfo(ScriptInfoAbstract): + def __init__(self, nodeName, code, execs): + self._node_name = nodeName + self._code = code + self._exec = execs class ScriptInfoDeco: def __init__(self, eff, father): @@ -300,11 +312,7 @@ class ScriptInfoDeco: def __repr__(self): return self._eff.__repr__() -class ContainerLogInfo: - def __init__(self,contLogPtr): - self._log_file = contLogPtr.getLogFile() - self._ns_entry = contLogPtr.getContainerEntryInNS() - self._scripts = [ScriptInfo(elt) for elt in contLogPtr.listOfScripts()] +class ContainerLogInfoAbstract: def log(self): with open(self.logfile,"rb") as f: @@ -327,6 +335,18 @@ class ContainerLogInfo: def __str__(self): return """NS entry = {self.ns_entry} LogFile = {self.logfile}""".format(**locals()) + +class ContainerLogInfoClt(ContainerLogInfoAbstract): + def __init__(self,contLogPtr): + self._log_file = contLogPtr.getLogFile() + self._ns_entry = contLogPtr.getContainerEntryInNS() + self._scripts = [ScriptInfoClt(elt) for elt in contLogPtr.listOfScripts()] + +class ContainerLogInfo(ContainerLogInfoAbstract): + def __init__(self, logFile, nsEntry, scripts): + self._log_file = logFile + self._ns_entry = nsEntry + self._scripts = scripts from abc import ABC, abstractmethod diff --git a/src/KERNEL_PY/__init__.py b/src/KERNEL_PY/__init__.py index 1adfba2a3..9a8a02a85 100644 --- a/src/KERNEL_PY/__init__.py +++ b/src/KERNEL_PY/__init__.py @@ -453,7 +453,7 @@ def ContainerManagerSetOverrideEnvForContainersSimple(self,env): def LogManagerFetch(self): import SALOME_ContainerHelper - return [SALOME_ContainerHelper.ContainerLogInfo(elt) for elt in self.listOfContainerLogs()] + return [SALOME_ContainerHelper.ContainerLogInfoClt(elt) for elt in self.listOfContainerLogs()] #to expose all objects to pydoc __all__=dir() diff --git a/src/Launcher/SALOME_LogManager.cxx b/src/Launcher/SALOME_LogManager.cxx index ea61ade70..baaa30783 100644 --- a/src/Launcher/SALOME_LogManager.cxx +++ b/src/Launcher/SALOME_LogManager.cxx @@ -48,6 +48,16 @@ static std::vector FromPyToCpp(PyObject *obj) return ret; } +static SALOME::vectorOfByte *FromVectCharToCorba(const std::vector& data) +{ + SALOME::vectorOfByte_var ret = new SALOME::vectorOfByte; + auto length = data.size(); + ret->length(length); + for(auto i = 0 ; i < length ; ++i) + ret[i] = data[i]; + return ret._retn(); +} + PortableServer::POA_var SALOME_ContainerScriptExecPerfLog::getPOA() { return father()->getPOA(); @@ -67,12 +77,12 @@ void SALOME_ContainerScriptExecPerfLog::assign(const SALOME::vectorOfByte& value SALOME::vectorOfByte *SALOME_ContainerScriptExecPerfLog::getObj() { - SALOME::vectorOfByte_var ret = new SALOME::vectorOfByte; - auto length = this->_data.size(); - ret->length(length); - for(auto i = 0 ; i < length ; ++i) - ret[i] = _data[i]; - return ret._retn(); + return FromVectCharToCorba(this->_data); +} + +void SALOME_ContainerScriptExecPerfLog::accept(SALOME_VisitorContainerLog &visitor) +{ + visitor.visitContainerScriptExecPerfLog( *this ); } void SALOME_ContainerScriptExecPerfLog::start() @@ -118,6 +128,19 @@ char *SALOME_ContainerScriptPerfLog::getName() return CORBA::string_dup( _name.c_str() ); } +void SALOME_ContainerScriptPerfLog::accept(SALOME_VisitorContainerLog &visitor) +{ + visitor.enterContainerScriptPerfLog( *this ); + for(auto session : _sessions) + { + PortableServer::ServantBase *serv = getPOA()->reference_to_servant( session ); + serv->_remove_ref(); + SALOME_ContainerScriptExecPerfLog *servC = dynamic_cast(serv); + visitor.visitContainerScriptExecPerfLog( *servC ); + } + visitor.enterContainerScriptPerfLog( *this ); +} + Engines::ContainerScriptExecPerfLog_ptr SALOME_ContainerScriptPerfLog::addExecutionSession() { SALOME_ContainerScriptExecPerfLog *execution = new SALOME_ContainerScriptExecPerfLog(this); @@ -190,6 +213,19 @@ Engines::ListOfContainerScriptPerfLog *SALOME_ContainerPerfLog::listOfScripts() return ret._retn(); } +void SALOME_ContainerPerfLog::accept(SALOME_VisitorContainerLog &visitor) +{ + visitor.enterContainerPerfLog( *this ); + for(auto script : _scripts) + { + PortableServer::ServantBase *serv = getPOA()->reference_to_servant( script ); + serv->_remove_ref(); + SALOME_ContainerScriptPerfLog *servC = dynamic_cast(serv); + servC->accept(visitor); + } + visitor.leaveContainerPerfLog( *this ); +} + char *SALOME_ContainerPerfLog::getLogFile() { return CORBA::string_dup( this->_log_file.c_str() ); @@ -254,3 +290,138 @@ Engines::ListOfContainerPerfLog *SALOME_LogManager::listOfContainerLogs() } return ret._retn(); } + +void SALOME_LogManager::accept(SALOME_VisitorContainerLog &visitor) +{ + visitor.enterLogManager( *this ); + for(auto container : _containers) + { + PortableServer::ServantBase *serv = getPOA()->reference_to_servant( container ); + serv->_remove_ref(); + SALOME_ContainerPerfLog *servC = dynamic_cast(serv); + servC->accept(visitor); + } + visitor.leaveLogManager( *this ); +} + +SALOME::vectorOfByte *SALOME_LogManager::getAllStruct() +{ + std::vector data = this->dumpCppInternalFrmt(); + return FromVectCharToCorba(data); +} + +/////////////////////// + + #include + +static void PushIntInVC(std::uint32_t val, std::vector& data) +{ + char *valPtr = reinterpret_cast(&val); + data.insert(data.end(),valPtr,valPtr+sizeof(std::uint32_t)); +} + +template +static void PushStringInVC(const T& str, std::vector& data) +{ + std::uint32_t sz = static_cast( str.size() ); + PushIntInVC(sz,data); + data.insert(data.end(),str.data(),str.data()+sz); +} + +class InternalFormatVisitorDump : public SALOME_VisitorContainerLog +{ +public: + InternalFormatVisitorDump(std::vector *data):_data(data) { } + void enterLogManager(SALOME_LogManager& inst) override; + void leaveLogManager(SALOME_LogManager& inst) override { } + void enterContainerPerfLog(SALOME_ContainerPerfLog& inst) override; + void leaveContainerPerfLog(SALOME_ContainerPerfLog& inst) override { } + void enterContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst) override; + void leaveContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst) override { } + void visitContainerScriptExecPerfLog(SALOME_ContainerScriptExecPerfLog& inst) override; +private: + std::vector *_data = nullptr; +}; + +void InternalFormatVisitorDump::visitContainerScriptExecPerfLog(SALOME_ContainerScriptExecPerfLog& inst) +{ + PushStringInVC>(inst.data(),*_data); +} + +void InternalFormatVisitorDump::enterContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst) +{ + PushStringInVC(inst.name(),*_data); + PushStringInVC(inst.code(),*_data); + PushIntInVC((std::uint32_t)inst.getNumberOfSessions(),*_data); +} + +void InternalFormatVisitorDump::enterContainerPerfLog(SALOME_ContainerPerfLog& inst) +{ + PushStringInVC(inst.nameInNS(),*_data); + PushStringInVC(inst.logFile(),*_data); + PushIntInVC((std::uint32_t)inst.getNumberOfScripts(),*_data); +} + +void InternalFormatVisitorDump::enterLogManager(SALOME_LogManager& inst) +{ + PushIntInVC((std::uint32_t)inst.getNumberOfContainers(),*_data); +} + +/////////////////////// + +std::vector FetchVCFromVC(std::vector& data, std::size_t& offset) +{ + std::uint32_t *sz = reinterpret_cast( data.data()+offset); + std::vector ret(data.data()+offset+sizeof(std::uint32_t),data.data()+offset+sizeof(std::uint32_t)+*sz); + offset += sizeof(std::uint32_t)+*sz; + return ret; +} + +std::string FetchStringFromVC(std::vector& data, std::size_t& offset) +{ + std::uint32_t *sz = reinterpret_cast( data.data() ); + std::string ret(data.data()+sizeof(std::uint32_t),*sz); + offset += sizeof(std::uint32_t)+*sz; + return ret; +} + +class InternalFormatVisitorLoad : public SALOME_VisitorContainerLog +{ +public: + InternalFormatVisitorLoad(std::vector *data):_data(data) { } + void enterContainerPerfLog(SALOME_ContainerPerfLog& inst) override; + void leaveContainerPerfLog(SALOME_ContainerPerfLog& inst) override { } + void enterContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst) override; + void leaveContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst) override { } + void visitContainerScriptExecPerfLog(SALOME_ContainerScriptExecPerfLog& inst) override; +private: + std::vector *_data = nullptr; + std::size_t _offset = 0; +}; + +void InternalFormatVisitorLoad::visitContainerScriptExecPerfLog(SALOME_ContainerScriptExecPerfLog& inst) +{ + inst.setData( FetchVCFromVC( *_data, _offset ) ); +} + +void InternalFormatVisitorLoad::enterContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst) +{ + inst.setName( FetchStringFromVC(*_data, _offset) ); + inst.setCode( FetchStringFromVC(*_data, _offset) ); +} + +void InternalFormatVisitorLoad::enterContainerPerfLog(SALOME_ContainerPerfLog& inst) +{ + inst.setNameInNS( FetchStringFromVC(*_data, _offset) ); + inst.setLogFile( FetchStringFromVC(*_data, _offset) ); +} + +/////////////////////// + +std::vector SALOME_LogManager::dumpCppInternalFrmt() +{ + std::vector ret; + InternalFormatVisitorDump visitor(&ret); + this->accept( visitor ); + return ret; +} diff --git a/src/Launcher/SALOME_LogManager.hxx b/src/Launcher/SALOME_LogManager.hxx index 81c587669..80cc55514 100644 --- a/src/Launcher/SALOME_LogManager.hxx +++ b/src/Launcher/SALOME_LogManager.hxx @@ -37,6 +37,19 @@ class SALOME_NamingService_Abstract; class SALOME_LogManager; class SALOME_ContainerPerfLog; class SALOME_ContainerScriptPerfLog; +class SALOME_ContainerScriptExecPerfLog; + +class SALOMELAUNCHER_EXPORT SALOME_VisitorContainerLog +{ +public: + virtual void enterLogManager(SALOME_LogManager& inst) = 0; + virtual void leaveLogManager(SALOME_LogManager& inst) = 0; + virtual void enterContainerPerfLog(SALOME_ContainerPerfLog& inst) = 0; + virtual void leaveContainerPerfLog(SALOME_ContainerPerfLog& inst) = 0; + virtual void enterContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst) = 0; + virtual void leaveContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst) = 0; + virtual void visitContainerScriptExecPerfLog(SALOME_ContainerScriptExecPerfLog& inst) = 0; +}; class SALOMELAUNCHER_EXPORT SALOME_ContainerScriptExecPerfLog : public POA_Engines::ContainerScriptExecPerfLog { @@ -48,6 +61,10 @@ public: PortableServer::POA_var getPOA(); void assign(const SALOME::vectorOfByte& value) override; SALOME::vectorOfByte *getObj() override; + const std::vector& data() const { return _data; } + void setData(std::vector&& data) { _data = std::move(data); } +public: + void accept(SALOME_VisitorContainerLog &visitor); public: void start(); AutoPyRef end(); @@ -69,6 +86,13 @@ public: Engines::ListOfContainerScriptExecPerfLog *listOfExecs() override; char *getCode() override; char *getName() override; + const std::string& name() const { return _name; } + const std::string& code() const { return _code; } + void setName(const std::string& name) { _name = name; } + void setCode(const std::string& code) { _code = code; } + std::size_t getNumberOfSessions() const { return _sessions.size(); } +public: + void accept(SALOME_VisitorContainerLog &visitor); private: AutoPyRef _pyScriptLog; SALOME_ContainerPerfLog *_father = nullptr; @@ -89,6 +113,13 @@ public: char *getContainerEntryInNS() override; Engines::ContainerScriptPerfLog_ptr addScript(const char *name, const char *code) override; Engines::ListOfContainerScriptPerfLog *listOfScripts() override; + const std::string& nameInNS() const { return _name_in_ns; } + const std::string& logFile() const { return _log_file; } + void setNameInNS(const std::string& name) { _name_in_ns = name; } + void setLogFile(const std::string& logFile) { _log_file = logFile; } + std::size_t getNumberOfScripts() const { return _scripts.size(); } +public: + void accept(SALOME_VisitorContainerLog &visitor); private: AutoPyRef _pyContLog; SALOME_LogManager *_father = nullptr; @@ -106,6 +137,12 @@ class SALOMELAUNCHER_EXPORT SALOME_LogManager : public POA_Engines::LogManager virtual ~SALOME_LogManager() = default; Engines::ContainerPerfLog_ptr declareContainer(const char *contInNS, const char *logfile) override; Engines::ListOfContainerPerfLog *listOfContainerLogs() override; + SALOME::vectorOfByte *getAllStruct() override; + std::size_t getNumberOfContainers() const { return _containers.size(); } + public: + void accept(SALOME_VisitorContainerLog &visitor); + private: + std::vector dumpCppInternalFrmt(); private: PyObject *_pyLogManager = nullptr; std::unique_ptr _NS; diff --git a/src/ResourcesManager/ResourcesManager.cxx b/src/ResourcesManager/ResourcesManager.cxx index fa528d523..22156a57b 100644 --- a/src/ResourcesManager/ResourcesManager.cxx +++ b/src/ResourcesManager/ResourcesManager.cxx @@ -25,6 +25,7 @@ #include "SALOME_ResourcesCatalog_Handler.hxx" #include #include +#include "utilities.h" #include #include @@ -118,18 +119,19 @@ ResourcesManager_cpp::ResourcesManager_cpp() std::ifstream ifile(user_file.c_str(), std::ifstream::in ); if (ifile) { // The file exists, and is open for input + DEBUG_MESSAGE("USER_CATALOG_RESOURCES_FILE positioned -> add it into resourcefiles list"); _path_resources.push_back(user_file); } else { default_catalog_resource = false; - RES_INFOS("Warning: USER_CATALOG_RESOURCES_FILE is set and file cannot be found.") - RES_INFOS("Warning: That's why we try to create a new one.") + WARNING_MESSAGE("Warning: USER_CATALOG_RESOURCES_FILE is set and file cannot be found.") + WARNING_MESSAGE("Warning: That's why we try to create a new one.") std::ofstream user_catalog_file; user_catalog_file.open(user_file.c_str()); if (user_catalog_file.fail()) { - RES_INFOS("Error: cannot write in the user catalog resources files"); - RES_INFOS("Error: using default CatalogResources.xml file"); + WARNING_MESSAGE("Error: cannot write in the user catalog resources files"); + WARNING_MESSAGE("Error: using default CatalogResources.xml file"); default_catalog_resource = true; } else @@ -155,6 +157,7 @@ ResourcesManager_cpp::ResourcesManager_cpp() std::ifstream ifile(default_file.c_str(), std::ifstream::in ); if (ifile) { // The file exists, and is open for input + DEBUG_MESSAGE("${APPLI}/CatalogResources.xml exists -> add it into resourcefiles list"); _path_resources.push_back(default_file); default_catalog_resource=false; } @@ -167,6 +170,7 @@ ResourcesManager_cpp::ResourcesManager_cpp() throw ResourcesException("you must define KERNEL_ROOT_DIR environment variable!! -> cannot load a CatalogResources.xml"); default_file = getenv("KERNEL_ROOT_DIR"); default_file += "/share/salome/resources/kernel/CatalogResources.xml"; + DEBUG_MESSAGE("${KERNEL_ROOT_DIR}/share/salome/resources/kernel/CatalogResources.xml -> add it into resourcefiles list"); _path_resources.push_back(default_file); } @@ -445,12 +449,13 @@ const MapOfParserResourcesType& ResourcesManager_cpp::ParseXmlFiles() int result = stat((*_path_resources_it).c_str(), &statinfo); if (result < 0) { - RES_MESSAGE("Resource file " << *_path_resources_it << " does not exist"); + WARNING_MESSAGE("Resource file " << *_path_resources_it << " does not exist -> no parsing"); return _resourcesList; } if(_lasttime == 0 || statinfo.st_mtime > _lasttime) { + DEBUG_MESSAGE("Resource file " << *_path_resources_it << " has been detected to be present and newer than Resources in memory"); to_parse = true; _lasttime = statinfo.st_mtime; } @@ -458,6 +463,7 @@ const MapOfParserResourcesType& ResourcesManager_cpp::ParseXmlFiles() if (to_parse) { + DEBUG_MESSAGE("After analyze of resoure files time meta data, a load of resources from scratch from files is necessary."); _resourcesList.clear(); AddDefaultResourceInCatalog(); // On parse tous les fichiers @@ -465,15 +471,15 @@ const MapOfParserResourcesType& ResourcesManager_cpp::ParseXmlFiles() { MapOfParserResourcesType _resourcesList_tmp; MapOfParserResourcesType _resourcesBatchList_tmp; - SALOME_ResourcesCatalog_Handler *handler( new SALOME_ResourcesCatalog_Handler(_resourcesList_tmp) ); + std::unique_ptr handler( new SALOME_ResourcesCatalog_Handler(_resourcesList_tmp) ); const char *aFilePath( (*_path_resources_it).c_str() ); FILE* aFile = fopen(aFilePath, "r"); - if (aFile != NULL) { xmlDocPtr aDoc = xmlReadFile(aFilePath, NULL, 0); if (aDoc != NULL) { + DEBUG_MESSAGE("XML parsing of Resource file \"" << aFilePath << "\""); handler->ProcessXmlDocument(aDoc); // adding new resources to the file @@ -482,39 +488,38 @@ const MapOfParserResourcesType& ResourcesManager_cpp::ParseXmlFiles() MapOfParserResourcesType_it j = _resourcesList.find(i->first); if (i->second.HostName == DEFAULT_RESOURCE_NAME || i->second.HostName == Kernel_Utils::GetHostname()) { + DEBUG_MESSAGE("Resource \"" << i->first << "\" in file \"" << aFilePath << "\" is detected as localhost"); MapOfParserResourcesType_it it0(_resourcesList.find(DEFAULT_RESOURCE_NAME)); if(it0!=_resourcesList.end()) { + DEBUG_MESSAGE("Resource \"" << i->first << "\" in file \"" << aFilePath << "\" detected as localhost is already in memory -> update resource with content in file ( for attributes : nbOfNodes, nbOfProcPerNode, CPUFreqMHz and memInMB)"); ParserResourcesType& localhostElt((*it0).second); localhostElt.DataForSort._nbOfNodes=(*i).second.DataForSort._nbOfNodes; localhostElt.DataForSort._nbOfProcPerNode=(*i).second.DataForSort._nbOfProcPerNode; localhostElt.DataForSort._CPUFreqMHz=(*i).second.DataForSort._CPUFreqMHz; localhostElt.DataForSort._memInMB=(*i).second.DataForSort._memInMB; } - RES_MESSAGE("Resource " << i->first << " is not added because it is the same " - "machine as default local resource \"" << DEFAULT_RESOURCE_NAME << "\""); + DEBUG_MESSAGE("Resource \"" << i->first << "\" is not added because it is the same machine as default local resource \"" << DEFAULT_RESOURCE_NAME << "\""); } else if (j != _resourcesList.end()) { - cerr << "ParseXmlFiles Warning, two resources with the same name were found, " - "taking the first declaration : " << i->first << endl; + WARNING_MESSAGE("ParseXmlFiles Warning, two resources with the same name were found, taking the first declaration : " << i->first ); } else { + DEBUG_MESSAGE("Resource \"" << i->first << "\" added"); _resourcesList[i->first] = i->second; } } } else - std::cerr << "ResourcesManager_cpp: could not parse file " << aFilePath << std::endl; + ERROR_MESSAGE( "ResourcesManager_cpp: could not parse file " << aFilePath ); // Free the document xmlFreeDoc(aDoc); fclose(aFile); } else - std::cerr << "ResourcesManager_cpp: file " << aFilePath << " is not readable." << std::endl; - - delete handler; + ERROR_MESSAGE( "ResourcesManager_cpp: file " << aFilePath << " is not readable." ); } } return _resourcesList; @@ -666,4 +671,5 @@ void ResourcesManager_cpp::AddDefaultResourceInCatalog() resource.can_launch_batch_jobs = true; resource.can_run_containers = true; _resourcesList[resource.Name] = resource; + DEBUG_MESSAGE("Put Ressource \"" << resource.Name << "\" in dictionary of resources. This resource will be present even if resource files define it later."); } diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx index adf58b6a3..7e898d2bc 100644 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx @@ -156,13 +156,12 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) } aCurNode = aCurNode->next; } - - DEBUG_MESSAGE( "************************************************" ); + DEBUG_MESSAGE( "************ Resources in memory ************"); for (std::map::const_iterator iter = _resources_list.begin(); iter != _resources_list.end(); iter++) { - DEBUG_MESSAGE( "Resource " << (*iter).first << " found: " << std::endl << (*iter).second); + DEBUG_MESSAGE( "Resource \"" << (*iter).first << "\" -> " << (*iter).second.dump(' ')); } - DEBUG_MESSAGE( "************************************************" ); + DEBUG_MESSAGE( "************ Resources in memory ************"); } bool diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx index 037297f17..ec821320c 100644 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx @@ -195,38 +195,45 @@ AccessProtocolType ParserResourcesType::stringToProtocol(const std::string & pro throw ResourcesException((string("Unknown protocol ") + protocolStr).c_str()); } -ostream & operator<<(ostream &os, const ParserResourcesType &prt) +std::string ParserResourcesType::dump(char sep) const { - os << "Name: " << prt.Name << endl << - "HostName: " << prt.HostName << endl << - "Type: " << prt.getResourceTypeStr() << endl << - "NbOfNodes: " << prt.DataForSort._nbOfNodes << endl << - "NbOfProcPerNode: " << prt.DataForSort._nbOfProcPerNode << endl << - "CPUFreqMHz: " << prt.DataForSort._CPUFreqMHz << endl << - "MemInMB: " << prt.DataForSort._memInMB << endl << - "Protocol: " << prt.getAccessProtocolTypeStr() << endl << - "ClusterInternalProtocol: " << prt.getClusterInternalProtocolStr() << endl << - "Batch: " << prt.getBatchTypeStr() << endl << - "mpi: " << prt.getMpiImplTypeStr() << endl << - "UserName: " << prt.UserName << endl << - "AppliPath: " << prt.AppliPath << endl << - "OS: " << prt.OS << endl << - "batchQueue: " << prt.batchQueue << endl << - "userCommands: " << prt.userCommands << endl << - "use: " << prt.use << endl << - "NbOfProc: " << prt.nbOfProc << endl << - "Can Launch Batch Jobs: " << prt.can_launch_batch_jobs << endl << - "Can Run Containers: " << prt.can_run_containers << endl << - "Working Directory: " << prt.working_directory << endl; - - for(unsigned int i=0 ; iName << sep << + "HostName: " << this->HostName << sep << + "Type: " << this->getResourceTypeStr() << sep << + "NbOfNodes: " << this->DataForSort._nbOfNodes << sep << + "NbOfProcPerNode: " << this->DataForSort._nbOfProcPerNode << sep << + "CPUFreqMHz: " << this->DataForSort._CPUFreqMHz << sep << + "MemInMB: " << this->DataForSort._memInMB << sep << + "Protocol: " << this->getAccessProtocolTypeStr() << sep << + "ClusterInternalProtocol: " << this->getClusterInternalProtocolStr() << sep << + "Batch: " << this->getBatchTypeStr() << sep << + "mpi: " << this->getMpiImplTypeStr() << sep << + "UserName: " << this->UserName << sep << + "AppliPath: " << this->AppliPath << sep << + "OS: " << this->OS << sep << + "batchQueue: " << this->batchQueue << sep << + "userCommands: " << this->userCommands << sep << + "use: " << this->use << sep << + "NbOfProc: " << this->nbOfProc << sep << + "Can Launch Batch Jobs: " << this->can_launch_batch_jobs << sep << + "Can Run Containers: " << this->can_run_containers << sep << + "Working Directory: " << this->working_directory << sep; + + for(unsigned int i=0 ; iComponentsList.size() ; i++) + oss << "Component " << i+1 << " called: " << this->ComponentsList[i] << sep; list::const_iterator it; - for(it = prt.ClusterMembersList.begin() ; it != prt.ClusterMembersList.end() ; it++) + for(it = this->ClusterMembersList.cbegin() ; it != this->ClusterMembersList.cend() ; it++) { - os << "Cluster member called: " << (*it).HostName << endl; + oss << "Cluster member called: " << (*it).HostName << sep; } + return oss.str(); +} + +ostream & operator<<(ostream &os, const ParserResourcesType &prt) +{ + os << prt.dump('\n'); return os; } diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx index 1c3780758..2001d353c 100644 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx @@ -107,6 +107,7 @@ public: void setClusterInternalProtocolStr(const std::string & internalProtocolTypeStr); void setCanLaunchBatchJobsStr(const std::string & canLaunchBatchJobsStr); void setCanRunContainersStr(const std::string & canRunContainersStr); + std::string dump(char sep) const; ResourceDataToSort DataForSort; std::string Name; -- 2.39.2