Version: 9.12.0
Engines_Parallel_Container_i Class Reference

C++ implementation of Engines::Container interface for parallel container implemented with PaCO++. More...

#include <SALOME_ParallelContainer_i.hxx>

Inheritance diagram for Engines_Parallel_Container_i:

Public Member Functions

 Engines_Parallel_Container_i (CORBA::ORB_ptr orb, char *ior, int rank, PortableServer::POA_ptr poa, std::string containerName, bool isServantAloneInProcess=true)
 Constructor. More...
 
virtual ~Engines_Parallel_Container_i ()
 Destructor. More...
 
virtual bool load_component_Library (const char *componentName, CORBA::String_out reason)
 load a new component class More...
 
virtual Engines::EngineComponent_ptr create_component_instance (const char *componentName)
 Create a new component instance. More...
 
virtual Engines::EngineComponent_ptr create_component_instance_env (const char *componentName, const Engines::FieldsDict &env, CORBA::String_out reason)
 Create a new component instance. More...
 
virtual char * create_python_service_instance (const char *CompName, CORBA::String_out reason)
 
Engines::EngineComponent_ptr find_component_instance (const char *registeredName)
 Find an existing (in the container) component instance. More...
 
Engines::EngineComponent_ptr load_impl (const char *nameToRegister, const char *componentName)
 Find or create a new component instance. More...
 
void create_paco_component_node_instance (const char *componentName, const char *proxy_containerName)
 
void updateInstanceNumber ()
 
void remove_impl (Engines::EngineComponent_ptr component_i)
 Remove the component instance from container. More...
 
void finalize_removal ()
 Unload component libraries from the container. More...
 
virtual void ping ()
 Ping the servant to check it is still alive. More...
 
char * name ()
 Get container name. More...
 
char * workingdir ()
 Get container working directory. More...
 
char * logfilename ()
 Get container log file name. More...
 
void logfilename (const char *name)
 Set container log file name. More...
 
virtual void Shutdown ()
 Shutdown the container. More...
 
char * getHostName ()
 Get container host name. More...
 
CORBA::Long getPID ()
 Get container PID. More...
 
bool Kill_impl ()
 Kill current container. More...
 
Engines::EngineComponent_ptr find_or_create_instance (std::string genericRegisterName)
 Finds an already existing component instance or create a new instance. More...
 
Engines::EngineComponent_ptr createCPPInstance (std::string genericRegisterName, void *handle)
 Create a new CPP component instance. More...
 
Engines::EngineComponent_ptr createPythonInstance (std::string genericRegisterName)
 Create a new Python component instance. More...
 
void set_id (PortableServer::ObjectId *id)
 
Engines::fileRef_ptr createFileRef (const char *origFileName)
 Get or create a file reference object associated to a local file (to transfer it) More...
 
Engines::fileTransfer_ptr getFileTransfer ()
 CORBA method: More...
 
virtual Engines::Salome_file_ptr createSalome_file (const char *origFileName)
 
void copyFile (Engines::Container_ptr container, const char *remoteFile, const char *localFile)
 copy a file from a remote host (container) to the local host More...
 
Engines::PyNode_ptr createPyNode (const char *nodeName, const char *code)
 create a PyNode object to execute remote python code More...
 
Engines::PyNode_ptr getDefaultPyNode (const char *nodeName)
 
Engines::PyScriptNode_ptr createPyScriptNode (const char *nodeName, const char *code)
 
Engines::PyScriptNode_ptr getDefaultPyScriptNode (const char *nodeName)
 

Static Public Member Functions

static bool isPythonContainer (const char *ContainerName)
 Indicate if container is a python one. More...
 
static void decInstanceCnt (std::string genericRegisterName)
 Decrement component instance reference count. More...
 

Protected Types

typedef std::map< std::string, Engines::EngineComponent_var > _listInstances_map_t
 
typedef std::map< std::string, Engines::fileRef_var > _fileRef_map_t
 
typedef std::map< std::string, Engines::Salome_file_var > _Salome_file_map_t
 
