Salome HOME
[EDF28561] : Set of toolkit to ease performance measures agy/edf28561
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 18 Sep 2023 06:33:37 +0000 (08:33 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 18 Sep 2023 06:33:37 +0000 (08:33 +0200)
idl/SALOME_ContainerManager.idl
src/Container/SALOME_ContainerManager.cxx
src/Container/SALOME_ContainerManager.hxx
src/Launcher_SWIG/Launcher.i
src/ResourcesManager/ResourcesManager.cxx
src/ResourcesManager/ResourcesManager.hxx

index 207b0ed9f89918808e3c3631ac7daa22ed5941ea..9251df6ab82ea1f3022d1eb6e3bb27f540d4e907 100644 (file)
@@ -97,8 +97,6 @@ interface ContainerManager
 
   void SetDeltaTimeBetweenNSLookupAtLaunchTimeInMilliSecond(in long timeInMS);
 
-  void MakeThisProcessAServer() raises (SALOME::SALOME_Exception);
-
   void SetOverrideEnvForContainers(in KeyValDict env);
 
   KeyValDict GetOverrideEnvForContainers();
index 23788a1fd00abd935c0ea6c4f86f7d57f781c289..adff087e557004f37b7901b6c281d10b4d9adc3a 100644 (file)
@@ -227,21 +227,6 @@ void SALOME_ContainerManager::SetDeltaTimeBetweenNSLookupAtLaunchTimeInMilliSeco
   this->_delta_time_ns_lookup_in_ms = timeInMS;
 }
 
-/*!
- * Launch a this->_orb->run() in order to respond to CORBA requests from the outside.
- */
-void SALOME_ContainerManager::MakeThisProcessAServer()
-{
-  if(_server_thread_launched)
-  {
-    THROW_SALOME_CORBA_EXCEPTION("orb.run() thread has already been launched. You are not supposed to launch it more than once",SALOME::BAD_PARAM);
-  }
-  _server_thread_launched = true;
-  auto ORBRunLauncher = [](CORBA::ORB_var orb) { MESSAGE("[SALOME_ContainerManager::MakeThisProcessAServer] ORB is running in a thread ...."); orb->run(); };
-  std::thread t(ORBRunLauncher,this->_orb);
-  t.detach();
-}
-
 //=============================================================================
 //! Loop on all the containers listed in naming service, ask shutdown on each
 /*! CORBA Method:
index 5f8388e515385d106bbd0787d76a0a9b83b5a727..67a333482df2c55960b76f931a2f8c2a22d09737 100644 (file)
@@ -69,8 +69,6 @@ public:
 
   void SetDeltaTimeBetweenNSLookupAtLaunchTimeInMilliSecond(CORBA::Long timeInMS) override;
 
-  void MakeThisProcessAServer();
-
   static const char *_ContainerManagerNameInNS;
 
 protected:
@@ -214,6 +212,5 @@ private:
   std::vector< std::pair<std::string, std::string> > _override_env;
   int _time_out_in_second;
   int _delta_time_ns_lookup_in_ms;
-  bool _server_thread_launched = false;
 };
 #endif
index b3c3401aa0ea910e5290a45e10fbc4a08590b9ba..f01e3126ef67d510a5fa39349e0600e93dbe067d 100644 (file)
@@ -173,7 +173,7 @@ public:
   ResourcesManager_cpp(const char *xmlFilePath);
   std::vector<std::string> GetFittingResources(const resourceParams& params);
   void WriteInXmlFile(std::string xml_file);
-
+  void DeleteAllResourcesInCatalog();
 %extend
 {
   ResourceDefinition_cpp GetResourceDefinition(const std::string& name)
@@ -336,9 +336,38 @@ def ResourceDefinition_cpp_repr(self):
 def ResourcesManager_cpp_GetList(self):
   return {name:self.GetResourceDefinition(name) for name in self.GetListOfEntries()}
 
+def ResourcesManager_cpp___getitem__(self,name):
+  return self.GetResourceDefinition(name)
+
+def ResourcesManager_cpp___repr__(self):
+  return str( self.GetList() )
+
+def RetrieveRMCppSingleton():
+  import KernelLauncher
+  return HandleToLocalInstance( KernelLauncher.RetrieveInternalInstanceOfLocalCppResourcesManager() )
+
+def GetPlayGroundInsideASlurmJob():
+  import subprocess as sp
+  cont = sp.check_output(["srun","hostname"])
+  nodesMul = [elt for elt in cont.decode().split("\n") if elt != ""]
+  from collections import defaultdict
+  d = defaultdict(int)
+  for elt in nodesMul:
+      d[elt]+=1
+  return d
+
+def BuildCatalogFromScratch(protocol):
+  import os
+  d = GetPlayGroundInsideASlurmJob()
+  rmcpp = RetrieveRMCppSingleton()
+  rmcpp.DeleteAllResourcesInCatalog()
+  for k,v in d.items():
+      contRes = CreateContainerResource(hostname=k,applipath=os.environ["APPLI"],protocol=protocol,nbOfNodes=v)
+      rmcpp.AddResourceInCatalog(contRes)
 
 ResourceDefinition_cpp.repr = ResourceDefinition_cpp_repr
 ResourceDefinition_cpp.__repr__ = ResourceDefinition_cpp_repr
 ResourcesManager_cpp.GetList = ResourcesManager_cpp_GetList
-
+ResourcesManager_cpp.__getitem__ = ResourcesManager_cpp___getitem__
+ResourcesManager_cpp.__repr__ = ResourcesManager_cpp___repr__
 %}
index 6e8535a7e6b81fb5dc731d75e06da9125f3971c2..fa528d5234948e4e81449f385419a42c8d6dde5e 100644 (file)
@@ -355,6 +355,11 @@ ResourcesManager_cpp::AddResourceInCatalog(const ParserResourcesType & new_resou
   _resourcesList[new_resource.Name] = new_resource;
 }
 
+void ResourcesManager_cpp::DeleteAllResourcesInCatalog()
+{
+  _resourcesList.clear();
+}
+
 //=============================================================================
 /*!
  *  Deletes a resource from the catalog
index d72308f253d8f38ae3e19d11b590444b2e9d983c..95e13c541cb67fcba99955b6bebb9cbc8a2e07d3 100644 (file)
@@ -82,6 +82,8 @@ class RESOURCESMANAGER_EXPORT ResourcesManager_cpp
     std::string Find(const std::string& policy, const std::vector<std::string>& listOfResources) const;
 
     void AddResourceInCatalog (const ParserResourcesType & new_resource);
+    
+    void DeleteAllResourcesInCatalog();
 
     void DeleteResourceInCatalog(const char * name);