From: Renaud Barate Date: Thu, 8 Jan 2015 09:44:06 +0000 (+0100) Subject: Fix a bug causing concurrent access problems to the Resources Manager X-Git-Tag: V7_5_1rc1~2^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6ba22390ee3d60fabbb7fcfca5a0911feca55717;p=modules%2Fkernel.git Fix a bug causing concurrent access problems to the Resources Manager Since the development of parallel container launch, the container manager is multi-threaded, but it used directly the resource manager which is not thread safe. With this fix, all calls from the container manager to the resource manager are done through CORBA, and since the resource manager runs in a single-thread POA, thread-safety is ensured. --- diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index 8a33c0fec..ee9a30adc 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -22,6 +22,7 @@ #include "SALOME_ContainerManager.hxx" #include "SALOME_NamingService.hxx" +#include "SALOME_ResourcesManager_Client.hxx" #include "SALOME_ModuleCatalog.hh" #include "Basics_Utils.hxx" #include "Basics_DirUtils.hxx" @@ -68,11 +69,12 @@ Utils_Mutex SALOME_ContainerManager::_systemMutex; */ //============================================================================= -SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_ResourcesManager *rm, SALOME_NamingService *ns):_nbprocUsed(1) +SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService *ns) + : _nbprocUsed(1) { MESSAGE("constructor"); _NS = ns; - _ResManager = rm; + _resManager = new SALOME_ResourcesManager_Client(ns); PortableServer::POAManager_var pman = poa->the_POAManager(); _orb = CORBA::ORB::_duplicate(orb) ; @@ -148,6 +150,7 @@ SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableSer SALOME_ContainerManager::~SALOME_ContainerManager() { MESSAGE("destructor"); + delete _resManager; #ifdef HAVE_MPI2 #ifdef WITHOPENMPI if( GetenvThreadSafe("OMPI_URI_FILE") != NULL ){ @@ -299,21 +302,22 @@ Engines::Container_ptr SALOME_ContainerManager::GiveContainer(const Engines::Con // Step 2: Get all possibleResources from the parameters // Consider only resources that can run containers - local_params.resource_params.can_run_containers = true; - Engines::ResourceList_var possibleResources = _ResManager->GetFittingResources(local_params.resource_params); - MESSAGE("[GiveContainer] - length of possible resources " << possibleResources->length()); + resourceParams resource_params = resourceParameters_CORBAtoCPP(local_params.resource_params); + resource_params.can_run_containers = true; + std::vector possibleResources = _resManager->GetFittingResources(resource_params); + MESSAGE("[GiveContainer] - length of possible resources " << possibleResources.size()); std::vector local_resources; // Step 3: if mode is "get" keep only machines with existing containers if(mode == "get") { - for(unsigned int i=0; i < possibleResources->length(); i++) + for(unsigned int i=0; i < possibleResources.size(); i++) { - Engines::Container_ptr cont = FindContainer(params, possibleResources[i].in()); + Engines::Container_ptr cont = FindContainer(params, possibleResources[i]); try { if(!cont->_non_existent()) - local_resources.push_back(std::string(possibleResources[i])); + local_resources.push_back(possibleResources[i]); } catch(CORBA::Exception&) {} } @@ -326,8 +330,7 @@ Engines::Container_ptr SALOME_ContainerManager::GiveContainer(const Engines::Con } } else - for(unsigned int i=0; i < possibleResources->length(); i++) - local_resources.push_back(std::string(possibleResources[i])); + local_resources = possibleResources; // Step 4: select the resource where to get/start the container bool resource_available = true; @@ -341,7 +344,7 @@ Engines::Container_ptr SALOME_ContainerManager::GiveContainer(const Engines::Con { try { - resource_selected = _ResManager->GetImpl()->Find(params.resource_params.policy.in(), resources); + resource_selected = _resManager->Find(params.resource_params.policy.in(), resources); // Remove resource_selected from vector std::vector::iterator it; for (it=resources.begin() ; it < resources.end(); it++ ) @@ -359,8 +362,8 @@ Engines::Container_ptr SALOME_ContainerManager::GiveContainer(const Engines::Con MESSAGE("[GiveContainer] Resource selected is: " << resource_selected); // Step 5: Create container name - Engines::ResourceDefinition_var resource_definition = _ResManager->GetResourceDefinition(resource_selected.c_str()); - std::string hostname(resource_definition->hostname.in()); + ParserResourcesType resource_definition = _resManager->GetResourceDefinition(resource_selected); + std::string hostname(resource_definition.HostName); std::string containerNameInNS; if(params.isMPI){ int nbproc; @@ -508,7 +511,7 @@ SALOME_ContainerManager::LaunchContainer(const Engines::ContainerParameters& par { // Preparing remote command std::string command = ""; - const ParserResourcesType resInfo(_ResManager->GetImpl()->GetResourcesDescr(resource_selected)); + const ParserResourcesType resInfo(_resManager->GetResourceDefinition(resource_selected)); command = getCommandToRunRemoteProcess(resInfo.Protocol, resInfo.HostName, resInfo.UserName); if (resInfo.AppliPath != "") command += resInfo.AppliPath; @@ -684,8 +687,8 @@ Engines::Container_ptr SALOME_ContainerManager::FindContainer(const Engines::Con Engines::Container_ptr SALOME_ContainerManager::FindContainer(const Engines::ContainerParameters& params, const std::string& resource) { - Engines::ResourceDefinition_var resource_definition = _ResManager->GetResourceDefinition(resource.c_str()); - std::string hostname(resource_definition->hostname.in()); + ParserResourcesType resource_definition = _resManager->GetResourceDefinition(resource); + std::string hostname(resource_definition.HostName); std::string containerNameInNS(_NS->BuildContainerNameForNS(params, hostname.c_str())); MESSAGE("[FindContainer] Try to find a container " << containerNameInNS << " on resource " << resource); CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str()); @@ -755,9 +758,7 @@ SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer(const std::string& else { int nbproc; - Engines::ResourceDefinition_var resource_definition = _ResManager->GetResourceDefinition(resource_name.c_str()); - std::string hostname(resource_definition->hostname.in()); - const ParserResourcesType resInfo(_ResManager->GetImpl()->GetResourcesDescr(resource_name)); + const ParserResourcesType resInfo(_resManager->GetResourceDefinition(resource_name)); if (params.isMPI) { @@ -1038,14 +1039,14 @@ std::string SALOME_ContainerManager::BuildTemporaryFileName() */ //============================================================================= -std::string SALOME_ContainerManager::BuildTempFileToLaunchRemoteContainer (const std::string& resource_name, const Engines::ContainerParameters& params, std::string& tmpFileName) const throw(SALOME_Exception) +std::string SALOME_ContainerManager::BuildTempFileToLaunchRemoteContainer (const std::string& resource_name, const Engines::ContainerParameters& params, std::string& tmpFileName) const { int status; tmpFileName = BuildTemporaryFileName(); std::ofstream tempOutputFile; tempOutputFile.open(tmpFileName.c_str(), std::ofstream::out ); - const ParserResourcesType resInfo(_ResManager->GetImpl()->GetResourcesDescr(resource_name)); + const ParserResourcesType resInfo(_resManager->GetResourceDefinition(resource_name)); tempOutputFile << "#! /bin/sh" << std::endl; // --- set env vars @@ -1175,7 +1176,7 @@ std::string SALOME_ContainerManager::GetMPIZeroNode(const std::string machine, c { if (_isAppliSalomeDefined) { - const ParserResourcesType resInfo(_ResManager->GetImpl()->GetResourcesDescr(machine)); + const ParserResourcesType resInfo(_resManager->GetResourceDefinition(machine)); if (resInfo.Protocol == rsh) command = "rsh "; @@ -1346,17 +1347,18 @@ SALOME_ContainerManager::checkPaCOParameters(Engines::ContainerParameters & para } // Step 2 : check resource_selected - Engines::ResourceDefinition_var resource_definition = _ResManager->GetResourceDefinition(resource_selected.c_str()); - std::string protocol = resource_definition->protocol.in(); - std::string username = resource_definition->username.in(); - std::string applipath = resource_definition->applipath.in(); + const ParserResourcesType resource_definition = _resManager->GetResourceDefinition(resource_selected); + //std::string protocol = resource_definition->protocol.in(); + std::string username = resource_definition.UserName; + std::string applipath = resource_definition.AppliPath; - if (protocol == "" || username == "" || applipath == "") + //if (protocol == "" || username == "" || applipath == "") + if (username == "" || applipath == "") { INFOS("[checkPaCOParameters] resource selected is not well defined"); - INFOS("[checkPaCOParameters] resource name: " << resource_definition->name.in()); - INFOS("[checkPaCOParameters] resource hostname: " << resource_definition->hostname.in()); - INFOS("[checkPaCOParameters] resource protocol: " << protocol); + INFOS("[checkPaCOParameters] resource name: " << resource_definition.Name); + INFOS("[checkPaCOParameters] resource hostname: " << resource_definition.HostName); + INFOS("[checkPaCOParameters] resource protocol: " << resource_definition.getAccessProtocolTypeStr()); INFOS("[checkPaCOParameters] resource username: " << username); INFOS("[checkPaCOParameters] resource applipath: " << applipath); result = false; diff --git a/src/Container/SALOME_ContainerManager.hxx b/src/Container/SALOME_ContainerManager.hxx index 3aa4b4a7e..fc55e7579 100644 --- a/src/Container/SALOME_ContainerManager.hxx +++ b/src/Container/SALOME_ContainerManager.hxx @@ -28,8 +28,7 @@ #include #include CORBA_CLIENT_HEADER(SALOME_Component) #include CORBA_CLIENT_HEADER(SALOME_ContainerManager) -#include "SALOME_ResourcesManager.hxx" -#include "SALOME_LoadRateManager.hxx" +#include "SALOME_ResourcesCatalog_Parser.hxx" #include "Utils_Mutex.hxx" @@ -37,12 +36,13 @@ #include class SALOME_NamingService; +class SALOME_ResourcesManager_Client; class CONTAINER_EXPORT SALOME_ContainerManager : public POA_Engines::ContainerManager { public: - SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_ResourcesManager *rm, SALOME_NamingService *ns); + SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService *ns); ~SALOME_ContainerManager(); // Corba Methods @@ -75,7 +75,7 @@ protected: std::string& tmpFileName) const; std::string BuildTempFileToLaunchRemoteContainer(const std::string& resource_name, - const Engines::ContainerParameters& params, std::string& tmpFileName) const throw(SALOME_Exception); + const Engines::ContainerParameters& params, std::string& tmpFileName) const; static void RmTmpFile(std::string& tmpFile); @@ -105,7 +105,7 @@ protected: CORBA::ORB_var _orb; PortableServer::POA_var _poa; - SALOME_ResourcesManager *_ResManager; + SALOME_ResourcesManager_Client *_resManager; SALOME_NamingService *_NS; //! different behaviour if $APPLI exists (SALOME Application) diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index 3c16fdf7a..707b29470 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -24,6 +24,7 @@ #include "BatchTest.hxx" #include "OpUtil.hxx" #include "SALOME_ContainerManager.hxx" +#include "SALOME_ResourcesManager.hxx" #include "Utils_CorbaException.hxx" @@ -59,7 +60,7 @@ SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa _NS = new SALOME_NamingService(orb); _ResManager = new SALOME_ResourcesManager(orb,poa,_NS); _l.SetResourcesManager(_ResManager->GetImpl()); - _ContManager = new SALOME_ContainerManager(orb,poa,_ResManager,_NS); + _ContManager = new SALOME_ContainerManager(orb,poa,_NS); _ResManager->_remove_ref(); _ContManager->_remove_ref(); diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index 41e294e02..5473178da 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -50,6 +50,7 @@ #include CORBA_CLIENT_HEADER(Logger) #include CORBA_CLIENT_HEADER(SALOME_Launcher) +#include "SALOME_ResourcesManager.hxx" #include "SALOME_ContainerManager.hxx" #include "SALOME_Component_i.hxx" #include "SALOME_NamingService.hxx" diff --git a/src/LifeCycleCORBA/TestContainerManager.cxx b/src/LifeCycleCORBA/TestContainerManager.cxx index 175ff62eb..40e2afabe 100644 --- a/src/LifeCycleCORBA/TestContainerManager.cxx +++ b/src/LifeCycleCORBA/TestContainerManager.cxx @@ -30,6 +30,7 @@ #endif #include #include "SALOME_NamingService.hxx" +#include "SALOME_ResourcesManager.hxx" #include "SALOME_ContainerManager.hxx" #include "SALOME_LifeCycleCORBA.hxx" #include "NamingService_WaitForServerReadiness.hxx" diff --git a/src/ResourcesManager/CMakeLists.txt b/src/ResourcesManager/CMakeLists.txt index 1bfa3cae6..f637a4d8d 100755 --- a/src/ResourcesManager/CMakeLists.txt +++ b/src/ResourcesManager/CMakeLists.txt @@ -54,7 +54,12 @@ INSTALL(TARGETS ResourcesManager EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) IF(NOT SALOME_LAUNCHER_ONLY) - ADD_LIBRARY(SalomeResourcesManager SALOME_ResourcesManager.cxx) + SET(SalomeResourcesManager_SOURCES + SALOME_ResourcesManager.cxx + SALOME_ResourcesManager_Client.cxx + SALOME_ResourcesManager_Common.cxx + ) + ADD_LIBRARY(SalomeResourcesManager ${SalomeResourcesManager_SOURCES}) TARGET_LINK_LIBRARIES(SalomeResourcesManager ResourcesManager ${COMMON_LIBS}) INSTALL(TARGETS SalomeResourcesManager EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) @@ -66,5 +71,7 @@ SET(COMMON_HEADERS_HXX SALOME_LoadRateManager.hxx SALOME_ResourcesCatalog_Parser.hxx SALOME_ResourcesManager.hxx + SALOME_ResourcesManager_Client.hxx + SALOME_ResourcesManager_Common.hxx ) INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS}) diff --git a/src/ResourcesManager/SALOME_ResourcesManager.hxx b/src/ResourcesManager/SALOME_ResourcesManager.hxx index e24c908a5..fbbdba515 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.hxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.hxx @@ -33,16 +33,7 @@ #include #include "ResourcesManager.hxx" - -#ifdef WIN32 -# if defined SALOMERESOURCESMANAGER_EXPORTS || defined SalomeResourcesManager_EXPORTS -# define SALOMERESOURCESMANAGER_EXPORT __declspec( dllexport ) -# else -# define SALOMERESOURCESMANAGER_EXPORT __declspec( dllimport ) -# endif -#else -# define SALOMERESOURCESMANAGER_EXPORT -#endif +#include "SALOME_ResourcesManager_Common.hxx" #ifdef WIN32 #pragma warning(disable:4275) // Disable warning interface non dll diff --git a/src/ResourcesManager/SALOME_ResourcesManager_Client.cxx b/src/ResourcesManager/SALOME_ResourcesManager_Client.cxx new file mode 100644 index 000000000..5b0ea027a --- /dev/null +++ b/src/ResourcesManager/SALOME_ResourcesManager_Client.cxx @@ -0,0 +1,64 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "SALOME_ResourcesManager_Client.hxx" +#include "SALOME_ResourcesManager.hxx" + +using namespace std; + +SALOME_ResourcesManager_Client::SALOME_ResourcesManager_Client(SALOME_NamingService *ns) + : _rm(Engines::ResourcesManager::_nil()) +{ + CORBA::Object_var objRM = ns->Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS); + if (!CORBA::is_nil(objRM)) + _rm = Engines::ResourcesManager::_narrow(objRM); + if (CORBA::is_nil(_rm)) + throw SALOME_Exception("Cannot get SALOME ResourcesManager"); +} + +SALOME_ResourcesManager_Client::~SALOME_ResourcesManager_Client() +{ + +} + +vector SALOME_ResourcesManager_Client::GetFittingResources(const resourceParams& params) +{ + Engines::ResourceParameters_var corba_params = resourceParameters_CPPtoCORBA(params); + Engines::ResourceList_var corba_rl = _rm->GetFittingResources(corba_params); + vector res = resourceList_CORBAtoCPP(corba_rl); + return res; +} + +string SALOME_ResourcesManager_Client::Find(const string & policy, const vector & listOfResources) +{ + Engines::ResourceList_var corba_rl = resourceList_CPPtoCORBA(listOfResources); + CORBA::String_var corba_res = _rm->Find(policy.c_str(), corba_rl); + string res = corba_res.in(); + return res; +} + +ParserResourcesType SALOME_ResourcesManager_Client::GetResourceDefinition(const std::string & name) +{ + Engines::ResourceDefinition_var corba_res = _rm->GetResourceDefinition(name.c_str()); + ParserResourcesType res = resourceDefinition_CORBAtoCPP(corba_res); + return res; +} diff --git a/src/ResourcesManager/SALOME_ResourcesManager_Client.hxx b/src/ResourcesManager/SALOME_ResourcesManager_Client.hxx new file mode 100644 index 000000000..ae6a291bc --- /dev/null +++ b/src/ResourcesManager/SALOME_ResourcesManager_Client.hxx @@ -0,0 +1,52 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef __SALOME_RESOURCESMANAGER_CLIENT_HXX__ +#define __SALOME_RESOURCESMANAGER_CLIENT_HXX__ + +#include "SALOME_ResourcesManager_Common.hxx" + +class SALOME_NamingService; + +// This class is fully thread-safe because the ResourcesManager CORBA object +// runs in a single-thread POA. +class SALOMERESOURCESMANAGER_EXPORT SALOME_ResourcesManager_Client +{ +public: + + SALOME_ResourcesManager_Client(SALOME_NamingService *ns); + ~SALOME_ResourcesManager_Client(); + + std::vector GetFittingResources(const resourceParams& params); + //std::string FindFirst(const std::vector& listOfResources) const; + std::string Find(const std::string & policy, const std::vector & listOfResources); + ParserResourcesType GetResourceDefinition(const std::string & name); + //void AddResource(const ParserResourcesType & new_resource, bool write, const std::string & xml_file); + //void RemoveResource(const std::string & name, bool write, const std::string & xml_file); + +protected: + + Engines::ResourcesManager_var _rm; + +}; + +#endif diff --git a/src/ResourcesManager/SALOME_ResourcesManager_Common.cxx b/src/ResourcesManager/SALOME_ResourcesManager_Common.cxx new file mode 100644 index 000000000..7969362ed --- /dev/null +++ b/src/ResourcesManager/SALOME_ResourcesManager_Common.cxx @@ -0,0 +1,114 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "SALOME_ResourcesManager_Common.hxx" + +using namespace std; + +template +vector strvec_CORBAtoCPP(const T & strvecCorba) +{ + vector strvecCpp; + for(unsigned int i=0; i +typename T::_var_type strvec_CPPtoCORBA(const vector & strvecCpp) +{ + typename T::_var_type strvecCorba = new T; + strvecCorba->length(strvecCpp.size()); + for(unsigned int i=0;i(params.componentList); + p.resourceList = resourceList_CORBAtoCPP(params.resList); + return p; +} + +Engines::ResourceParameters_var resourceParameters_CPPtoCORBA(const resourceParams & params) +{ + Engines::ResourceParameters_var p = new Engines::ResourceParameters; + p->name = params.name.c_str(); + p->hostname = params.hostname.c_str(); + p->can_launch_batch_jobs = params.can_launch_batch_jobs; + p->can_run_containers = params.can_run_containers; + p->OS = params.OS.c_str(); + p->nb_proc = params.nb_proc; + p->nb_node = params.nb_node; + p->nb_proc_per_node = params.nb_proc_per_node; + p->cpu_clock = params.cpu_clock; + p->mem_mb = params.mem_mb; + p->componentList = strvec_CPPtoCORBA(params.componentList); + p->resList = resourceList_CPPtoCORBA(params.resourceList); + return p; +} + +vector resourceList_CORBAtoCPP(const Engines::ResourceList & resList) +{ + return strvec_CORBAtoCPP(resList); +} + +Engines::ResourceList_var resourceList_CPPtoCORBA(const vector & resList) +{ + return strvec_CPPtoCORBA(resList); +} + +ParserResourcesType resourceDefinition_CORBAtoCPP(const Engines::ResourceDefinition & resDef) +{ + ParserResourcesType resource; + resource.Name = resDef.name; + resource.HostName = resDef.hostname; + resource.setResourceTypeStr(resDef.type.in()); + resource.OS = resDef.OS; + resource.AppliPath = resDef.applipath; + resource.DataForSort._memInMB = resDef.mem_mb; + resource.DataForSort._CPUFreqMHz = resDef.cpu_clock; + resource.DataForSort._nbOfNodes = resDef.nb_node; + resource.DataForSort._nbOfProcPerNode = resDef.nb_proc_per_node; + resource.UserName = resDef.username; + resource.can_launch_batch_jobs = resDef.can_launch_batch_jobs; + resource.can_run_containers = resDef.can_run_containers; + resource.working_directory = resDef.working_directory; + resource.setBatchTypeStr(resDef.batch.in()); + resource.setMpiImplTypeStr(resDef.mpiImpl.in()); + resource.setAccessProtocolTypeStr(resDef.protocol.in()); + resource.setClusterInternalProtocolStr(resDef.iprotocol.in()); + resource.ComponentsList = strvec_CORBAtoCPP(resDef.componentList); + return resource; +} diff --git a/src/ResourcesManager/SALOME_ResourcesManager_Common.hxx b/src/ResourcesManager/SALOME_ResourcesManager_Common.hxx new file mode 100644 index 000000000..5eb745bbf --- /dev/null +++ b/src/ResourcesManager/SALOME_ResourcesManager_Common.hxx @@ -0,0 +1,50 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef __SALOME_RESOURCESMANAGER_COMMON_HXX__ +#define __SALOME_RESOURCESMANAGER_COMMON_HXX__ + +#ifdef WIN32 +# if defined SALOMERESOURCESMANAGER_EXPORTS || defined SalomeResourcesManager_EXPORTS +# define SALOMERESOURCESMANAGER_EXPORT __declspec( dllexport ) +# else +# define SALOMERESOURCESMANAGER_EXPORT __declspec( dllimport ) +# endif +#else +# define SALOMERESOURCESMANAGER_EXPORT +#endif + +#include +#include CORBA_CLIENT_HEADER(SALOME_ResourcesManager) + +#include "ResourcesManager.hxx" + +// Functions for CPP <-> CORBA conversions +// All those functions are thread-safe +SALOMERESOURCESMANAGER_EXPORT resourceParams resourceParameters_CORBAtoCPP(const Engines::ResourceParameters & params); +SALOMERESOURCESMANAGER_EXPORT Engines::ResourceParameters_var resourceParameters_CPPtoCORBA(const resourceParams & params); + +SALOMERESOURCESMANAGER_EXPORT std::vector resourceList_CORBAtoCPP(const Engines::ResourceList & resList); +SALOMERESOURCESMANAGER_EXPORT Engines::ResourceList_var resourceList_CPPtoCORBA(const std::vector & resList); + +SALOMERESOURCESMANAGER_EXPORT ParserResourcesType resourceDefinition_CORBAtoCPP(const Engines::ResourceDefinition & resDef); +#endif