Version: 9.12.0
SALOME_ContainerManager Class Reference

#include <SALOME_ContainerManager.hxx>

Inheritance diagram for SALOME_ContainerManager:

Public Member Functions

 SALOME_ContainerManager (CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *ns)
 Constructor. More...
 
 ~SALOME_ContainerManager ()
 destructor More...
 
Engines::Container_ptr GiveContainer (const Engines::ContainerParameters &params) override
 Give a suitable Container given constraints. More...
 
void ShutdownContainers () override
 Loop on all the containers listed in naming service, ask shutdown on each. More...
 
void SetOverrideEnvForContainers (const Engines::KeyValDict &env) override
 
Engines::KeyValDictGetOverrideEnvForContainers () override
 
void SetCodeOnContainerStartUp (const char *code) override
 
void Shutdown ()
 shutdown all the containers, then the ContainerManager servant More...
 
void DeclareUsingSalomeSession ()
 
CORBA::Long GetTimeOutToLaunchServerInSecond () override
 
void SetTimeOutToLaunchServerInSecond (CORBA::Long timeInSecond) override
 
CORBA::Long GetDeltaTimeBetweenNSLookupAtLaunchTimeInMilliSecond () override
 
void SetDeltaTimeBetweenNSLookupAtLaunchTimeInMilliSecond (CORBA::Long timeInMS) override
 

Static Public Member Functions

static char * GetenvThreadSafe (const char *name)
 
static std::string GetenvThreadSafeAsString (const char *name)
 
static int SystemThreadSafe (const char *command)
 
static long SystemWithPIDThreadSafe (const std::vector< std::string > &command)
 
static void AddOmninamesParams (std::ostream &fileStream, SALOME_NamingService_Abstract *ns)
 add to command all options relative to naming service. More...
 
static void MakeTheCommandToBeLaunchedASync (std::string &command)
 
static int GetTimeOutToLoaunchServer ()
 Return in second the time out to give chance to server to be launched and to register into NS. More...
 
static void SleepInSecond (int ellapseTimeInSecond)
 

Static Public Attributes

static const char * _ContainerManagerNameInNS = "/ContainerManager"
 

Protected Types

typedef std::vector< std::string > actual_launch_machine_t
 

Protected Member Functions

Engines::Container_ptr FindContainer (const Engines::ContainerParameters &params, const Engines::ResourceList &possibleResources)
 Find a container given constraints (params) on a list of machines (possibleComputers) agy : this method is ThreadSafe. More...
 
Engines::Container_ptr FindContainer (const Engines::ContainerParameters &params, const std::string &resource)
 Find a container given constraints (params) on a machine (theMachine) agy : this method is ThreadSafe. More...
 
std::string GetCppBinaryOfKernelContainer () const
 
std::string GetRunRemoteExecutableScript () const
 
std::string BuildCommandToLaunchRemoteContainer (const std::string &resource_name, const Engines::ContainerParameters &params, const std::string &container_exe="SALOME_Container") const
 Builds the script to be launched. More...
 
std::string BuildCommandToLaunchLocalContainer (const Engines::ContainerParameters &params, const std::string &machinesFile, const std::string &container_exe, std::string &tmpFileName) const
 builds the command to be launched. More...
 
std::string BuildTempFileToLaunchRemoteContainer (const std::string &resource_name, const Engines::ContainerParameters &params, std::string &tmpFileName) const
 Builds in a temporary file the script to be launched. More...
 
void AddOmninamesParams (std::string &command) const
 add to command all options relative to naming service. More...
 
void AddOmninamesParams (std::ostream &fileStream) const
 add to command all options relative to naming service. More...
 
std::string GetMPIZeroNode (const std::string machine, const std::string machinesFile) const
 
std::string machinesFile (const int nbproc)
 
std::string getCommandToRunRemoteProcessCommon (const std::string &templateName, const std::string &remoteScript, AccessProtocolType protocol, const std::string &hostname, const std::string &username, const std::string &applipath, const std::string &workdir) const
 
