X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FContainer%2FSALOME_ContainerManager.cxx;h=f709319f22cb268909d9a7ea7b2b1e8894c400f9;hb=888f04cad3e3fa57bf92c96789959fc87bfdd555;hp=e93f6672842e5988a536d228fa69519f770eddfd;hpb=8c09838dcaecbd88cd1bf9830e805c739124df89;p=modules%2Fkernel.git diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index e93f66728..f709319f2 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -25,6 +25,7 @@ #include "SALOME_LoadRateManager.hxx" #include "SALOME_NamingService.hxx" #include "SALOME_ResourcesManager_Client.hxx" +#include "SALOME_Embedded_NamingService.hxx" #include "SALOME_ModuleCatalog.hh" #include "Basics_Utils.hxx" #include "Basics_DirUtils.hxx" @@ -81,7 +82,7 @@ Utils_Mutex SALOME_ContainerManager::_systemMutex; */ //============================================================================= -SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService *ns) +SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *ns) : _nbprocUsed(1) { MESSAGE("constructor"); @@ -99,10 +100,9 @@ SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableSer threadPol->destroy(); PortableServer::ObjectId_var id = _poa->activate_object(this); CORBA::Object_var obj = _poa->id_to_reference(id); - Engines::ContainerManager_var refContMan = - Engines::ContainerManager::_narrow(obj); - - _NS->Register(refContMan,_ContainerManagerNameInNS); + Engines::ContainerManager_var refContMan = Engines::ContainerManager::_narrow(obj); + if(_NS) + _NS->Register(refContMan,_ContainerManagerNameInNS); _isAppliSalomeDefined = (GetenvThreadSafe("APPLI") != 0); #ifdef HAVE_MPI2 @@ -195,7 +195,8 @@ void SALOME_ContainerManager::Shutdown() { MESSAGE("Shutdown"); ShutdownContainers(); - _NS->Destroy_Name(_ContainerManagerNameInNS); + if(_NS) + _NS->Destroy_Name(_ContainerManagerNameInNS); PortableServer::ObjectId_var oid = _poa->servant_to_id(this); _poa->deactivate_object(oid); } @@ -209,7 +210,8 @@ void SALOME_ContainerManager::Shutdown() void SALOME_ContainerManager::ShutdownContainers() { MESSAGE("ShutdownContainers"); - + if(!_NS) + return ; SALOME::Session_var session = SALOME::Session::_nil(); CORBA::Long pid = 0; CORBA::Object_var objS = _NS->Resolve("/Kernel/Session"); @@ -235,7 +237,7 @@ void SALOME_ContainerManager::ShutdownContainers() if(!CORBA::is_nil(cont) && pid != cont->getPID()) lstCont.push_back((*iter)); } - catch(const CORBA::Exception& e) + catch(const CORBA::Exception&) { // ignore this entry and continue } @@ -368,7 +370,7 @@ Engines::Container_ptr SALOME_ContainerManager::GiveContainer(const Engines::Con break; } } - catch(const SALOME_Exception &ex) + catch(const SALOME_Exception &ex) //!< TODO: unused variable { MESSAGE("[GiveContainer] Exception in ResourceManager find !: " << ex.what()); return ret; @@ -380,11 +382,7 @@ Engines::Container_ptr SALOME_ContainerManager::GiveContainer(const Engines::Con std::string hostname(resource_definition.HostName); std::string containerNameInNS; if(params.isMPI){ - int nbproc; - if ( params.nb_proc <= 0 ) - nbproc = 1; - else - nbproc = params.nb_proc; + int nbproc = params.nb_proc <= 0 ? 1 : params.nb_proc; try { if( GetenvThreadSafe("LIBBATCH_NODEFILE") != NULL ) @@ -472,7 +470,7 @@ SALOME_ContainerManager::LaunchContainer(const Engines::ContainerParameters& par // Mpi already tested in step 5, specific code on BuildCommandToLaunch Local/Remote Container methods // TODO -> separates Mpi from Classic/Exe // Classic or Exe ? - std::string container_exe = "SALOME_Container"; // Classic container + std::string container_exe = this->_isSSL ? "SALOME_Container_No_NS_Serv" : "SALOME_Container"; // Classic container Engines::ContainerParameters local_params(params); int found=0; try @@ -531,7 +529,8 @@ SALOME_ContainerManager::LaunchContainer(const Engines::ContainerParameters& par // Launch remote command command += " \"ls /tmp >/dev/null 2>&1\""; - int status = SystemThreadSafe(command.c_str()); + // Anthony : command is NO MORE launched to improve dramatically time to launch containers + int status = 0; if (status != 0) { // Error on resource - cannot launch commands @@ -683,7 +682,7 @@ SALOME_ContainerManager::FindContainer(const Engines::ContainerParameters& param else return Engines::Container::_narrow(obj); } - catch(const CORBA::Exception& e) + catch(const CORBA::Exception&) { return Engines::Container::_nil(); } @@ -701,7 +700,7 @@ bool isPythonContainer(const char* ContainerName) { return false; // VSR 02/08/2013: Python containers are no more supported bool ret = false; - int len = strlen(ContainerName); + size_t len = strlen(ContainerName); if (len >= 2) if (strcmp(ContainerName + len - 2, "Py") == 0) @@ -741,21 +740,12 @@ SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer(const std::string& command = BuildTempFileToLaunchRemoteContainer(resource_name, params, tmpFileName); else { - int nbproc; const ParserResourcesType resInfo(_resManager->GetResourceDefinition(resource_name)); - if (params.isMPI) - { - if ( params.nb_proc <= 0 ) - nbproc = 1; - else - nbproc = params.nb_proc; - } - std::string wdir = params.workingdir.in(); - // "ssh -l user machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \ - // SALOME_Container containerName -ORBInitRef NameService=IOR:01000..." + // "ssh -l user machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir + // SALOME_Container containerName -ORBInitRef NameService=IOR:01000..." // or // "ssh -l user machine distantLauncher remote -p hostNS -m portNS -d dir // -- SALOME_Container contName -ORBInitRef NameService=IOR:01000..." @@ -765,6 +755,7 @@ SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer(const std::string& if(params.isMPI) { + int nbproc = params.nb_proc <= 0 ? 1 : params.nb_proc; command += " mpirun -np "; std::ostringstream o; o << nbproc << " "; @@ -805,18 +796,14 @@ std::string SALOME_ContainerManager::BuildCommandToLaunchLocalContainer(const En { tmpFileName = BuildTemporaryFileName(); std::string command; - int nbproc = 0; std::ostringstream o; if (params.isMPI) { - o << "mpirun -np "; + int nbproc = params.nb_proc <= 0 ? 1 : params.nb_proc; - if ( params.nb_proc <= 0 ) - nbproc = 1; - else - nbproc = params.nb_proc; + o << "mpirun -np "; o << nbproc << " "; @@ -878,11 +865,21 @@ std::string SALOME_ContainerManager::BuildCommandToLaunchLocalContainer(const En o << container_exe + " "; } + + o << _NS->ContainerName(params) << " "; - o << _NS->ContainerName(params); - o << " -"; - AddOmninamesParams(o); - + if( this->_isSSL ) + { + Engines::EmbeddedNamingService_var ns = GetEmbeddedNamingService(); + CORBA::String_var iorNS = _orb->object_to_string(ns); + o << iorNS; + } + else + { + o << "-"; + AddOmninamesParams(o); + } + std::ofstream command_file( tmpFileName.c_str() ); command_file << o.str(); command_file.close(); @@ -907,7 +904,7 @@ std::string SALOME_ContainerManager::BuildCommandToLaunchLocalContainer(const En void SALOME_ContainerManager::RmTmpFile(std::string& tmpFileName) { - int length = tmpFileName.size(); + size_t length = tmpFileName.size(); if ( length > 0) { #ifdef WIN32 @@ -965,11 +962,15 @@ void SALOME_ContainerManager::AddOmninamesParams(std::ostream& fileStream) const */ //============================================================================= -void SALOME_ContainerManager::AddOmninamesParams(std::ostream& fileStream, SALOME_NamingService *ns) +void SALOME_ContainerManager::AddOmninamesParams(std::ostream& fileStream, SALOME_NamingService_Abstract *ns) { - CORBA::String_var iorstr(ns->getIORaddr()); - fileStream << "ORBInitRef NameService="; - fileStream << iorstr; + SALOME_NamingService *nsTrad(dynamic_cast(ns)); + if(nsTrad) + { + CORBA::String_var iorstr(nsTrad->getIORaddr()); + fileStream << "ORBInitRef NameService="; + fileStream << iorstr; + } } void SALOME_ContainerManager::MakeTheCommandToBeLaunchedASync(std::string& command) @@ -1059,15 +1060,9 @@ std::string SALOME_ContainerManager::BuildTempFileToLaunchRemoteContainer (const if (params.isMPI) { - tempOutputFile << "mpirun -np "; - int nbproc; - - if ( params.nb_proc <= 0 ) - nbproc = 1; - else - nbproc = params.nb_proc; + int nbproc = params.nb_proc <= 0 ? 1 : params.nb_proc; - std::ostringstream o; + tempOutputFile << "mpirun -np "; tempOutputFile << nbproc << " "; #ifdef LAM_MPI @@ -1141,7 +1136,7 @@ std::string SALOME_ContainerManager::BuildTempFileToLaunchRemoteContainer (const else if (resInfo.Protocol == srun) { - command = "srun -n 1 -N 1 -s --mem-per-cpu=0 --nodelist="; + command = "srun -n 1 -N 1 -s --mem-per-cpu=0 --cpu-bind=none --nodelist="; std::string commandRcp = "rcp "; commandRcp += tmpFileName; commandRcp += " "; @@ -1261,7 +1256,7 @@ std::string SALOME_ContainerManager::getCommandToRunRemoteProcess(AccessProtocol case srun: // no need to redefine the user with srun, the job user is taken by default // (note: for srun, user id can be specified with " --uid=") - command << "srun -n 1 -N 1 -s --mem-per-cpu=0 --nodelist=" << hostname << " "; + command << "srun -n 1 -N 1 -s --mem-per-cpu=0 --cpu-bind=none --nodelist=" << hostname << " "; break; case pbsdsh: command << "pbsdsh -o -h " << hostname << " "; @@ -1416,7 +1411,7 @@ long SALOME_ContainerManager::SystemWithPIDThreadSafe(const std::vector