typedef PortableServer::ObjectId *(* FACTORY_FUNCTION) (CORBA::ORB_ptr, char *, int, PortableServer::POA_ptr, PortableServer::ObjectId *, const char *, const char *)
 

Protected Attributes

SALOME_NamingService_NS
 
std::string _hostname
 
std::string _library_path
 
std::string _containerName
 
std::string _logfilename
 
CORBA::ORB_var _orb
 
PortableServer::POA_var _poa
 
PortableServer::ObjectId * _id
 
int _numInstance
 
CORBA::Long _pid
 
bool _isServantAloneInProcess
 
Engines::fileTransfer_var _fileTransfer
 
_listInstances_map_t _listInstances_map
 
_fileRef_map_t _fileRef_map
 
_Salome_file_map_t _Salome_file_map
 
std::map< std::string, PortableServer::ObjectId * > _par_obj_inst_map
 

Static Protected Attributes

static std::map< std::string, int > _cntInstances_map
 
static std::map< std::string, void * > _library_map
 
static std::map< std::string, void * > _toRemove_map
 
static omni_mutex _numInstanceMutex
 

Detailed Description

C++ implementation of Engines::Container interface for parallel container implemented with PaCO++.

Member Typedef Documentation

◆ _fileRef_map_t

typedef std::map<std::string,Engines::fileRef_var> Engines_Parallel_Container_i::_fileRef_map_t
protected

◆ _listInstances_map_t

typedef std::map<std::string,Engines::EngineComponent_var> Engines_Parallel_Container_i::_listInstances_map_t
protected

◆ _Salome_file_map_t

typedef std::map<std::string,Engines::Salome_file_var> Engines_Parallel_Container_i::_Salome_file_map_t
protected

◆ FACTORY_FUNCTION

typedef PortableServer::ObjectId*(* Engines_Parallel_Container_i::FACTORY_FUNCTION) (CORBA::ORB_ptr, char *, int, PortableServer::POA_ptr, PortableServer::ObjectId *, const char *, const char *)
protected

Constructor & Destructor Documentation

◆ Engines_Parallel_Container_i()

Engines_Parallel_Container_i::Engines_Parallel_Container_i ( CORBA::ORB_ptr  orb,
char *  ior,
int  rank,
PortableServer::POA_ptr  poa,
std::string  containerName,
bool  isServantAloneInProcess = true 
)

◆ ~Engines_Parallel_Container_i()

Engines_Parallel_Container_i::~Engines_Parallel_Container_i ( )
virtual

Destructor.

References _id, _NS, and MESSAGE.

Member Function Documentation

◆ copyFile()

void Engines_Parallel_Container_i::copyFile ( Engines::Container_ptr  container,
const char *  remoteFile,
const char *  localFile 
)

copy a file from a remote host (container) to the local host

Parameters
containerthe remote container
remoteFilethe file to copy locally from the remote host into localFile
localFilethe local file

References TestComponentPy::container, INFOS, MESSAGE, and SCRUTE.

◆ create_component_instance()

Engines::EngineComponent_ptr Engines_Parallel_Container_i::create_component_instance ( const char *  genericRegisterName)
virtual

Create a new component instance.

CORBA method: Creates a new servant instance of a component. The servant registers itself to naming service and Registry.

Parameters
genericRegisterNameName of the component instance to register in Registry & Name Service (without _inst_n suffix)
Returns
a loaded component

References create_component_instance_env().

Referenced by SALOME_ContainerPy.SALOME_ContainerPy_Gen_i::create_component_instance_env(), SALOME_ContainerPy.SALOME_ContainerPy_Gen_i::create_python_service_instance(), and find_or_create_instance().

◆ create_component_instance_env()

Engines::EngineComponent_ptr Engines_Parallel_Container_i::create_component_instance_env ( const char *  genericRegisterName,
const Engines::FieldsDict env,
CORBA::String_out  reason 
)
virtual

Create a new component instance.

CORBA method: Creates a new servant instance of a component. The servant registers itself to naming service and Registry.

Parameters
genericRegisterNameName of the component instance to register in Registry & Name Service (without _inst_n suffix)
envdict of environment variables
Returns
a loaded component

