Salome HOME
To avoid compilation pb on RedHat 8.0.
[modules/kernel.git] / src / ResourcesManager / SALOME_ResourcesManager.hxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
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.
8 // 
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.
13 //
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
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 #ifndef __SALOME_RESOURCESMANAGER_HXX__
21 #define __SALOME_RESOURCESMANAGER_HXX__
22
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)
30 #include <string>
31 #include <fstream>
32 #include <vector>
33
34 // --- WARNING ---
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
38 // session.
39
40 class RESOURCESMANAGER_EXPORT SALOME_ResourcesManager
41   {
42
43   public:
44
45     SALOME_ResourcesManager(CORBA::ORB_ptr orb, const char *xmlFilePath);
46     SALOME_ResourcesManager(CORBA::ORB_ptr orb);
47
48     ~SALOME_ResourcesManager();
49
50     std::vector<std::string>
51     GetFittingResources(const Engines::MachineParameters& params,
52                         const char *moduleName)
53     throw(SALOME_Exception);
54
55     std::string FindFirst(const Engines::MachineList& listOfMachines);
56     std::string FindNext(const Engines::MachineList& listOfMachines);
57     std::string FindBest(const Engines::MachineList& listOfMachines);
58
59     std::string BuildCommandToLaunchRemoteContainer
60     (const std::string& machine,
61      const Engines::MachineParameters& params, const long id);
62
63     std::string BuildCommandToLaunchLocalContainer
64     (const Engines::MachineParameters& params, const long id);
65
66     void RmTmpFile();
67
68     std::string BuildCommand(const std::string& machine,
69                              const char *containerName);
70
71     int AddResourceInCatalog
72     (const Engines::MachineParameters& paramsOfNewResources,
73      const std::map<std::string, std::string>& modulesOnNewResources,
74      const char *environPathOfPrerequired,
75      const char *alias,
76      const char *userName,
77      AccessModeType mode,
78      AccessProtocolType prot)
79     throw(SALOME_Exception);
80
81     void DeleteResourceInCatalog(const char *hostname);
82
83     void WriteInXmlFile();
84
85     const MapOfParserResourcesType& ParseXmlFile();
86
87     const MapOfParserResourcesType& GetList() const;
88
89     // Parallel extension
90     std::string BuildCommandToLaunchLocalParallelContainer(const std::string& exe_name, 
91                                                            const Engines::MachineParameters& params, 
92                                                            const std::string& log = "default");
93   protected:
94     
95     // Parallel extension
96     void startMPI();
97     bool _MpiStarted;
98
99     SALOME_NamingService *_NS;
100
101     std::string BuildTempFileToLaunchRemoteContainer
102     (const std::string& machine,
103      const Engines::MachineParameters& params);
104
105     void SelectOnlyResourcesWithOS(std::vector<std::string>& hosts,
106                                    const char *OS) const
107       throw(SALOME_Exception);
108
109     void KeepOnlyResourcesWithModule(std::vector<std::string>& hosts,
110                                      const char *moduleName) const
111       throw(SALOME_Exception);
112
113     void AddOmninamesParams(std::string& command) const;
114
115     void AddOmninamesParams(std::ofstream& fileStream) const;
116
117     std::string BuildTemporaryFileName() const;
118
119
120     //! will contain the path to the ressources catalog
121     std::string _path_resources;
122
123     //! attribute that contains current tmp files generated
124     std::string _TmpFileName;
125
126     //! contains the rsh or ssh command to access directly to machine.
127     //  Only used by this->RmTmpFile in case of a remote launch.
128     std::string _CommandForRemAccess;
129
130     //! will contain the informations on the data type catalog(after parsing)
131     MapOfParserResourcesType _resourcesList;
132
133     SALOME_LoadRateManager _dynamicResourcesSelecter;
134
135     //! different behaviour if $APPLI exists (SALOME Application) 
136     bool _isAppliSalomeDefined;
137   };
138
139 #endif // RESSOURCESCATALOG_IMPL_H