1 // Copyright (C) 2007-2008 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
22 #include "SALOME_ContainerManager.hxx"
23 #include "SALOME_NamingService.hxx"
24 #include "SALOME_ModuleCatalog.hh"
25 #include "Basics_Utils.hxx"
26 #include "Basics_DirUtils.hxx"
27 #include <sys/types.h>
33 #include "Utils_CorbaException.hxx"
36 #ifdef WITH_PACO_PARALLEL
40 #define TIME_OUT_TO_LAUNCH_CONT 61
44 const char *SALOME_ContainerManager::_ContainerManagerNameInNS =
47 omni_mutex SALOME_ContainerManager::_numInstanceMutex;
50 //=============================================================================
54 * Define a CORBA single thread policy for the server, which avoid to deal
55 * with non thread-safe usage like Change_Directory in SALOME naming service
57 //=============================================================================
59 SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_ResourcesManager *rm, SALOME_NamingService *ns):_nbprocUsed(0)
61 MESSAGE("constructor");
65 PortableServer::POAManager_var pman = poa->the_POAManager();
66 _orb = CORBA::ORB::_duplicate(orb) ;
67 CORBA::PolicyList policies;
69 PortableServer::ThreadPolicy_var threadPol =
70 poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL);
71 policies[0] = PortableServer::ThreadPolicy::_duplicate(threadPol);
73 _poa = poa->create_POA("SThreadPOA",pman,policies);
75 PortableServer::ObjectId_var id = _poa->activate_object(this);
76 CORBA::Object_var obj = _poa->id_to_reference(id);
77 Engines::ContainerManager_var refContMan =
78 Engines::ContainerManager::_narrow(obj);
80 _NS->Register(refContMan,_ContainerManagerNameInNS);
81 _isAppliSalomeDefined = (getenv("APPLI") != 0);
85 if( getenv("OMPI_URI_FILE") != NULL ){
86 system("killall ompi-server");
88 command = "ompi-server -r ";
89 command += getenv("OMPI_URI_FILE");
90 int status=system(command.c_str());
92 throw SALOME_Exception("Error when launching ompi-server");
97 MESSAGE("constructor end");
100 //=============================================================================
104 //=============================================================================
106 SALOME_ContainerManager::~SALOME_ContainerManager()
108 MESSAGE("destructor");
111 if( getenv("OMPI_URI_FILE") != NULL )
112 system("killall ompi-server");
117 //=============================================================================
118 //! shutdown all the containers, then the ContainerManager servant
121 //=============================================================================
123 void SALOME_ContainerManager::Shutdown()
126 ShutdownContainers();
127 _NS->Destroy_Name(_ContainerManagerNameInNS);
128 PortableServer::ObjectId_var oid = _poa->servant_to_id(this);
129 _poa->deactivate_object(oid);
132 //=============================================================================
133 //! Loop on all the containers listed in naming service, ask shutdown on each
136 //=============================================================================
138 void SALOME_ContainerManager::ShutdownContainers()
140 MESSAGE("ShutdownContainers");
142 isOK = _NS->Change_Directory("/Containers");
144 vector<string> vec = _NS->list_directory_recurs();
145 list<string> lstCont;
146 for(vector<string>::iterator iter = vec.begin();iter!=vec.end();iter++)
149 CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
152 Engines::Container_var cont=Engines::Container::_narrow(obj);
153 if(!CORBA::is_nil(cont))
154 lstCont.push_back((*iter));
156 catch(const CORBA::Exception& e)
158 // ignore this entry and continue
161 MESSAGE("Container list: ");
162 for(list<string>::iterator iter=lstCont.begin();iter!=lstCont.end();iter++){
165 for(list<string>::iterator iter=lstCont.begin();iter!=lstCont.end();iter++)
170 CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
171 Engines::Container_var cont=Engines::Container::_narrow(obj);
172 if(!CORBA::is_nil(cont))
174 MESSAGE("ShutdownContainers: " << (*iter));
178 MESSAGE("ShutdownContainers: no container ref for " << (*iter));
180 catch(CORBA::SystemException& e)
182 INFOS("CORBA::SystemException ignored : " << e);
184 catch(CORBA::Exception&)
186 INFOS("CORBA::Exception ignored.");
190 INFOS("Unknown exception ignored.");
196 //=============================================================================
197 //! Give a suitable Container given constraints
199 * \param params Container Parameters required for the container
200 * \return the container or nil
202 //=============================================================================
203 Engines::Container_ptr
204 SALOME_ContainerManager::GiveContainer(const Engines::ContainerParameters& params)
207 Engines::Container_ptr ret = Engines::Container::_nil();
209 // Step 0: Default mode is start
210 Engines::ContainerParameters local_params(params);
211 if (std::string(local_params.mode.in()) == "")
212 local_params.mode = CORBA::string_dup("start");
213 std::string mode = local_params.mode.in();
214 MESSAGE("[GiveContainer] starting with mode: " << mode);
216 // Step 1: Find Container for find and findorstart mode
217 if (mode == "find" or mode == "findorstart")
219 ret = FindContainer(params, params.resource_params.resList);
220 if(!CORBA::is_nil(ret))
226 MESSAGE("[GiveContainer] no container found");
236 // Step 2: Get all possibleResources from the parameters
237 Engines::ResourceList_var possibleResources = _ResManager->GetFittingResources(local_params.resource_params);
238 MESSAGE("[GiveContainer] - length of possible resources " << possibleResources->length());
239 std::vector<std::string> local_resources;
241 // Step 3: if mode is "get" keep only machines with existing containers
244 for(unsigned int i=0; i < possibleResources->length(); i++)
246 Engines::Container_ptr cont = FindContainer(params, possibleResources[i].in());
249 if(!cont->_non_existent())
250 local_resources.push_back(string(possibleResources[i]));
252 catch(CORBA::Exception&) {}
255 // if local_resources is empty, we cannot give a container
256 if (local_resources.size() == 0)
258 MESSAGE("[GiveContainer] cannot find a container for mode get");
263 for(unsigned int i=0; i < possibleResources->length(); i++)
264 local_resources.push_back(string(possibleResources[i]));
266 // Step 4: select the resource where to get/start the container
267 std::string resource_selected;
270 resource_selected = _ResManager->GetImpl()->Find(params.resource_params.policy.in(), local_resources);
272 catch(const SALOME_Exception &ex)
274 MESSAGE("[GiveContainer] Exception in ResourceManager find !: " << ex.what());
277 MESSAGE("[GiveContainer] Resource selected is: " << resource_selected);
279 // Step 5: get container in the naming service
280 Engines::ResourceDefinition_var resource_definition = _ResManager->GetResourceDefinition(resource_selected.c_str());
281 std::string hostname(resource_definition->hostname.in());
282 std::string containerNameInNS;
285 if ( (params.resource_params.nb_node <= 0) && (params.resource_params.nb_proc_per_node <= 0) )
287 else if ( params.resource_params.nb_node == 0 )
288 nbproc = params.resource_params.nb_proc_per_node;
289 else if ( params.resource_params.nb_proc_per_node == 0 )
290 nbproc = params.resource_params.nb_node;
292 nbproc = params.resource_params.nb_node * params.resource_params.nb_proc_per_node;
293 if( getenv("LIBBATCH_NODEFILE") != NULL )
294 machFile = machinesFile(nbproc);
295 // A mpi parallel container register on zero node in NS
296 containerNameInNS = _NS->BuildContainerNameForNS(params, GetMPIZeroNode(hostname,machFile).c_str());
299 containerNameInNS = _NS->BuildContainerNameForNS(params, hostname.c_str());
300 MESSAGE("[GiveContainer] Container name in the naming service: " << containerNameInNS);
302 // Step 6: check if the name exists in naming service
303 //if params.mode == "getorstart" or "get" use the existing container
304 //if params.mode == "start" shutdown the existing container before launching a new one with that name
305 CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
306 if (!CORBA::is_nil(obj))
310 Engines::Container_var cont=Engines::Container::_narrow(obj);
311 if(!cont->_non_existent())
313 if(std::string(params.mode.in())=="getorstart" or std::string(params.mode.in())=="get"){
314 return cont._retn(); /* the container exists and params.mode is getorstart or get use it*/
318 INFOS("[GiveContainer] A container is already registered with the name: " << containerNameInNS << ", shutdown the existing container");
319 cont->Shutdown(); // shutdown the registered container if it exists
323 catch(CORBA::Exception&)
325 INFOS("[GiveContainer] CORBA::Exception ignored when trying to get the container - we start a new one");
329 // Step 7: type of container: PaCO, Exe, Mpi or Classic
330 // Mpi already tested in step 5, specific code on BuildCommandToLaunch Local/Remote Container methods
331 // TODO -> separates Mpi from Classic/Exe
333 std::string container_exe = "SALOME_Container"; // Classic container
337 CORBA::String_var container_exe_tmp;
338 CORBA::Object_var obj = _NS->Resolve("/Kernel/ModulCatalog");
339 SALOME_ModuleCatalog::ModuleCatalog_var Catalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ;
340 if (CORBA::is_nil (Catalog))
342 INFOS("[GiveContainer] Module Catalog is not found -> cannot launch a container");
345 // Loop through component list
346 for(unsigned int i=0; i < local_params.resource_params.componentList.length(); i++)
348 const char* compoi = local_params.resource_params.componentList[i];
349 SALOME_ModuleCatalog::Acomponent_var compoInfo = Catalog->GetComponent(compoi);
350 if (CORBA::is_nil (compoInfo))
354 SALOME_ModuleCatalog::ImplType impl=compoInfo->implementation_type();
355 container_exe_tmp=compoInfo->implementation_name();
356 if(impl==SALOME_ModuleCatalog::CEXE)
360 INFOS("ContainerManager Error: you can't have 2 CEXE component in the same container" );
361 return Engines::Container::_nil();
363 MESSAGE("[GiveContainer] Exe container found !: " << container_exe_tmp);
364 container_exe = container_exe_tmp.in();
369 catch (ServiceUnreachable&)
371 INFOS("Caught exception: Naming Service Unreachable");
376 INFOS("Caught unknown exception.");
380 // Step 8: start a new container
381 // Check if a PaCO container
383 if (std::string(local_params.parallelLib.in()) != "")
385 ret = StartPaCOPPContainer(params, resource_selected);
388 // Other type of containers...
389 MESSAGE("[GiveContainer] Try to launch a new container on " << resource_selected);
391 // if a parallel container is launched in batch job, command is: "mpirun -np nbproc -machinefile nodesfile SALOME_MPIContainer"
392 if( getenv("LIBBATCH_NODEFILE") != NULL && params.isMPI )
393 command = BuildCommandToLaunchLocalContainer(params, machFile, container_exe);
394 // if a container is launched on localhost, command is "SALOME_Container" or "mpirun -np nbproc SALOME_MPIContainer"
395 else if(hostname == Kernel_Utils::GetHostname())
396 command = BuildCommandToLaunchLocalContainer(params, machFile, container_exe);
397 // if a container is launched in remote mode, command is "ssh resource_selected SALOME_Container" or "ssh resource_selected mpirun -np nbproc SALOME_MPIContainer"
399 command = BuildCommandToLaunchRemoteContainer(resource_selected, params, container_exe);
401 //redirect stdout and stderr in a file
403 string logFilename=getenv("TEMP");
406 string logFilename="/tmp";
407 char* val = getenv("SALOME_TMP_DIR");
410 struct stat file_info;
411 stat(val, &file_info);
412 bool is_dir = S_ISDIR(file_info.st_mode);
413 if (is_dir)logFilename=val;
414 else std::cerr << "SALOME_TMP_DIR environment variable is not a directory use /tmp instead" << std::endl;
418 logFilename += _NS->ContainerName(params)+"_"+ resource_selected +"_"+getenv( "USER" )+".log" ;
419 command += " > " + logFilename + " 2>&1";
421 command = "%PYTHONBIN% -c \"import win32pm ; win32pm.spawnpid(r'" + command + "', '')\"";
426 // launch container with a system call
427 int status=system(command.c_str());
430 MESSAGE("SALOME_ContainerManager::StartContainer rsh failed (system command status -1)");
431 RmTmpFile(_TmpFileName); // command file can be removed here
432 return Engines::Container::_nil();
434 else if (status == 217){
435 MESSAGE("SALOME_ContainerManager::StartContainer rsh failed (system command status 217)");
436 RmTmpFile(_TmpFileName); // command file can be removed here
437 return Engines::Container::_nil();
441 int count = TIME_OUT_TO_LAUNCH_CONT;
442 MESSAGE("[GiveContainer] waiting " << count << " second steps");
443 while (CORBA::is_nil(ret) && count)
451 MESSAGE("[GiveContainer] step " << count << " Waiting for container on " << resource_selected);
452 CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
453 ret=Engines::Container::_narrow(obj);
455 if (CORBA::is_nil(ret))
457 INFOS("[GiveContainer] was not able to launch container " << containerNameInNS);
461 // Setting log file name
462 logFilename=":"+logFilename;
463 logFilename="@"+Kernel_Utils::GetHostname()+logFilename;
464 logFilename=getenv( "USER" )+logFilename;
465 ret->logfilename(logFilename.c_str());
466 RmTmpFile(_TmpFileName); // command file can be removed here
472 //=============================================================================
473 //! Find a container given constraints (params) on a list of machines (possibleComputers)
477 //=============================================================================
479 Engines::Container_ptr
480 SALOME_ContainerManager::FindContainer(const Engines::ContainerParameters& params,
481 const Engines::ResourceList& possibleResources)
483 MESSAGE("[FindContainer] FindContainer on " << possibleResources.length() << " resources");
484 for(unsigned int i=0; i < possibleResources.length();i++)
486 Engines::Container_ptr cont = FindContainer(params, possibleResources[i].in());
487 if(!CORBA::is_nil(cont))
490 MESSAGE("[FindContainer] no container found");
491 return Engines::Container::_nil();
494 //=============================================================================
495 //! Find a container given constraints (params) on a machine (theMachine)
499 //=============================================================================
501 Engines::Container_ptr
502 SALOME_ContainerManager::FindContainer(const Engines::ContainerParameters& params,
503 const std::string& resource)
505 Engines::ResourceDefinition_var resource_definition = _ResManager->GetResourceDefinition(resource.c_str());
506 std::string hostname(resource_definition->hostname.in());
507 std::string containerNameInNS(_NS->BuildContainerNameForNS(params, hostname.c_str()));
508 MESSAGE("[FindContainer] Try to find a container " << containerNameInNS << " on resource " << resource);
509 CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
512 if(obj->_non_existent())
513 return Engines::Container::_nil();
515 return Engines::Container::_narrow(obj);
517 catch(const CORBA::Exception& e)
519 return Engines::Container::_nil();
523 //=============================================================================
525 * This is no longer valid (C++ container are also python containers)
527 //=============================================================================
528 bool isPythonContainer(const char* ContainerName)
531 int len = strlen(ContainerName);
534 if (strcmp(ContainerName + len - 2, "Py") == 0)
540 //=============================================================================
542 * Builds the script to be launched
544 * If SALOME Application not defined ($APPLI),
545 * see BuildTempFileToLaunchRemoteContainer()
547 * Else rely on distant configuration. Command is under the form (example):
548 * ssh user@machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \
549 * SALOME_Container containerName &"
551 * - where user is ommited if not specified in CatalogResources,
552 * - where distant path is always relative to user@machine $HOME, and
553 * equal to $APPLI if not specified in CatalogResources,
554 * - where hostNS is the hostname of CORBA naming server (set by scripts to
555 * use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh)
556 * - where portNS is the port used by CORBA naming server (set by scripts to
557 * use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh)
558 * - where workingdir is the requested working directory for the container.
559 * If WORKINGDIR (and workingdir) is not present the working dir will be $HOME
561 //=============================================================================
564 SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer
565 (const string& resource_name,
566 const Engines::ContainerParameters& params, const std::string& container_exe)
570 if (!_isAppliSalomeDefined)
571 command = BuildTempFileToLaunchRemoteContainer(resource_name, params);
575 Engines::ResourceDefinition_var resource_definition = _ResManager->GetResourceDefinition(resource_name.c_str());
576 std::string hostname(resource_definition->hostname.in());
577 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesDescr(resource_name);
581 if ((params.resource_params.nb_node <= 0) && (params.resource_params.nb_proc_per_node <= 0))
583 else if (params.resource_params.nb_node == 0)
584 nbproc = params.resource_params.nb_proc_per_node;
585 else if (params.resource_params.nb_proc_per_node == 0)
586 nbproc = params.resource_params.nb_node;
588 nbproc = params.resource_params.nb_node * params.resource_params.nb_proc_per_node;
591 // "ssh -l user machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \
592 // SALOME_Container containerName &"
593 if (resInfo.Protocol == rsh)
595 else if (resInfo.Protocol == ssh)
598 throw SALOME_Exception("Unknown protocol");
600 if (resInfo.UserName != "")
603 command += resInfo.UserName;
607 command += resInfo.HostName;
610 if (resInfo.AppliPath != "")
611 command += resInfo.AppliPath; // path relative to user@machine $HOME
614 ASSERT(getenv("APPLI"));
615 command += getenv("APPLI"); // path relative to user@machine $HOME
618 command += "/runRemote.sh ";
620 ASSERT(getenv("NSHOST"));
621 command += getenv("NSHOST"); // hostname of CORBA name server
624 ASSERT(getenv("NSPORT"));
625 command += getenv("NSPORT"); // port of CORBA name server
627 std::string wdir = params.workingdir.in();
630 command += " WORKINGDIR ";
632 if(wdir == "$TEMPDIR")
634 command += wdir; // requested working directory
640 command += " mpirun -np ";
641 std::ostringstream o;
645 command += "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
646 #elif defined(WITHOPENMPI)
647 if( getenv("OMPI_URI_FILE") == NULL )
648 command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
650 command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
651 command += getenv("OMPI_URI_FILE");
654 command += " SALOME_MPIContainer ";
657 command += " " +container_exe+ " ";
659 command += _NS->ContainerName(params);
661 AddOmninamesParams(command);
663 MESSAGE("command =" << command);
669 //=============================================================================
671 * builds the command to be launched.
673 //=============================================================================
675 SALOME_ContainerManager::BuildCommandToLaunchLocalContainer
676 (const Engines::ContainerParameters& params, const std::string& machinesFile, const std::string& container_exe)
678 _TmpFileName = BuildTemporaryFileName();
688 if ( (params.resource_params.nb_node <= 0) && (params.resource_params.nb_proc_per_node <= 0) )
690 else if ( params.resource_params.nb_node == 0 )
691 nbproc = params.resource_params.nb_proc_per_node;
692 else if ( params.resource_params.nb_proc_per_node == 0 )
693 nbproc = params.resource_params.nb_node;
695 nbproc = params.resource_params.nb_node * params.resource_params.nb_proc_per_node;
699 if( getenv("LIBBATCH_NODEFILE") != NULL )
700 o << "-machinefile " << machinesFile << " ";
703 o << "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
704 #elif defined(WITHOPENMPI)
705 if( getenv("OMPI_URI_FILE") == NULL )
706 o << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
709 o << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
710 o << getenv("OMPI_URI_FILE");
714 if (isPythonContainer(params.container_name))
715 o << " pyMPI SALOME_ContainerPy.py ";
717 o << " SALOME_MPIContainer ";
722 std::string wdir=params.workingdir.in();
725 // a working directory is requested
726 if(wdir == "$TEMPDIR")
728 // a new temporary directory is requested
729 string dir = Kernel_Utils::GetTmpDir();
731 o << "cd /d " << dir << endl;
733 o << "cd " << dir << ";";
739 // a permanent directory is requested use it or create it
741 o << "mkdir " + wdir << endl;
742 o << "cd /D " + wdir << endl;
744 o << "mkdir -p " << wdir << " && cd " << wdir + ";";
748 if (isPythonContainer(params.container_name))
749 o << "SALOME_ContainerPy.py ";
751 o << container_exe + " ";
755 o << _NS->ContainerName(params);
757 AddOmninamesParams(o);
759 ofstream command_file( _TmpFileName.c_str() );
760 command_file << o.str();
761 command_file.close();
764 chmod(_TmpFileName.c_str(), 0x1ED);
766 command = _TmpFileName;
768 MESSAGE("Command is file ... " << command);
769 MESSAGE("Command is ... " << o.str());
774 //=============================================================================
776 * removes the generated temporary file in case of a remote launch.
778 //=============================================================================
780 void SALOME_ContainerManager::RmTmpFile(std::string& tmpFileName)
782 int lenght = tmpFileName.size();
786 string command = "del /F ";
788 string command = "rm ";
791 command += tmpFileName.substr(0, lenght - 3 );
793 command += tmpFileName;
795 system(command.c_str());
796 //if dir is empty - remove it
797 string tmp_dir = Kernel_Utils::GetDirByPath( tmpFileName );
798 if ( Kernel_Utils::IsEmptyDir( tmp_dir ) )
801 command = "del /F " + tmp_dir;
803 command = "rmdir " + tmp_dir;
805 system(command.c_str());
810 //=============================================================================
812 * add to command all options relative to naming service.
814 //=============================================================================
816 void SALOME_ContainerManager::AddOmninamesParams(string& command) const
818 CORBA::String_var iorstr = _NS->getIORaddr();
819 command += "ORBInitRef NameService=";
823 //=============================================================================
825 * add to command all options relative to naming service.
827 //=============================================================================
829 void SALOME_ContainerManager::AddOmninamesParams(ofstream& fileStream) const
831 CORBA::String_var iorstr = _NS->getIORaddr();
832 fileStream << "ORBInitRef NameService=";
833 fileStream << iorstr;
836 //=============================================================================
838 * add to command all options relative to naming service.
840 //=============================================================================
842 void SALOME_ContainerManager::AddOmninamesParams(ostringstream& oss) const
844 CORBA::String_var iorstr = _NS->getIORaddr();
845 oss << "ORBInitRef NameService=";
849 //=============================================================================
851 * generate a file name in /tmp directory
853 //=============================================================================
855 string SALOME_ContainerManager::BuildTemporaryFileName() const
857 //build more complex file name to support multiple salome session
858 string aFileName = Kernel_Utils::GetTmpFileName();
867 //=============================================================================
869 * Builds in a temporary file the script to be launched.
871 * Used if SALOME Application ($APPLI) is not defined.
872 * The command is build with data from CatalogResources, in which every path
873 * used on remote computer must be defined.
875 //=============================================================================
878 SALOME_ContainerManager::BuildTempFileToLaunchRemoteContainer
879 (const string& resource_name,
880 const Engines::ContainerParameters& params) throw(SALOME_Exception)
884 _TmpFileName = BuildTemporaryFileName();
885 ofstream tempOutputFile;
886 tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
887 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesDescr(resource_name);
888 tempOutputFile << "#! /bin/sh" << endl;
892 tempOutputFile << "export SALOME_trace=local" << endl; // mkr : 27.11.2006 : PAL13967 - Distributed supervision graphs - Problem with "SALOME_trace"
893 //tempOutputFile << "source " << resInfo.PreReqFilePath << endl;
899 tempOutputFile << "mpirun -np ";
902 if ( (params.resource_params.nb_node <= 0) && (params.resource_params.nb_proc_per_node <= 0) )
904 else if ( params.resource_params.nb_node == 0 )
905 nbproc = params.resource_params.nb_proc_per_node;
906 else if ( params.resource_params.nb_proc_per_node == 0 )
907 nbproc = params.resource_params.nb_node;
909 nbproc = params.resource_params.nb_node * params.resource_params.nb_proc_per_node;
911 std::ostringstream o;
913 tempOutputFile << nbproc << " ";
915 tempOutputFile << "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
916 #elif defined(WITHOPENMPI)
917 if( getenv("OMPI_URI_FILE") == NULL )
918 tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
920 tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
921 tempOutputFile << getenv("OMPI_URI_FILE");
926 tempOutputFile << getenv("KERNEL_ROOT_DIR") << "/bin/salome/";
930 if (isPythonContainer(params.container_name))
931 tempOutputFile << " pyMPI SALOME_ContainerPy.py ";
933 tempOutputFile << " SALOME_MPIContainer ";
938 if (isPythonContainer(params.container_name))
939 tempOutputFile << "SALOME_ContainerPy.py ";
941 tempOutputFile << "SALOME_Container ";
944 tempOutputFile << _NS->ContainerName(params) << " -";
945 AddOmninamesParams(tempOutputFile);
946 tempOutputFile << " &" << endl;
947 tempOutputFile.flush();
948 tempOutputFile.close();
950 chmod(_TmpFileName.c_str(), 0x1ED);
957 if (resInfo.Protocol == rsh)
960 string commandRcp = "rcp ";
961 commandRcp += _TmpFileName;
963 commandRcp += resInfo.HostName;
965 commandRcp += _TmpFileName;
966 status = system(commandRcp.c_str());
969 else if (resInfo.Protocol == ssh)
972 string commandRcp = "scp ";
973 commandRcp += _TmpFileName;
975 commandRcp += resInfo.HostName;
977 commandRcp += _TmpFileName;
978 status = system(commandRcp.c_str());
981 throw SALOME_Exception("Unknown protocol");
984 throw SALOME_Exception("Error of connection on remote host");
986 command += resInfo.HostName;
987 _CommandForRemAccess = command;
989 command += _TmpFileName;
997 string SALOME_ContainerManager::GetMPIZeroNode(const string machine, const string machinesFile)
1002 string tmpFile = BuildTemporaryFileName();
1004 if( getenv("LIBBATCH_NODEFILE") == NULL )
1006 if (_isAppliSalomeDefined)
1008 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesDescr(machine);
1010 if (resInfo.Protocol == rsh)
1012 else if (resInfo.Protocol == ssh)
1015 throw SALOME_Exception("Unknown protocol");
1017 if (resInfo.UserName != "")
1020 command += resInfo.UserName;
1024 command += resInfo.HostName;
1027 if (resInfo.AppliPath != "")
1028 command += resInfo.AppliPath; // path relative to user@machine $HOME
1031 ASSERT(getenv("APPLI"));
1032 command += getenv("APPLI"); // path relative to user@machine $HOME
1035 command += "/runRemote.sh ";
1037 ASSERT(getenv("NSHOST"));
1038 command += getenv("NSHOST"); // hostname of CORBA name server
1041 ASSERT(getenv("NSPORT"));
1042 command += getenv("NSPORT"); // port of CORBA name server
1044 command += " mpirun -np 1 hostname > " + tmpFile;
1047 command = "mpirun -np 1 hostname > " + tmpFile;
1050 command = "mpirun -np 1 -machinefile " + machinesFile + " hostname > " + tmpFile;
1052 status = system(command.c_str());
1054 ifstream fp(tmpFile.c_str(),ios::in);
1063 string SALOME_ContainerManager::machinesFile(const int nbproc)
1066 string nodesFile = getenv("LIBBATCH_NODEFILE");
1067 string machinesFile = Kernel_Utils::GetTmpFileName();
1068 ifstream fpi(nodesFile.c_str(),ios::in);
1069 ofstream fpo(machinesFile.c_str(),ios::out);
1071 _numInstanceMutex.lock();
1073 for(int i=0;i<_nbprocUsed;i++)
1076 for(int i=0;i<nbproc;i++)
1080 throw SALOME_Exception("You ask more processes than batch session have allocated!");
1082 _nbprocUsed += nbproc;
1086 _numInstanceMutex.unlock();
1088 return machinesFile;
1093 SALOME_ContainerManager::checkPaCOParameters(Engines::ContainerParameters & params, std::string resource_selected)
1097 // Step 1 : check ContainerParameters
1098 // Check container_name, has to be defined
1099 if (std::string(params.container_name.in()) == "")
1101 INFOS("[checkPaCOParameters] You must define a container_name to launch a PaCO++ container");
1104 // Check parallelLib
1105 std::string parallelLib = params.parallelLib.in();
1106 if (parallelLib != "Mpi" and parallelLib != "Dummy")
1108 INFOS("[checkPaCOParameters] parallelLib is not correctly defined");
1109 INFOS("[checkPaCOParameters] you can chosse between: Mpi and Dummy");
1110 INFOS("[checkPaCOParameters] you entered: " << parallelLib);
1114 if (params.nb_proc <= 0)
1116 INFOS("[checkPaCOParameters] You must define a nb_proc > 0");
1120 // Step 2 : check resource_selected
1121 Engines::ResourceDefinition_var resource_definition = _ResManager->GetResourceDefinition(resource_selected.c_str());
1122 std::string protocol = resource_definition->protocol.in();
1123 std::string username = resource_definition->username.in();
1124 std::string applipath = resource_definition->applipath.in();
1126 if (protocol == "" or username == "" or applipath == "")
1128 INFOS("[checkPaCOParameters] resource selected is not well defined");
1129 INFOS("[checkPaCOParameters] resource name: " << resource_definition->name.in());
1130 INFOS("[checkPaCOParameters] resource hostname: " << resource_definition->hostname.in());
1131 INFOS("[checkPaCOParameters] resource protocol: " << protocol);
1132 INFOS("[checkPaCOParameters] resource username: " << username);
1133 INFOS("[checkPaCOParameters] resource applipath: " << applipath);
1139 #ifdef WITH_PACO_PARALLEL
1141 //=============================================================================
1143 * Start a suitable PaCO++ Parallel Container in a list of machines.
1144 * \param params Container Parameters required for the container
1145 * \return CORBA container reference.
1147 //=============================================================================
1148 Engines::Container_ptr
1149 SALOME_ContainerManager::StartPaCOPPContainer(const Engines::ContainerParameters& params_const,
1150 std::string resource_selected)
1152 CORBA::Object_var obj;
1153 PaCO::InterfaceManager_var container_proxy;
1154 Engines::Container_ptr ret = Engines::Container::_nil();
1155 Engines::ContainerParameters params(params_const);
1156 params.resource_params.name = CORBA::string_dup(resource_selected.c_str());
1158 // Step 0 : Check parameters
1159 if (!checkPaCOParameters(params, resource_selected))
1161 INFOS("[StartPaCOPPContainer] check parameters failed ! see logs...");
1165 // Step 1 : Starting a new parallel container !
1166 INFOS("[StartPaCOPPContainer] Starting a PaCO++ parallel container");
1167 INFOS("[StartPaCOPPContainer] on resource : " << resource_selected);
1169 // Step 2 : Get a MachineFile for the parallel container
1170 std::string machine_file_name = _ResManager->getMachineFile(resource_selected,
1172 params.parallelLib.in());
1174 if (machine_file_name == "")
1176 INFOS("[StartPaCOPPContainer] Machine file generation failed");
1180 // Step 3 : starting parallel container proxy
1181 std::string command_proxy("");
1182 std::string proxy_machine;
1185 command_proxy = BuildCommandToLaunchPaCOProxyContainer(params, machine_file_name, proxy_machine);
1187 catch(const SALOME_Exception & ex)
1189 INFOS("[StartPaCOPPContainer] Exception in BuildCommandToLaunchPaCOContainer");
1193 obj = LaunchPaCOProxyContainer(command_proxy, params, proxy_machine);
1194 if (CORBA::is_nil(obj))
1196 INFOS("[StartPaCOPPContainer] LaunchPaCOContainer for proxy returns NIL !");
1199 container_proxy = PaCO::InterfaceManager::_narrow(obj);
1200 MESSAGE("[StartPaCOPPContainer] PaCO container proxy is launched");
1202 // Step 4 : starting parallel container nodes
1203 std::string command_nodes("");
1204 SALOME_ContainerManager::actual_launch_machine_t nodes_machines;
1207 command_nodes = BuildCommandToLaunchPaCONodeContainer(params, machine_file_name, nodes_machines, proxy_machine);
1209 catch(const SALOME_Exception & ex)
1211 INFOS("[StarPaCOPPContainer] Exception in BuildCommandToLaunchPaCONodeContainer");
1216 std::string container_generic_node_name = std::string(params.container_name.in()) + std::string("Node");
1217 bool result = LaunchPaCONodeContainer(command_nodes, params, container_generic_node_name, nodes_machines);
1220 INFOS("[StarPaCOPPContainer] LaunchPaCONodeContainer failed !");
1221 // Il faut tuer le proxy
1224 Engines::Container_var proxy = Engines::Container::_narrow(container_proxy);
1229 INFOS("[StarPaCOPPContainer] Exception catched from proxy Shutdown...");
1234 // Step 4 : connecting nodes and the proxy to actually create a parallel container
1235 for (int i = 0; i < params.nb_proc; i++)
1237 std::ostringstream tmp;
1239 std::string proc_number = tmp.str();
1240 std::string container_node_name = container_generic_node_name + proc_number;
1242 std::string theNodeMachine(nodes_machines[i]);
1243 std::string containerNameInNS = _NS->BuildContainerNameForNS(container_node_name.c_str(), theNodeMachine.c_str());
1244 obj = _NS->Resolve(containerNameInNS.c_str());
1245 if (CORBA::is_nil(obj))
1247 INFOS("[StarPaCOPPContainer] CONNECTION FAILED From Naming Service !");
1248 INFOS("[StarPaCOPPContainer] Container name is " << containerNameInNS);
1253 MESSAGE("[StarPaCOPPContainer] Deploying node : " << container_node_name);
1254 PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(obj);
1256 MESSAGE("[StarPaCOPPContainer] node " << container_node_name << " is deployed");
1258 catch(CORBA::SystemException& e)
1260 INFOS("[StarPaCOPPContainer] Exception in deploying node : " << containerNameInNS);
1261 INFOS("CORBA::SystemException : " << e);
1264 catch(CORBA::Exception& e)
1266 INFOS("[StarPaCOPPContainer] Exception in deploying node : " << containerNameInNS);
1267 INFOS("CORBA::Exception" << e);
1272 INFOS("[StarPaCOPPContainer] Exception in deploying node : " << containerNameInNS);
1273 INFOS("Unknown exception !");
1278 // Step 5 : starting parallel container
1281 MESSAGE ("[StarPaCOPPContainer] Starting parallel object");
1282 container_proxy->start();
1283 MESSAGE ("[StarPaCOPPContainer] Parallel object is started");
1284 ret = Engines::Container::_narrow(container_proxy);
1286 catch(CORBA::SystemException& e)
1288 INFOS("Caught CORBA::SystemException. : " << e);
1290 catch(PortableServer::POA::ServantAlreadyActive&)
1292 INFOS("Caught CORBA::ServantAlreadyActiveException");
1294 catch(CORBA::Exception&)
1296 INFOS("Caught CORBA::Exception.");
1298 catch(std::exception& exc)
1300 INFOS("Caught std::exception - "<<exc.what());
1304 INFOS("Caught unknown exception.");
1310 SALOME_ContainerManager::BuildCommandToLaunchPaCOProxyContainer(const Engines::ContainerParameters& params,
1311 std::string machine_file_name,
1312 std::string & proxy_hostname)
1314 // In the proxy case, we always launch a Dummy Proxy
1315 std::string exe_name = "SALOME_ParallelContainerProxyDummy";
1316 std::string container_name = params.container_name.in();
1318 // Convert nb_proc in string
1319 std::ostringstream tmp_string;
1320 tmp_string << params.nb_proc;
1321 std::string nb_proc_str = tmp_string.str();
1323 // Get resource definition
1324 Engines::ResourceDefinition_var resource_definition =
1325 _ResManager->GetResourceDefinition(params.resource_params.name);
1328 std::string hostname;
1329 std::ifstream machine_file(machine_file_name.c_str());
1330 std::getline(machine_file, hostname, ' ');
1331 size_t found = hostname.find('\n');
1332 if (found!=string::npos)
1333 hostname.erase(found, 1); // Remove \n
1334 proxy_hostname = hostname;
1335 MESSAGE("[BuildCommandToLaunchPaCOProxyContainer] machine file name extracted is " << hostname);
1338 bool remote_execution = false;
1339 if (hostname != std::string(Kernel_Utils::GetHostname()))
1341 MESSAGE("[BuildCommandToLaunchPaCOProxyContainer] remote machine case detected !");
1342 remote_execution = true;
1345 // Log environnement
1346 std::string log_type("");
1347 char * get_val = getenv("PARALLEL_LOG");
1351 // Generating the command
1352 std::string command_begin("");
1353 std::string command_end("");
1354 std::ostringstream command;
1356 LogConfiguration(log_type, "proxy", container_name, hostname, command_begin, command_end);
1357 command << command_begin;
1359 // Adding connection command
1360 // We can only have a remote execution with
1361 // a SALOME application
1362 if (remote_execution)
1364 ASSERT(getenv("NSHOST"));
1365 ASSERT(getenv("NSPORT"));
1367 command << resource_definition->protocol.in();
1369 command << resource_definition->username.in();
1370 command << " " << hostname;
1371 command << " " << resource_definition->applipath.in();
1372 command << "/runRemote.sh ";
1373 command << getenv("NSHOST") << " "; // hostname of CORBA name server
1374 command << getenv("NSPORT") << " "; // port of CORBA name server
1377 command << exe_name;
1378 command << " " << container_name;
1379 command << " Dummy";
1380 command << " " << hostname;
1381 command << " " << nb_proc_str;
1383 AddOmninamesParams(command);
1386 command << command_end;
1387 MESSAGE("[BuildCommandToLaunchPaCOProxyContainer] Command is: " << command.str());
1389 return command.str();
1393 SALOME_ContainerManager::BuildCommandToLaunchPaCONodeContainer(const Engines::ContainerParameters& params,
1394 const std::string & machine_file_name,
1395 SALOME_ContainerManager::actual_launch_machine_t & vect_machine,
1396 const std::string & proxy_hostname)
1399 std::string exe_name = "SALOME_ParallelContainerNode";
1400 exe_name += params.parallelLib.in();
1401 std::string container_name = params.container_name.in();
1403 // Convert nb_proc in string
1404 std::ostringstream nb_proc_stream;
1405 nb_proc_stream << params.nb_proc;
1407 // Get resource definition
1408 Engines::ResourceDefinition_var resource_definition =
1409 _ResManager->GetResourceDefinition(params.resource_params.name);
1411 // Log environnement
1412 std::string log_type("");
1413 char * get_val = getenv("PARALLEL_LOG");
1417 // Now the command is different according to paralleLib
1418 std::ostringstream command_nodes;
1419 std::ifstream machine_file(machine_file_name.c_str());
1420 if (std::string(params.parallelLib.in()) == "Dummy")
1422 for (int i= 0; i < params.nb_proc; i++)
1425 std::string hostname;
1426 std::getline(machine_file, hostname);
1427 MESSAGE("[BuildCommandToLaunchPaCONodeContainer] machine file name extracted is " << hostname);
1430 bool remote_execution = false;
1431 if (hostname != std::string(Kernel_Utils::GetHostname()))
1433 MESSAGE("[BuildCommandToLaunchPaCONodeContainer] remote machine case detected !");
1434 remote_execution = true;
1437 // For each node we have a new command
1438 // Generating the command
1439 std::ostringstream command_node_stream;
1440 std::string command_node_begin("");
1441 std::string command_node_end("");
1442 std::ostringstream node_number;
1444 std::string container_node_name = container_name + node_number.str();
1445 LogConfiguration(log_type, "node", container_node_name, hostname, command_node_begin, command_node_end);
1447 // Adding connection command
1448 // We can only have a remote execution with
1449 // a SALOME application
1450 if (remote_execution)
1452 ASSERT(getenv("NSHOST"));
1453 ASSERT(getenv("NSPORT"));
1455 command_node_stream << resource_definition->protocol.in();
1456 command_node_stream << " -l ";
1457 command_node_stream << resource_definition->username.in();
1458 command_node_stream << " " << hostname;
1459 command_node_stream << " " << resource_definition->applipath.in();
1460 command_node_stream << "/runRemote.sh ";
1461 command_node_stream << getenv("NSHOST") << " "; // hostname of CORBA name server
1462 command_node_stream << getenv("NSPORT") << " "; // port of CORBA name server
1465 command_node_stream << exe_name;
1466 command_node_stream << " " << container_name;
1467 command_node_stream << " " << params.parallelLib.in();
1468 command_node_stream << " " << proxy_hostname;
1469 command_node_stream << " " << node_number.str();
1470 command_node_stream << " -";
1471 AddOmninamesParams(command_node_stream);
1473 command_nodes << command_node_begin << command_node_stream.str() << command_node_end;
1474 vect_machine.push_back(hostname);
1478 else if (std::string(params.parallelLib.in()) == "Mpi")
1481 std::string hostname;
1482 std::getline(machine_file, hostname, ' ');
1483 MESSAGE("[BuildCommandToLaunchPaCONodeContainer] machine file name extracted is " << hostname);
1486 bool remote_execution = false;
1487 if (hostname != std::string(Kernel_Utils::GetHostname()))
1489 MESSAGE("[BuildCommandToLaunchPaCONodeContainer] remote machine case detected !");
1490 remote_execution = true;
1493 // In case of Mpi and Remote, we copy machine_file in the applipath
1494 // scp mpi_machine_file user@machine:Path
1495 std::ostringstream command_remote_stream;
1496 std::string::size_type last = machine_file_name.find_last_of("/");
1497 if (last == std::string::npos)
1500 std::string protocol = resource_definition->protocol.in();
1501 if (protocol == "rsh")
1502 command_remote_stream << "rcp ";
1504 command_remote_stream << "scp ";
1505 command_remote_stream << machine_file_name << " ";
1506 command_remote_stream << resource_definition->username.in() << "@";
1507 command_remote_stream << hostname << ":" << resource_definition->applipath.in();
1508 command_remote_stream << "/" << machine_file_name.substr(last+1);
1510 int status = system(command_remote_stream.str().c_str());
1513 INFOS("copy of the MPI machine file failed ! - sorry !");
1517 // Generating the command
1518 std::string command_begin("");
1519 std::string command_end("");
1521 LogConfiguration(log_type, "nodes", container_name, hostname, command_begin, command_end);
1522 command_nodes << command_begin;
1524 // Adding connection command
1525 // We can only have a remote execution with
1526 // a SALOME application
1527 if (remote_execution)
1529 ASSERT(getenv("NSHOST"));
1530 ASSERT(getenv("NSPORT"));
1532 command_nodes << resource_definition->protocol.in();
1533 command_nodes << " -l ";
1534 command_nodes << resource_definition->username.in();
1535 command_nodes << " " << hostname;
1536 command_nodes << " " << resource_definition->applipath.in();
1537 command_nodes << "/runRemote.sh ";
1538 command_nodes << getenv("NSHOST") << " "; // hostname of CORBA name server
1539 command_nodes << getenv("NSPORT") << " "; // port of CORBA name server
1542 if (std::string(resource_definition->mpiImpl.in()) == "lam")
1544 command_nodes << "mpiexec -ssi boot ";
1545 command_nodes << "-machinefile " << machine_file_name << " ";
1546 command_nodes << "-n " << params.nb_proc;
1550 command_nodes << "mpirun -np " << params.nb_proc;
1552 command_nodes << " " << exe_name;
1553 command_nodes << " " << container_name;
1554 command_nodes << " " << params.parallelLib.in();
1555 command_nodes << " " << proxy_hostname;
1556 command_nodes << " -";
1557 AddOmninamesParams(command_nodes);
1559 // We don't put hostname, because nodes are registered in the resource of the proxy
1560 for (int i= 0; i < params.nb_proc; i++)
1561 vect_machine.push_back(proxy_hostname);
1563 command_nodes << command_end;
1565 return command_nodes.str();
1569 SALOME_ContainerManager::LogConfiguration(const std::string & log_type,
1570 const std::string & exe_type,
1571 const std::string & container_name,
1572 const std::string & hostname,
1573 std::string & begin,
1576 if(log_type == "xterm")
1578 begin = "xterm -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export PATH=$PATH;";
1581 else if(log_type == "xterm_debug")
1583 begin = "xterm -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export PATH=$PATH;";
1588 // default into a file...
1589 std::string logFilename = "/tmp/" + container_name + "_" + hostname + "_" + exe_type + "_";
1590 logFilename += std::string(getenv("USER")) + ".log";
1591 end = " > " + logFilename + " 2>&1 & ";
1596 SALOME_ContainerManager::LaunchPaCOProxyContainer(const std::string& command,
1597 const Engines::ContainerParameters& params,
1598 const std::string & hostname)
1600 PaCO::InterfaceManager_ptr container_proxy = PaCO::InterfaceManager::_nil();
1602 MESSAGE("[LaunchPaCOProxyContainer] Launch command");
1603 int status = system(command.c_str());
1605 INFOS("[LaunchPaCOProxyContainer] failed : system command status -1");
1606 return container_proxy;
1608 else if (status == 217) {
1609 INFOS("[LaunchPaCOProxyContainer] failed : system command status 217");
1610 return container_proxy;
1613 int count = TIME_OUT_TO_LAUNCH_CONT;
1614 CORBA::Object_var obj = CORBA::Object::_nil();
1615 std::string containerNameInNS = _NS->BuildContainerNameForNS(params.container_name.in(),
1617 MESSAGE("[LaunchParallelContainer] Waiting for Parallel Container proxy : " << containerNameInNS);
1619 while (CORBA::is_nil(obj) && count)
1623 obj = _NS->Resolve(containerNameInNS.c_str());
1628 container_proxy = PaCO::InterfaceManager::_narrow(obj);
1630 catch(CORBA::SystemException& e)
1632 INFOS("[StarPaCOPPContainer] Exception in _narrow after LaunchParallelContainer for proxy !");
1633 INFOS("CORBA::SystemException : " << e);
1634 return container_proxy;
1636 catch(CORBA::Exception& e)
1638 INFOS("[StarPaCOPPContainer] Exception in _narrow after LaunchParallelContainer for proxy !");
1639 INFOS("CORBA::Exception" << e);
1640 return container_proxy;
1644 INFOS("[StarPaCOPPContainer] Exception in _narrow after LaunchParallelContainer for proxy !");
1645 INFOS("Unknown exception !");
1646 return container_proxy;
1648 if (CORBA::is_nil(container_proxy))
1650 INFOS("[StarPaCOPPContainer] PaCO::InterfaceManager::_narrow returns NIL !");
1651 return container_proxy;
1656 //=============================================================================
1657 /*! This method launches the parallel container.
1658 * It will may be placed on the ressources manager.
1660 * \param command to launch
1661 * \param container's parameters
1662 * \param name of the container
1664 * \return CORBA container reference
1666 //=============================================================================
1668 SALOME_ContainerManager::LaunchPaCONodeContainer(const std::string& command,
1669 const Engines::ContainerParameters& params,
1670 const std::string& name,
1671 SALOME_ContainerManager::actual_launch_machine_t & vect_machine)
1673 INFOS("[LaunchPaCONodeContainer] Launch command");
1674 int status = system(command.c_str());
1676 INFOS("[LaunchPaCONodeContainer] failed : system command status -1");
1679 else if (status == 217) {
1680 INFOS("[LaunchPaCONodeContainer] failed : system command status 217");
1684 INFOS("[LaunchPaCONodeContainer] Waiting for the nodes of the parallel container");
1685 // We are waiting all the nodes
1686 for (int i = 0; i < params.nb_proc; i++)
1688 CORBA::Object_var obj = CORBA::Object::_nil();
1689 std::string theMachine(vect_machine[i]);
1691 std::ostringstream tmp;
1693 std::string proc_number = tmp.str();
1694 std::string container_node_name = name + proc_number;
1695 std::string containerNameInNS = _NS->BuildContainerNameForNS((char*) container_node_name.c_str(), theMachine.c_str());
1696 INFOS("[LaunchPaCONodeContainer] Waiting for Parallel Container node " << containerNameInNS << " on " << theMachine);
1697 int count = TIME_OUT_TO_LAUNCH_CONT;
1698 while (CORBA::is_nil(obj) && count) {
1701 obj = _NS->Resolve(containerNameInNS.c_str());
1703 if (CORBA::is_nil(obj))
1705 INFOS("[LaunchPaCONodeContainer] Launch of node failed (or not found) !");
1714 Engines::Container_ptr
1715 SALOME_ContainerManager::StartPaCOPPContainer(const Engines::ContainerParameters& params,
1716 std::string resource_selected)
1718 Engines::Container_ptr ret = Engines::Container::_nil();
1719 INFOS("[StarPaCOPPContainer] is disabled !");
1720 INFOS("[StarPaCOPPContainer] recompile SALOME Kernel to enable PaCO++ parallel extension");
1725 SALOME_ContainerManager::BuildCommandToLaunchPaCOProxyContainer(const Engines::ContainerParameters& params,
1726 std::string machine_file_name,
1727 std::string & proxy_hostname)
1733 SALOME_ContainerManager::BuildCommandToLaunchPaCONodeContainer(const Engines::ContainerParameters& params,
1734 const std::string & machine_file_name,
1735 SALOME_ContainerManager::actual_launch_machine_t & vect_machine,
1736 const std::string & proxy_hostname)
1741 SALOME_ContainerManager::LogConfiguration(const std::string & log_type,
1742 const std::string & exe_type,
1743 const std::string & container_name,
1744 const std::string & hostname,
1745 std::string & begin,
1751 SALOME_ContainerManager::LaunchPaCOProxyContainer(const std::string& command,
1752 const Engines::ContainerParameters& params,
1753 const std::string& hostname)
1755 CORBA::Object_ptr ret = CORBA::Object::_nil();
1760 SALOME_ContainerManager::LaunchPaCONodeContainer(const std::string& command,
1761 const Engines::ContainerParameters& params,
1762 const std::string& name,
1763 SALOME_ContainerManager::actual_launch_machine_t & vect_machine)