References ParallelGlobalProcessVar_i::_library_map, _numInstance, ParallelGlobalProcessVar_i::_numInstanceMutex, createCPPInstance(), createPythonInstance(), and MESSAGE.

Referenced by create_component_instance().

◆ create_paco_component_node_instance()

◆ create_python_service_instance()

char * Engines_Parallel_Container_i::create_python_service_instance ( const char *  CompName,
CORBA::String_out  reason 
)
virtual

◆ createCPPInstance()

Engines::EngineComponent_ptr Engines_Parallel_Container_i::createCPPInstance ( std::string  genericRegisterName,
void *  handle 
)

Create a new CPP component instance.

C++ method: create a servant instance of a component.

Parameters
genericRegisterNameName of the component instance to register in Registry & Name Service, (without _inst_n suffix, like "COMPONENT")
handleloaded library handle
Returns
a loaded component

example with names: aGenRegisterName = COMPONENT (= first argument) _containerName = /Containers/cli76ce/FactoryServer factoryName = COMPONENTEngine_factory component_registerBase = /Containers/cli76ce/FactoryServer/COMPONENT instanceName = COMPONENT_inst_1 component_registerName = /Containers/cli76ce/FactoryServer/COMPONENT_inst_1

References ParallelGlobalProcessVar_i::_cntInstances_map, _containerName, _id, _listInstances_map, _NS, _numInstance, _orb, _poa, INFOS, MESSAGE, KERNEL_PY.batchmode_salome::obj, and SALOME_NamingService::Register().

Referenced by create_component_instance_env().

◆ createFileRef()

Engines::fileRef_ptr Engines_Parallel_Container_i::createFileRef ( const char *  origFileName)

Get or create a file reference object associated to a local file (to transfer it)

CORBA method: get or create a fileRef object associated to a local file (a file on the computer on which runs the container server), which stores a list of (machine, localFileName) corresponding to copies already done.

Parameters
origFileNameabsolute path for a local file to copy on other computers
Returns
a fileRef object associated to the file.

References _fileRef_map, _id, ParallelGlobalProcessVar_i::_numInstanceMutex, _poa, ASSERT, INFOS, and KERNEL_PY.batchmode_salome::obj.

◆ createPyNode()

Engines::PyNode_ptr Engines_Parallel_Container_i::createPyNode ( const char *  nodeName,
const char *  code 
)

create a PyNode object to execute remote python code

Parameters
nodeNamethe name of the node
codethe python code to load
Returns
the PyNode

References INFOS.

◆ createPyScriptNode()

Engines::PyScriptNode_ptr Engines_Parallel_Container_i::createPyScriptNode ( const char *  nodeName,
const char *  code 
)

References INFOS.

◆ createPythonInstance()

Engines::EngineComponent_ptr Engines_Parallel_Container_i::createPythonInstance ( std::string  genericRegisterName)

Create a new Python component instance.

C++ method: create a servant instance of a component.

Parameters
genericRegisterNameName of the component instance to register in Registry & Name Service, (without _inst_n suffix, like "COMPONENT")
handleloaded library handle
Returns
a loaded component

example with names: aGenRegisterName = COMPONENT (= first argument) _containerName = /Containers/cli76ce/FactoryServer factoryName = COMPONENTEngine_factory component_registerBase = /Containers/cli76ce/FactoryServer/COMPONENT instanceName = COMPONENT_inst_1 component_registerName = /Containers/cli76ce/FactoryServer/COMPONENT_inst_1

References _containerName, _listInstances_map, _numInstance, _orb, IDLparser::error(), and KERNEL_PY.batchmode_salome::obj.

Referenced by create_component_instance_env().

◆ createSalome_file()

Engines::Salome_file_ptr Engines_Parallel_Container_i::createSalome_file ( const char *  origFileName)
virtual

◆ decInstanceCnt()

◆ finalize_removal()

void Engines_Parallel_Container_i::finalize_removal ( )

Unload component libraries from the container.

CORBA method: Discharges unused libraries from the container.

