Salome HOME
clean warning message
[modules/kernel.git] / src / Container / SALOME_ContainerManager.hxx
1 //  Copyright (C) 2007-2010  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
36 class SALOME_NamingService;
37
38 class CONTAINER_EXPORT SALOME_ContainerManager:
39   public POA_Engines::ContainerManager
40 {
41
42 public:
43   SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_ResourcesManager *rm, SALOME_NamingService *ns);
44   ~SALOME_ContainerManager();
45
46   // Corba Methods
47   Engines::Container_ptr
48   GiveContainer(const Engines::ContainerParameters& params);
49
50   void ShutdownContainers();
51
52   // C++ Methods
53   void Shutdown();
54
55   static const char *_ContainerManagerNameInNS;
56
57 protected:
58   // C++ methods
59   Engines::Container_ptr
60   FindContainer(const Engines::ContainerParameters& params,
61                 const Engines::ResourceList& possibleResources);
62
63   Engines::Container_ptr
64   FindContainer(const Engines::ContainerParameters& params,
65                 const std::string& resource);
66
67   std::string BuildCommandToLaunchRemoteContainer(const std::string & resource_name,
68                                                   const Engines::ContainerParameters& params, 
69                                                   const std::string& container_exe="SALOME_Container");
70
71   std::string BuildCommandToLaunchLocalContainer(const Engines::ContainerParameters& params, 
72                                                  const std::string& machinesFile,
73                                                  const std::string& container_exe="SALOME_Container");
74
75   std::string BuildTempFileToLaunchRemoteContainer(const std::string& resource_name,
76                                                    const Engines::ContainerParameters& params) throw(SALOME_Exception);
77
78   void RmTmpFile(std::string& tmpFile);
79
80   void AddOmninamesParams(std::string& command) const;
81
82   void AddOmninamesParams(std::ostringstream& oss) const;
83
84   void AddOmninamesParams(std::ofstream& fileStream) const;
85
86   std::string BuildTemporaryFileName() const;
87
88   std::string GetMPIZeroNode(const std::string machine, const std::string machinesFile);
89
90   std::string machinesFile(const int nbproc);
91
92   CORBA::ORB_var _orb;
93   PortableServer::POA_var _poa;
94
95   SALOME_ResourcesManager *_ResManager;
96   SALOME_NamingService *_NS;
97
98   //! attribute that contains current tmp files generated
99   std::string _TmpFileName;
100
101   //! contains the rsh or ssh command to access directly to machine.
102   //  Only used by this->RmTmpFile in case of a remote launch.
103   std::string _CommandForRemAccess;
104
105   //! different behaviour if $APPLI exists (SALOME Application) 
106   bool _isAppliSalomeDefined;
107
108   //! attribute that contains the number of processes used in batch mode by MPI containers
109   int _nbprocUsed;
110
111   static omni_mutex _numInstanceMutex ; // lib and instance protection
112
113   // Begin of PacO++ Parallel extension
114   typedef std::vector<std::string> actual_launch_machine_t;
115
116   bool checkPaCOParameters(Engines::ContainerParameters & params, std::string resource_selected);
117
118   Engines::Container_ptr 
119   StartPaCOPPContainer(const Engines::ContainerParameters& params, std::string resource_selected);
120
121
122
123   std::string BuildCommandToLaunchPaCOProxyContainer(const Engines::ContainerParameters& params,
124                                                      std::string machine_file_name,
125                                                      std::string & proxy_hostname);
126
127   std::string BuildCommandToLaunchPaCONodeContainer(const Engines::ContainerParameters& params,
128                                                     const std::string & machine_file_name,
129                                                     SALOME_ContainerManager::actual_launch_machine_t & vect_machine, 
130                                                     const std::string & proxy_hostname); 
131
132   void LogConfiguration(const std::string & log_type,
133                         const std::string & exe_type,
134                         const std::string & container_name,
135                         const std::string & hostname,
136                         std::string & begin, 
137                         std::string & end);
138
139   CORBA::Object_ptr 
140   LaunchPaCOProxyContainer(const std::string& command, 
141                            const Engines::ContainerParameters& params,
142                            const std::string& hostname);
143
144   bool 
145   LaunchPaCONodeContainer(const std::string& command, 
146                           const Engines::ContainerParameters& params,
147                           const std::string& name,
148                           SALOME_ContainerManager::actual_launch_machine_t & vect_machine);
149   // End of PaCO++ Parallel extension
150 };
151 #endif