std::string getCommandToRunRemoteProcess (AccessProtocolType protocol, const std::string &hostname, const std::string &username, const std::string &applipath, const std::string &workdir="") const
 
std::string getCommandToRunRemoteProcessNoAppli (AccessProtocolType protocol, const std::string &hostname, const std::string &username, const std::string &applipath, const std::string &workdir="") const
 
Engines::Container_ptr LaunchContainer (const Engines::ContainerParameters &params, const std::string &resource_selected, const std::string &hostname, const std::string &machFile, const std::string &containerNameInNS)
 
bool checkPaCOParameters (Engines::ContainerParameters &params, std::string resource_selected)
 
Engines::Container_ptr StartPaCOPPContainer (const Engines::ContainerParameters &params, std::string resource_selected)
 
std::string BuildCommandToLaunchPaCOProxyContainer (const Engines::ContainerParameters &params, std::string machine_file_name, std::string &proxy_hostname)
 
std::string BuildCommandToLaunchPaCONodeContainer (const Engines::ContainerParameters &params, const std::string &machine_file_name, SALOME_ContainerManager::actual_launch_machine_t &vect_machine, const std::string &proxy_hostname)
 
void LogConfiguration (const std::string &log_type, const std::string &exe_type, const std::string &container_name, const std::string &hostname, std::string &begin, std::string &end)
 
CORBA::Object_ptr LaunchPaCOProxyContainer (const std::string &command, const Engines::ContainerParameters &params, const std::string &hostname)
 
bool LaunchPaCONodeContainer (const std::string &command, const Engines::ContainerParameters &params, const std::string &name, SALOME_ContainerManager::actual_launch_machine_t &vect_machine)
 

Static Protected Member Functions

static void RmTmpFile (std::string &tmpFile)
 removes the generated temporary file in case of a remote launch. More...
 
static std::string BuildTemporaryFileName ()
 generate a file name in /tmp directory More...
 

Protected Attributes

CORBA::ORB_var _orb
 
PortableServer::POA_var _poa
 
SALOME_ResourcesManager_Client_resManager
 
SALOME_NamingService_Abstract_NS
 
bool _isAppliSalomeDefined
 different behaviour if $APPLI exists (SALOME Application) More...
 
int _nbprocUsed
 attribute that contains the number of processes used in batch mode by MPI containers More...
 
bool _isSSL = true
 attribute that specifies the launch mode. More...
 
Utils_Mutex _giveContainerMutex1
 attributes to allow concurrency for // GiveContainer More...
 
pid_t _pid_mpiServer
 

Static Protected Attributes

static omni_mutex _numInstanceMutex
 

Private Attributes

std::vector< std::pair< std::string, std::string > > _override_env
 
int _time_out_in_second
 
int _delta_time_ns_lookup_in_ms
 
std::string _code_to_exe_on_startup
 

Static Private Attributes

static const int TIME_OUT_TO_LAUNCH_CONT =60
 
static const int DFT_DELTA_TIME_NS_LOOKUP_IN_MS =1000
 
static Utils_Mutex _getenvMutex
 
static Utils_Mutex _systemMutex
 

Member Typedef Documentation

◆ actual_launch_machine_t

typedef std::vector<std::string> SALOME_ContainerManager::actual_launch_machine_t
protected

Constructor & Destructor Documentation

◆ SALOME_ContainerManager()

SALOME_ContainerManager::SALOME_ContainerManager ( CORBA::ORB_ptr  orb,
PortableServer::POA_var  poa,
SALOME_NamingService_Abstract ns 
)

Constructor.

Parameters
orbDefine a CORBA single thread policy for the server, which avoid to deal with non thread-safe usage like Change_Directory in SALOME naming service

References _ContainerManagerNameInNS, _isAppliSalomeDefined, _NS, _orb, _pid_mpiServer, _poa, _resManager, _time_out_in_second, GetenvThreadSafe(), GetenvThreadSafeAsString(), GetTimeOutToLoaunchServer(), MESSAGE, KERNEL_PY.batchmode_salome::obj, salome::orb, SALOME_ContainerPy::poa, and SALOME_NamingService_Container_Abstract::Register().

