Version: 6.3.1

src/Container/SALOME_ContainerManager.hxx

00001 // Copyright (C) 2007-2011  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   CORBA::ORB_var _orb;
00096   PortableServer::POA_var _poa;
00097 
00098   SALOME_ResourcesManager *_ResManager;
00099   SALOME_NamingService *_NS;
00100 
00102   std::string _TmpFileName;
00103 
00105   //  Only used by this->RmTmpFile in case of a remote launch.
00106   std::string _CommandForRemAccess;
00107 
00109   bool _isAppliSalomeDefined;
00110 
00112   int _nbprocUsed;
00113 
00114   static omni_mutex _numInstanceMutex ; // lib and instance protection
00115 
00116   pid_t _pid_ompiServer;
00117 
00118   // Begin of PacO++ Parallel extension
00119   typedef std::vector<std::string> actual_launch_machine_t;
00120 
00121   bool checkPaCOParameters(Engines::ContainerParameters & params, std::string resource_selected);
00122 
00123   Engines::Container_ptr 
00124   StartPaCOPPContainer(const Engines::ContainerParameters& params, std::string resource_selected);
00125 
00126 
00127 
00128   std::string BuildCommandToLaunchPaCOProxyContainer(const Engines::ContainerParameters& params,
00129                                                      std::string machine_file_name,
00130                                                      std::string & proxy_hostname);
00131 
00132   std::string BuildCommandToLaunchPaCONodeContainer(const Engines::ContainerParameters& params,
00133                                                     const std::string & machine_file_name,
00134                                                     SALOME_ContainerManager::actual_launch_machine_t & vect_machine, 
00135                                                     const std::string & proxy_hostname); 
00136 
00137   void LogConfiguration(const std::string & log_type,
00138                         const std::string & exe_type,
00139                         const std::string & container_name,
00140                         const std::string & hostname,
00141                         std::string & begin, 
00142                         std::string & end);
00143 
00144   CORBA::Object_ptr 
00145   LaunchPaCOProxyContainer(const std::string& command, 
00146                            const Engines::ContainerParameters& params,
00147                            const std::string& hostname);
00148 
00149   bool 
00150   LaunchPaCONodeContainer(const std::string& command, 
00151                           const Engines::ContainerParameters& params,
00152                           const std::string& name,
00153                           SALOME_ContainerManager::actual_launch_machine_t & vect_machine);
00154   // End of PaCO++ Parallel extension
00155 };
00156 #endif
Copyright © 2007-2011 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