Version: 6.5.0
SALOME_ContainerManager.hxx
1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, 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.
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)
31 #include "SALOME_ResourcesManager.hxx"
32 #include "SALOME_LoadRateManager.hxx"
33 
34 #include <string>
35 #include <set>
36 
38 
39 class CONTAINER_EXPORT SALOME_ContainerManager:
40  public POA_Engines::ContainerManager
41 {
42 
43 public:
44  SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_ResourcesManager *rm, SALOME_NamingService *ns);
46 
47  // Corba Methods
48  Engines::Container_ptr
49  GiveContainer(const Engines::ContainerParameters& params);
50 
51  void ShutdownContainers();
52 
53  // C++ Methods
54  void Shutdown();
55 
56  static const char *_ContainerManagerNameInNS;
57 
58 protected:
59  // C++ methods
60  Engines::Container_ptr
61  FindContainer(const Engines::ContainerParameters& params,
62  const Engines::ResourceList& possibleResources);
63 
64  Engines::Container_ptr
65  FindContainer(const Engines::ContainerParameters& params,
66  const std::string& resource);
67 
68  std::string BuildCommandToLaunchRemoteContainer(const std::string & resource_name,
69  const Engines::ContainerParameters& params,
70  const std::string& container_exe="SALOME_Container");
71 
72  std::string BuildCommandToLaunchLocalContainer(const Engines::ContainerParameters& params,
73  const std::string& machinesFile,
74  const std::string& container_exe="SALOME_Container");
75 
76  std::string BuildTempFileToLaunchRemoteContainer(const std::string& resource_name,
77  const Engines::ContainerParameters& params) throw(SALOME_Exception);
78 
79  void RmTmpFile(std::string& tmpFile);
80 
81  void AddOmninamesParams(std::string& command) const;
82 
83  void AddOmninamesParams(std::ostringstream& oss) const;
84 
85  void AddOmninamesParams(std::ofstream& fileStream) const;
86 
87  std::string BuildTemporaryFileName() const;
88 
89  std::string GetMPIZeroNode(const std::string machine, const std::string machinesFile);
90 
91  std::string machinesFile(const int nbproc);
92 
93  std::set<pid_t> getpidofprogram(const std::string program);
94 
95  std::string getCommandToRunRemoteProcess(AccessProtocolType protocol,
96  const std::string & hostname,
97  const std::string & username);
98 
99  Engines::Container_ptr
100  LaunchContainer(const Engines::ContainerParameters& params,
101  const std::string & resource_selected,
102  const std::string & hostname,
103  const std::string & machFile,
104  const std::string & containerNameInNS);
105 
106  CORBA::ORB_var _orb;
107  PortableServer::POA_var _poa;
108 
109  SALOME_ResourcesManager *_ResManager;
111 
113  std::string _TmpFileName;
114 
116  // Only used by this->RmTmpFile in case of a remote launch.
117  std::string _CommandForRemAccess;
118 
121 
124 
125  static omni_mutex _numInstanceMutex ; // lib and instance protection
126 
127  pid_t _pid_mpiServer;
128 
129  // Begin of PacO++ Parallel extension
130  typedef std::vector<std::string> actual_launch_machine_t;
131 
132  bool checkPaCOParameters(Engines::ContainerParameters & params, std::string resource_selected);
133 
134  Engines::Container_ptr
135  StartPaCOPPContainer(const Engines::ContainerParameters& params, std::string resource_selected);
136 
137 
138 
139  std::string BuildCommandToLaunchPaCOProxyContainer(const Engines::ContainerParameters& params,
140  std::string machine_file_name,
141  std::string & proxy_hostname);
142 
143  std::string BuildCommandToLaunchPaCONodeContainer(const Engines::ContainerParameters& params,
144  const std::string & machine_file_name,
145  SALOME_ContainerManager::actual_launch_machine_t & vect_machine,
146  const std::string & proxy_hostname);
147 
148  void LogConfiguration(const std::string & log_type,
149  const std::string & exe_type,
150  const std::string & container_name,
151  const std::string & hostname,
152  std::string & begin,
153  std::string & end);
154 
155  CORBA::Object_ptr
156  LaunchPaCOProxyContainer(const std::string& command,
157  const Engines::ContainerParameters& params,
158  const std::string& hostname);
159 
160  bool
161  LaunchPaCONodeContainer(const std::string& command,
162  const Engines::ContainerParameters& params,
163  const std::string& name,
164  SALOME_ContainerManager::actual_launch_machine_t & vect_machine);
165  // End of PaCO++ Parallel extension
166 };
167 #endif
bool _isAppliSalomeDefined
different behaviour if $APPLI exists (SALOME Application)
Definition: SALOME_ContainerManager.hxx:120
std::string _TmpFileName
attribute that contains current tmp files generated
Definition: SALOME_ContainerManager.hxx:113
int _nbprocUsed
attribute that contains the number of processes used in batch mode by MPI containers ...
Definition: SALOME_ContainerManager.hxx:123
A class to manage the SALOME naming service.
Definition: SALOME_NamingService.hxx:48
Definition: SALOME_ContainerManager.hxx:39
std::string _CommandForRemAccess
contains the rsh or ssh command to access directly to machine.
Definition: SALOME_ContainerManager.hxx:117
Definition: Utils_SALOME_Exception.hxx:67
sequence< string > ResourceList
Type to transmit list of resources.
Definition: SALOME_ContainerManager.idl:36
Type to describe required properties of a container.
Definition: SALOME_ContainerManager.idl:86
Copyright © 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS