1 // Copyright (C) 2007-2011 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
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);
96 PortableServer::POA_var _poa;
98 SALOME_ResourcesManager *_ResManager;
99 SALOME_NamingService *_NS;
101 //! attribute that contains current tmp files generated
102 std::string _TmpFileName;
104 //! contains the rsh or ssh command to access directly to machine.
105 // Only used by this->RmTmpFile in case of a remote launch.
106 std::string _CommandForRemAccess;
108 //! different behaviour if $APPLI exists (SALOME Application)
109 bool _isAppliSalomeDefined;
111 //! attribute that contains the number of processes used in batch mode by MPI containers
114 static omni_mutex _numInstanceMutex ; // lib and instance protection
116 pid_t _pid_mpiServer;
118 // Begin of PacO++ Parallel extension
119 typedef std::vector<std::string> actual_launch_machine_t;
121 bool checkPaCOParameters(Engines::ContainerParameters & params, std::string resource_selected);
123 Engines::Container_ptr
124 StartPaCOPPContainer(const Engines::ContainerParameters& params, std::string resource_selected);
128 std::string BuildCommandToLaunchPaCOProxyContainer(const Engines::ContainerParameters& params,
129 std::string machine_file_name,
130 std::string & proxy_hostname);
132 std::string BuildCommandToLaunchPaCONodeContainer(const Engines::ContainerParameters& params,
133 const std::string & machine_file_name,
134 SALOME_ContainerManager::actual_launch_machine_t & vect_machine,
135 const std::string & proxy_hostname);
137 void LogConfiguration(const std::string & log_type,
138 const std::string & exe_type,
139 const std::string & container_name,
140 const std::string & hostname,
145 LaunchPaCOProxyContainer(const std::string& command,
146 const Engines::ContainerParameters& params,
147 const std::string& hostname);
150 LaunchPaCONodeContainer(const std::string& command,
151 const Engines::ContainerParameters& params,
152 const std::string& name,
153 SALOME_ContainerManager::actual_launch_machine_t & vect_machine);
154 // End of PaCO++ Parallel extension