References ParallelGlobalProcessVar_i::_numInstanceMutex, ParallelGlobalProcessVar_i::_toRemove_map, and MESSAGE.

◆ find_component_instance()

Engines::EngineComponent_ptr Engines_Parallel_Container_i::find_component_instance ( const char *  registeredName)

Find an existing (in the container) component instance.

CORBA method: Finds a servant instance of a component

Parameters
registeredNameName of the component in Registry or Name Service, without instance suffix number
Returns
the first found instance

References _listInstances_map, and SCRUTE.

◆ find_or_create_instance()

Engines::EngineComponent_ptr Engines_Parallel_Container_i::find_or_create_instance ( std::string  genericRegisterName)

Finds an already existing component instance or create a new instance.

C++ method: Finds an already existing servant instance of a component, or create an instance. -— USE ONLY FOR MULTISTUDY INSTANCES ! -----—

Parameters
genericRegisterNameName of the component instance to register in Registry & Name Service, (without _inst_n suffix, like "COMPONENT")
Returns
a loaded component

example with names: aGenRegisterName = COMPONENT (= first argument) impl_name = libCOMPONENTEngine.so (= second argument) _containerName = /Containers/cli76ce/FactoryServer factoryName = COMPONENTEngine_factory component_registerBase = /Containers/cli76ce/FactoryServer/COMPONENT

instanceName = COMPONENT_inst_1 component_registerName = /Containers/cli76ce/FactoryServer/COMPONENT_inst_1

References _containerName, _NS, create_component_instance(), INFOS, KERNEL_PY.batchmode_salome::obj, and SALOME_NamingService::ResolveFirst().

Referenced by load_impl().

◆ getDefaultPyNode()

Engines::PyNode_ptr Engines_Parallel_Container_i::getDefaultPyNode ( const char *  nodeName)

References INFOS.

◆ getDefaultPyScriptNode()

Engines::PyScriptNode_ptr Engines_Parallel_Container_i::getDefaultPyScriptNode ( const char *  nodeName)

References INFOS.

◆ getFileTransfer()

Engines::fileTransfer_ptr Engines_Parallel_Container_i::getFileTransfer ( )

CORBA method:

Returns
a reference to the fileTransfer object

References _fileTransfer.

◆ getHostName()

char * Engines_Parallel_Container_i::getHostName ( )

Get container host name.

CORBA method: Get the hostName of the Container (without domain extensions)

References _hostname, and MESSAGE.

◆ getPID()

CORBA::Long Engines_Parallel_Container_i::getPID ( )

Get container PID.

CORBA method: Get the PID (process identification) of the Container

References _pid, and MESSAGE.

◆ isPythonContainer()

bool Engines_Parallel_Container_i::isPythonContainer ( const char *  ContainerName)
static

Indicate if container is a python one.

Retrieves only with container naming convention if it is a python container

References TestKernelHelpers::ret.

◆ Kill_impl()

bool Engines_Parallel_Container_i::Kill_impl ( )

Kill current container.

Kill the container.

CORBA method: Kill the container process with exit(0). To remove : never returns !

References _containerName, _hostname, _pid, ASSERT, INFOS, and MESSAGE.

◆ load_component_Library()

bool Engines_Parallel_Container_i::load_component_Library ( const char *  componentName,
CORBA::String_out  reason 
)
virtual

load a new component class

CORBA method: load a new component class (Python or C++ implementation)

Parameters
componentNamelike COMPONENT try to make a Python import of COMPONENT, then a lib open of libCOMPONENTEngine.so
Returns
true if dlopen successful or already done, false otherwise

References ParallelGlobalProcessVar_i::_library_map, ParallelGlobalProcessVar_i::_numInstanceMutex, ParallelGlobalProcessVar_i::_toRemove_map, MESSAGE, and TestKernelHelpers::ret.

Referenced by load_impl().

◆ load_impl()

Engines::EngineComponent_ptr Engines_Parallel_Container_i::load_impl ( const char *  genericRegisterName,
const char *  componentName 
)

Find or create a new component instance.