◆ ~SALOME_ContainerManager()

SALOME_ContainerManager::~SALOME_ContainerManager ( )

Member Function Documentation

◆ AddOmninamesParams() [1/3]

void SALOME_ContainerManager::AddOmninamesParams ( std::ostream &  fileStream) const
protected

add to command all options relative to naming service.

References _NS, and AddOmninamesParams().

◆ AddOmninamesParams() [2/3]

void SALOME_ContainerManager::AddOmninamesParams ( std::ostream &  fileStream,
SALOME_NamingService_Abstract ns 
)
static

add to command all options relative to naming service.

References SALOME_NamingService::getIORaddr().

◆ AddOmninamesParams() [3/3]

void SALOME_ContainerManager::AddOmninamesParams ( std::string &  command) const
protected

◆ BuildCommandToLaunchLocalContainer()

◆ BuildCommandToLaunchPaCONodeContainer()

std::string SALOME_ContainerManager::BuildCommandToLaunchPaCONodeContainer ( const Engines::ContainerParameters params,
const std::string &  machine_file_name,
SALOME_ContainerManager::actual_launch_machine_t vect_machine,
const std::string &  proxy_hostname 
)
protected

◆ BuildCommandToLaunchPaCOProxyContainer()

std::string SALOME_ContainerManager::BuildCommandToLaunchPaCOProxyContainer ( const Engines::ContainerParameters params,
std::string  machine_file_name,
std::string &  proxy_hostname 
)
protected

◆ BuildCommandToLaunchRemoteContainer()

std::string SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer ( const std::string &  resource_name,
const Engines::ContainerParameters params,
const std::string &  container_exe = "SALOME_Container" 
) const
protected

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 omitted 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

References _isAppliSalomeDefined, _isSSL, _NS, _orb, _resManager, AddOmninamesParams(), ParserResourcesType::AppliPath, TestKernelHelpers::command, SALOME_NamingService_Abstract::ContainerName(), getCommandToRunRemoteProcess(), getCommandToRunRemoteProcessNoAppli(), GetEmbeddedNamingService(), GetenvThreadSafe(), GetenvThreadSafeAsString(), Kernel_Utils::GetHostname(), SALOME_ResourcesManager_Client::GetResourceDefinition(), ParserResourcesType::HostName, Engines::ContainerParameters::isMPI, MESSAGE, Engines::ContainerParameters::nb_proc, ParserResourcesType::Protocol, ParserResourcesType::UserName, and Engines::ContainerParameters::workingdir.

Referenced by LaunchContainer().

◆ BuildTempFileToLaunchRemoteContainer()

std::string SALOME_ContainerManager::BuildTempFileToLaunchRemoteContainer ( const std::string &  resource_name,
const Engines::ContainerParameters params,
std::string &  tmpFileName 
) const
protected

◆ BuildTemporaryFileName()

std::string SALOME_ContainerManager::BuildTemporaryFileName ( )
staticprotected

◆ checkPaCOParameters()

◆ DeclareUsingSalomeSession()

void SALOME_ContainerManager::DeclareUsingSalomeSession ( )

◆ FindContainer() [1/2]

Engines::Container_ptr SALOME_ContainerManager::FindContainer ( const Engines::ContainerParameters params,
const Engines::ResourceList possibleResources 
)
protected

Find a container given constraints (params) on a list of machines (possibleComputers) agy : this method is ThreadSafe.

References MESSAGE.

Referenced by GiveContainer().

◆ FindContainer() [2/2]

Engines::Container_ptr SALOME_ContainerManager::FindContainer ( const Engines::ContainerParameters params,
const std::string &  resource 
)
protected

◆ getCommandToRunRemoteProcess()

std::string SALOME_ContainerManager::getCommandToRunRemoteProcess ( AccessProtocolType  protocol,
const std::string &  hostname,
const std::string &  username,
const std::string &  applipath,
const std::string &  workdir = "" 
) const
protected

◆ getCommandToRunRemoteProcessCommon()

