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
444 return Engines::Container::_nil();
446 else if (status == 217){
447 MESSAGE("SALOME_ContainerManager::StartContainer rsh failed (system command status 217)");
448 RmTmpFile(_TmpFileName); // command file can be removed here
450 return Engines::Container::_nil();
454 int count = TIME_OUT_TO_LAUNCH_CONT;
455 MESSAGE("[GiveContainer] waiting " << count << " second steps");
456 while (CORBA::is_nil(ret) && count)
464 MESSAGE("[GiveContainer] step " << count << " Waiting for container on " << resource_selected);
465 CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
466 ret=Engines::Container::_narrow(obj);
468 if (CORBA::is_nil(ret))
470 INFOS("[GiveContainer] was not able to launch container " << containerNameInNS);
474 // Setting log file name
475 logFilename=":"+logFilename;
476 logFilename="@"+Kernel_Utils::GetHostname()+logFilename;
477 logFilename=user+logFilename;
478 ret->logfilename(logFilename.c_str());
479 RmTmpFile(_TmpFileName); // command file can be removed here
486 //=============================================================================
487 //! Find a container given constraints (params) on a list of machines (possibleComputers)
491 //=============================================================================
493 Engines::Container_ptr
494 SALOME_ContainerManager::FindContainer(const Engines::ContainerParameters& params,
495 const Engines::ResourceList& possibleResources)
497 MESSAGE("[FindContainer] FindContainer on " << possibleResources.length() << " resources");
498 for(unsigned int i=0; i < possibleResources.length();i++)
500 Engines::Container_ptr cont = FindContainer(params, possibleResources[i].in());
501 if(!CORBA::is_nil(cont))
504 MESSAGE("[FindContainer] no container found");
505 return Engines::Container::_nil();
508 //=============================================================================
509 //! Find a container given constraints (params) on a machine (theMachine)
513 //=============================================================================
515 Engines::Container_ptr
516 SALOME_ContainerManager::FindContainer(const Engines::ContainerParameters& params,
517 const std::string& resource)
519 Engines::ResourceDefinition_var resource_definition = _ResManager->GetResourceDefinition(resource.c_str());
520 std::string hostname(resource_definition->hostname.in());
521 std::string containerNameInNS(_NS->BuildContainerNameForNS(params, hostname.c_str()));
522 MESSAGE("[FindContainer] Try to find a container " << containerNameInNS << " on resource " << resource);
523 CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
526 if(obj->_non_existent())
527 return Engines::Container::_nil();
529 return Engines::Container::_narrow(obj);
531 catch(const CORBA::Exception& e)
533 return Engines::Container::_nil();
538 bool isPythonContainer(const char* ContainerName);
540 //=============================================================================
542 * This is no longer valid (C++ container are also python containers)
544 //=============================================================================
545 bool isPythonContainer(const char* ContainerName)
548 int len = strlen(ContainerName);
551 if (strcmp(ContainerName + len - 2, "Py") == 0)
557 //=============================================================================
559 * Builds the script to be launched
561 * If SALOME Application not defined ($APPLI),
562 * see BuildTempFileToLaunchRemoteContainer()
564 * Else rely on distant configuration. Command is under the form (example):
565 * ssh user@machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \
566 * SALOME_Container containerName &"
568 * - where user is ommited if not specified in CatalogResources,
569 * - where distant path is always relative to user@machine $HOME, and
570 * equal to $APPLI if not specified in CatalogResources,
571 * - where hostNS is the hostname of CORBA naming server (set by scripts to
572 * use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh)
573 * - where portNS is the port used by CORBA naming server (set by scripts to
574 * use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh)
575 * - where workingdir is the requested working directory for the container.
576 * If WORKINGDIR (and workingdir) is not present the working dir will be $HOME
578 //=============================================================================
581 SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer
582 (const std::string& resource_name,
583 const Engines::ContainerParameters& params, const std::string& container_exe)
587 if (!_isAppliSalomeDefined)
588 command = BuildTempFileToLaunchRemoteContainer(resource_name, params);
592 Engines::ResourceDefinition_var resource_definition = _ResManager->GetResourceDefinition(resource_name.c_str());
593 std::string hostname(resource_definition->hostname.in());
594 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesDescr(resource_name);
598 if ( params.nb_proc <= 0 )
601 nbproc = params.nb_proc;
604 // "ssh -l user machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \
605 // SALOME_Container containerName &"
606 if (resInfo.Protocol == rsh)
608 else if (resInfo.Protocol == ssh)
611 throw SALOME_Exception("Unknown protocol");
613 if (resInfo.UserName != "")
616 command += resInfo.UserName;
620 command += resInfo.HostName;
623 if (resInfo.AppliPath != "")
624 command += resInfo.AppliPath; // path relative to user@machine $HOME
627 ASSERT(getenv("APPLI"));
628 command += getenv("APPLI"); // path relative to user@machine $HOME
631 command += "/runRemote.sh ";
633 ASSERT(getenv("NSHOST"));
634 command += getenv("NSHOST"); // hostname of CORBA name server
637 ASSERT(getenv("NSPORT"));
638 command += getenv("NSPORT"); // port of CORBA name server
640 std::string wdir = params.workingdir.in();
643 command += " WORKINGDIR ";
645 if(wdir == "$TEMPDIR")
647 command += wdir; // requested working directory
653 command += " mpirun -np ";
654 std::ostringstream o;
658 command += "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
659 #elif defined(WITHOPENMPI)
660 if( getenv("OMPI_URI_FILE") == NULL )
661 command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
663 command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
664 command += getenv("OMPI_URI_FILE");
667 command += " SALOME_MPIContainer ";
670 command += " " +container_exe+ " ";
672 command += _NS->ContainerName(params);
674 AddOmninamesParams(command);
676 MESSAGE("command =" << command);
682 //=============================================================================
684 * builds the command to be launched.
686 //=============================================================================
688 SALOME_ContainerManager::BuildCommandToLaunchLocalContainer
689 (const Engines::ContainerParameters& params, const std::string& machinesFile, const std::string& container_exe)
691 _TmpFileName = BuildTemporaryFileName();
695 std::ostringstream o;
701 if ( params.nb_proc <= 0 )
704 nbproc = params.nb_proc;
708 if( getenv("LIBBATCH_NODEFILE") != NULL )
709 o << "-machinefile " << machinesFile << " ";
712 o << "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
713 #elif defined(WITHOPENMPI)
714 if( getenv("OMPI_URI_FILE") == NULL )
715 o << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
718 o << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
719 o << getenv("OMPI_URI_FILE");
723 if (isPythonContainer(params.container_name))
724 o << " pyMPI SALOME_ContainerPy.py ";
726 o << " SALOME_MPIContainer ";
731 std::string wdir=params.workingdir.in();
734 // a working directory is requested
735 if(wdir == "$TEMPDIR")
737 // a new temporary directory is requested
738 std::string dir = Kernel_Utils::GetTmpDir();
740 o << "cd /d " << dir << std::endl;
742 o << "cd " << dir << ";";
748 // a permanent directory is requested use it or create it
750 o << "mkdir " + wdir << std::endl;
751 o << "cd /D " + wdir << std::endl;
753 o << "mkdir -p " << wdir << " && cd " << wdir + ";";
757 if (isPythonContainer(params.container_name))
758 o << "SALOME_ContainerPy.py ";
760 o << container_exe + " ";
764 o << _NS->ContainerName(params);
766 AddOmninamesParams(o);
768 std::ofstream command_file( _TmpFileName.c_str() );
769 command_file << o.str();
770 command_file.close();
773 chmod(_TmpFileName.c_str(), 0x1ED);
775 command = _TmpFileName;
777 MESSAGE("Command is file ... " << command);
778 MESSAGE("Command is ... " << o.str());
783 //=============================================================================
785 * removes the generated temporary file in case of a remote launch.
787 //=============================================================================
789 void SALOME_ContainerManager::RmTmpFile(std::string& tmpFileName)
791 int lenght = tmpFileName.size();
795 std::string command = "del /F ";
797 std::string command = "rm ";
800 command += tmpFileName.substr(0, lenght - 3 );
802 command += tmpFileName;
804 system(command.c_str());
805 //if dir is empty - remove it
806 std::string tmp_dir = Kernel_Utils::GetDirByPath( tmpFileName );
807 if ( Kernel_Utils::IsEmptyDir( tmp_dir ) )
810 command = "del /F " + tmp_dir;
812 command = "rmdir " + tmp_dir;
814 system(command.c_str());
819 //=============================================================================
821 * add to command all options relative to naming service.
823 //=============================================================================
825 void SALOME_ContainerManager::AddOmninamesParams(std::string& command) const
827 CORBA::String_var iorstr = _NS->getIORaddr();
828 command += "ORBInitRef NameService=";
832 //=============================================================================
834 * add to command all options relative to naming service.
836 //=============================================================================
838 void SALOME_ContainerManager::AddOmninamesParams(std::ofstream& fileStream) const
840 CORBA::String_var iorstr = _NS->getIORaddr();
841 fileStream << "ORBInitRef NameService=";
842 fileStream << iorstr;
845 //=============================================================================
847 * add to command all options relative to naming service.
849 //=============================================================================
851 void SALOME_ContainerManager::AddOmninamesParams(std::ostringstream& oss) const
853 CORBA::String_var iorstr = _NS->getIORaddr();
854 oss << "ORBInitRef NameService=";
858 //=============================================================================
860 * generate a file name in /tmp directory
862 //=============================================================================
864 std::string SALOME_ContainerManager::BuildTemporaryFileName() const
866 //build more complex file name to support multiple salome session
867 std::string aFileName = Kernel_Utils::GetTmpFileName();
876 //=============================================================================
878 * Builds in a temporary file the script to be launched.
880 * Used if SALOME Application ($APPLI) is not defined.
881 * The command is build with data from CatalogResources, in which every path
882 * used on remote computer must be defined.
884 //=============================================================================
887 SALOME_ContainerManager::BuildTempFileToLaunchRemoteContainer
888 (const std::string& resource_name,
889 const Engines::ContainerParameters& params) throw(SALOME_Exception)
893 _TmpFileName = BuildTemporaryFileName();
894 std::ofstream tempOutputFile;
895 tempOutputFile.open(_TmpFileName.c_str(), std::ofstream::out );
896 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesDescr(resource_name);
897 tempOutputFile << "#! /bin/sh" << std::endl;
901 tempOutputFile << "export SALOME_trace=local" << std::endl; // mkr : 27.11.2006 : PAL13967 - Distributed supervision graphs - Problem with "SALOME_trace"
902 //tempOutputFile << "source " << resInfo.PreReqFilePath << endl;
908 tempOutputFile << "mpirun -np ";
911 if ( params.nb_proc <= 0 )
914 nbproc = params.nb_proc;
916 std::ostringstream o;
918 tempOutputFile << nbproc << " ";
920 tempOutputFile << "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
921 #elif defined(WITHOPENMPI)
922 if( getenv("OMPI_URI_FILE") == NULL )
923 tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
925 tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
926 tempOutputFile << getenv("OMPI_URI_FILE");
931 tempOutputFile << getenv("KERNEL_ROOT_DIR") << "/bin/salome/";
935 if (isPythonContainer(params.container_name))
936 tempOutputFile << " pyMPI SALOME_ContainerPy.py ";
938 tempOutputFile << " SALOME_MPIContainer ";
943 if (isPythonContainer(params.container_name))
944 tempOutputFile << "SALOME_ContainerPy.py ";
946 tempOutputFile << "SALOME_Container ";
949 tempOutputFile << _NS->ContainerName(params) << " -";
950 AddOmninamesParams(tempOutputFile);
951 tempOutputFile << " &" << std::endl;
952 tempOutputFile.flush();
953 tempOutputFile.close();
955 chmod(_TmpFileName.c_str(), 0x1ED);
962 if (resInfo.Protocol == rsh)
965 std::string commandRcp = "rcp ";
966 commandRcp += _TmpFileName;
968 commandRcp += resInfo.HostName;
970 commandRcp += _TmpFileName;
971 status = system(commandRcp.c_str());
974 else if (resInfo.Protocol == ssh)
977 std::string commandRcp = "scp ";
978 commandRcp += _TmpFileName;
980 commandRcp += resInfo.HostName;
982 commandRcp += _TmpFileName;
983 status = system(commandRcp.c_str());
986 throw SALOME_Exception("Unknown protocol");
989 throw SALOME_Exception("Error of connection on remote host");
991 command += resInfo.HostName;
992 _CommandForRemAccess = command;
994 command += _TmpFileName;
1002 std::string SALOME_ContainerManager::GetMPIZeroNode(const std::string machine, const std::string machinesFile)
1005 std::string zeronode;
1006 std::string command;
1007 std::string tmpFile = BuildTemporaryFileName();
1009 if( getenv("LIBBATCH_NODEFILE") == NULL )
1011 if (_isAppliSalomeDefined)
1013 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesDescr(machine);
1015 if (resInfo.Protocol == rsh)
1017 else if (resInfo.Protocol == ssh)
1020 throw SALOME_Exception("Unknown protocol");
1022 if (resInfo.UserName != "")
1025 command += resInfo.UserName;
1029 command += resInfo.HostName;
1032 if (resInfo.AppliPath != "")
1033 command += resInfo.AppliPath; // path relative to user@machine $HOME
1036 ASSERT(getenv("APPLI"));
1037 command += getenv("APPLI"); // path relative to user@machine $HOME
1040 command += "/runRemote.sh ";
1042 ASSERT(getenv("NSHOST"));
1043 command += getenv("NSHOST"); // hostname of CORBA name server
1046 ASSERT(getenv("NSPORT"));
1047 command += getenv("NSPORT"); // port of CORBA name server
1049 command += " mpirun -np 1 hostname > " + tmpFile;
1052 command = "mpirun -np 1 hostname > " + tmpFile;
1055 command = "mpirun -np 1 -machinefile " + machinesFile + " hostname > " + tmpFile;
1057 status = system(command.c_str());
1059 std::ifstream fp(tmpFile.c_str(),std::ios::in);
1060 while(fp >> zeronode);
1068 std::string SALOME_ContainerManager::machinesFile(const int nbproc)
1071 std::string nodesFile = getenv("LIBBATCH_NODEFILE");
1072 std::string machinesFile = Kernel_Utils::GetTmpFileName();
1073 std::ifstream fpi(nodesFile.c_str(),std::ios::in);
1074 std::ofstream fpo(machinesFile.c_str(),std::ios::out);
1076 _numInstanceMutex.lock();
1078 for(int i=0;i<_nbprocUsed;i++)
1081 for(int i=0;i<nbproc;i++)
1083 fpo << tmp << std::endl;
1085 throw SALOME_Exception("You ask more processes than batch session have allocated!");
1087 _nbprocUsed += nbproc;
1091 _numInstanceMutex.unlock();
1093 return machinesFile;
1098 SALOME_ContainerManager::checkPaCOParameters(Engines::ContainerParameters & params, std::string resource_selected)
1102 // Step 1 : check ContainerParameters
1103 // Check container_name, has to be defined
1104 if (std::string(params.container_name.in()) == "")
1106 INFOS("[checkPaCOParameters] You must define a container_name to launch a PaCO++ container");
1109 // Check parallelLib
1110 std::string parallelLib = params.parallelLib.in();
1111 if (parallelLib != "Mpi" && parallelLib != "Dummy")
1113 INFOS("[checkPaCOParameters] parallelLib is not correctly defined");
1114 INFOS("[checkPaCOParameters] you can chosse between: Mpi and Dummy");
1115 INFOS("[checkPaCOParameters] you entered: " << parallelLib);
1119 if (params.nb_proc <= 0)
1121 INFOS("[checkPaCOParameters] You must define a nb_proc > 0");
1125 // Step 2 : check resource_selected
1126 Engines::ResourceDefinition_var resource_definition = _ResManager->GetResourceDefinition(resource_selected.c_str());
1127 std::string protocol = resource_definition->protocol.in();
1128 std::string username = resource_definition->username.in();
1129 std::string applipath = resource_definition->applipath.in();
1131 if (protocol == "" || username == "" || applipath == "")
1133 INFOS("[checkPaCOParameters] resource selected is not well defined");
1134 INFOS("[checkPaCOParameters] resource name: " << resource_definition->name.in());
1135 INFOS("[checkPaCOParameters] resource hostname: " << resource_definition->hostname.in());
1136 INFOS("[checkPaCOParameters] resource protocol: " << protocol);
1137 INFOS("[checkPaCOParameters] resource username: " << username);
1138 INFOS("[checkPaCOParameters] resource applipath: " << applipath);
1144 #ifdef WITH_PACO_PARALLEL
1146 //=============================================================================
1148 * Start a suitable PaCO++ Parallel Container in a list of machines.
1149 * \param params Container Parameters required for the container
1150 * \return CORBA container reference.
1152 //=============================================================================
1153 Engines::Container_ptr
1154 SALOME_ContainerManager::StartPaCOPPContainer(const Engines::ContainerParameters& params_const,
1155 std::string resource_selected)
1157 CORBA::Object_var obj;
1158 PaCO::InterfaceManager_var container_proxy;
1159 Engines::Container_ptr ret = Engines::Container::_nil();
1160 Engines::ContainerParameters params(params_const);
1161 params.resource_params.name = CORBA::string_dup(resource_selected.c_str());
1163 // Step 0 : Check parameters
1164 if (!checkPaCOParameters(params, resource_selected))
1166 INFOS("[StartPaCOPPContainer] check parameters failed ! see logs...");
1170 // Step 1 : Starting a new parallel container !
1171 INFOS("[StartPaCOPPContainer] Starting a PaCO++ parallel container");
1172 INFOS("[StartPaCOPPContainer] on resource : " << resource_selected);
1174 // Step 2 : Get a MachineFile for the parallel container
1175 std::string machine_file_name = _ResManager->getMachineFile(resource_selected,
1177 params.parallelLib.in());
1179 if (machine_file_name == "")
1181 INFOS("[StartPaCOPPContainer] Machine file generation failed");
1185 // Step 3 : starting parallel container proxy
1186 std::string command_proxy("");
1187 std::string proxy_machine;
1190 command_proxy = BuildCommandToLaunchPaCOProxyContainer(params, machine_file_name, proxy_machine);
1192 catch(const SALOME_Exception & ex)
1194 INFOS("[StartPaCOPPContainer] Exception in BuildCommandToLaunchPaCOContainer");
1198 obj = LaunchPaCOProxyContainer(command_proxy, params, proxy_machine);
1199 if (CORBA::is_nil(obj))
1201 INFOS("[StartPaCOPPContainer] LaunchPaCOContainer for proxy returns NIL !");
1204 container_proxy = PaCO::InterfaceManager::_narrow(obj);
1205 MESSAGE("[StartPaCOPPContainer] PaCO container proxy is launched");
1207 // Step 4 : starting parallel container nodes
1208 std::string command_nodes("");
1209 SALOME_ContainerManager::actual_launch_machine_t nodes_machines;
1212 command_nodes = BuildCommandToLaunchPaCONodeContainer(params, machine_file_name, nodes_machines, proxy_machine);
1214 catch(const SALOME_Exception & ex)
1216 INFOS("[StarPaCOPPContainer] Exception in BuildCommandToLaunchPaCONodeContainer");
1221 std::string container_generic_node_name = std::string(params.container_name.in()) + std::string("Node");
1222 bool result = LaunchPaCONodeContainer(command_nodes, params, container_generic_node_name, nodes_machines);
1225 INFOS("[StarPaCOPPContainer] LaunchPaCONodeContainer failed !");
1226 // Il faut tuer le proxy
1229 Engines::Container_var proxy = Engines::Container::_narrow(container_proxy);
1234 INFOS("[StarPaCOPPContainer] Exception catched from proxy Shutdown...");
1239 // Step 4 : connecting nodes and the proxy to actually create a parallel container
1240 for (int i = 0; i < params.nb_proc; i++)
1242 std::ostringstream tmp;
1244 std::string proc_number = tmp.str();
1245 std::string container_node_name = container_generic_node_name + proc_number;
1247 std::string theNodeMachine(nodes_machines[i]);
1248 std::string containerNameInNS = _NS->BuildContainerNameForNS(container_node_name.c_str(), theNodeMachine.c_str());
1249 obj = _NS->Resolve(containerNameInNS.c_str());
1250 if (CORBA::is_nil(obj))
1252 INFOS("[StarPaCOPPContainer] CONNECTION FAILED From Naming Service !");
1253 INFOS("[StarPaCOPPContainer] Container name is " << containerNameInNS);
1258 MESSAGE("[StarPaCOPPContainer] Deploying node : " << container_node_name);
1259 PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(obj);
1261 MESSAGE("[StarPaCOPPContainer] node " << container_node_name << " is deployed");
1263 catch(CORBA::SystemException& e)
1265 INFOS("[StarPaCOPPContainer] Exception in deploying node : " << containerNameInNS);
1266 INFOS("CORBA::SystemException : " << e);
1269 catch(CORBA::Exception& e)
1271 INFOS("[StarPaCOPPContainer] Exception in deploying node : " << containerNameInNS);
1272 INFOS("CORBA::Exception" << e);
1277 INFOS("[StarPaCOPPContainer] Exception in deploying node : " << containerNameInNS);
1278 INFOS("Unknown exception !");
1283 // Step 5 : starting parallel container
1286 MESSAGE ("[StarPaCOPPContainer] Starting parallel object");
1287 container_proxy->start();
1288 MESSAGE ("[StarPaCOPPContainer] Parallel object is started");
1289 ret = Engines::Container::_narrow(container_proxy);
1291 catch(CORBA::SystemException& e)
1293 INFOS("Caught CORBA::SystemException. : " << e);
1295 catch(PortableServer::POA::ServantAlreadyActive&)
1297 INFOS("Caught CORBA::ServantAlreadyActiveException");
1299 catch(CORBA::Exception&)
1301 INFOS("Caught CORBA::Exception.");
1303 catch(std::exception& exc)
1305 INFOS("Caught std::exception - "<<exc.what());
1309 INFOS("Caught unknown exception.");
1315 SALOME_ContainerManager::BuildCommandToLaunchPaCOProxyContainer(const Engines::ContainerParameters& params,
1316 std::string machine_file_name,
1317 std::string & proxy_hostname)
1319 // In the proxy case, we always launch a Dummy Proxy
1320 std::string exe_name = "SALOME_ParallelContainerProxyDummy";
1321 std::string container_name = params.container_name.in();
1323 // Convert nb_proc in string
1324 std::ostringstream tmp_string;
1325 tmp_string << params.nb_proc;
1326 std::string nb_proc_str = tmp_string.str();
1328 // Get resource definition
1329 Engines::ResourceDefinition_var resource_definition =
1330 _ResManager->GetResourceDefinition(params.resource_params.name);
1333 std::string hostname;
1334 std::ifstream machine_file(machine_file_name.c_str());
1335 std::getline(machine_file, hostname, ' ');
1336 size_t found = hostname.find('\n');
1337 if (found!=std::string::npos)
1338 hostname.erase(found, 1); // Remove \n
1339 proxy_hostname = hostname;
1340 MESSAGE("[BuildCommandToLaunchPaCOProxyContainer] machine file name extracted is " << hostname);
1343 bool remote_execution = false;
1344 if (hostname != std::string(Kernel_Utils::GetHostname()))
1346 MESSAGE("[BuildCommandToLaunchPaCOProxyContainer] remote machine case detected !");
1347 remote_execution = true;
1350 // Log environnement
1351 std::string log_type("");
1352 char * get_val = getenv("PARALLEL_LOG");
1356 // Generating the command
1357 std::string command_begin("");
1358 std::string command_end("");
1359 std::ostringstream command;
1361 LogConfiguration(log_type, "proxy", container_name, hostname, command_begin, command_end);
1362 command << command_begin;
1364 // Adding connection command
1365 // We can only have a remote execution with
1366 // a SALOME application
1367 if (remote_execution)
1369 ASSERT(getenv("NSHOST"));
1370 ASSERT(getenv("NSPORT"));
1372 command << resource_definition->protocol.in();
1374 command << resource_definition->username.in();
1375 command << " " << hostname;
1376 command << " " << resource_definition->applipath.in();
1377 command << "/runRemote.sh ";
1378 command << getenv("NSHOST") << " "; // hostname of CORBA name server
1379 command << getenv("NSPORT") << " "; // port of CORBA name server
1382 command << exe_name;
1383 command << " " << container_name;
1384 command << " Dummy";
1385 command << " " << hostname;
1386 command << " " << nb_proc_str;
1388 AddOmninamesParams(command);
1391 command << command_end;
1392 MESSAGE("[BuildCommandToLaunchPaCOProxyContainer] Command is: " << command.str());
1394 return command.str();
1398 SALOME_ContainerManager::BuildCommandToLaunchPaCONodeContainer(const Engines::ContainerParameters& params,
1399 const std::string & machine_file_name,
1400 SALOME_ContainerManager::actual_launch_machine_t & vect_machine,
1401 const std::string & proxy_hostname)
1404 std::string exe_name = "SALOME_ParallelContainerNode";
1405 exe_name += params.parallelLib.in();
1406 std::string container_name = params.container_name.in();
1408 // Convert nb_proc in string
1409 std::ostringstream nb_proc_stream;
1410 nb_proc_stream << params.nb_proc;
1412 // Get resource definition
1413 Engines::ResourceDefinition_var resource_definition =
1414 _ResManager->GetResourceDefinition(params.resource_params.name);
1416 // Log environnement
1417 std::string log_type("");
1418 char * get_val = getenv("PARALLEL_LOG");
1422 // Now the command is different according to paralleLib
1423 std::ostringstream command_nodes;
1424 std::ifstream machine_file(machine_file_name.c_str());
1425 if (std::string(params.parallelLib.in()) == "Dummy")
1427 for (int i= 0; i < params.nb_proc; i++)
1430 std::string hostname;
1431 std::getline(machine_file, hostname);
1432 MESSAGE("[BuildCommandToLaunchPaCONodeContainer] machine file name extracted is " << hostname);
1435 bool remote_execution = false;
1436 if (hostname != std::string(Kernel_Utils::GetHostname()))
1438 MESSAGE("[BuildCommandToLaunchPaCONodeContainer] remote machine case detected !");
1439 remote_execution = true;
1442 // For each node we have a new command
1443 // Generating the command
1444 std::ostringstream command_node_stream;
1445 std::string command_node_begin("");
1446 std::string command_node_end("");
1447 std::ostringstream node_number;
1449 std::string container_node_name = container_name + node_number.str();
1450 LogConfiguration(log_type, "node", container_node_name, hostname, command_node_begin, command_node_end);
1452 // Adding connection command
1453 // We can only have a remote execution with
1454 // a SALOME application
1455 if (remote_execution)
1457 ASSERT(getenv("NSHOST"));
1458 ASSERT(getenv("NSPORT"));
1460 command_node_stream << resource_definition->protocol.in();
1461 command_node_stream << " -l ";
1462 command_node_stream << resource_definition->username.in();
1463 command_node_stream << " " << hostname;
1464 command_node_stream << " " << resource_definition->applipath.in();
1465 command_node_stream << "/runRemote.sh ";
1466 command_node_stream << getenv("NSHOST") << " "; // hostname of CORBA name server
1467 command_node_stream << getenv("NSPORT") << " "; // port of CORBA name server
1470 command_node_stream << exe_name;
1471 command_node_stream << " " << container_name;
1472 command_node_stream << " " << params.parallelLib.in();
1473 command_node_stream << " " << proxy_hostname;
1474 command_node_stream << " " << node_number.str();
1475 command_node_stream << " -";
1476 AddOmninamesParams(command_node_stream);
1478 command_nodes << command_node_begin << command_node_stream.str() << command_node_end;
1479 vect_machine.push_back(hostname);
1483 else if (std::string(params.parallelLib.in()) == "Mpi")
1486 std::string hostname;
1487 std::getline(machine_file, hostname, ' ');
1488 MESSAGE("[BuildCommandToLaunchPaCONodeContainer] machine file name extracted is " << hostname);
1491 bool remote_execution = false;
1492 if (hostname != std::string(Kernel_Utils::GetHostname()))
1494 MESSAGE("[BuildCommandToLaunchPaCONodeContainer] remote machine case detected !");
1495 remote_execution = true;
1498 // In case of Mpi and Remote, we copy machine_file in the applipath
1499 // scp mpi_machine_file user@machine:Path
1500 std::ostringstream command_remote_stream;
1501 std::string::size_type last = machine_file_name.find_last_of("/");
1502 if (last == std::string::npos)
1505 std::string protocol = resource_definition->protocol.in();
1506 if (protocol == "rsh")
1507 command_remote_stream << "rcp ";
1509 command_remote_stream << "scp ";
1510 command_remote_stream << machine_file_name << " ";
1511 command_remote_stream << resource_definition->username.in() << "@";
1512 command_remote_stream << hostname << ":" << resource_definition->applipath.in();
1513 command_remote_stream << "/" << machine_file_name.substr(last+1);
1515 int status = system(command_remote_stream.str().c_str());
1518 INFOS("copy of the MPI machine file failed ! - sorry !");
1522 // Generating the command
1523 std::string command_begin("");
1524 std::string command_end("");
1526 LogConfiguration(log_type, "nodes", container_name, hostname, command_begin, command_end);
1527 command_nodes << command_begin;
1529 // Adding connection command
1530 // We can only have a remote execution with
1531 // a SALOME application
1532 if (remote_execution)
1534 ASSERT(getenv("NSHOST"));
1535 ASSERT(getenv("NSPORT"));
1537 command_nodes << resource_definition->protocol.in();
1538 command_nodes << " -l ";
1539 command_nodes << resource_definition->username.in();
1540 command_nodes << " " << hostname;
1541 command_nodes << " " << resource_definition->applipath.in();
1542 command_nodes << "/runRemote.sh ";
1543 command_nodes << getenv("NSHOST") << " "; // hostname of CORBA name server
1544 command_nodes << getenv("NSPORT") << " "; // port of CORBA name server
1547 if (std::string(resource_definition->mpiImpl.in()) == "lam")
1549 command_nodes << "mpiexec -ssi boot ";
1550 command_nodes << "-machinefile " << machine_file_name << " ";
1551 command_nodes << "-n " << params.nb_proc;
1555 command_nodes << "mpirun -np " << params.nb_proc;
1557 command_nodes << " " << exe_name;
1558 command_nodes << " " << container_name;
1559 command_nodes << " " << params.parallelLib.in();
1560 command_nodes << " " << proxy_hostname;
1561 command_nodes << " -";
1562 AddOmninamesParams(command_nodes);
1564 // We don't put hostname, because nodes are registered in the resource of the proxy
1565 for (int i= 0; i < params.nb_proc; i++)
1566 vect_machine.push_back(proxy_hostname);
1568 command_nodes << command_end;
1570 return command_nodes.str();
1574 SALOME_ContainerManager::LogConfiguration(const std::string & log_type,
1575 const std::string & exe_type,
1576 const std::string & container_name,
1577 const std::string & hostname,
1578 std::string & begin,
1581 if(log_type == "xterm")
1583 begin = "xterm -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export PATH=$PATH;";
1586 else if(log_type == "xterm_debug")
1588 begin = "xterm -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export PATH=$PATH;";
1593 // default into a file...
1594 std::string logFilename = "/tmp/" + container_name + "_" + hostname + "_" + exe_type + "_";
1595 logFilename += std::string(getenv("USER")) + ".log";
1596 end = " > " + logFilename + " 2>&1 & ";
1601 SALOME_ContainerManager::LaunchPaCOProxyContainer(const std::string& command,
1602 const Engines::ContainerParameters& params,
1603 const std::string & hostname)
1605 PaCO::InterfaceManager_ptr container_proxy = PaCO::InterfaceManager::_nil();
1607 MESSAGE("[LaunchPaCOProxyContainer] Launch command");
1608 int status = system(command.c_str());
1610 INFOS("[LaunchPaCOProxyContainer] failed : system command status -1");
1611 return container_proxy;
1613 else if (status == 217) {
1614 INFOS("[LaunchPaCOProxyContainer] failed : system command status 217");
1615 return container_proxy;
1618 int count = TIME_OUT_TO_LAUNCH_CONT;
1619 CORBA::Object_var obj = CORBA::Object::_nil();
1620 std::string containerNameInNS = _NS->BuildContainerNameForNS(params.container_name.in(),
1622 MESSAGE("[LaunchParallelContainer] Waiting for Parallel Container proxy : " << containerNameInNS);
1624 while (CORBA::is_nil(obj) && count)
1628 obj = _NS->Resolve(containerNameInNS.c_str());
1633 container_proxy = PaCO::InterfaceManager::_narrow(obj);
1635 catch(CORBA::SystemException& e)
1637 INFOS("[StarPaCOPPContainer] Exception in _narrow after LaunchParallelContainer for proxy !");
1638 INFOS("CORBA::SystemException : " << e);
1639 return container_proxy;
1641 catch(CORBA::Exception& e)
1643 INFOS("[StarPaCOPPContainer] Exception in _narrow after LaunchParallelContainer for proxy !");
1644 INFOS("CORBA::Exception" << e);
1645 return container_proxy;
1649 INFOS("[StarPaCOPPContainer] Exception in _narrow after LaunchParallelContainer for proxy !");
1650 INFOS("Unknown exception !");
1651 return container_proxy;
1653 if (CORBA::is_nil(container_proxy))
1655 INFOS("[StarPaCOPPContainer] PaCO::InterfaceManager::_narrow returns NIL !");
1656 return container_proxy;
1661 //=============================================================================
1662 /*! This method launches the parallel container.
1663 * It will may be placed on the ressources manager.
1665 * \param command to launch
1666 * \param container's parameters
1667 * \param name of the container
1669 * \return CORBA container reference
1671 //=============================================================================
1673 SALOME_ContainerManager::LaunchPaCONodeContainer(const std::string& command,
1674 const Engines::ContainerParameters& params,
1675 const std::string& name,
1676 SALOME_ContainerManager::actual_launch_machine_t & vect_machine)
1678 INFOS("[LaunchPaCONodeContainer] Launch command");
1679 int status = system(command.c_str());
1681 INFOS("[LaunchPaCONodeContainer] failed : system command status -1");
1684 else if (status == 217) {
1685 INFOS("[LaunchPaCONodeContainer] failed : system command status 217");
1689 INFOS("[LaunchPaCONodeContainer] Waiting for the nodes of the parallel container");
1690 // We are waiting all the nodes
1691 for (int i = 0; i < params.nb_proc; i++)
1693 CORBA::Object_var obj = CORBA::Object::_nil();
1694 std::string theMachine(vect_machine[i]);
1696 std::ostringstream tmp;
1698 std::string proc_number = tmp.str();
1699 std::string container_node_name = name + proc_number;
1700 std::string containerNameInNS = _NS->BuildContainerNameForNS((char*) container_node_name.c_str(), theMachine.c_str());
1701 INFOS("[LaunchPaCONodeContainer] Waiting for Parallel Container node " << containerNameInNS << " on " << theMachine);
1702 int count = TIME_OUT_TO_LAUNCH_CONT;
1703 while (CORBA::is_nil(obj) && count) {
1706 obj = _NS->Resolve(containerNameInNS.c_str());
1708 if (CORBA::is_nil(obj))
1710 INFOS("[LaunchPaCONodeContainer] Launch of node failed (or not found) !");
1719 Engines::Container_ptr
1720 SALOME_ContainerManager::StartPaCOPPContainer(const Engines::ContainerParameters& params,
1721 std::string resource_selected)
1723 Engines::Container_ptr ret = Engines::Container::_nil();
1724 INFOS("[StarPaCOPPContainer] is disabled !");
1725 INFOS("[StarPaCOPPContainer] recompile SALOME Kernel to enable PaCO++ parallel extension");
1730 SALOME_ContainerManager::BuildCommandToLaunchPaCOProxyContainer(const Engines::ContainerParameters& params,
1731 std::string machine_file_name,
1732 std::string & proxy_hostname)
1738 SALOME_ContainerManager::BuildCommandToLaunchPaCONodeContainer(const Engines::ContainerParameters& params,
1739 const std::string & machine_file_name,
1740 SALOME_ContainerManager::actual_launch_machine_t & vect_machine,
1741 const std::string & proxy_hostname)
1746 SALOME_ContainerManager::LogConfiguration(const std::string & log_type,
1747 const std::string & exe_type,
1748 const std::string & container_name,
1749 const std::string & hostname,
1750 std::string & begin,
1756 SALOME_ContainerManager::LaunchPaCOProxyContainer(const std::string& command,
1757 const Engines::ContainerParameters& params,
1758 const std::string& hostname)
1760 CORBA::Object_ptr ret = CORBA::Object::_nil();
1765 SALOME_ContainerManager::LaunchPaCONodeContainer(const std::string& command,
1766 const Engines::ContainerParameters& params,
1767 const std::string& name,
1768 SALOME_ContainerManager::actual_launch_machine_t & vect_machine)