Back to index

salome-kernel  6.5.0
SALOME_ContainerManager.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #ifndef __SALOME_CONTAINERMANAGER_HXX__
00024 #define __SALOME_CONTAINERMANAGER_HXX__
00025 
00026 #include "SALOME_Container.hxx"
00027 
00028 #include <SALOMEconfig.h>
00029 #include CORBA_CLIENT_HEADER(SALOME_Component)
00030 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
00031 #include "SALOME_ResourcesManager.hxx"
00032 #include "SALOME_LoadRateManager.hxx"
00033 
00034 #include <string>
00035 #include <set>
00036 
00037 class SALOME_NamingService;
00038 
00039 class CONTAINER_EXPORT SALOME_ContainerManager:
00040   public POA_Engines::ContainerManager
00041 {
00042 
00043 public:
00044   SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_ResourcesManager *rm, SALOME_NamingService *ns);
00045   ~SALOME_ContainerManager();
00046 
00047   // Corba Methods
00048   Engines::Container_ptr
00049   GiveContainer(const Engines::ContainerParameters& params);
00050 
00051   void ShutdownContainers();
00052 
00053   // C++ Methods
00054   void Shutdown();
00055 
00056   static const char *_ContainerManagerNameInNS;
00057 
00058 protected:
00059   // C++ methods
00060   Engines::Container_ptr
00061   FindContainer(const Engines::ContainerParameters& params,
00062                 const Engines::ResourceList& possibleResources);
00063 
00064   Engines::Container_ptr
00065   FindContainer(const Engines::ContainerParameters& params,
00066                 const std::string& resource);
00067 
00068   std::string BuildCommandToLaunchRemoteContainer(const std::string & resource_name,
00069                                                   const Engines::ContainerParameters& params, 
00070                                                   const std::string& container_exe="SALOME_Container");
00071 
00072   std::string BuildCommandToLaunchLocalContainer(const Engines::ContainerParameters& params,
00073                                                  const std::string& machinesFile,
00074                                                  const std::string& container_exe="SALOME_Container");
00075 
00076   std::string BuildTempFileToLaunchRemoteContainer(const std::string& resource_name,
00077                                                    const Engines::ContainerParameters& params) throw(SALOME_Exception);
00078 
00079   void RmTmpFile(std::string& tmpFile);
00080 
00081   void AddOmninamesParams(std::string& command) const;
00082 
00083   void AddOmninamesParams(std::ostringstream& oss) const;
00084 
00085   void AddOmninamesParams(std::ofstream& fileStream) const;
00086 
00087   std::string BuildTemporaryFileName() const;
00088 
00089   std::string GetMPIZeroNode(const std::string machine, const std::string machinesFile);
00090 
00091   std::string machinesFile(const int nbproc);
00092 
00093   std::set<pid_t> getpidofprogram(const std::string program);
00094 
00095   std::string getCommandToRunRemoteProcess(AccessProtocolType protocol,
00096                                            const std::string & hostname,
00097                                            const std::string & username);
00098 
00099   Engines::Container_ptr
00100   LaunchContainer(const Engines::ContainerParameters& params,
00101                   const std::string & resource_selected,
00102                   const std::string & hostname,
00103                   const std::string & machFile,
00104                   const std::string & containerNameInNS);
00105 
00106   CORBA::ORB_var _orb;
00107   PortableServer::POA_var _poa;
00108 
00109   SALOME_ResourcesManager *_ResManager;
00110   SALOME_NamingService *_NS;
00111 
00113   std::string _TmpFileName;
00114 
00116   //  Only used by this->RmTmpFile in case of a remote launch.
00117   std::string _CommandForRemAccess;
00118 
00120   bool _isAppliSalomeDefined;
00121 
00123   int _nbprocUsed;
00124 
00125   static omni_mutex _numInstanceMutex ; // lib and instance protection
00126 
00127   pid_t _pid_mpiServer;
00128 
00129   // Begin of PacO++ Parallel extension
00130   typedef std::vector<std::string> actual_launch_machine_t;
00131 
00132   bool checkPaCOParameters(Engines::ContainerParameters & params, std::string resource_selected);
00133 
00134   Engines::Container_ptr 
00135   StartPaCOPPContainer(const Engines::ContainerParameters& params, std::string resource_selected);
00136 
00137 
00138 
00139   std::string BuildCommandToLaunchPaCOProxyContainer(const Engines::ContainerParameters& params,
00140                                                      std::string machine_file_name,
00141                                                      std::string & proxy_hostname);
00142 
00143   std::string BuildCommandToLaunchPaCONodeContainer(const Engines::ContainerParameters& params,
00144                                                     const std::string & machine_file_name,
00145                                                     SALOME_ContainerManager::actual_launch_machine_t & vect_machine, 
00146                                                     const std::string & proxy_hostname); 
00147 
00148   void LogConfiguration(const std::string & log_type,
00149                         const std::string & exe_type,
00150                         const std::string & container_name,
00151                         const std::string & hostname,
00152                         std::string & begin, 
00153                         std::string & end);
00154 
00155   CORBA::Object_ptr 
00156   LaunchPaCOProxyContainer(const std::string& command, 
00157                            const Engines::ContainerParameters& params,
00158                            const std::string& hostname);
00159 
00160   bool 
00161   LaunchPaCONodeContainer(const std::string& command, 
00162                           const Engines::ContainerParameters& params,
00163                           const std::string& name,
00164                           SALOME_ContainerManager::actual_launch_machine_t & vect_machine);
00165   // End of PaCO++ Parallel extension
00166 };
00167 #endif