std::string SALOME_ContainerManager::getCommandToRunRemoteProcessCommon ( const std::string &  templateName,
const std::string &  remoteScript,
AccessProtocolType  protocol,
const std::string &  hostname,
const std::string &  username,
const std::string &  applipath,
const std::string &  workdir 
) const
protected

◆ getCommandToRunRemoteProcessNoAppli()

std::string SALOME_ContainerManager::getCommandToRunRemoteProcessNoAppli ( AccessProtocolType  protocol,
const std::string &  hostname,
const std::string &  username,
const std::string &  applipath,
const std::string &  workdir = "" 
) const
protected

◆ GetCppBinaryOfKernelContainer()

std::string SALOME_ContainerManager::GetCppBinaryOfKernelContainer ( ) const
protected

References _isSSL, and TestKernelHelpers::ret.

Referenced by LaunchContainer().

◆ GetDeltaTimeBetweenNSLookupAtLaunchTimeInMilliSecond()

CORBA::Long SALOME_ContainerManager::GetDeltaTimeBetweenNSLookupAtLaunchTimeInMilliSecond ( )
override

◆ GetenvThreadSafe()

◆ GetenvThreadSafeAsString()

◆ GetMPIZeroNode()

◆ GetOverrideEnvForContainers()

Engines::KeyValDict * SALOME_ContainerManager::GetOverrideEnvForContainers ( )
override

◆ GetRunRemoteExecutableScript()

std::string SALOME_ContainerManager::GetRunRemoteExecutableScript ( ) const
protected

◆ GetTimeOutToLaunchServerInSecond()

CORBA::Long SALOME_ContainerManager::GetTimeOutToLaunchServerInSecond ( )
override

References _time_out_in_second.

◆ GetTimeOutToLoaunchServer()

int SALOME_ContainerManager::GetTimeOutToLoaunchServer ( )
static

Return in second the time out to give chance to server to be launched and to register into NS.

References GetenvThreadSafe(), GetenvThreadSafeAsString(), INFOS, and TIME_OUT_TO_LAUNCH_CONT.

Referenced by CreateDataScope(), and SALOME_ContainerManager().

◆ GiveContainer()

◆ LaunchContainer()

◆ LaunchPaCONodeContainer()

bool SALOME_ContainerManager::LaunchPaCONodeContainer ( const std::string &  command,
const Engines::ContainerParameters params,
const std::string &  name,
SALOME_ContainerManager::actual_launch_machine_t vect_machine 
)
protected

◆ LaunchPaCOProxyContainer()

CORBA::Object_ptr SALOME_ContainerManager::LaunchPaCOProxyContainer ( const std::string &  command,
const Engines::ContainerParameters params,
const std::string &  hostname 
)
protected

◆ LogConfiguration()

void SALOME_ContainerManager::LogConfiguration ( const std::string &  log_type,
const std::string &  exe_type,
const std::string &  container_name,
const std::string &  hostname,
std::string &  begin,
std::string &  end 
)
protected

◆ machinesFile()

std::string SALOME_ContainerManager::machinesFile ( const int  nbproc)
protected

◆ MakeTheCommandToBeLaunchedASync()

void SALOME_ContainerManager::MakeTheCommandToBeLaunchedASync ( std::string &  command)
static

◆ RmTmpFile()

void SALOME_ContainerManager::RmTmpFile ( std::string &  tmpFileName)
staticprotected

removes the generated temporary file in case of a remote launch.

This method is thread safe

References TestKernelHelpers::command, Kernel_Utils::GetDirByPath(), Kernel_Utils::IsEmptyDir(), and SystemThreadSafe().

Referenced by GetMPIZeroNode(), and LaunchContainer().

◆ SetCodeOnContainerStartUp()

void SALOME_ContainerManager::SetCodeOnContainerStartUp ( const char *  code)
override

◆ SetDeltaTimeBetweenNSLookupAtLaunchTimeInMilliSecond()

void SALOME_ContainerManager::SetDeltaTimeBetweenNSLookupAtLaunchTimeInMilliSecond ( CORBA::Long  timeInMS)
override

