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)
34 #if defined RESOURCESMANAGER_EXPORTS
36 #define RESOURCESMANAGER_EXPORT __declspec( dllexport )
38 #define RESOURCESMANAGER_EXPORT
42 #define RESOURCESMANAGER_EXPORT __declspec( dllimport )
44 #define RESOURCESMANAGER_EXPORT
49 // The call of BuildTempFileToLaunchRemoteContainer and RmTmpFile must be done
50 // in a critical section to be sure to be clean.
51 // Only one thread should use the SALOME_ResourcesManager class in a SALOME
54 class RESOURCESMANAGER_EXPORT SALOME_ResourcesManager:
55 public POA_Engines::ResourcesManager,
56 public PortableServer::RefCountServantBase
61 SALOME_ResourcesManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService *ns, const char *xmlFilePath);
62 SALOME_ResourcesManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService *ns);
64 ~SALOME_ResourcesManager();
66 Engines::MachineList *
67 GetFittingResources(const Engines::MachineParameters& params,
68 const Engines::CompoList& componentList);
69 // throw(SALOME_Exception);
71 char* FindFirst(const Engines::MachineList& listOfMachines);
72 std::string FindNext(const Engines::MachineList& listOfMachines);
73 std::string FindBest(const Engines::MachineList& listOfMachines);
75 std::string BuildCommandToLaunchRemoteContainer
76 (const std::string& machine,
77 const Engines::MachineParameters& params, const long id);
79 std::string BuildCommandToLaunchLocalContainer
80 (const Engines::MachineParameters& params, const long id);
84 std::string BuildCommand(const std::string& machine,
85 const char *containerName);
87 int AddResourceInCatalog
88 (const Engines::MachineParameters& paramsOfNewResources,
89 const std::vector<std::string>& modulesOnNewResources,
93 AccessProtocolType prot)
94 throw(SALOME_Exception);
96 void DeleteResourceInCatalog(const char *hostname);
98 void WriteInXmlFile();
100 const MapOfParserResourcesType& ParseXmlFile();
102 const MapOfParserResourcesType& GetList() const;
104 // Parallel extension
105 std::string BuildCommandToLaunchLocalParallelContainer(const std::string& exe_name,
106 const Engines::MachineParameters& params,
107 const std::string& log = "default");
108 Engines::MachineParameters* GetMachineParameters(const char *hostname);
112 static const char *_ResourcesManagerNameInNS;
116 // Parallel extension
120 SALOME_NamingService *_NS;
122 PortableServer::POA_var _poa;
124 std::string BuildTempFileToLaunchRemoteContainer
125 (const std::string& machine,
126 const Engines::MachineParameters& params) throw(SALOME_Exception);
128 void SelectOnlyResourcesWithOS(std::vector<std::string>& hosts,
129 const char *OS) const
130 throw(SALOME_Exception);
132 void KeepOnlyResourcesWithModule(std::vector<std::string>& hosts,
133 const Engines::CompoList& componentList) const
134 throw(SALOME_Exception);
136 void AddOmninamesParams(std::string& command) const;
138 void AddOmninamesParams(std::ofstream& fileStream) const;
140 std::string BuildTemporaryFileName() const;
142 //! will contain the path to the ressources catalog
143 std::string _path_resources;
145 //! attribute that contains current tmp files generated
146 std::string _TmpFileName;
148 //! contains the rsh or ssh command to access directly to machine.
149 // Only used by this->RmTmpFile in case of a remote launch.
150 std::string _CommandForRemAccess;
152 //! will contain the informations on the data type catalog(after parsing)
153 MapOfParserResourcesType _resourcesList;
155 SALOME_LoadRateManager _dynamicResourcesSelecter;
157 //! different behaviour if $APPLI exists (SALOME Application)
158 bool _isAppliSalomeDefined;
161 #endif // RESSOURCESCATALOG_IMPL_H