SALOME documentation central

src/Container/SALOME_ContainerManager.hxx

00001 //  Copyright (C) 2007-2008  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 #ifndef __SALOME_CONTAINERMANAGER_HXX__
00023 #define __SALOME_CONTAINERMANAGER_HXX__
00024 
00025 #include "SALOME_Container.hxx"
00026 
00027 #include <SALOMEconfig.h>
00028 #include CORBA_CLIENT_HEADER(SALOME_Component)
00029 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
00030 #include "SALOME_ResourcesManager.hxx"
00031 #include "SALOME_LoadRateManager.hxx"
00032 
00033 #include <string>
00034 
00035 class SALOME_NamingService;
00036 
00037 class CONTAINER_EXPORT SALOME_ContainerManager:
00038   public POA_Engines::ContainerManager
00039 {
00040 
00041 public:
00042   SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_ResourcesManager *rm, SALOME_NamingService *ns);
00043   ~SALOME_ContainerManager();
00044 
00045   void Shutdown();
00046   void ShutdownContainers();
00047 
00048   Engines::Container_ptr
00049   StartContainer(const Engines::MachineParameters& params,
00050                  const Engines::MachineList& possibleComputer,
00051                  const std::string& container_exe="SALOME_Container");
00052 
00053   Engines::Container_ptr
00054   StartContainer(const Engines::MachineParameters& params);
00055 
00056   Engines::Container_ptr
00057   GiveContainer(const Engines::MachineParameters& params);
00058 
00059   Engines::Container_ptr
00060   FindOrStartContainer(const Engines::MachineParameters& params);
00061 
00062   static const char *_ContainerManagerNameInNS;
00063 
00064   // PaCO++ Parallel extension
00065   Engines::Container_ptr
00066   StartParallelContainer(const Engines::MachineParameters& params);
00067 
00068 protected:
00069   Engines::Container_ptr
00070   FindContainer(const Engines::MachineParameters& params,
00071                 const Engines::MachineList& possibleComputers);
00072 
00073   Engines::Container_ptr
00074   FindContainer(const Engines::MachineParameters& params,
00075                 const char *theMachine);
00076 
00077   void fillBatchLaunchedContainers();
00078 
00079   std::string BuildCommandToLaunchRemoteContainer(const std::string& machine,
00080                                                   const Engines::MachineParameters& params, 
00081                                                   const std::string& container_exe="SALOME_Container");
00082 
00083   std::string BuildCommandToLaunchLocalContainer(const Engines::MachineParameters& params, 
00084                                                  const std::string& container_exe="SALOME_Container");
00085 
00086   std::string BuildTempFileToLaunchRemoteContainer(const std::string& machine,
00087                                                    const Engines::MachineParameters& params) throw(SALOME_Exception);
00088 
00089   void RmTmpFile(std::string& tmpFile);
00090 
00091   void AddOmninamesParams(std::string& command) const;
00092 
00093   void AddOmninamesParams(std::ofstream& fileStream) const;
00094 
00095   std::string BuildTemporaryFileName() const;
00096 
00097   std::string GetMPIZeroNode(std::string machine);
00098 
00099   // For PacO++ Parallel extension
00100   typedef std::vector<std::string> actual_launch_machine_t;
00101   std::string BuildCommandToLaunchParallelContainer(const std::string& exe_name, 
00102                                                     const Engines::MachineParameters& params,
00103                                                     SALOME_ContainerManager::actual_launch_machine_t & vect_machine, 
00104                                                     const std::string proxy_hostname = ""); 
00105   CORBA::Object_ptr 
00106   LaunchParallelContainer(const std::string& command, 
00107                           const Engines::MachineParameters& params,
00108                           const std::string& name,
00109                           SALOME_ContainerManager::actual_launch_machine_t & vect_machine);
00110   CORBA::ORB_var _orb;
00111   PortableServer::POA_var _poa;
00112 
00113   SALOME_ResourcesManager *_ResManager;
00114   SALOME_NamingService *_NS;
00115   static std::vector<Engines::Container_ptr> _batchLaunchedContainers;
00116   static std::vector<Engines::Container_ptr>::iterator _batchLaunchedContainersIter;
00117 
00119   std::string _TmpFileName;
00120 
00122   //  Only used by this->RmTmpFile in case of a remote launch.
00123   std::string _CommandForRemAccess;
00124 
00126   bool _isAppliSalomeDefined;
00127 
00128 };
00129 #endif