◆ SetOverrideEnvForContainers()

void SALOME_ContainerManager::SetOverrideEnvForContainers ( const Engines::KeyValDict env)
override

References _override_env.

◆ SetTimeOutToLaunchServerInSecond()

void SALOME_ContainerManager::SetTimeOutToLaunchServerInSecond ( CORBA::Long  timeInSecond)
override

References _time_out_in_second.

◆ Shutdown()

void SALOME_ContainerManager::Shutdown ( )

shutdown all the containers, then the ContainerManager servant

CORBA method:

References _ContainerManagerNameInNS, _NS, _poa, SALOME_NamingService_Container_Abstract::Destroy_Name(), MESSAGE, and ShutdownContainers().

Referenced by SALOME_Launcher::Shutdown().

◆ ShutdownContainers()

void SALOME_ContainerManager::ShutdownContainers ( )
override

◆ SleepInSecond()

void SALOME_ContainerManager::SleepInSecond ( int  ellapseTimeInSecond)
static

Referenced by CreateDataScope().

◆ StartPaCOPPContainer()

Engines::Container_ptr SALOME_ContainerManager::StartPaCOPPContainer ( const Engines::ContainerParameters params,
std::string  resource_selected 
)
protected

References INFOS, and TestKernelHelpers::ret.

Referenced by LaunchContainer().

◆ SystemThreadSafe()

int SALOME_ContainerManager::SystemThreadSafe ( const char *  command)
static

◆ SystemWithPIDThreadSafe()

long SALOME_ContainerManager::SystemWithPIDThreadSafe ( const std::vector< std::string > &  command)
static

Field Documentation

◆ _code_to_exe_on_startup

std::string SALOME_ContainerManager::_code_to_exe_on_startup
private

◆ _ContainerManagerNameInNS

const char * SALOME_ContainerManager::_ContainerManagerNameInNS = "/ContainerManager"
static

◆ _delta_time_ns_lookup_in_ms

int SALOME_ContainerManager::_delta_time_ns_lookup_in_ms
private

◆ _getenvMutex

Utils_Mutex SALOME_ContainerManager::_getenvMutex
staticprivate

Referenced by GetenvThreadSafe().

◆ _giveContainerMutex1

Utils_Mutex SALOME_ContainerManager::_giveContainerMutex1
protected

attributes to allow concurrency for // GiveContainer

Referenced by GiveContainer(), and LaunchContainer().

◆ _isAppliSalomeDefined

bool SALOME_ContainerManager::_isAppliSalomeDefined
protected

different behaviour if $APPLI exists (SALOME Application)

Referenced by BuildCommandToLaunchRemoteContainer(), GetMPIZeroNode(), LaunchContainer(), and SALOME_ContainerManager().

◆ _isSSL

bool SALOME_ContainerManager::_isSSL = true
protected

◆ _nbprocUsed

int SALOME_ContainerManager::_nbprocUsed
protected

attribute that contains the number of processes used in batch mode by MPI containers

Referenced by machinesFile().

◆ _NS

◆ _numInstanceMutex

omni_mutex SALOME_ContainerManager::_numInstanceMutex
staticprotected

Referenced by machinesFile().

◆ _orb

◆ _override_env

std::vector< std::pair<std::string, std::string> > SALOME_ContainerManager::_override_env
private

◆ _pid_mpiServer

pid_t SALOME_ContainerManager::_pid_mpiServer
protected

◆ _poa

◆ _resManager

◆ _systemMutex

Utils_Mutex SALOME_ContainerManager::_systemMutex
staticprivate

◆ _time_out_in_second

int SALOME_ContainerManager::_time_out_in_second
private

◆ DFT_DELTA_TIME_NS_LOOKUP_IN_MS

const int SALOME_ContainerManager::DFT_DELTA_TIME_NS_LOOKUP_IN_MS =1000
staticprivate

◆ TIME_OUT_TO_LAUNCH_CONT

const int SALOME_ContainerManager::TIME_OUT_TO_LAUNCH_CONT =60
staticprivate