1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #ifndef __SALOME_CONTAINERMANAGER_HXX__
23 #define __SALOME_CONTAINERMANAGER_HXX__
25 #include "SALOME_Container.hxx"
27 #include <SALOMEconfig.h>
28 #include CORBA_CLIENT_HEADER(SALOME_Component)
29 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
30 #include "SALOME_ResourcesManager.hxx"
31 #include "SALOME_LoadRateManager.hxx"
35 class SALOME_NamingService;
37 class CONTAINER_EXPORT SALOME_ContainerManager:
38 public POA_Engines::ContainerManager
42 SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_ResourcesManager *rm, SALOME_NamingService *ns);
43 ~SALOME_ContainerManager();
46 void ShutdownContainers();
48 Engines::Container_ptr
49 StartContainer(const Engines::MachineParameters& params,
50 const Engines::MachineList& possibleComputer,
51 const std::string& container_exe="SALOME_Container");
53 Engines::Container_ptr
54 StartContainer(const Engines::MachineParameters& params);
56 Engines::Container_ptr
57 GiveContainer(const Engines::MachineParameters& params);
59 Engines::Container_ptr
60 FindOrStartContainer(const Engines::MachineParameters& params);
62 static const char *_ContainerManagerNameInNS;
65 Engines::Container_ptr
66 FindOrStartParallelContainer(const Engines::MachineParameters& params);
68 Engines::Container_ptr
69 FindContainer(const Engines::MachineParameters& params,
70 const Engines::MachineList& possibleComputers);
72 Engines::Container_ptr
73 FindContainer(const Engines::MachineParameters& params,
74 const char *theMachine);
78 LaunchParallelContainer(const std::string& command,
79 const Engines::MachineParameters& params,
80 const std::string& name);
82 void fillBatchLaunchedContainers();
84 std::string BuildCommandToLaunchRemoteContainer(const std::string& machine,
85 const Engines::MachineParameters& params,
86 const std::string& container_exe="SALOME_Container");
88 std::string BuildCommandToLaunchLocalContainer(const Engines::MachineParameters& params,
89 const std::string& container_exe="SALOME_Container");
91 std::string BuildTempFileToLaunchRemoteContainer(const std::string& machine,
92 const Engines::MachineParameters& params) throw(SALOME_Exception);
94 void RmTmpFile(std::string& tmpFile);
96 void AddOmninamesParams(std::string& command) const;
98 void AddOmninamesParams(std::ofstream& fileStream) const;
100 std::string BuildTemporaryFileName() const;
102 std::string GetMPIZeroNode(std::string machine);
104 // Parallel extension
105 std::string BuildCommandToLaunchLocalParallelContainer(const std::string& exe_name,
106 const Engines::MachineParameters& params,
107 const std::string& log = "default");
112 PortableServer::POA_var _poa;
114 SALOME_ResourcesManager *_ResManager;
115 SALOME_NamingService *_NS;
116 static std::vector<Engines::Container_ptr> _batchLaunchedContainers;
117 static std::vector<Engines::Container_ptr>::iterator _batchLaunchedContainersIter;
119 //! attribute that contains current tmp files generated
120 std::string _TmpFileName;
122 //! contains the rsh or ssh command to access directly to machine.
123 // Only used by this->RmTmpFile in case of a remote launch.
124 std::string _CommandForRemAccess;
126 //! different behaviour if $APPLI exists (SALOME Application)
127 bool _isAppliSalomeDefined;