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" || 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" || 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();
524 bool isPythonContainer(const char* ContainerName);
526 //=============================================================================
528 * This is no longer valid (C++ container are also python containers)
530 //=============================================================================
531 bool isPythonContainer(const char* ContainerName)
534 int len = strlen(ContainerName);
537 if (strcmp(ContainerName + len - 2, "Py") == 0)
543 //=============================================================================
545 * Builds the script to be launched
547 * If SALOME Application not defined ($APPLI),
548 * see BuildTempFileToLaunchRemoteContainer()
550 * Else rely on distant configuration. Command is under the form (example):
551 * ssh user@machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \
552 * SALOME_Container containerName &"
554 * - where user is ommited if not specified in CatalogResources,
555 * - where distant path is always relative to user@machine $HOME, and
556 * equal to $APPLI if not specified in CatalogResources,
557 * - where hostNS is the hostname of CORBA naming server (set by scripts to
558 * use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh)
559 * - where portNS is the port used by CORBA naming server (set by scripts to
560 * use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh)
561 * - where workingdir is the requested working directory for the container.
562 * If WORKINGDIR (and workingdir) is not present the working dir will be $HOME
564 //=============================================================================
567 SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer
568 (const string& resource_name,
569 const Engines::ContainerParameters& params, const std::string& container_exe)
573 if (!_isAppliSalomeDefined)
574 command = BuildTempFileToLaunchRemoteContainer(resource_name, params);
578 Engines::ResourceDefinition_var resource_definition = _ResManager->GetResourceDefinition(resource_name.c_str());
579 std::string hostname(resource_definition->hostname.in());
580 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesDescr(resource_name);
584 if ((params.resource_params.nb_node <= 0) && (params.resource_params.nb_proc_per_node <= 0))
586 else if (params.resource_params.nb_node == 0)
587 nbproc = params.resource_params.nb_proc_per_node;
588 else if (params.resource_params.nb_proc_per_node == 0)
589 nbproc = params.resource_params.nb_node;
591 nbproc = params.resource_params.nb_node * params.resource_params.nb_proc_per_node;
594 // "ssh -l user machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \
595 // SALOME_Container containerName &"
596 if (resInfo.Protocol == rsh)
598 else if (resInfo.Protocol == ssh)
601 throw SALOME_Exception("Unknown protocol");
603 if (resInfo.UserName != "")
606 command += resInfo.UserName;
610 command += resInfo.HostName;
613 if (resInfo.AppliPath != "")
614 command += resInfo.AppliPath; // path relative to user@machine $HOME
617 ASSERT(getenv("APPLI"));
618 command += getenv("APPLI"); // path relative to user@machine $HOME
621 command += "/runRemote.sh ";
623 ASSERT(getenv("NSHOST"));
624 command += getenv("NSHOST"); // hostname of CORBA name server
627 ASSERT(getenv("NSPORT"));
628 command += getenv("NSPORT"); // port of CORBA name server
630 std::string wdir = params.workingdir.in();
633 command += " WORKINGDIR ";
635 if(wdir == "$TEMPDIR")
637 command += wdir; // requested working directory
643 command += " mpirun -np ";
644 std::ostringstream o;
648 command += "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
649 #elif defined(WITHOPENMPI)
650 if( getenv("OMPI_URI_FILE") == NULL )
651 command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
653 command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
654 command += getenv("OMPI_URI_FILE");
657 command += " SALOME_MPIContainer ";
660 command += " " +container_exe+ " ";
662 command += _NS->ContainerName(params);
664 AddOmninamesParams(command);
666 MESSAGE("command =" << command);
672 //=============================================================================
674 * builds the command to be launched.
676 //=============================================================================
678 SALOME_ContainerManager::BuildCommandToLaunchLocalContainer
679 (const Engines::ContainerParameters& params, const std::string& machinesFile, const std::string& container_exe)
681 _TmpFileName = BuildTemporaryFileName();
691 if ( (params.resource_params.nb_node <= 0) && (params.resource_params.nb_proc_per_node <= 0) )
693 else if ( params.resource_params.nb_node == 0 )
694 nbproc = params.resource_params.nb_proc_per_node;
695 else if ( params.resource_params.nb_proc_per_node == 0 )
696 nbproc = params.resource_params.nb_node;
698 nbproc = params.resource_params.nb_node * params.resource_params.nb_proc_per_node;
702 if( getenv("LIBBATCH_NODEFILE") != NULL )
703 o << "-machinefile " << machinesFile << " ";
706 o << "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
707 #elif defined(WITHOPENMPI)
708 if( getenv("OMPI_URI_FILE") == NULL )
709 o << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
712 o << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
713 o << getenv("OMPI_URI_FILE");
717 if (isPythonContainer(params.container_name))
718 o << " pyMPI SALOME_ContainerPy.py ";
720 o << " SALOME_MPIContainer ";
725 std::string wdir=params.workingdir.in();
728 // a working directory is requested
729 if(wdir == "$TEMPDIR")
731 // a new temporary directory is requested
732 string dir = Kernel_Utils::GetTmpDir();
734 o << "cd /d " << dir << endl;
736 o << "cd " << dir << ";";
742 // a permanent directory is requested use it or create it
744 o << "mkdir " + wdir << endl;
745 o << "cd /D " + wdir << endl;
747 o << "mkdir -p " << wdir << " && cd " << wdir + ";";
751 if (isPythonContainer(params.container_name))
752 o << "SALOME_ContainerPy.py ";
754 o << container_exe + " ";
758 o << _NS->ContainerName(params);
760 AddOmninamesParams(o);
762 ofstream command_file( _TmpFileName.c_str() );
763 command_file << o.str();
764 command_file.close();
767 chmod(_TmpFileName.c_str(), 0x1ED);
769 command = _TmpFileName;
771 MESSAGE("Command is file ... " << command);
772 MESSAGE("Command is ... " << o.str());
777 //=============================================================================
779 * removes the generated temporary file in case of a remote launch.
781 //=============================================================================
783 void SALOME_ContainerManager::RmTmpFile(std::string& tmpFileName)
785 int lenght = tmpFileName.size();
789 string command = "del /F ";
791 string command = "rm ";
794 command += tmpFileName.substr(0, lenght - 3 );
796 command += tmpFileName;
798 system(command.c_str());
799 //if dir is empty - remove it
800 string tmp_dir = Kernel_Utils::GetDirByPath( tmpFileName );
801 if ( Kernel_Utils::IsEmptyDir( tmp_dir ) )
804 command = "del /F " + tmp_dir;
806 command = "rmdir " + tmp_dir;
808 system(command.c_str());
813 //=============================================================================
815 * add to command all options relative to naming service.
817 //=============================================================================
819 void SALOME_ContainerManager::AddOmninamesParams(string& command) const
821 CORBA::String_var iorstr = _NS->getIORaddr();
822 command += "ORBInitRef NameService=";
826 //=============================================================================
828 * add to command all options relative to naming service.
830 //=============================================================================
832 void SALOME_ContainerManager::AddOmninamesParams(ofstream& fileStream) const
834 CORBA::String_var iorstr = _NS->getIORaddr();
835 fileStream << "ORBInitRef NameService=";
836 fileStream << iorstr;
839 //=============================================================================
841 * add to command all options relative to naming service.
843 //=============================================================================
845 void SALOME_ContainerManager::AddOmninamesParams(ostringstream& oss) const
847 CORBA::String_var iorstr = _NS->getIORaddr();
848 oss << "ORBInitRef NameService=";
852 //=============================================================================
854 * generate a file name in /tmp directory
856 //=============================================================================
858 string SALOME_ContainerManager::BuildTemporaryFileName() const
860 //build more complex file name to support multiple salome session
861 string aFileName = Kernel_Utils::GetTmpFileName();
870 //=============================================================================
872 * Builds in a temporary file the script to be launched.
874 * Used if SALOME Application ($APPLI) is not defined.
875 * The command is build with data from CatalogResources, in which every path
876 * used on remote computer must be defined.
878 //=============================================================================
881 SALOME_ContainerManager::BuildTempFileToLaunchRemoteContainer
882 (const string& resource_name,
883 const Engines::ContainerParameters& params) throw(SALOME_Exception)
887 _TmpFileName = BuildTemporaryFileName();
888 ofstream tempOutputFile;
889 tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
890 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesDescr(resource_name);
891 tempOutputFile << "#! /bin/sh" << endl;
895 tempOutputFile << "export SALOME_trace=local" << endl; // mkr : 27.11.2006 : PAL13967 - Distributed supervision graphs - Problem with "SALOME_trace"
896 //tempOutputFile << "source " << resInfo.PreReqFilePath << endl;
902 tempOutputFile << "mpirun -np ";
905 if ( (params.resource_params.nb_node <= 0) && (params.resource_params.nb_proc_per_node <= 0) )
907 else if ( params.resource_params.nb_node == 0 )
908 nbproc = params.resource_params.nb_proc_per_node;
909 else if ( params.resource_params.nb_proc_per_node == 0 )
910 nbproc = params.resource_params.nb_node;
912 nbproc = params.resource_params.nb_node * params.resource_params.nb_proc_per_node;
914 std::ostringstream o;
916 tempOutputFile << nbproc << " ";
918 tempOutputFile << "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
919 #elif defined(WITHOPENMPI)
920 if( getenv("OMPI_URI_FILE") == NULL )
921 tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
923 tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
924 tempOutputFile << getenv("OMPI_URI_FILE");
929 tempOutputFile << getenv("KERNEL_ROOT_DIR") << "/bin/salome/";
933 if (isPythonContainer(params.container_name))
934 tempOutputFile << " pyMPI SALOME_ContainerPy.py ";
936 tempOutputFile << " SALOME_MPIContainer ";
941 if (isPythonContainer(params.container_name))
942 tempOutputFile << "SALOME_ContainerPy.py ";
944 tempOutputFile << "SALOME_Container ";
947 tempOutputFile << _NS->ContainerName(params) << " -";
948 AddOmninamesParams(tempOutputFile);
949 tempOutputFile << " &" << endl;
950 tempOutputFile.flush();
951 tempOutputFile.close();
953 chmod(_TmpFileName.c_str(), 0x1ED);
960 if (resInfo.Protocol == rsh)
963 string commandRcp = "rcp ";
964 commandRcp += _TmpFileName;
966 commandRcp += resInfo.HostName;
968 commandRcp += _TmpFileName;
969 status = system(commandRcp.c_str());
972 else if (resInfo.Protocol == ssh)
975 string commandRcp = "scp ";
976 commandRcp += _TmpFileName;
978 commandRcp += resInfo.HostName;
980 commandRcp += _TmpFileName;
981 status = system(commandRcp.c_str());
984 throw SALOME_Exception("Unknown protocol");
987 throw SALOME_Exception("Error of connection on remote host");
989 command += resInfo.HostName;
990 _CommandForRemAccess = command;
992 command += _TmpFileName;
1000 string SALOME_ContainerManager::GetMPIZeroNode(const string machine, const string machinesFile)
1005 string tmpFile = BuildTemporaryFileName();
1007 if( getenv("LIBBATCH_NODEFILE") == NULL )
1009 if (_isAppliSalomeDefined)
1011 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesDescr(machine);
1013 if (resInfo.Protocol == rsh)
1015 else if (resInfo.Protocol == ssh)
1018 throw SALOME_Exception("Unknown protocol");
1020 if (resInfo.UserName != "")
1023 command += resInfo.UserName;
1027 command += resInfo.HostName;
1030 if (resInfo.AppliPath != "")
1031 command += resInfo.AppliPath; // path relative to user@machine $HOME
1034 ASSERT(getenv("APPLI"));
1035 command += getenv("APPLI"); // path relative to user@machine $HOME
1038 command += "/runRemote.sh ";
1040 ASSERT(getenv("NSHOST"));
1041 command += getenv("NSHOST"); // hostname of CORBA name server
1044 ASSERT(getenv("NSPORT"));
1045 command += getenv("NSPORT"); // port of CORBA name server
1047 command += " mpirun -np 1 hostname > " + tmpFile;
1050 command = "mpirun -np 1 hostname > " + tmpFile;
1053 command = "mpirun -np 1 -machinefile " + machinesFile + " hostname > " + tmpFile;
1055 status = system(command.c_str());
1057 ifstream fp(tmpFile.c_str(),ios::in);
1066 string SALOME_ContainerManager::machinesFile(const int nbproc)
1069 string nodesFile = getenv("LIBBATCH_NODEFILE");
1070 string machinesFile = Kernel_Utils::GetTmpFileName();
1071 ifstream fpi(nodesFile.c_str(),ios::in);
1072 ofstream fpo(machinesFile.c_str(),ios::out);
1074 _numInstanceMutex.lock();
1076 for(int i=0;i<_nbprocUsed;i++)
1079 for(int i=0;i<nbproc;i++)
1083 throw SALOME_Exception("You ask more processes than batch session have allocated!");
1085 _nbprocUsed += nbproc;
1089 _numInstanceMutex.unlock();
1091 return machinesFile;
1096 SALOME_ContainerManager::checkPaCOParameters(Engines::ContainerParameters & params, std::string resource_selected)
1100 // Step 1 : check ContainerParameters
1101 // Check container_name, has to be defined
1102 if (std::string(params.container_name.in()) == "")
1104 INFOS("[checkPaCOParameters] You must define a container_name to launch a PaCO++ container");
1107 // Check parallelLib
1108 std::string parallelLib = params.parallelLib.in();
1109 if (parallelLib != "Mpi" && parallelLib != "Dummy")
1111 INFOS("[checkPaCOParameters] parallelLib is not correctly defined");
1112 INFOS("[checkPaCOParameters] you can chosse between: Mpi and Dummy");
1113 INFOS("[checkPaCOParameters] you entered: " << parallelLib);
1117 if (params.nb_proc <= 0)
1119 INFOS("[checkPaCOParameters] You must define a nb_proc > 0");
1123 // Step 2 : check resource_selected
1124 Engines::ResourceDefinition_var resource_definition = _ResManager->GetResourceDefinition(resource_selected.c_str());
1125 std::string protocol = resource_definition->protocol.in();
1126 std::string username = resource_definition->username.in();
1127 std::string applipath = resource_definition->applipath.in();
1129 if (protocol == "" || username == "" || applipath == "")
1131 INFOS("[checkPaCOParameters] resource selected is not well defined");
1132 INFOS("[checkPaCOParameters] resource name: " << resource_definition->name.in());
1133 INFOS("[checkPaCOParameters] resource hostname: " << resource_definition->hostname.in());
1134 INFOS("[checkPaCOParameters] resource protocol: " << protocol);
1135 INFOS("[checkPaCOParameters] resource username: " << username);
1136 INFOS("[checkPaCOParameters] resource applipath: " << applipath);
1142 #ifdef WITH_PACO_PARALLEL
1144 //=============================================================================
1146 * Start a suitable PaCO++ Parallel Container in a list of machines.
1147 * \param params Container Parameters required for the container
1148 * \return CORBA container reference.
1150 //=============================================================================
1151 Engines::Container_ptr
1152 SALOME_ContainerManager::StartPaCOPPContainer(const Engines::ContainerParameters& params_const,
1153 std::string resource_selected)
1155 CORBA::Object_var obj;
1156 PaCO::InterfaceManager_var container_proxy;
1157 Engines::Container_ptr ret = Engines::Container::_nil();
1158 Engines::ContainerParameters params(params_const);
1159 params.resource_params.name = CORBA::string_dup(resource_selected.c_str());
1161 // Step 0 : Check parameters
1162 if (!checkPaCOParameters(params, resource_selected))
1164 INFOS("[StartPaCOPPContainer] check parameters failed ! see logs...");
1168 // Step 1 : Starting a new parallel container !
1169 INFOS("[StartPaCOPPContainer] Starting a PaCO++ parallel container");
1170 INFOS("[StartPaCOPPContainer] on resource : " << resource_selected);
1172 // Step 2 : Get a MachineFile for the parallel container
1173 std::string machine_file_name = _ResManager->getMachineFile(resource_selected,
1175 params.parallelLib.in());
1177 if (machine_file_name == "")
1179 INFOS("[StartPaCOPPContainer] Machine file generation failed");
1183 // Step 3 : starting parallel container proxy
1184 std::string command_proxy("");
1185 std::string proxy_machine;
1188 command_proxy = BuildCommandToLaunchPaCOProxyContainer(params, machine_file_name, proxy_machine);
1190 catch(const SALOME_Exception & ex)
1192 INFOS("[StartPaCOPPContainer] Exception in BuildCommandToLaunchPaCOContainer");
1196 obj = LaunchPaCOProxyContainer(command_proxy, params, proxy_machine);
1197 if (CORBA::is_nil(obj))
1199 INFOS("[StartPaCOPPContainer] LaunchPaCOContainer for proxy returns NIL !");
1202 container_proxy = PaCO::InterfaceManager::_narrow(obj);
1203 MESSAGE("[StartPaCOPPContainer] PaCO container proxy is launched");
1205 // Step 4 : starting parallel container nodes
1206 std::string command_nodes("");
1207 SALOME_ContainerManager::actual_launch_machine_t nodes_machines;
1210 command_nodes = BuildCommandToLaunchPaCONodeContainer(params, machine_file_name, nodes_machines, proxy_machine);
1212 catch(const SALOME_Exception & ex)
1214 INFOS("[StarPaCOPPContainer] Exception in BuildCommandToLaunchPaCONodeContainer");
1219 std::string container_generic_node_name = std::string(params.container_name.in()) + std::string("Node");
1220 bool result = LaunchPaCONodeContainer(command_nodes, params, container_generic_node_name, nodes_machines);
1223 INFOS("[StarPaCOPPContainer] LaunchPaCONodeContainer failed !");
1224 // Il faut tuer le proxy
1227 Engines::Container_var proxy = Engines::Container::_narrow(container_proxy);
1232 INFOS("[StarPaCOPPContainer] Exception catched from proxy Shutdown...");
1237 // Step 4 : connecting nodes and the proxy to actually create a parallel container
1238 for (int i = 0; i < params.nb_proc; i++)
1240 std::ostringstream tmp;
1242 std::string proc_number = tmp.str();
1243 std::string container_node_name = container_generic_node_name + proc_number;
1245 std::string theNodeMachine(nodes_machines[i]);
1246 std::string containerNameInNS = _NS->BuildContainerNameForNS(container_node_name.c_str(), theNodeMachine.c_str());
1247 obj = _NS->Resolve(containerNameInNS.c_str());
1248 if (CORBA::is_nil(obj))
1250 INFOS("[StarPaCOPPContainer] CONNECTION FAILED From Naming Service !");
1251 INFOS("[StarPaCOPPContainer] Container name is " << containerNameInNS);
1256 MESSAGE("[StarPaCOPPContainer] Deploying node : " << container_node_name);
1257 PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(obj);
1259 MESSAGE("[StarPaCOPPContainer] node " << container_node_name << " is deployed");
1261 catch(CORBA::SystemException& e)
1263 INFOS("[StarPaCOPPContainer] Exception in deploying node : " << containerNameInNS);
1264 INFOS("CORBA::SystemException : " << e);
1267 catch(CORBA::Exception& e)
1269 INFOS("[StarPaCOPPContainer] Exception in deploying node : " << containerNameInNS);
1270 INFOS("CORBA::Exception" << e);
1275 INFOS("[StarPaCOPPContainer] Exception in deploying node : " << containerNameInNS);
1276 INFOS("Unknown exception !");
1281 // Step 5 : starting parallel container
1284 MESSAGE ("[StarPaCOPPContainer] Starting parallel object");
1285 container_proxy->start();
1286 MESSAGE ("[StarPaCOPPContainer] Parallel object is started");
1287 ret = Engines::Container::_narrow(container_proxy);
1289 catch(CORBA::SystemException& e)
1291 INFOS("Caught CORBA::SystemException. : " << e);
1293 catch(PortableServer::POA::ServantAlreadyActive&)
1295 INFOS("Caught CORBA::ServantAlreadyActiveException");
1297 catch(CORBA::Exception&)
1299 INFOS("Caught CORBA::Exception.");
1301 catch(std::exception& exc)
1303 INFOS("Caught std::exception - "<<exc.what());
1307 INFOS("Caught unknown exception.");
1313 SALOME_ContainerManager::BuildCommandToLaunchPaCOProxyContainer(const Engines::ContainerParameters& params,
1314 std::string machine_file_name,
1315 std::string & proxy_hostname)
1317 // In the proxy case, we always launch a Dummy Proxy
1318 std::string exe_name = "SALOME_ParallelContainerProxyDummy";
1319 std::string container_name = params.container_name.in();
1321 // Convert nb_proc in string
1322 std::ostringstream tmp_string;
1323 tmp_string << params.nb_proc;
1324 std::string nb_proc_str = tmp_string.str();
1326 // Get resource definition
1327 Engines::ResourceDefinition_var resource_definition =
1328 _ResManager->GetResourceDefinition(params.resource_params.name);
1331 std::string hostname;
1332 std::ifstream machine_file(machine_file_name.c_str());
1333 std::getline(machine_file, hostname, ' ');
1334 size_t found = hostname.find('\n');
1335 if (found!=string::npos)
1336 hostname.erase(found, 1); // Remove \n
1337 proxy_hostname = hostname;
1338 MESSAGE("[BuildCommandToLaunchPaCOProxyContainer] machine file name extracted is " << hostname);
1341 bool remote_execution = false;
1342 if (hostname != std::string(Kernel_Utils::GetHostname()))
1344 MESSAGE("[BuildCommandToLaunchPaCOProxyContainer] remote machine case detected !");
1345 remote_execution = true;
1348 // Log environnement
1349 std::string log_type("");
1350 char * get_val = getenv("PARALLEL_LOG");
1354 // Generating the command
1355 std::string command_begin("");
1356 std::string command_end("");
1357 std::ostringstream command;
1359 LogConfiguration(log_type, "proxy", container_name, hostname, command_begin, command_end);
1360 command << command_begin;
1362 // Adding connection command
1363 // We can only have a remote execution with
1364 // a SALOME application
1365 if (remote_execution)
1367 ASSERT(getenv("NSHOST"));
1368 ASSERT(getenv("NSPORT"));
1370 command << resource_definition->protocol.in();
1372 command << resource_definition->username.in();
1373 command << " " << hostname;
1374 command << " " << resource_definition->applipath.in();
1375 command << "/runRemote.sh ";
1376 command << getenv("NSHOST") << " "; // hostname of CORBA name server
1377 command << getenv("NSPORT") << " "; // port of CORBA name server
1380 command << exe_name;
1381 command << " " << container_name;
1382 command << " Dummy";
1383 command << " " << hostname;
1384 command << " " << nb_proc_str;
1386 AddOmninamesParams(command);
1389 command << command_end;
1390 MESSAGE("[BuildCommandToLaunchPaCOProxyContainer] Command is: " << command.str());
1392 return command.str();
1396 SALOME_ContainerManager::BuildCommandToLaunchPaCONodeContainer(const Engines::ContainerParameters& params,
1397 const std::string & machine_file_name,
1398 SALOME_ContainerManager::actual_launch_machine_t & vect_machine,
1399 const std::string & proxy_hostname)
1402 std::string exe_name = "SALOME_ParallelContainerNode";
1403 exe_name += params.parallelLib.in();
1404 std::string container_name = params.container_name.in();
1406 // Convert nb_proc in string
1407 std::ostringstream nb_proc_stream;
1408 nb_proc_stream << params.nb_proc;
1410 // Get resource definition
1411 Engines::ResourceDefinition_var resource_definition =
1412 _ResManager->GetResourceDefinition(params.resource_params.name);
1414 // Log environnement
1415 std::string log_type("");
1416 char * get_val = getenv("PARALLEL_LOG");
1420 // Now the command is different according to paralleLib
1421 std::ostringstream command_nodes;
1422 std::ifstream machine_file(machine_file_name.c_str());
1423 if (std::string(params.parallelLib.in()) == "Dummy")
1425 for (int i= 0; i < params.nb_proc; i++)
1428 std::string hostname;
1429 std::getline(machine_file, hostname);
1430 MESSAGE("[BuildCommandToLaunchPaCONodeContainer] machine file name extracted is " << hostname);
1433 bool remote_execution = false;
1434 if (hostname != std::string(Kernel_Utils::GetHostname()))
1436 MESSAGE("[BuildCommandToLaunchPaCONodeContainer] remote machine case detected !");
1437 remote_execution = true;
1440 // For each node we have a new command
1441 // Generating the command
1442 std::ostringstream command_node_stream;
1443 std::string command_node_begin("");
1444 std::string command_node_end("");
1445 std::ostringstream node_number;
1447 std::string container_node_name = container_name + node_number.str();
1448 LogConfiguration(log_type, "node", container_node_name, hostname, command_node_begin, command_node_end);
1450 // Adding connection command
1451 // We can only have a remote execution with
1452 // a SALOME application
1453 if (remote_execution)
1455 ASSERT(getenv("NSHOST"));
1456 ASSERT(getenv("NSPORT"));
1458 command_node_stream << resource_definition->protocol.in();
1459 command_node_stream << " -l ";
1460 command_node_stream << resource_definition->username.in();
1461 command_node_stream << " " << hostname;
1462 command_node_stream << " " << resource_definition->applipath.in();
1463 command_node_stream << "/runRemote.sh ";
1464 command_node_stream << getenv("NSHOST") << " "; // hostname of CORBA name server
1465 command_node_stream << getenv("NSPORT") << " "; // port of CORBA name server
1468 command_node_stream << exe_name;
1469 command_node_stream << " " << container_name;
1470 command_node_stream << " " << params.parallelLib.in();
1471 command_node_stream << " " << proxy_hostname;
1472 command_node_stream << " " << node_number.str();
1473 command_node_stream << " -";
1474 AddOmninamesParams(command_node_stream);
1476 command_nodes << command_node_begin << command_node_stream.str() << command_node_end;
1477 vect_machine.push_back(hostname);
1481 else if (std::string(params.parallelLib.in()) == "Mpi")
1484 std::string hostname;
1485 std::getline(machine_file, hostname, ' ');
1486 MESSAGE("[BuildCommandToLaunchPaCONodeContainer] machine file name extracted is " << hostname);
1489 bool remote_execution = false;
1490 if (hostname != std::string(Kernel_Utils::GetHostname()))
1492 MESSAGE("[BuildCommandToLaunchPaCONodeContainer] remote machine case detected !");
1493 remote_execution = true;
1496 // In case of Mpi and Remote, we copy machine_file in the applipath
1497 // scp mpi_machine_file user@machine:Path
1498 std::ostringstream command_remote_stream;
1499 std::string::size_type last = machine_file_name.find_last_of("/");
1500 if (last == std::string::npos)
1503 std::string protocol = resource_definition->protocol.in();
1504 if (protocol == "rsh")
1505 command_remote_stream << "rcp ";
1507 command_remote_stream << "scp ";
1508 command_remote_stream << machine_file_name << " ";
1509 command_remote_stream << resource_definition->username.in() << "@";
1510 command_remote_stream << hostname << ":" << resource_definition->applipath.in();
1511 command_remote_stream << "/" << machine_file_name.substr(last+1);
1513 int status = system(command_remote_stream.str().c_str());
1516 INFOS("copy of the MPI machine file failed ! - sorry !");
1520 // Generating the command
1521 std::string command_begin("");
1522 std::string command_end("");
1524 LogConfiguration(log_type, "nodes", container_name, hostname, command_begin, command_end);
1525 command_nodes << command_begin;
1527 // Adding connection command
1528 // We can only have a remote execution with
1529 // a SALOME application
1530 if (remote_execution)
1532 ASSERT(getenv("NSHOST"));
1533 ASSERT(getenv("NSPORT"));
1535 command_nodes << resource_definition->protocol.in();
1536 command_nodes << " -l ";
1537 command_nodes << resource_definition->username.in();
1538 command_nodes << " " << hostname;
1539 command_nodes << " " << resource_definition->applipath.in();
1540 command_nodes << "/runRemote.sh ";
1541 command_nodes << getenv("NSHOST") << " "; // hostname of CORBA name server
1542 command_nodes << getenv("NSPORT") << " "; // port of CORBA name server
1545 if (std::string(resource_definition->mpiImpl.in()) == "lam")
1547 command_nodes << "mpiexec -ssi boot ";
1548 command_nodes << "-machinefile " << machine_file_name << " ";
1549 command_nodes << "-n " << params.nb_proc;
1553 command_nodes << "mpirun -np " << params.nb_proc;
1555 command_nodes << " " << exe_name;
1556 command_nodes << " " << container_name;
1557 command_nodes << " " << params.parallelLib.in();
1558 command_nodes << " " << proxy_hostname;
1559 command_nodes << " -";
1560 AddOmninamesParams(command_nodes);
1562 // We don't put hostname, because nodes are registered in the resource of the proxy
1563 for (int i= 0; i < params.nb_proc; i++)
1564 vect_machine.push_back(proxy_hostname);
1566 command_nodes << command_end;
1568 return command_nodes.str();
1572 SALOME_ContainerManager::LogConfiguration(const std::string & log_type,
1573 const std::string & exe_type,
1574 const std::string & container_name,
1575 const std::string & hostname,
1576 std::string & begin,
1579 if(log_type == "xterm")
1581 begin = "xterm -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export PATH=$PATH;";
1584 else if(log_type == "xterm_debug")
1586 begin = "xterm -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export PATH=$PATH;";
1591 // default into a file...
1592 std::string logFilename = "/tmp/" + container_name + "_" + hostname + "_" + exe_type + "_";
1593 logFilename += std::string(getenv("USER")) + ".log";
1594 end = " > " + logFilename + " 2>&1 & ";
1599 SALOME_ContainerManager::LaunchPaCOProxyContainer(const std::string& command,
1600 const Engines::ContainerParameters& params,
1601 const std::string & hostname)
1603 PaCO::InterfaceManager_ptr container_proxy = PaCO::InterfaceManager::_nil();
1605 MESSAGE("[LaunchPaCOProxyContainer] Launch command");
1606 int status = system(command.c_str());
1608 INFOS("[LaunchPaCOProxyContainer] failed : system command status -1");
1609 return container_proxy;
1611 else if (status == 217) {
1612 INFOS("[LaunchPaCOProxyContainer] failed : system command status 217");
1613 return container_proxy;
1616 int count = TIME_OUT_TO_LAUNCH_CONT;
1617 CORBA::Object_var obj = CORBA::Object::_nil();
1618 std::string containerNameInNS = _NS->BuildContainerNameForNS(params.container_name.in(),
1620 MESSAGE("[LaunchParallelContainer] Waiting for Parallel Container proxy : " << containerNameInNS);
1622 while (CORBA::is_nil(obj) && count)
1626 obj = _NS->Resolve(containerNameInNS.c_str());
1631 container_proxy = PaCO::InterfaceManager::_narrow(obj);
1633 catch(CORBA::SystemException& e)
1635 INFOS("[StarPaCOPPContainer] Exception in _narrow after LaunchParallelContainer for proxy !");
1636 INFOS("CORBA::SystemException : " << e);
1637 return container_proxy;
1639 catch(CORBA::Exception& e)
1641 INFOS("[StarPaCOPPContainer] Exception in _narrow after LaunchParallelContainer for proxy !");
1642 INFOS("CORBA::Exception" << e);
1643 return container_proxy;
1647 INFOS("[StarPaCOPPContainer] Exception in _narrow after LaunchParallelContainer for proxy !");
1648 INFOS("Unknown exception !");
1649 return container_proxy;
1651 if (CORBA::is_nil(container_proxy))
1653 INFOS("[StarPaCOPPContainer] PaCO::InterfaceManager::_narrow returns NIL !");
1654 return container_proxy;
1659 //=============================================================================
1660 /*! This method launches the parallel container.
1661 * It will may be placed on the ressources manager.
1663 * \param command to launch
1664 * \param container's parameters
1665 * \param name of the container
1667 * \return CORBA container reference
1669 //=============================================================================
1671 SALOME_ContainerManager::LaunchPaCONodeContainer(const std::string& command,
1672 const Engines::ContainerParameters& params,
1673 const std::string& name,
1674 SALOME_ContainerManager::actual_launch_machine_t & vect_machine)
1676 INFOS("[LaunchPaCONodeContainer] Launch command");
1677 int status = system(command.c_str());
1679 INFOS("[LaunchPaCONodeContainer] failed : system command status -1");
1682 else if (status == 217) {
1683 INFOS("[LaunchPaCONodeContainer] failed : system command status 217");
1687 INFOS("[LaunchPaCONodeContainer] Waiting for the nodes of the parallel container");
1688 // We are waiting all the nodes
1689 for (int i = 0; i < params.nb_proc; i++)
1691 CORBA::Object_var obj = CORBA::Object::_nil();
1692 std::string theMachine(vect_machine[i]);
1694 std::ostringstream tmp;
1696 std::string proc_number = tmp.str();
1697 std::string container_node_name = name + proc_number;
1698 std::string containerNameInNS = _NS->BuildContainerNameForNS((char*) container_node_name.c_str(), theMachine.c_str());
1699 INFOS("[LaunchPaCONodeContainer] Waiting for Parallel Container node " << containerNameInNS << " on " << theMachine);
1700 int count = TIME_OUT_TO_LAUNCH_CONT;
1701 while (CORBA::is_nil(obj) && count) {
1704 obj = _NS->Resolve(containerNameInNS.c_str());
1706 if (CORBA::is_nil(obj))
1708 INFOS("[LaunchPaCONodeContainer] Launch of node failed (or not found) !");
1717 Engines::Container_ptr
1718 SALOME_ContainerManager::StartPaCOPPContainer(const Engines::ContainerParameters& params,
1719 std::string resource_selected)
1721 Engines::Container_ptr ret = Engines::Container::_nil();
1722 INFOS("[StarPaCOPPContainer] is disabled !");
1723 INFOS("[StarPaCOPPContainer] recompile SALOME Kernel to enable PaCO++ parallel extension");
1728 SALOME_ContainerManager::BuildCommandToLaunchPaCOProxyContainer(const Engines::ContainerParameters& params,
1729 std::string machine_file_name,
1730 std::string & proxy_hostname)
1736 SALOME_ContainerManager::BuildCommandToLaunchPaCONodeContainer(const Engines::ContainerParameters& params,
1737 const std::string & machine_file_name,
1738 SALOME_ContainerManager::actual_launch_machine_t & vect_machine,
1739 const std::string & proxy_hostname)
1744 SALOME_ContainerManager::LogConfiguration(const std::string & log_type,
1745 const std::string & exe_type,
1746 const std::string & container_name,
1747 const std::string & hostname,
1748 std::string & begin,
1754 SALOME_ContainerManager::LaunchPaCOProxyContainer(const std::string& command,
1755 const Engines::ContainerParameters& params,
1756 const std::string& hostname)
1758 CORBA::Object_ptr ret = CORBA::Object::_nil();
1763 SALOME_ContainerManager::LaunchPaCONodeContainer(const std::string& command,
1764 const Engines::ContainerParameters& params,
1765 const std::string& name,
1766 SALOME_ContainerManager::actual_launch_machine_t & vect_machine)