1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef __SALOME_RESOURCESMANAGER_HXX__
21 #define __SALOME_RESOURCESMANAGER_HXX__
23 #include "Utils_SALOME_Exception.hxx"
24 #include "utilities.h"
25 #include <SALOMEconfig.h>
26 #include "SALOME_ResourcesCatalog_Handler.hxx"
27 #include "SALOME_LoadRateManager.hxx"
28 #include "SALOME_NamingService.hxx"
29 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
35 // The call of BuildTempFileToLaunchRemoteContainer and RmTmpFile must be done
36 // in a critical section to be sure to be clean.
37 // Only one thread should use the SALOME_ResourcesManager class in a SALOME
40 class RESOURCESMANAGER_EXPORT SALOME_ResourcesManager
45 SALOME_ResourcesManager(CORBA::ORB_ptr orb, const char *xmlFilePath);
46 SALOME_ResourcesManager(CORBA::ORB_ptr orb);
48 ~SALOME_ResourcesManager();
50 std::vector<std::string>
51 GetFittingResources(const Engines::MachineParameters& params,
52 const char *moduleName)
53 throw(SALOME_Exception);
55 std::string FindBest(const Engines::MachineList& listOfMachines);
57 std::string BuildCommandToLaunchRemoteContainer
58 (const std::string& machine,
59 const Engines::MachineParameters& params, const long id);
61 std::string BuildCommandToLaunchLocalContainer
62 (const Engines::MachineParameters& params, const long id);
66 std::string BuildCommand(const std::string& machine,
67 const char *containerName);
69 int AddResourceInCatalog
70 (const Engines::MachineParameters& paramsOfNewResources,
71 const std::map<std::string, std::string>& modulesOnNewResources,
72 const char *environPathOfPrerequired,
76 AccessProtocolType prot)
77 throw(SALOME_Exception);
79 void DeleteResourceInCatalog(const char *hostname);
81 void WriteInXmlFile();
83 const MapOfParserResourcesType& ParseXmlFile();
85 const MapOfParserResourcesType& GetList() const;
88 std::string BuildCommandToLaunchLocalParallelContainer(const std::string& exe_name,
89 const Engines::MachineParameters& params,
90 const std::string& log = "default");
97 SALOME_NamingService *_NS;
99 std::string BuildTempFileToLaunchRemoteContainer
100 (const std::string& machine,
101 const Engines::MachineParameters& params);
103 void SelectOnlyResourcesWithOS(std::vector<std::string>& hosts,
104 const char *OS) const
105 throw(SALOME_Exception);
107 void KeepOnlyResourcesWithModule(std::vector<std::string>& hosts,
108 const char *moduleName) const
109 throw(SALOME_Exception);
111 void AddOmninamesParams(std::string& command) const;
113 void AddOmninamesParams(std::ofstream& fileStream) const;
115 std::string BuildTemporaryFileName() const;
118 //! will contain the path to the ressources catalog
119 QString _path_resources;
121 //! attribute that contains current tmp files generated
122 std::string _TmpFileName;
124 //! contains the rsh or ssh command to access directly to machine.
125 // Only used by this->RmTmpFile in case of a remote launch.
126 std::string _CommandForRemAccess;
128 //! will contain the informations on the data type catalog(after parsing)
129 MapOfParserResourcesType _resourcesList;
131 SALOME_LoadRateManager _dynamicResourcesSelecter;
133 //! different behaviour if $APPLI exists (SALOME Application)
134 bool _isAppliSalomeDefined;
137 #endif // RESSOURCESCATALOG_IMPL_H