- else
- {
- INFOS("[LaunchParallelContainer] launching the nodes of the parallel container");
- // We are waiting all the nodes
- for (int i = 0; i < params.nb_component_nodes; i++)
- {
- obj = CORBA::Object::_nil();
- std::string theMachine(vect_machine[i]);
- // Name of the node
- std::ostringstream tmp;
- tmp << i;
- std::string proc_number = tmp.str();
- std::string container_node_name = name + proc_number;
- containerNameInNS = _NS->BuildContainerNameForNS((char*) container_node_name.c_str(), theMachine.c_str());
- INFOS("[LaunchParallelContainer] Waiting for Parallel Container node " << containerNameInNS << " on " << theMachine);
- while (CORBA::is_nil(obj) && count) {
-#ifndef WIN32
- sleep(1) ;
-#else
- Sleep(1000);
-#endif
- count-- ;
- obj = _NS->Resolve(containerNameInNS.c_str());
- }
- if (CORBA::is_nil(obj))
- {
- INFOS("[LaunchParallelContainer] Launch of node failed (or not found) !");
- return obj;
- }
- }
- }
- if (CORBA::is_nil(obj))
- INFOS("[LaunchParallelContainer] failed");
-
- return obj;
-}
-
-void SALOME_ContainerManager::fillBatchLaunchedContainers()
-{
- _batchLaunchedContainers.clear();
- _NS->Change_Directory("/Containers");
- vector<string> vec = _NS->list_directory_recurs();
- for(vector<string>::iterator iter = vec.begin();iter!=vec.end();iter++){
- CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
- Engines::Container_ptr cont=Engines::Container::_narrow(obj);
- if(!CORBA::is_nil(cont)){
- _batchLaunchedContainers.push_back(cont);
- }
- }
- _batchLaunchedContainersIter=_batchLaunchedContainers.begin();
-}
-
-//=============================================================================
-/*!
- * This is no longer valid (C++ container are also python containers)
- */
-//=============================================================================
-
-bool isPythonContainer(const char* ContainerName)
-{
- bool ret = false;
- int len = strlen(ContainerName);
-
- if (len >= 2)
- if (strcmp(ContainerName + len - 2, "Py") == 0)
- ret = true;
-
- return ret;
-}
-
-//=============================================================================
-/*!
- * Builds the script to be launched
- *
- * If SALOME Application not defined ($APPLI),
- * see BuildTempFileToLaunchRemoteContainer()
- *
- * Else rely on distant configuration. Command is under the form (example):
- * ssh user@machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \
- * SALOME_Container containerName &"
-
- * - where user is ommited if not specified in CatalogResources,
- * - where distant path is always relative to user@machine $HOME, and
- * equal to $APPLI if not specified in CatalogResources,
- * - where hostNS is the hostname of CORBA naming server (set by scripts to
- * use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh)
- * - where portNS is the port used by CORBA naming server (set by scripts to
- * use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh)
- * - where workingdir is the requested working directory for the container.
- * If WORKINGDIR (and workingdir) is not present the working dir will be $HOME
- */
-//=============================================================================
-
-string
-SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer
-(const string& machine,
- const Engines::MachineParameters& params, const std::string& container_exe)
-{
- string command;
- int nbproc;
-
- if ( ! _isAppliSalomeDefined )
- command = BuildTempFileToLaunchRemoteContainer(machine, params);
-
- else
- {
- const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(machine);
-
- if (params.isMPI)
- {
- if ( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) )
- nbproc = 1;
- else if ( params.nb_node == 0 )
- nbproc = params.nb_proc_per_node;
- else if ( params.nb_proc_per_node == 0 )
- nbproc = params.nb_node;
- else
- nbproc = params.nb_node * params.nb_proc_per_node;
- }
-
- // "ssh user@machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \
- // SALOME_Container containerName &"
-
- if (resInfo.Protocol == rsh)
- command = "rsh ";
- else if (resInfo.Protocol == ssh)
- command = "ssh ";
- else
- throw SALOME_Exception("Unknown protocol");
-
- if (resInfo.UserName != "")
- {
- command += resInfo.UserName;
- command += "@";
- }
-
- command += machine;
- command += " ";
-
- if (resInfo.AppliPath != "")
- command += resInfo.AppliPath; // path relative to user@machine $HOME
- else
- {
- ASSERT(getenv("APPLI"));
- command += getenv("APPLI"); // path relative to user@machine $HOME
- }
-
- command += "/runRemote.sh ";
-
- ASSERT(getenv("NSHOST"));
- command += getenv("NSHOST"); // hostname of CORBA name server
-
- command += " ";
- ASSERT(getenv("NSPORT"));
- command += getenv("NSPORT"); // port of CORBA name server
-
- std::string wdir=params.workingdir.in();
- if(wdir != "")
- {
- command += " WORKINGDIR ";
- command += " '";
- if(wdir == "$TEMPDIR")
- wdir="\\$TEMPDIR";
- command += wdir; // requested working directory
- command += "'";
- }
-
- if(params.isMPI)
- {
- command += " mpirun -np ";
- std::ostringstream o;
- o << nbproc << " ";
- command += o.str();
-#ifdef WITHLAM
- command += "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
-#elif defined(WITHOPENMPI)
- if( getenv("OMPI_URI_FILE") == NULL )
- command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
- else{
- command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
- command += getenv("OMPI_URI_FILE");
- }
-#endif
- command += " SALOME_MPIContainer ";
- }
- else
- command += " " +container_exe+ " ";
-
- command += _NS->ContainerName(params);
- command += " -";
- AddOmninamesParams(command);
-
- MESSAGE("command =" << command);
- }