CORBA method: find or create an instance of the component (servant), load a new component class (dynamic library) if required, -— FOR COMPATIBILITY WITH 2.2 -— -— USE ONLY FOR MULTISTUDY INSTANCES ! -----— The servant registers itself to naming service and Registry.

Parameters
genericRegisterNameName of the component to register in Registry & Name Service
componentNameName of the constructed library of the component
Returns
a loaded component

References find_or_create_instance(), and load_component_Library().

◆ logfilename() [1/2]

char * Engines_Parallel_Container_i::logfilename ( )

Get container log file name.

CORBA attribute: Container log file name

References _logfilename.

◆ logfilename() [2/2]

void Engines_Parallel_Container_i::logfilename ( const char *  name)

Set container log file name.

References _logfilename, and name().

◆ name()

char * Engines_Parallel_Container_i::name ( )

Get container name.

CORBA attribute: Container name (see constructor)

References _containerName.

Referenced by IDLparser.Tree::__repr__(), IDLparser.Tree::getNode(), logfilename(), and IDLparser.Tree::output_xml().

◆ ping()

void Engines_Parallel_Container_i::ping ( )
virtual

Ping the servant to check it is still alive.

CORBA method: check if servant is still alive

References _pid, and MESSAGE.

◆ remove_impl()

void Engines_Parallel_Container_i::remove_impl ( Engines::EngineComponent_ptr  component_i)

Remove the component instance from container.

CORBA method: Stops the component servant, and deletes all related objects

Parameters
component_iComponent to be removed

References _listInstances_map, _NS, ParallelGlobalProcessVar_i::_numInstanceMutex, ASSERT, SALOME_NamingService::Destroy_Name(), and MESSAGE.

◆ set_id()

void Engines_Parallel_Container_i::set_id ( PortableServer::ObjectId *  id)

◆ Shutdown()

void Engines_Parallel_Container_i::Shutdown ( )
virtual

Shutdown the container.

CORBA method, oneway: Server shutdown.

  • Container name removed from naming service,
  • servant deactivation,
  • orb shutdown if no other servants in the process

References _containerName, _isServantAloneInProcess, _listInstances_map, _NS, _orb, _par_obj_inst_map, _poa, SALOME_NamingService::Destroy_FullDirectory(), SALOME_NamingService::Destroy_Name(), and MESSAGE.

◆ updateInstanceNumber()

void Engines_Parallel_Container_i::updateInstanceNumber ( )

◆ workingdir()

char * Engines_Parallel_Container_i::workingdir ( )

Get container working directory.

CORBA attribute: Container working directory

Field Documentation

◆ _cntInstances_map

std::map< std::string, int > ParallelGlobalProcessVar_i::_cntInstances_map
staticprotectedinherited

◆ _containerName

◆ _fileRef_map

_fileRef_map_t Engines_Parallel_Container_i::_fileRef_map
protected

Referenced by createFileRef().

◆ _fileTransfer

Engines::fileTransfer_var Engines_Parallel_Container_i::_fileTransfer
protected

◆ _hostname

std::string Engines_Parallel_Container_i::_hostname
protected

◆ _id

◆ _isServantAloneInProcess

bool Engines_Parallel_Container_i::_isServantAloneInProcess
protected

Referenced by Shutdown().

◆ _library_map

◆ _library_path

std::string Engines_Parallel_Container_i::_library_path
protected

◆ _listInstances_map

◆ _logfilename

std::string Engines_Parallel_Container_i::_logfilename
protected

◆ _NS

◆ _numInstance

◆ _numInstanceMutex

◆ _orb

◆ _par_obj_inst_map

std::map<std::string, PortableServer::ObjectId *> Engines_Parallel_Container_i::_par_obj_inst_map
protected

◆ _pid

CORBA::Long Engines_Parallel_Container_i::_pid
protected

◆ _poa

◆ _Salome_file_map

_Salome_file_map_t Engines_Parallel_Container_i::_Salome_file_map
protected

Referenced by createSalome_file().

◆ _toRemove_map

std::map< std::string, void * > ParallelGlobalProcessVar_i::_toRemove_map
staticprotectedinherited