1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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
23 #ifndef __SALOME_CONTAINERMANAGER_HXX__
24 #define __SALOME_CONTAINERMANAGER_HXX__
26 #include "SALOME_Container.hxx"
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"
37 class SALOME_NamingService;
39 class CONTAINER_EXPORT SALOME_ContainerManager:
40 public POA_Engines::ContainerManager
44 SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_ResourcesManager *rm, SALOME_NamingService *ns);
45 ~SALOME_ContainerManager();
48 Engines::Container_ptr
49 GiveContainer(const Engines::ContainerParameters& params);
51 void ShutdownContainers();
56 static const char *_ContainerManagerNameInNS;
60 Engines::Container_ptr
61 FindContainer(const Engines::ContainerParameters& params,
62 const Engines::ResourceList& possibleResources);
64 Engines::Container_ptr
65 FindContainer(const Engines::ContainerParameters& params,
66 const std::string& resource);
68 std::string BuildCommandToLaunchRemoteContainer(const std::string & resource_name,
69 const Engines::ContainerParameters& params,
70 const std::string& container_exe="SALOME_Container");
72 std::string BuildCommandToLaunchLocalContainer(const Engines::ContainerParameters& params,
73 const std::string& machinesFile,
74 const std::string& container_exe="SALOME_Container");
76 std::string BuildTempFileToLaunchRemoteContainer(const std::string& resource_name,
77 const Engines::ContainerParameters& params) throw(SALOME_Exception);
79 void RmTmpFile(std::string& tmpFile);
81 void AddOmninamesParams(std::string& command) const;
83 void AddOmninamesParams(std::ostringstream& oss) const;
85 void AddOmninamesParams(std::ofstream& fileStream) const;
87 std::string BuildTemporaryFileName() const;
89 std::string GetMPIZeroNode(const std::string machine, const std::string machinesFile);
91 std::string machinesFile(const int nbproc);
93 std::set<pid_t> getpidofprogram(const std::string program);
95 std::string getCommandToRunRemoteProcess(AccessProtocolType protocol,
96 const std::string & hostname,
97 const std::string & username);
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);
107 PortableServer::POA_var _poa;
109 SALOME_ResourcesManager *_ResManager;
110 SALOME_NamingService *_NS;
112 //! attribute that contains current tmp files generated
113 std::string _TmpFileName;
115 //! contains the rsh or ssh command to access directly to machine.
116 // Only used by this->RmTmpFile in case of a remote launch.
117 std::string _CommandForRemAccess;
119 //! different behaviour if $APPLI exists (SALOME Application)
120 bool _isAppliSalomeDefined;
122 //! attribute that contains the number of processes used in batch mode by MPI containers
125 static omni_mutex _numInstanceMutex ; // lib and instance protection
127 pid_t _pid_mpiServer;
129 // Begin of PacO++ Parallel extension
130 typedef std::vector<std::string> actual_launch_machine_t;
132 bool checkPaCOParameters(Engines::ContainerParameters & params, std::string resource_selected);
134 Engines::Container_ptr
135 StartPaCOPPContainer(const Engines::ContainerParameters& params, std::string resource_selected);
139 std::string BuildCommandToLaunchPaCOProxyContainer(const Engines::ContainerParameters& params,
140 std::string machine_file_name,
141 std::string & proxy_hostname);
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);
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,
156 LaunchPaCOProxyContainer(const std::string& command,
157 const Engines::ContainerParameters& params,
158 const std::string& hostname);
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