Version: 9.12.0
SALOME_ContainerManager.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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, or (at your option) any later version.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 
23 #ifndef __SALOME_CONTAINERMANAGER_HXX__
24 #define __SALOME_CONTAINERMANAGER_HXX__
25 
26 #include "SALOME_Container.hxx"
27 
28 #include <SALOMEconfig.h>
29 #include CORBA_CLIENT_HEADER(SALOME_Component)
30 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
32 
33 #include "Utils_Mutex.hxx"
34 
35 #include <vector>
36 #include <string>
37 #include <utility>
38 #include <set>
39 
42 
44 {
45 
46 public:
47  SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *ns);
49 
50  // Corba Methods
51  Engines::Container_ptr GiveContainer(const Engines::ContainerParameters& params) override;
52 
53  void ShutdownContainers() override;
54 
55  void SetOverrideEnvForContainers(const Engines::KeyValDict& env) override;
56 
57  Engines::KeyValDict *GetOverrideEnvForContainers() override;
58 
59  void SetCodeOnContainerStartUp(const char *code) override;
60 
61  // C++ Methods
62  void Shutdown();
63 
64  void DeclareUsingSalomeSession() { _isSSL = false; }
65 
66  CORBA::Long GetTimeOutToLaunchServerInSecond() override;
67 
68  void SetTimeOutToLaunchServerInSecond(CORBA::Long timeInSecond) override;
69 
70  CORBA::Long GetDeltaTimeBetweenNSLookupAtLaunchTimeInMilliSecond() override;
71 
72  void SetDeltaTimeBetweenNSLookupAtLaunchTimeInMilliSecond(CORBA::Long timeInMS) override;
73 
74  static const char *_ContainerManagerNameInNS;
75 
76 protected:
77  // C++ methods
78  Engines::Container_ptr
79  FindContainer(const Engines::ContainerParameters& params,
80  const Engines::ResourceList& possibleResources);
81 
82  Engines::Container_ptr
83  FindContainer(const Engines::ContainerParameters& params,
84  const std::string& resource);
85 
86  std::string GetCppBinaryOfKernelContainer() const;
87 
88  std::string GetRunRemoteExecutableScript() const;
89 
90  std::string BuildCommandToLaunchRemoteContainer(const std::string & resource_name,
91  const Engines::ContainerParameters& params,
92  const std::string& container_exe="SALOME_Container") const;
93 
94  std::string BuildCommandToLaunchLocalContainer(const Engines::ContainerParameters& params,
95  const std::string& machinesFile,
96  const std::string& container_exe,//"SALOME_Container"
97  std::string& tmpFileName) const;
98 
99  std::string BuildTempFileToLaunchRemoteContainer(const std::string& resource_name,
100  const Engines::ContainerParameters& params, std::string& tmpFileName) const;
101 
102  static void RmTmpFile(std::string& tmpFile);
103 
104  void AddOmninamesParams(std::string& command) const;
105 
106  void AddOmninamesParams(std::ostream& fileStream) const;
107 
108  static std::string BuildTemporaryFileName();
109 
110  std::string GetMPIZeroNode(const std::string machine, const std::string machinesFile) const;
111 
112  std::string machinesFile(const int nbproc);
113 
114  std::string getCommandToRunRemoteProcessCommon(const std::string& templateName, const std::string& remoteScript,
115  AccessProtocolType protocol,
116  const std::string & hostname,
117  const std::string & username,
118  const std::string & applipath,
119  const std::string & workdir) const;
120 
121  std::string getCommandToRunRemoteProcess(AccessProtocolType protocol,
122  const std::string & hostname,
123  const std::string & username,
124  const std::string & applipath,
125  const std::string & workdir="") const;
126 
127  std::string getCommandToRunRemoteProcessNoAppli(AccessProtocolType protocol,
128  const std::string & hostname,
129  const std::string & username,
130  const std::string & applipath,
131  const std::string & workdir="") const;
132 
133  Engines::Container_ptr
134  LaunchContainer(const Engines::ContainerParameters& params,
135  const std::string & resource_selected,
136  const std::string & hostname,
137  const std::string & machFile,
138  const std::string & containerNameInNS);
139 
140  CORBA::ORB_var _orb;
141  PortableServer::POA_var _poa;
142 
145 
148 
151 
153  bool _isSSL = true;
154 
155  static omni_mutex _numInstanceMutex ; // lib and instance protection
156 
159 
161 
162  // Begin of PacO++ Parallel extension
163  typedef std::vector<std::string> actual_launch_machine_t;
164 
165  bool checkPaCOParameters(Engines::ContainerParameters & params, std::string resource_selected);
166 
167  Engines::Container_ptr
168  StartPaCOPPContainer(const Engines::ContainerParameters& params, std::string resource_selected);
169 
170 
171 
172  std::string BuildCommandToLaunchPaCOProxyContainer(const Engines::ContainerParameters& params,
173  std::string machine_file_name,
174  std::string & proxy_hostname);
175 
176  std::string BuildCommandToLaunchPaCONodeContainer(const Engines::ContainerParameters& params,
177  const std::string & machine_file_name,
179  const std::string & proxy_hostname);
180 
181  void LogConfiguration(const std::string & log_type,
182  const std::string & exe_type,
183  const std::string & container_name,
184  const std::string & hostname,
185  std::string & begin,
186  std::string & end);
187 
188  CORBA::Object_ptr
189  LaunchPaCOProxyContainer(const std::string& command,
190  const Engines::ContainerParameters& params,
191  const std::string& hostname);
192 
193  bool
194  LaunchPaCONodeContainer(const std::string& command,
195  const Engines::ContainerParameters& params,
196  const std::string& name,
198  // End of PaCO++ Parallel extension
199 public:
200  static char *GetenvThreadSafe(const char *name);
201  static std::string GetenvThreadSafeAsString(const char *name);
202  static int SystemThreadSafe(const char *command);
203  static long SystemWithPIDThreadSafe(const std::vector<std::string>& command);
204  static void AddOmninamesParams(std::ostream& fileStream, SALOME_NamingService_Abstract *ns);
205  static void MakeTheCommandToBeLaunchedASync(std::string& command);
206  static int GetTimeOutToLoaunchServer();
207  static void SleepInSecond(int ellapseTimeInSecond);
208  private:
209  static const int TIME_OUT_TO_LAUNCH_CONT;
213 private:
214  std::vector< std::pair<std::string, std::string> > _override_env;
218 };
219 #endif
#define CONTAINER_EXPORT
Definition: SALOME_Container.hxx:37
AccessProtocolType
Definition: SALOME_ResourcesCatalog_Parser.hxx:44
Definition: SALOME_ContainerManager.hxx:44
void DeclareUsingSalomeSession()
Definition: SALOME_ContainerManager.hxx:64
PortableServer::POA_var _poa
Definition: SALOME_ContainerManager.hxx:141
std::vector< std::pair< std::string, std::string > > _override_env
Definition: SALOME_ContainerManager.hxx:214
SALOME_NamingService_Abstract * _NS
Definition: SALOME_ContainerManager.hxx:144
std::string _code_to_exe_on_startup
Definition: SALOME_ContainerManager.hxx:217
int _nbprocUsed
attribute that contains the number of processes used in batch mode by MPI containers
Definition: SALOME_ContainerManager.hxx:150
static Utils_Mutex _systemMutex
Definition: SALOME_ContainerManager.hxx:212
static omni_mutex _numInstanceMutex
Definition: SALOME_ContainerManager.hxx:155
static const int TIME_OUT_TO_LAUNCH_CONT
Definition: SALOME_ContainerManager.hxx:209
static Utils_Mutex _getenvMutex
Definition: SALOME_ContainerManager.hxx:211
pid_t _pid_mpiServer
Definition: SALOME_ContainerManager.hxx:160
static const int DFT_DELTA_TIME_NS_LOOKUP_IN_MS
Definition: SALOME_ContainerManager.hxx:210
CORBA::ORB_var _orb
Definition: SALOME_ContainerManager.hxx:140
int _delta_time_ns_lookup_in_ms
Definition: SALOME_ContainerManager.hxx:216
int _time_out_in_second
Definition: SALOME_ContainerManager.hxx:215
static const char * _ContainerManagerNameInNS
Definition: SALOME_ContainerManager.hxx:74
Utils_Mutex _giveContainerMutex1
attributes to allow concurrency for // GiveContainer
Definition: SALOME_ContainerManager.hxx:158
std::vector< std::string > actual_launch_machine_t
Definition: SALOME_ContainerManager.hxx:163
SALOME_ResourcesManager_Client * _resManager
Definition: SALOME_ContainerManager.hxx:143
bool _isAppliSalomeDefined
different behaviour if $APPLI exists (SALOME Application)
Definition: SALOME_ContainerManager.hxx:147
Definition: SALOME_NamingService_Abstract.hxx:46
Definition: SALOME_ResourcesManager_Client.hxx:33
Definition: Utils_Mutex.hxx:37
sequence< string > ResourceList
Type to transmit list of resources.
Definition: SALOME_ResourcesManager.idl:35
sequence< KeyValPairString > KeyValDict
Definition: SALOME_ContainerManager.idl:76
poa
Definition: SALOME_ContainerPy.py:377
list command
Definition: TestKernelHelpers.py:48
container_name
Definition: TestLifeCycleCORBA.py:42
ContainerManager
Definition: TestLifeCycleCORBA.py:57
string name
Definition: pythfilter.py:56
orb
Definition: salome.py:122
hostname
Definition: test.py:29
Type to describe required properties of a container.
Definition: SALOME_ContainerManager.idl:38