]> SALOME platform Git repositories - modules/kernel.git/blob - src/Container/SALOME_ContainerManager.hxx
Salome HOME
Merging from V4_1_0_maintainance for porting on Win32 Platform
[modules/kernel.git] / src / Container / SALOME_ContainerManager.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_CONTAINERMANAGER_HXX__
21 #define __SALOME_CONTAINERMANAGER_HXX__
22
23 #include "SALOME_Container.hxx"
24
25 #include <SALOMEconfig.h>
26 #include CORBA_CLIENT_HEADER(SALOME_Component)
27 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
28 #include "SALOME_ResourcesManager.hxx"
29 #include "SALOME_LoadRateManager.hxx"
30
31 #include <string>
32
33 class SALOME_NamingService;
34
35 class CONTAINER_EXPORT SALOME_ContainerManager:
36   public POA_Engines::ContainerManager
37 {
38
39 public:
40   SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_ResourcesManager *rm, SALOME_NamingService *ns);
41   ~SALOME_ContainerManager();
42
43   Engines::Container_ptr
44   FindOrStartContainer(const Engines::MachineParameters& params,
45                        const Engines::MachineList& possibleComputer);
46
47   Engines::Container_ptr
48   StartContainer(const Engines::MachineParameters& params,
49                  const Engines::MachineList& possibleComputer,
50                  Engines::ResPolicy policy,
51      const std::string& container_exe="SALOME_Container");
52
53   Engines::Container_ptr
54   StartContainer(const Engines::MachineParameters& params,
55                 Engines::ResPolicy policy,
56                 const Engines::CompoList& componentList);
57
58   Engines::Container_ptr
59   GiveContainer(const Engines::MachineParameters& params,
60                 Engines::ResPolicy policy,
61                 const Engines::CompoList& componentList);
62
63   void Shutdown();
64   void ShutdownContainers();
65
66   static const char *_ContainerManagerNameInNS;
67
68   // Parallel extension
69   Engines::Container_ptr
70   FindOrStartParallelContainer(const Engines::MachineParameters& params,
71                                const Engines::MachineList& possibleComputer);
72 protected:
73   Engines::Container_ptr
74   FindContainer(const Engines::MachineParameters& params,
75                 const Engines::MachineList& possibleComputers);
76
77   Engines::Container_ptr
78   FindContainer(const Engines::MachineParameters& params,
79                 const char *theMachine);
80
81   // Parallel extension
82   CORBA::Object_ptr 
83   LaunchParallelContainer(const std::string& command, 
84                           const Engines::MachineParameters& params,
85                           const std::string& name);
86
87   void fillBatchLaunchedContainers();
88
89   long GetIdForContainer(void);
90
91   std::string BuildCommandToLaunchRemoteContainer(const std::string& machine,
92                                                   const Engines::MachineParameters& params, const long id,
93               const std::string& container_exe="SALOME_Container");
94
95   std::string BuildCommandToLaunchLocalContainer(const Engines::MachineParameters& params, const long id,
96                                                  const std::string& container_exe="SALOME_Container");
97
98   std::string BuildTempFileToLaunchRemoteContainer(const std::string& machine,
99                                                    const Engines::MachineParameters& params) throw(SALOME_Exception);
100
101   void RmTmpFile();
102
103   void AddOmninamesParams(std::string& command) const;
104
105   void AddOmninamesParams(std::ofstream& fileStream) const;
106
107   std::string BuildTemporaryFileName() const;
108
109   // Parallel extension
110   std::string BuildCommandToLaunchLocalParallelContainer(const std::string& exe_name, 
111                                                          const Engines::MachineParameters& params, 
112                                                          const std::string& log = "default");
113   void startMPI();
114   bool _MpiStarted;
115
116   long _id;
117   CORBA::ORB_var _orb;
118   PortableServer::POA_var _poa;
119
120   SALOME_ResourcesManager *_ResManager;
121   SALOME_NamingService *_NS;
122   static std::vector<Engines::Container_ptr> _batchLaunchedContainers;
123   static std::vector<Engines::Container_ptr>::iterator _batchLaunchedContainersIter;
124
125   //! attribute that contains current tmp files generated
126   std::string _TmpFileName;
127
128   //! contains the rsh or ssh command to access directly to machine.
129   //  Only used by this->RmTmpFile in case of a remote launch.
130   std::string _CommandForRemAccess;
131
132   //! different behaviour if $APPLI exists (SALOME Application) 
133   bool _isAppliSalomeDefined;
134
135 };
136 #endif