1 // Copyright (C) 2007-2010 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 #include "SALOME_ContainerManager.hxx"
24 #include "SALOME_NamingService.hxx"
25 #include "SALOME_ModuleCatalog.hh"
26 #include "Basics_Utils.hxx"
27 #include "Basics_DirUtils.hxx"
28 #include <sys/types.h>
34 #include "Utils_CorbaException.hxx"
39 #define getpid _getpid
42 #ifdef WITH_PACO_PARALLEL
46 #define TIME_OUT_TO_LAUNCH_CONT 61
48 const char *SALOME_ContainerManager::_ContainerManagerNameInNS =
51 omni_mutex SALOME_ContainerManager::_numInstanceMutex;
54 //=============================================================================
58 * Define a CORBA single thread policy for the server, which avoid to deal
59 * with non thread-safe usage like Change_Directory in SALOME naming service
61 //=============================================================================
63 SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_ResourcesManager *rm, SALOME_NamingService *ns):_nbprocUsed(0)
65 MESSAGE("constructor");
69 PortableServer::POAManager_var pman = poa->the_POAManager();
70 _orb = CORBA::ORB::_duplicate(orb) ;
71 CORBA::PolicyList policies;
73 PortableServer::ThreadPolicy_var threadPol =
74 poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL);
75 policies[0] = PortableServer::ThreadPolicy::_duplicate(threadPol);
77 _poa = poa->create_POA("SThreadPOA",pman,policies);
79 PortableServer::ObjectId_var id = _poa->activate_object(this);
80 CORBA::Object_var obj = _poa->id_to_reference(id);
81 Engines::ContainerManager_var refContMan =
82 Engines::ContainerManager::_narrow(obj);
84 _NS->Register(refContMan,_ContainerManagerNameInNS);
85 _isAppliSalomeDefined = (getenv("APPLI") != 0);
89 std::string urifile = getenv("HOME");
90 std::ostringstream mypid;
92 urifile += "/.urifile_" + mypid.str();
93 setenv("OMPI_URI_FILE",urifile.c_str(),0);
94 if( getenv("OMPI_URI_FILE") != NULL ){
95 system("killall ompi-server");
97 command = "ompi-server -r ";
98 command += getenv("OMPI_URI_FILE");
99 int status=system(command.c_str());
101 throw SALOME_Exception("Error when launching ompi-server");
106 MESSAGE("constructor end");
109 //=============================================================================
113 //=============================================================================
115 SALOME_ContainerManager::~SALOME_ContainerManager()
117 MESSAGE("destructor");
120 if( getenv("OMPI_URI_FILE") != NULL )
121 system("killall ompi-server");
126 //=============================================================================
127 //! shutdown all the containers, then the ContainerManager servant
130 //=============================================================================
132 void SALOME_ContainerManager::Shutdown()
135 ShutdownContainers();
136 _NS->Destroy_Name(_ContainerManagerNameInNS);
137 PortableServer::ObjectId_var oid = _poa->servant_to_id(this);
138 _poa->deactivate_object(oid);
141 //=============================================================================
142 //! Loop on all the containers listed in naming service, ask shutdown on each
145 //=============================================================================
147 void SALOME_ContainerManager::ShutdownContainers()
149 MESSAGE("ShutdownContainers");
151 isOK = _NS->Change_Directory("/Containers");
153 std::vector<std::string> vec = _NS->list_directory_recurs();
154 std::list<std::string> lstCont;
155 for(std::vector<std::string>::iterator iter = vec.begin();iter!=vec.end();iter++)
158 CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
161 Engines::Container_var cont=Engines::Container::_narrow(obj);
162 if(!CORBA::is_nil(cont))
163 lstCont.push_back((*iter));
165 catch(const CORBA::Exception& e)
167 // ignore this entry and continue
170 MESSAGE("Container list: ");
171 for(std::list<std::string>::iterator iter=lstCont.begin();iter!=lstCont.end();iter++){
174 for(std::list<std::string>::iterator iter=lstCont.begin();iter!=lstCont.end();iter++)
179 CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
180 Engines::Container_var cont=Engines::Container::_narrow(obj);
181 if(!CORBA::is_nil(cont))
183 MESSAGE("ShutdownContainers: " << (*iter));
187 MESSAGE("ShutdownContainers: no container ref for " << (*iter));
189 catch(CORBA::SystemException& e)
191 INFOS("CORBA::SystemException ignored : " << e);
193 catch(CORBA::Exception&)
195 INFOS("CORBA::Exception ignored.");
199 INFOS("Unknown exception ignored.");
205 //=============================================================================
206 //! Give a suitable Container given constraints
208 * \param params Container Parameters required for the container
209 * \return the container or nil
211 //=============================================================================
212 Engines::Container_ptr
213 SALOME_ContainerManager::GiveContainer(const Engines::ContainerParameters& params)
215 std::string machFile;
216 Engines::Container_ptr ret = Engines::Container::_nil();
218 // Step 0: Default mode is start
219 Engines::ContainerParameters local_params(params);
220 if (std::string(local_params.mode.in()) == "")
221 local_params.mode = CORBA::string_dup("start");
222 std::string mode = local_params.mode.in();
223 MESSAGE("[GiveContainer] starting with mode: " << mode);
225 // Step 1: Find Container for find and findorstart mode
226 if (mode == "find" || mode == "findorstart")
228 ret = FindContainer(params, params.resource_params.resList);
229 if(!CORBA::is_nil(ret))
235 MESSAGE("[GiveContainer] no container found");
245 // Step 2: Get all possibleResources from the parameters
246 Engines::ResourceList_var possibleResources = _ResManager->GetFittingResources(local_params.resource_params);
247 MESSAGE("[GiveContainer] - length of possible resources " << possibleResources->length());
248 std::vector<std::string> local_resources;
250 // Step 3: if mode is "get" keep only machines with existing containers
253 for(unsigned int i=0; i < possibleResources->length(); i++)
255 Engines::Container_ptr cont = FindContainer(params, possibleResources[i].in());
258 if(!cont->_non_existent())
259 local_resources.push_back(std::string(possibleResources[i]));
261 catch(CORBA::Exception&) {}
264 // if local_resources is empty, we cannot give a container
265 if (local_resources.size() == 0)
267 MESSAGE("[GiveContainer] cannot find a container for mode get");
272 for(unsigned int i=0; i < possibleResources->length(); i++)
273 local_resources.push_back(std::string(possibleResources[i]));
275 // Step 4: select the resource where to get/start the container
276 std::string resource_selected;
279 resource_selected = _ResManager->GetImpl()->Find(params.resource_params.policy.in(), local_resources);
281 catch(const SALOME_Exception &ex)
283 MESSAGE("[GiveContainer] Exception in ResourceManager find !: " << ex.what());
286 MESSAGE("[GiveContainer] Resource selected is: " << resource_selected);
288 // Step 5: get container in the naming service
289 Engines::ResourceDefinition_var resource_definition = _ResManager->GetResourceDefinition(resource_selected.c_str());
290 std::string hostname(resource_definition->hostname.in());
291 std::string containerNameInNS;
294 if ( params.nb_proc <= 0 )
297 nbproc = params.nb_proc;
298 if( getenv("LIBBATCH_NODEFILE") != NULL )
299 machFile = machinesFile(nbproc);
300 // A mpi parallel container register on zero node in NS
301 containerNameInNS = _NS->BuildContainerNameForNS(params, GetMPIZeroNode(hostname,machFile).c_str());
304 containerNameInNS = _NS->BuildContainerNameForNS(params, hostname.c_str());
305 MESSAGE("[GiveContainer] Container name in the naming service: " << containerNameInNS);
307 // Step 6: check if the name exists in naming service
308 //if params.mode == "getorstart" or "get" use the existing container
309 //if params.mode == "start" shutdown the existing container before launching a new one with that name
310 CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
311 if (!CORBA::is_nil(obj))
315 Engines::Container_var cont=Engines::Container::_narrow(obj);
316 if(!cont->_non_existent())
318 if(std::string(params.mode.in())=="getorstart" || std::string(params.mode.in())=="get"){
319 return cont._retn(); /* the container exists and params.mode is getorstart or get use it*/
323 INFOS("[GiveContainer] A container is already registered with the name: " << containerNameInNS << ", shutdown the existing container");
324 cont->Shutdown(); // shutdown the registered container if it exists
328 catch(CORBA::Exception&)
330 INFOS("[GiveContainer] CORBA::Exception ignored when trying to get the container - we start a new one");
334 // Step 7: type of container: PaCO, Exe, Mpi or Classic
335 // Mpi already tested in step 5, specific code on BuildCommandToLaunch Local/Remote Container methods
336 // TODO -> separates Mpi from Classic/Exe
338 std::string container_exe = "SALOME_Container"; // Classic container
342 CORBA::String_var container_exe_tmp;
343 CORBA::Object_var obj = _NS->Resolve("/Kernel/ModulCatalog");
344 SALOME_ModuleCatalog::ModuleCatalog_var Catalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ;
345 if (CORBA::is_nil (Catalog))
347 INFOS("[GiveContainer] Module Catalog is not found -> cannot launch a container");
350 // Loop through component list
351 for(unsigned int i=0; i < local_params.resource_params.componentList.length(); i++)
353 const char* compoi = local_params.resource_params.componentList[i];
354 SALOME_ModuleCatalog::Acomponent_var compoInfo = Catalog->GetComponent(compoi);
355 if (CORBA::is_nil (compoInfo))
359 SALOME_ModuleCatalog::ImplType impl=compoInfo->implementation_type();
360 container_exe_tmp=compoInfo->implementation_name();
361 if(impl==SALOME_ModuleCatalog::CEXE)
365 INFOS("ContainerManager Error: you can't have 2 CEXE component in the same container" );
366 return Engines::Container::_nil();
368 MESSAGE("[GiveContainer] Exe container found !: " << container_exe_tmp);
369 container_exe = container_exe_tmp.in();
374 catch (ServiceUnreachable&)
376 INFOS("Caught exception: Naming Service Unreachable");
381 INFOS("Caught unknown exception.");
385 // Step 8: start a new container
386 // Check if a PaCO container
388 if (std::string(local_params.parallelLib.in()) != "")
390 ret = StartPaCOPPContainer(params, resource_selected);
393 // Other type of containers...
394 MESSAGE("[GiveContainer] Try to launch a new container on " << resource_selected);
396 // if a parallel container is launched in batch job, command is: "mpirun -np nbproc -machinefile nodesfile SALOME_MPIContainer"
397 if( getenv("LIBBATCH_NODEFILE") != NULL && params.isMPI )
398 command = BuildCommandToLaunchLocalContainer(params, machFile, container_exe);
399 // if a container is launched on localhost, command is "SALOME_Container" or "mpirun -np nbproc SALOME_MPIContainer"
400 else if(hostname == Kernel_Utils::GetHostname())
401 command = BuildCommandToLaunchLocalContainer(params, machFile, container_exe);
402 // if a container is launched in remote mode, command is "ssh resource_selected SALOME_Container" or "ssh resource_selected mpirun -np nbproc SALOME_MPIContainer"
404 command = BuildCommandToLaunchRemoteContainer(resource_selected, params, container_exe);
406 //redirect stdout and stderr in a file
408 std::string logFilename=getenv("TEMP");
410 std::string user = getenv( "USERNAME" );
412 std::string user = getenv( "USER" );
413 std::string logFilename="/tmp";
414 char* val = getenv("SALOME_TMP_DIR");
417 struct stat file_info;
418 stat(val, &file_info);
419 bool is_dir = S_ISDIR(file_info.st_mode);
420 if (is_dir)logFilename=val;
421 else std::cerr << "SALOME_TMP_DIR environment variable is not a directory use /tmp instead" << std::endl;
425 logFilename += _NS->ContainerName(params)+"_"+ resource_selected +"_"+user;
426 std::ostringstream tmp;
427 tmp << "_" << getpid();
428 logFilename += tmp.str();
429 logFilename += ".log" ;
430 command += " > " + logFilename + " 2>&1";
432 command = "%PYTHONBIN% -c \"import win32pm ; win32pm.spawnpid(r'" + command + "', '')\"";
437 // launch container with a system call
438 int status=system(command.c_str());
441 MESSAGE("SALOME_ContainerManager::StartContainer rsh failed (system command status -1)");
442 RmTmpFile(_TmpFileName); // command file can be removed here
443 return Engines::Container::_nil();
445 else if (status == 217){
446 MESSAGE("SALOME_ContainerManager::StartContainer rsh failed (system command status 217)");
447 RmTmpFile(_TmpFileName); // command file can be removed here
448 return Engines::Container::_nil();
452 int count = TIME_OUT_TO_LAUNCH_CONT;
453 MESSAGE("[GiveContainer] waiting " << count << " second steps");
454 while (CORBA::is_nil(ret) && count)
462 MESSAGE("[GiveContainer] step " << count << " Waiting for container on " << resource_selected);
463 CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
464 ret=Engines::Container::_narrow(obj);
466 if (CORBA::is_nil(ret))
468 INFOS("[GiveContainer] was not able to launch container " << containerNameInNS);
472 // Setting log file name
473 logFilename=":"+logFilename;
474 logFilename="@"+Kernel_Utils::GetHostname()+logFilename;
475 logFilename=user+logFilename;
476 ret->logfilename(logFilename.c_str());
477 RmTmpFile(_TmpFileName); // command file can be removed here
483 //=============================================================================
484 //! Find a container given constraints (params) on a list of machines (possibleComputers)
488 //=============================================================================
490 Engines::Container_ptr
491 SALOME_ContainerManager::FindContainer(const Engines::ContainerParameters& params,
492 const Engines::ResourceList& possibleResources)
494 MESSAGE("[FindContainer] FindContainer on " << possibleResources.length() << " resources");
495 for(unsigned int i=0; i < possibleResources.length();i++)
497 Engines::Container_ptr cont = FindContainer(params, possibleResources[i].in());
498 if(!CORBA::is_nil(cont))
501 MESSAGE("[FindContainer] no container found");
502 return Engines::Container::_nil();
505 //=============================================================================
506 //! Find a container given constraints (params) on a machine (theMachine)
510 //=============================================================================
512 Engines::Container_ptr
513 SALOME_ContainerManager::FindContainer(const Engines::ContainerParameters& params,
514 const std::string& resource)
516 Engines::ResourceDefinition_var resource_definition = _ResManager->GetResourceDefinition(resource.c_str());
517 std::string hostname(resource_definition->hostname.in());
518 std::string containerNameInNS(_NS->BuildContainerNameForNS(params, hostname.c_str()));
519 MESSAGE("[FindContainer] Try to find a container " << containerNameInNS << " on resource " << resource);
520 CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
523 if(obj->_non_existent())
524 return Engines::Container::_nil();
526 return Engines::Container::_narrow(obj);
528 catch(const CORBA::Exception& e)
530 return Engines::Container::_nil();
535 bool isPythonContainer(const char* ContainerName);
537 //=============================================================================
539 * This is no longer valid (C++ container are also python containers)
541 //=============================================================================
542 bool isPythonContainer(const char* ContainerName)
545 int len = strlen(ContainerName);
548 if (strcmp(ContainerName + len - 2, "Py") == 0)
554 //=============================================================================
556 * Builds the script to be launched
558 * If SALOME Application not defined ($APPLI),
559 * see BuildTempFileToLaunchRemoteContainer()
561 * Else rely on distant configuration. Command is under the form (example):
562 * ssh user@machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \
563 * SALOME_Container containerName &"
565 * - where user is ommited if not specified in CatalogResources,
566 * - where distant path is always relative to user@machine $HOME, and
567 * equal to $APPLI if not specified in CatalogResources,
568 * - where hostNS is the hostname of CORBA naming server (set by scripts to
569 * use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh)
570 * - where portNS is the port used by CORBA naming server (set by scripts to
571 * use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh)
572 * - where workingdir is the requested working directory for the container.
573 * If WORKINGDIR (and workingdir) is not present the working dir will be $HOME
575 //=============================================================================
578 SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer
579 (const std::string& resource_name,
580 const Engines::ContainerParameters& params, const std::string& container_exe)
584 if (!_isAppliSalomeDefined)
585 command = BuildTempFileToLaunchRemoteContainer(resource_name, params);
589 Engines::ResourceDefinition_var resource_definition = _ResManager->GetResourceDefinition(resource_name.c_str());
590 std::string hostname(resource_definition->hostname.in());
591 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesDescr(resource_name);
595 if ( params.nb_proc <= 0 )
598 nbproc = params.nb_proc;
601 // "ssh -l user machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \
602 // SALOME_Container containerName &"
603 if (resInfo.Protocol == rsh)
605 else if (resInfo.Protocol == ssh)
608 throw SALOME_Exception("Unknown protocol");
610 if (resInfo.UserName != "")
613 command += resInfo.UserName;
617 command += resInfo.HostName;
620 if (resInfo.AppliPath != "")
621 command += resInfo.AppliPath; // path relative to user@machine $HOME
624 ASSERT(getenv("APPLI"));
625 command += getenv("APPLI"); // path relative to user@machine $HOME
628 command += "/runRemote.sh ";
630 ASSERT(getenv("NSHOST"));
631 command += getenv("NSHOST"); // hostname of CORBA name server
634 ASSERT(getenv("NSPORT"));
635 command += getenv("NSPORT"); // port of CORBA name server
637 std::string wdir = params.workingdir.in();
640 command += " WORKINGDIR ";
642 if(wdir == "$TEMPDIR")
644 command += wdir; // requested working directory
650 command += " mpirun -np ";
651 std::ostringstream o;
655 command += "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
656 #elif defined(WITHOPENMPI)
657 if( getenv("OMPI_URI_FILE") == NULL )
658 command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
660 command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
661 command += getenv("OMPI_URI_FILE");
664 command += " SALOME_MPIContainer ";
667 command += " " +container_exe+ " ";
669 command += _NS->ContainerName(params);
671 AddOmninamesParams(command);
673 MESSAGE("command =" << command);
679 //=============================================================================
681 * builds the command to be launched.
683 //=============================================================================
685 SALOME_ContainerManager::BuildCommandToLaunchLocalContainer
686 (const Engines::ContainerParameters& params, const std::string& machinesFile, const std::string& container_exe)
688 _TmpFileName = BuildTemporaryFileName();
692 std::ostringstream o;
698 if ( params.nb_proc <= 0 )
701 nbproc = params.nb_proc;
705 if( getenv("LIBBATCH_NODEFILE") != NULL )
706 o << "-machinefile " << machinesFile << " ";
709 o << "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
710 #elif defined(WITHOPENMPI)
711 if( getenv("OMPI_URI_FILE") == NULL )
712 o << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
715 o << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
716 o << getenv("OMPI_URI_FILE");
720 if (isPythonContainer(params.container_name))
721 o << " pyMPI SALOME_ContainerPy.py ";
723 o << " SALOME_MPIContainer ";
728 std::string wdir=params.workingdir.in();
731 // a working directory is requested
732 if(wdir == "$TEMPDIR")
734 // a new temporary directory is requested
735 std::string dir = Kernel_Utils::GetTmpDir();
737 o << "cd /d " << dir << std::endl;
739 o << "cd " << dir << ";";
745 // a permanent directory is requested use it or create it
747 o << "mkdir " + wdir << std::endl;
748 o << "cd /D " + wdir << std::endl;
750 o << "mkdir -p " << wdir << " && cd " << wdir + ";";
754 if (isPythonContainer(params.container_name))
755 o << "SALOME_ContainerPy.py ";
757 o << container_exe + " ";
761 o << _NS->ContainerName(params);
763 AddOmninamesParams(o);
765 std::ofstream command_file( _TmpFileName.c_str() );
766 command_file << o.str();
767 command_file.close();
770 chmod(_TmpFileName.c_str(), 0x1ED);
772 command = _TmpFileName;
774 MESSAGE("Command is file ... " << command);
775 MESSAGE("Command is ... " << o.str());
780 //=============================================================================
782 * removes the generated temporary file in case of a remote launch.
784 //=============================================================================
786 void SALOME_ContainerManager::RmTmpFile(std::string& tmpFileName)
788 int lenght = tmpFileName.size();
792 std::string command = "del /F ";
794 std::string command = "rm ";
797 command += tmpFileName.substr(0, lenght - 3 );
799 command += tmpFileName;
801 system(command.c_str());
802 //if dir is empty - remove it
803 std::string tmp_dir = Kernel_Utils::GetDirByPath( tmpFileName );
804 if ( Kernel_Utils::IsEmptyDir( tmp_dir ) )
807 command = "del /F " + tmp_dir;
809 command = "rmdir " + tmp_dir;
811 system(command.c_str());
816 //=============================================================================
818 * add to command all options relative to naming service.
820 //=============================================================================
822 void SALOME_ContainerManager::AddOmninamesParams(std::string& command) const
824 CORBA::String_var iorstr = _NS->getIORaddr();
825 command += "ORBInitRef NameService=";
829 //=============================================================================
831 * add to command all options relative to naming service.
833 //=============================================================================
835 void SALOME_ContainerManager::AddOmninamesParams(std::ofstream& fileStream) const
837 CORBA::String_var iorstr = _NS->getIORaddr();
838 fileStream << "ORBInitRef NameService=";
839 fileStream << iorstr;
842 //=============================================================================
844 * add to command all options relative to naming service.
846 //=============================================================================
848 void SALOME_ContainerManager::AddOmninamesParams(std::ostringstream& oss) const
850 CORBA::String_var iorstr = _NS->getIORaddr();
851 oss << "ORBInitRef NameService=";
855 //=============================================================================
857 * generate a file name in /tmp directory
859 //=============================================================================
861 std::string SALOME_ContainerManager::BuildTemporaryFileName() const
863 //build more complex file name to support multiple salome session
864 std::string aFileName = Kernel_Utils::GetTmpFileName();
873 //=============================================================================
875 * Builds in a temporary file the script to be launched.
877 * Used if SALOME Application ($APPLI) is not defined.
878 * The command is build with data from CatalogResources, in which every path
879 * used on remote computer must be defined.
881 //=============================================================================
884 SALOME_ContainerManager::BuildTempFileToLaunchRemoteContainer
885 (const std::string& resource_name,
886 const Engines::ContainerParameters& params) throw(SALOME_Exception)
890 _TmpFileName = BuildTemporaryFileName();
891 std::ofstream tempOutputFile;
892 tempOutputFile.open(_TmpFileName.c_str(), std::ofstream::out );
893 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesDescr(resource_name);
894 tempOutputFile << "#! /bin/sh" << std::endl;
898 tempOutputFile << "export SALOME_trace=local" << std::endl; // mkr : 27.11.2006 : PAL13967 - Distributed supervision graphs - Problem with "SALOME_trace"
899 //tempOutputFile << "source " << resInfo.PreReqFilePath << endl;
905 tempOutputFile << "mpirun -np ";
908 if ( params.nb_proc <= 0 )
911 nbproc = params.nb_proc;
913 std::ostringstream o;
915 tempOutputFile << nbproc << " ";
917 tempOutputFile << "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
918 #elif defined(WITHOPENMPI)
919 if( getenv("OMPI_URI_FILE") == NULL )
920 tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
922 tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
923 tempOutputFile << getenv("OMPI_URI_FILE");
928 tempOutputFile << getenv("KERNEL_ROOT_DIR") << "/bin/salome/";
932 if (isPythonContainer(params.container_name))
933 tempOutputFile << " pyMPI SALOME_ContainerPy.py ";
935 tempOutputFile << " SALOME_MPIContainer ";
940 if (isPythonContainer(params.container_name))
941 tempOutputFile << "SALOME_ContainerPy.py ";
943 tempOutputFile << "SALOME_Container ";
946 tempOutputFile << _NS->ContainerName(params) << " -";
947 AddOmninamesParams(tempOutputFile);
948 tempOutputFile << " &" << std::endl;
949 tempOutputFile.flush();
950 tempOutputFile.close();
952 chmod(_TmpFileName.c_str(), 0x1ED);
959 if (resInfo.Protocol == rsh)
962 std::string commandRcp = "rcp ";
963 commandRcp += _TmpFileName;
965 commandRcp += resInfo.HostName;
967 commandRcp += _TmpFileName;
968 status = system(commandRcp.c_str());
971 else if (resInfo.Protocol == ssh)
974 std::string commandRcp = "scp ";
975 commandRcp += _TmpFileName;
977 commandRcp += resInfo.HostName;
979 commandRcp += _TmpFileName;
980 status = system(commandRcp.c_str());
983 throw SALOME_Exception("Unknown protocol");
986 throw SALOME_Exception("Error of connection on remote host");
988 command += resInfo.HostName;
989 _CommandForRemAccess = command;
991 command += _TmpFileName;
999 std::string SALOME_ContainerManager::GetMPIZeroNode(const std::string machine, const std::string machinesFile)
1002 std::string zeronode;
1003 std::string command;
1004 std::string tmpFile = BuildTemporaryFileName();
1006 if( getenv("LIBBATCH_NODEFILE") == NULL )
1008 if (_isAppliSalomeDefined)
1010 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesDescr(machine);
1012 if (resInfo.Protocol == rsh)
1014 else if (resInfo.Protocol == ssh)
1017 throw SALOME_Exception("Unknown protocol");
1019 if (resInfo.UserName != "")
1022 command += resInfo.UserName;
1026 command += resInfo.HostName;
1029 if (resInfo.AppliPath != "")
1030 command += resInfo.AppliPath; // path relative to user@machine $HOME
1033 ASSERT(getenv("APPLI"));
1034 command += getenv("APPLI"); // path relative to user@machine $HOME
1037 command += "/runRemote.sh ";
1039 ASSERT(getenv("NSHOST"));
1040 command += getenv("NSHOST"); // hostname of CORBA name server
1043 ASSERT(getenv("NSPORT"));
1044 command += getenv("NSPORT"); // port of CORBA name server
1046 command += " mpirun -np 1 hostname > " + tmpFile;
1049 command = "mpirun -np 1 hostname > " + tmpFile;
1052 command = "mpirun -np 1 -machinefile " + machinesFile + " hostname > " + tmpFile;
1054 status = system(command.c_str());
1056 std::ifstream fp(tmpFile.c_str(),std::ios::in);
1057 while(fp >> zeronode);
1065 std::string SALOME_ContainerManager::machinesFile(const int nbproc)
1068 std::string nodesFile = getenv("LIBBATCH_NODEFILE");
1069 std::string machinesFile = Kernel_Utils::GetTmpFileName();
1070 std::ifstream fpi(nodesFile.c_str(),std::ios::in);
1071 std::ofstream fpo(machinesFile.c_str(),std::ios::out);
1073 _numInstanceMutex.lock();
1075 for(int i=0;i<_nbprocUsed;i++)
1078 for(int i=0;i<nbproc;i++)
1080 fpo << tmp << std::endl;
1082 throw SALOME_Exception("You ask more processes than batch session have allocated!");
1084 _nbprocUsed += nbproc;
1088 _numInstanceMutex.unlock();
1090 return machinesFile;
1095 SALOME_ContainerManager::checkPaCOParameters(Engines::ContainerParameters & params, std::string resource_selected)
1099 // Step 1 : check ContainerParameters
1100 // Check container_name, has to be defined
1101 if (std::string(params.container_name.in()) == "")
1103 INFOS("[checkPaCOParameters] You must define a container_name to launch a PaCO++ container");
1106 // Check parallelLib
1107 std::string parallelLib = params.parallelLib.in();
1108 if (parallelLib != "Mpi" && parallelLib != "Dummy")
1110 INFOS("[checkPaCOParameters] parallelLib is not correctly defined");
1111 INFOS("[checkPaCOParameters] you can chosse between: Mpi and Dummy");
1112 INFOS("[checkPaCOParameters] you entered: " << parallelLib);
1116 if (params.nb_proc <= 0)
1118 INFOS("[checkPaCOParameters] You must define a nb_proc > 0");
1122 // Step 2 : check resource_selected
1123 Engines::ResourceDefinition_var resource_definition = _ResManager->GetResourceDefinition(resource_selected.c_str());
1124 std::string protocol = resource_definition->protocol.in();
1125 std::string username = resource_definition->username.in();
1126 std::string applipath = resource_definition->applipath.in();
1128 if (protocol == "" || username == "" || applipath == "")
1130 INFOS("[checkPaCOParameters] resource selected is not well defined");
1131 INFOS("[checkPaCOParameters] resource name: " << resource_definition->name.in());
1132 INFOS("[checkPaCOParameters] resource hostname: " << resource_definition->hostname.in());
1133 INFOS("[checkPaCOParameters] resource protocol: " << protocol);
1134 INFOS("[checkPaCOParameters] resource username: " << username);
1135 INFOS("[checkPaCOParameters] resource applipath: " << applipath);
1141 #ifdef WITH_PACO_PARALLEL
1143 //=============================================================================
1145 * Start a suitable PaCO++ Parallel Container in a list of machines.
1146 * \param params Container Parameters required for the container
1147 * \return CORBA container reference.
1149 //=============================================================================
1150 Engines::Container_ptr
1151 SALOME_ContainerManager::StartPaCOPPContainer(const Engines::ContainerParameters& params_const,
1152 std::string resource_selected)
1154 CORBA::Object_var obj;
1155 PaCO::InterfaceManager_var container_proxy;
1156 Engines::Container_ptr ret = Engines::Container::_nil();
1157 Engines::ContainerParameters params(params_const);
1158 params.resource_params.name = CORBA::string_dup(resource_selected.c_str());
1160 // Step 0 : Check parameters
1161 if (!checkPaCOParameters(params, resource_selected))
1163 INFOS("[StartPaCOPPContainer] check parameters failed ! see logs...");
1167 // Step 1 : Starting a new parallel container !
1168 INFOS("[StartPaCOPPContainer] Starting a PaCO++ parallel container");
1169 INFOS("[StartPaCOPPContainer] on resource : " << resource_selected);
1171 // Step 2 : Get a MachineFile for the parallel container
1172 std::string machine_file_name = _ResManager->getMachineFile(resource_selected,
1174 params.parallelLib.in());
1176 if (machine_file_name == "")
1178 INFOS("[StartPaCOPPContainer] Machine file generation failed");
1182 // Step 3 : starting parallel container proxy
1183 std::string command_proxy("");
1184 std::string proxy_machine;
1187 command_proxy = BuildCommandToLaunchPaCOProxyContainer(params, machine_file_name, proxy_machine);
1189 catch(const SALOME_Exception & ex)
1191 INFOS("[StartPaCOPPContainer] Exception in BuildCommandToLaunchPaCOContainer");
1195 obj = LaunchPaCOProxyContainer(command_proxy, params, proxy_machine);
1196 if (CORBA::is_nil(obj))
1198 INFOS("[StartPaCOPPContainer] LaunchPaCOContainer for proxy returns NIL !");
1201 container_proxy = PaCO::InterfaceManager::_narrow(obj);
1202 MESSAGE("[StartPaCOPPContainer] PaCO container proxy is launched");
1204 // Step 4 : starting parallel container nodes
1205 std::string command_nodes("");
1206 SALOME_ContainerManager::actual_launch_machine_t nodes_machines;
1209 command_nodes = BuildCommandToLaunchPaCONodeContainer(params, machine_file_name, nodes_machines, proxy_machine);
1211 catch(const SALOME_Exception & ex)
1213 INFOS("[StarPaCOPPContainer] Exception in BuildCommandToLaunchPaCONodeContainer");
1218 std::string container_generic_node_name = std::string(params.container_name.in()) + std::string("Node");
1219 bool result = LaunchPaCONodeContainer(command_nodes, params, container_generic_node_name, nodes_machines);
1222 INFOS("[StarPaCOPPContainer] LaunchPaCONodeContainer failed !");
1223 // Il faut tuer le proxy
1226 Engines::Container_var proxy = Engines::Container::_narrow(container_proxy);
1231 INFOS("[StarPaCOPPContainer] Exception catched from proxy Shutdown...");
1236 // Step 4 : connecting nodes and the proxy to actually create a parallel container
1237 for (int i = 0; i < params.nb_proc; i++)
1239 std::ostringstream tmp;
1241 std::string proc_number = tmp.str();
1242 std::string container_node_name = container_generic_node_name + proc_number;
1244 std::string theNodeMachine(nodes_machines[i]);
1245 std::string containerNameInNS = _NS->BuildContainerNameForNS(container_node_name.c_str(), theNodeMachine.c_str());
1246 obj = _NS->Resolve(containerNameInNS.c_str());
1247 if (CORBA::is_nil(obj))
1249 INFOS("[StarPaCOPPContainer] CONNECTION FAILED From Naming Service !");
1250 INFOS("[StarPaCOPPContainer] Container name is " << containerNameInNS);
1255 MESSAGE("[StarPaCOPPContainer] Deploying node : " << container_node_name);
1256 PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(obj);
1258 MESSAGE("[StarPaCOPPContainer] node " << container_node_name << " is deployed");
1260 catch(CORBA::SystemException& e)
1262 INFOS("[StarPaCOPPContainer] Exception in deploying node : " << containerNameInNS);
1263 INFOS("CORBA::SystemException : " << e);
1266 catch(CORBA::Exception& e)
1268 INFOS("[StarPaCOPPContainer] Exception in deploying node : " << containerNameInNS);
1269 INFOS("CORBA::Exception" << e);
1274 INFOS("[StarPaCOPPContainer] Exception in deploying node : " << containerNameInNS);
1275 INFOS("Unknown exception !");
1280 // Step 5 : starting parallel container
1283 MESSAGE ("[StarPaCOPPContainer] Starting parallel object");
1284 container_proxy->start();
1285 MESSAGE ("[StarPaCOPPContainer] Parallel object is started");
1286 ret = Engines::Container::_narrow(container_proxy);
1288 catch(CORBA::SystemException& e)
1290 INFOS("Caught CORBA::SystemException. : " << e);
1292 catch(PortableServer::POA::ServantAlreadyActive&)
1294 INFOS("Caught CORBA::ServantAlreadyActiveException");
1296 catch(CORBA::Exception&)
1298 INFOS("Caught CORBA::Exception.");
1300 catch(std::exception& exc)
1302 INFOS("Caught std::exception - "<<exc.what());
1306 INFOS("Caught unknown exception.");
1312 SALOME_ContainerManager::BuildCommandToLaunchPaCOProxyContainer(const Engines::ContainerParameters& params,
1313 std::string machine_file_name,
1314 std::string & proxy_hostname)
1316 // In the proxy case, we always launch a Dummy Proxy
1317 std::string exe_name = "SALOME_ParallelContainerProxyDummy";
1318 std::string container_name = params.container_name.in();
1320 // Convert nb_proc in string
1321 std::ostringstream tmp_string;
1322 tmp_string << params.nb_proc;
1323 std::string nb_proc_str = tmp_string.str();
1325 // Get resource definition
1326 Engines::ResourceDefinition_var resource_definition =
1327 _ResManager->GetResourceDefinition(params.resource_params.name);
1330 std::string hostname;
1331 std::ifstream machine_file(machine_file_name.c_str());
1332 std::getline(machine_file, hostname, ' ');
1333 size_t found = hostname.find('\n');
1334 if (found!=std::string::npos)
1335 hostname.erase(found, 1); // Remove \n
1336 proxy_hostname = hostname;
1337 MESSAGE("[BuildCommandToLaunchPaCOProxyContainer] machine file name extracted is " << hostname);
1340 bool remote_execution = false;
1341 if (hostname != std::string(Kernel_Utils::GetHostname()))
1343 MESSAGE("[BuildCommandToLaunchPaCOProxyContainer] remote machine case detected !");
1344 remote_execution = true;
1347 // Log environnement
1348 std::string log_type("");
1349 char * get_val = getenv("PARALLEL_LOG");
1353 // Generating the command
1354 std::string command_begin("");
1355 std::string command_end("");
1356 std::ostringstream command;
1358 LogConfiguration(log_type, "proxy", container_name, hostname, command_begin, command_end);
1359 command << command_begin;
1361 // Adding connection command
1362 // We can only have a remote execution with
1363 // a SALOME application
1364 if (remote_execution)
1366 ASSERT(getenv("NSHOST"));
1367 ASSERT(getenv("NSPORT"));
1369 command << resource_definition->protocol.in();
1371 command << resource_definition->username.in();
1372 command << " " << hostname;
1373 command << " " << resource_definition->applipath.in();
1374 command << "/runRemote.sh ";
1375 command << getenv("NSHOST") << " "; // hostname of CORBA name server
1376 command << getenv("NSPORT") << " "; // port of CORBA name server
1379 command << exe_name;
1380 command << " " << container_name;
1381 command << " Dummy";
1382 command << " " << hostname;
1383 command << " " << nb_proc_str;
1385 AddOmninamesParams(command);
1388 command << command_end;
1389 MESSAGE("[BuildCommandToLaunchPaCOProxyContainer] Command is: " << command.str());
1391 return command.str();
1395 SALOME_ContainerManager::BuildCommandToLaunchPaCONodeContainer(const Engines::ContainerParameters& params,
1396 const std::string & machine_file_name,
1397 SALOME_ContainerManager::actual_launch_machine_t & vect_machine,
1398 const std::string & proxy_hostname)
1401 std::string exe_name = "SALOME_ParallelContainerNode";
1402 exe_name += params.parallelLib.in();
1403 std::string container_name = params.container_name.in();
1405 // Convert nb_proc in string
1406 std::ostringstream nb_proc_stream;
1407 nb_proc_stream << params.nb_proc;
1409 // Get resource definition
1410 Engines::ResourceDefinition_var resource_definition =
1411 _ResManager->GetResourceDefinition(params.resource_params.name);
1413 // Log environnement
1414 std::string log_type("");
1415 char * get_val = getenv("PARALLEL_LOG");
1419 // Now the command is different according to paralleLib
1420 std::ostringstream command_nodes;
1421 std::ifstream machine_file(machine_file_name.c_str());
1422 if (std::string(params.parallelLib.in()) == "Dummy")
1424 for (int i= 0; i < params.nb_proc; i++)
1427 std::string hostname;
1428 std::getline(machine_file, hostname);
1429 MESSAGE("[BuildCommandToLaunchPaCONodeContainer] machine file name extracted is " << hostname);
1432 bool remote_execution = false;
1433 if (hostname != std::string(Kernel_Utils::GetHostname()))
1435 MESSAGE("[BuildCommandToLaunchPaCONodeContainer] remote machine case detected !");
1436 remote_execution = true;
1439 // For each node we have a new command
1440 // Generating the command
1441 std::ostringstream command_node_stream;
1442 std::string command_node_begin("");
1443 std::string command_node_end("");
1444 std::ostringstream node_number;
1446 std::string container_node_name = container_name + node_number.str();
1447 LogConfiguration(log_type, "node", container_node_name, hostname, command_node_begin, command_node_end);
1449 // Adding connection command
1450 // We can only have a remote execution with
1451 // a SALOME application
1452 if (remote_execution)
1454 ASSERT(getenv("NSHOST"));
1455 ASSERT(getenv("NSPORT"));
1457 command_node_stream << resource_definition->protocol.in();
1458 command_node_stream << " -l ";
1459 command_node_stream << resource_definition->username.in();
1460 command_node_stream << " " << hostname;
1461 command_node_stream << " " << resource_definition->applipath.in();
1462 command_node_stream << "/runRemote.sh ";
1463 command_node_stream << getenv("NSHOST") << " "; // hostname of CORBA name server
1464 command_node_stream << getenv("NSPORT") << " "; // port of CORBA name server
1467 command_node_stream << exe_name;
1468 command_node_stream << " " << container_name;
1469 command_node_stream << " " << params.parallelLib.in();
1470 command_node_stream << " " << proxy_hostname;
1471 command_node_stream << " " << node_number.str();
1472 command_node_stream << " -";
1473 AddOmninamesParams(command_node_stream);
1475 command_nodes << command_node_begin << command_node_stream.str() << command_node_end;
1476 vect_machine.push_back(hostname);
1480 else if (std::string(params.parallelLib.in()) == "Mpi")
1483 std::string hostname;
1484 std::getline(machine_file, hostname, ' ');
1485 MESSAGE("[BuildCommandToLaunchPaCONodeContainer] machine file name extracted is " << hostname);
1488 bool remote_execution = false;
1489 if (hostname != std::string(Kernel_Utils::GetHostname()))
1491 MESSAGE("[BuildCommandToLaunchPaCONodeContainer] remote machine case detected !");
1492 remote_execution = true;
1495 // In case of Mpi and Remote, we copy machine_file in the applipath
1496 // scp mpi_machine_file user@machine:Path
1497 std::ostringstream command_remote_stream;
1498 std::string::size_type last = machine_file_name.find_last_of("/");
1499 if (last == std::string::npos)
1502 std::string protocol = resource_definition->protocol.in();
1503 if (protocol == "rsh")
1504 command_remote_stream << "rcp ";
1506 command_remote_stream << "scp ";
1507 command_remote_stream << machine_file_name << " ";
1508 command_remote_stream << resource_definition->username.in() << "@";
1509 command_remote_stream << hostname << ":" << resource_definition->applipath.in();
1510 command_remote_stream << "/" << machine_file_name.substr(last+1);
1512 int status = system(command_remote_stream.str().c_str());
1515 INFOS("copy of the MPI machine file failed ! - sorry !");
1519 // Generating the command
1520 std::string command_begin("");
1521 std::string command_end("");
1523 LogConfiguration(log_type, "nodes", container_name, hostname, command_begin, command_end);
1524 command_nodes << command_begin;
1526 // Adding connection command
1527 // We can only have a remote execution with
1528 // a SALOME application
1529 if (remote_execution)
1531 ASSERT(getenv("NSHOST"));
1532 ASSERT(getenv("NSPORT"));
1534 command_nodes << resource_definition->protocol.in();
1535 command_nodes << " -l ";
1536 command_nodes << resource_definition->username.in();
1537 command_nodes << " " << hostname;
1538 command_nodes << " " << resource_definition->applipath.in();
1539 command_nodes << "/runRemote.sh ";
1540 command_nodes << getenv("NSHOST") << " "; // hostname of CORBA name server
1541 command_nodes << getenv("NSPORT") << " "; // port of CORBA name server
1544 if (std::string(resource_definition->mpiImpl.in()) == "lam")
1546 command_nodes << "mpiexec -ssi boot ";
1547 command_nodes << "-machinefile " << machine_file_name << " ";
1548 command_nodes << "-n " << params.nb_proc;
1552 command_nodes << "mpirun -np " << params.nb_proc;
1554 command_nodes << " " << exe_name;
1555 command_nodes << " " << container_name;
1556 command_nodes << " " << params.parallelLib.in();
1557 command_nodes << " " << proxy_hostname;
1558 command_nodes << " -";
1559 AddOmninamesParams(command_nodes);
1561 // We don't put hostname, because nodes are registered in the resource of the proxy
1562 for (int i= 0; i < params.nb_proc; i++)
1563 vect_machine.push_back(proxy_hostname);
1565 command_nodes << command_end;
1567 return command_nodes.str();
1571 SALOME_ContainerManager::LogConfiguration(const std::string & log_type,
1572 const std::string & exe_type,
1573 const std::string & container_name,
1574 const std::string & hostname,
1575 std::string & begin,
1578 if(log_type == "xterm")
1580 begin = "xterm -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export PATH=$PATH;";
1583 else if(log_type == "xterm_debug")
1585 begin = "xterm -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export PATH=$PATH;";
1590 // default into a file...
1591 std::string logFilename = "/tmp/" + container_name + "_" + hostname + "_" + exe_type + "_";
1592 logFilename += std::string(getenv("USER")) + ".log";
1593 end = " > " + logFilename + " 2>&1 & ";
1598 SALOME_ContainerManager::LaunchPaCOProxyContainer(const std::string& command,
1599 const Engines::ContainerParameters& params,
1600 const std::string & hostname)
1602 PaCO::InterfaceManager_ptr container_proxy = PaCO::InterfaceManager::_nil();
1604 MESSAGE("[LaunchPaCOProxyContainer] Launch command");
1605 int status = system(command.c_str());
1607 INFOS("[LaunchPaCOProxyContainer] failed : system command status -1");
1608 return container_proxy;
1610 else if (status == 217) {
1611 INFOS("[LaunchPaCOProxyContainer] failed : system command status 217");
1612 return container_proxy;
1615 int count = TIME_OUT_TO_LAUNCH_CONT;
1616 CORBA::Object_var obj = CORBA::Object::_nil();
1617 std::string containerNameInNS = _NS->BuildContainerNameForNS(params.container_name.in(),
1619 MESSAGE("[LaunchParallelContainer] Waiting for Parallel Container proxy : " << containerNameInNS);
1621 while (CORBA::is_nil(obj) && count)
1625 obj = _NS->Resolve(containerNameInNS.c_str());
1630 container_proxy = PaCO::InterfaceManager::_narrow(obj);
1632 catch(CORBA::SystemException& e)
1634 INFOS("[StarPaCOPPContainer] Exception in _narrow after LaunchParallelContainer for proxy !");
1635 INFOS("CORBA::SystemException : " << e);
1636 return container_proxy;
1638 catch(CORBA::Exception& e)
1640 INFOS("[StarPaCOPPContainer] Exception in _narrow after LaunchParallelContainer for proxy !");
1641 INFOS("CORBA::Exception" << e);
1642 return container_proxy;
1646 INFOS("[StarPaCOPPContainer] Exception in _narrow after LaunchParallelContainer for proxy !");
1647 INFOS("Unknown exception !");
1648 return container_proxy;
1650 if (CORBA::is_nil(container_proxy))
1652 INFOS("[StarPaCOPPContainer] PaCO::InterfaceManager::_narrow returns NIL !");
1653 return container_proxy;
1658 //=============================================================================
1659 /*! This method launches the parallel container.
1660 * It will may be placed on the ressources manager.
1662 * \param command to launch
1663 * \param container's parameters
1664 * \param name of the container
1666 * \return CORBA container reference
1668 //=============================================================================
1670 SALOME_ContainerManager::LaunchPaCONodeContainer(const std::string& command,
1671 const Engines::ContainerParameters& params,
1672 const std::string& name,
1673 SALOME_ContainerManager::actual_launch_machine_t & vect_machine)
1675 INFOS("[LaunchPaCONodeContainer] Launch command");
1676 int status = system(command.c_str());
1678 INFOS("[LaunchPaCONodeContainer] failed : system command status -1");
1681 else if (status == 217) {
1682 INFOS("[LaunchPaCONodeContainer] failed : system command status 217");
1686 INFOS("[LaunchPaCONodeContainer] Waiting for the nodes of the parallel container");
1687 // We are waiting all the nodes
1688 for (int i = 0; i < params.nb_proc; i++)
1690 CORBA::Object_var obj = CORBA::Object::_nil();
1691 std::string theMachine(vect_machine[i]);
1693 std::ostringstream tmp;
1695 std::string proc_number = tmp.str();
1696 std::string container_node_name = name + proc_number;
1697 std::string containerNameInNS = _NS->BuildContainerNameForNS((char*) container_node_name.c_str(), theMachine.c_str());
1698 INFOS("[LaunchPaCONodeContainer] Waiting for Parallel Container node " << containerNameInNS << " on " << theMachine);
1699 int count = TIME_OUT_TO_LAUNCH_CONT;
1700 while (CORBA::is_nil(obj) && count) {
1703 obj = _NS->Resolve(containerNameInNS.c_str());
1705 if (CORBA::is_nil(obj))
1707 INFOS("[LaunchPaCONodeContainer] Launch of node failed (or not found) !");
1716 Engines::Container_ptr
1717 SALOME_ContainerManager::StartPaCOPPContainer(const Engines::ContainerParameters& params,
1718 std::string resource_selected)
1720 Engines::Container_ptr ret = Engines::Container::_nil();
1721 INFOS("[StarPaCOPPContainer] is disabled !");
1722 INFOS("[StarPaCOPPContainer] recompile SALOME Kernel to enable PaCO++ parallel extension");
1727 SALOME_ContainerManager::BuildCommandToLaunchPaCOProxyContainer(const Engines::ContainerParameters& params,
1728 std::string machine_file_name,
1729 std::string & proxy_hostname)
1735 SALOME_ContainerManager::BuildCommandToLaunchPaCONodeContainer(const Engines::ContainerParameters& params,
1736 const std::string & machine_file_name,
1737 SALOME_ContainerManager::actual_launch_machine_t & vect_machine,
1738 const std::string & proxy_hostname)
1743 SALOME_ContainerManager::LogConfiguration(const std::string & log_type,
1744 const std::string & exe_type,
1745 const std::string & container_name,
1746 const std::string & hostname,
1747 std::string & begin,
1753 SALOME_ContainerManager::LaunchPaCOProxyContainer(const std::string& command,
1754 const Engines::ContainerParameters& params,
1755 const std::string& hostname)
1757 CORBA::Object_ptr ret = CORBA::Object::_nil();
1762 SALOME_ContainerManager::LaunchPaCONodeContainer(const std::string& command,
1763 const Engines::ContainerParameters& params,
1764 const std::string& name,
1765 SALOME_ContainerManager::actual_launch_machine_t & vect_machine)