Salome HOME
[EDF29150] : Add relevant traces in resource manager + dump of logmanager service
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 4 Jan 2024 17:08:01 +0000 (18:08 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 4 Jan 2024 17:08:01 +0000 (18:08 +0100)
idl/SALOME_LogManager.idl
src/Container/SALOME_ContainerHelper.py
src/KERNEL_PY/__init__.py
src/Launcher/SALOME_LogManager.cxx
src/Launcher/SALOME_LogManager.hxx
src/ResourcesManager/ResourcesManager.cxx
src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx
src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx
src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx

index 23415c700b769828d61ae8ecbdff8844e5a17e3d..c461c66d720f42691502ec2fbe5aabcb026b9cd3 100644 (file)
@@ -57,6 +57,7 @@ module Engines
   {
     ContainerPerfLog declareContainer(in string contInNS, in string logfile);
     ListOfContainerPerfLog listOfContainerLogs();
+    SALOME::vectorOfByte getAllStruct();
   };
 };
 
index c0dce572c5235b6425d2e2512cd8778c3c3ee25b..2d356284684943a7721809f55e23554a5cd555f7 100644 (file)
@@ -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
 
index 1adfba2a3e392338e467cb6f4e4dc91df34074fc..9a8a02a8598b73a1d23f29df262af0aae0e49838 100644 (file)
@@ -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()
index ea61ade7053b7fd665782fc29c0a0e7b2dcfcd54..baaa30783f0b4e652ed752f4eeecea332c663504 100644 (file)
@@ -48,6 +48,16 @@ static std::vector<char> FromPyToCpp(PyObject *obj)
   return ret;
 }
 
+static SALOME::vectorOfByte *FromVectCharToCorba(const std::vector<char>& 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<SALOME_ContainerScriptExecPerfLog *>(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<SALOME_ContainerScriptPerfLog *>(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<SALOME_ContainerPerfLog *>(serv);
+    servC->accept(visitor);
+  }
+  visitor.leaveLogManager( *this );
+}
+
+SALOME::vectorOfByte *SALOME_LogManager::getAllStruct()
+{
+  std::vector<char> data = this->dumpCppInternalFrmt();
+  return FromVectCharToCorba(data);
+}
+
+///////////////////////
+ #include <cstdint>
+
+static void PushIntInVC(std::uint32_t val, std::vector<char>& data)
+{
+  char *valPtr = reinterpret_cast<char *>(&val);
+  data.insert(data.end(),valPtr,valPtr+sizeof(std::uint32_t));
+}
+template<class T>
+static void PushStringInVC(const T& str, std::vector<char>& data)
+{
+  std::uint32_t sz = static_cast<std::uint32_t>( str.size() );
+  PushIntInVC(sz,data);
+  data.insert(data.end(),str.data(),str.data()+sz);
+}
+
+class InternalFormatVisitorDump : public SALOME_VisitorContainerLog
+{
+public:
+  InternalFormatVisitorDump(std::vector<char> *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<char> *_data = nullptr;
+};
+
+void InternalFormatVisitorDump::visitContainerScriptExecPerfLog(SALOME_ContainerScriptExecPerfLog& inst)
+{
+  PushStringInVC<std::vector<char>>(inst.data(),*_data);
+}
+
+void InternalFormatVisitorDump::enterContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst)
+{
+  PushStringInVC<std::string>(inst.name(),*_data);
+  PushStringInVC<std::string>(inst.code(),*_data);
+  PushIntInVC((std::uint32_t)inst.getNumberOfSessions(),*_data);
+}
+
+void InternalFormatVisitorDump::enterContainerPerfLog(SALOME_ContainerPerfLog& inst)
+{
+  PushStringInVC<std::string>(inst.nameInNS(),*_data);
+  PushStringInVC<std::string>(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<char> FetchVCFromVC(std::vector<char>& data, std::size_t& offset)
+{
+  std::uint32_t *sz = reinterpret_cast<std::uint32_t *>( data.data()+offset);
+  std::vector<char> 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<char>& data, std::size_t& offset)
+{
+  std::uint32_t *sz = reinterpret_cast<std::uint32_t *>( 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<char> *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<char> *_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<char> SALOME_LogManager::dumpCppInternalFrmt()
+{
+  std::vector<char> ret;
+  InternalFormatVisitorDump visitor(&ret);
+  this->accept( visitor );
+  return ret;
+}
index 81c58766900bdf61978be9c933f7a47d9081a85c..80cc55514ddd5d97d94886e942127ea1a1035df2 100644 (file)
@@ -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<char>& data() const { return _data; }
+  void setData(std::vector<char>&& 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<char> dumpCppInternalFrmt();
  private:
   PyObject *_pyLogManager = nullptr;
   std::unique_ptr<SALOME_NamingService_Abstract> _NS;
index fa528d5234948e4e81449f385419a42c8d6dde5e..22156a57b05ae2bdebf21a418c8970bde76d2d4f 100644 (file)
@@ -25,6 +25,7 @@
 #include "SALOME_ResourcesCatalog_Handler.hxx"
 #include <Basics_Utils.hxx>
 #include <Basics_DirUtils.hxx>
+#include "utilities.h"
 
 #include <fstream>
 #include <iostream>
@@ -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<SALOME_ResourcesCatalog_Handler> 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.");
 }
index adf58b6a347f5fd2379b55f3c2bd1e62afd14415..7e898d2bc9d4c60932adbcc2fbc1fe2261331ec5 100644 (file)
@@ -156,13 +156,12 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc)
     }
     aCurNode = aCurNode->next;
   }
-
-  DEBUG_MESSAGE( "************************************************" );
+  DEBUG_MESSAGE( "************ Resources in memory ************");
   for (std::map<std::string, ParserResourcesType>::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
index 037297f17830b2f0166b73492098c351894f1b00..ec821320c17383606dbc369efadcb27f87a7c57f 100644 (file)
@@ -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 ; i<prt.ComponentsList.size() ; i++)
-    os << "Component " << i+1 << " called: " << prt.ComponentsList[i] << endl;
+  std::ostringstream oss;
+  oss << "Name: " << this->Name << 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 ; i<this->ComponentsList.size() ; i++)
+    oss << "Component " << i+1 << " called: " << this->ComponentsList[i] << sep;
 
   list<ParserResourcesType>::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;
 }
 
index 1c3780758427a6d4168441ddfe67a2600c9ba201..2001d353c96734ef96c970acafb68a644c28274a 100644 (file)
@@ -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;