X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FParallelContainer%2FSALOME_ParallelComponent_i.cxx;h=4a2e797172accb10b132b0ccaefb5e36b2d8bcef;hb=d8edd4804d9e6513a17c497c1a30326d4ba0d677;hp=f5fb351fcfec955efc3ec92e4b48b487e0390cbd;hpb=531c1656a2501cfeeefe6ad6a21fb2aa134612bb;p=modules%2Fkernel.git diff --git a/src/ParallelContainer/SALOME_ParallelComponent_i.cxx b/src/ParallelContainer/SALOME_ParallelComponent_i.cxx index f5fb351fc..4a2e79717 100644 --- a/src/ParallelContainer/SALOME_ParallelComponent_i.cxx +++ b/src/ParallelContainer/SALOME_ParallelComponent_i.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 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 @@ -22,7 +22,7 @@ // SALOME_ParallelComponent : implementation of container and engine for Parallel Kernel // File : SALOME_ParallelComponent_i.cxx -// Author : André RIBES, EDF +// Author : Andr� RIBES, EDF // Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA // #include "SALOME_ParallelComponent_i.hxx" @@ -53,11 +53,10 @@ int SIGUSR11 = 1000; extern bool _Sleeping ; static Engines_Parallel_Component_i * theEngines_Component ; -bool Engines_Parallel_Component_i::_isMultiStudy = true; bool Engines_Parallel_Component_i::_isMultiInstance = false; //============================================================================= -/*! +/*! * Standard Constructor for generic Component, used in derived class * Connection to Registry and Notification * \param orb Object Request broker given by Container @@ -70,13 +69,13 @@ bool Engines_Parallel_Component_i::_isMultiInstance = false; //============================================================================= Engines_Parallel_Component_i::Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior, int rank, - PortableServer::POA_ptr poa, - PortableServer::ObjectId * contId, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, const char *instanceName, const char *interfaceName, bool notif, bool regist) : - InterfaceParallel_impl(orb,ior,rank), + InterfaceParallel_impl(orb,ior,rank), Engines::EngineComponent_serv(orb,ior,rank), Engines::EngineComponent_base_serv(orb,ior,rank), Engines::Parallel_Component_serv(orb,ior,rank), @@ -90,7 +89,6 @@ Engines_Parallel_Component_i::Engines_Parallel_Component_i(CORBA::ORB_ptr orb, c _Executed(false) , _graphName("") , _nodeName(""), - _studyId(-1), _destroyed(false), _CanceledThread(false) { @@ -116,7 +114,7 @@ Engines_Parallel_Component_i::Engines_Parallel_Component_i(CORBA::ORB_ptr orb, c } //============================================================================= -/*! +/*! * Destructor: call Container for decrement of instances count. * When instances count falls to 0, the container tries to remove the * component library (dlclose) @@ -139,7 +137,7 @@ Engines_Parallel_Component_i::~Engines_Parallel_Component_i() } //============================================================================= -/*! +/*! * CORBA method: return name of the instance, unique in this Container */ //============================================================================= @@ -150,7 +148,7 @@ char* Engines_Parallel_Component_i::instanceName() } //============================================================================= -/*! +/*! * CORBA method: return name of the component class */ //============================================================================= @@ -161,21 +159,7 @@ char* Engines_Parallel_Component_i::interfaceName() } //============================================================================= -/*! - * CORBA method: Get study Id - * \return -1: not initialised (Internal Error) - * 0: multistudy component instance - * >0: study id associated to this instance - */ -//============================================================================= - -CORBA::Long Engines_Parallel_Component_i::getStudyId() -{ - return _studyId; -} - -//============================================================================= -/*! +/*! * CORBA method: Test if instance is alive and responds */ //============================================================================= @@ -192,7 +176,7 @@ void Engines_Parallel_Component_i::ping() } //============================================================================= -/*! +/*! * CORBA method: Deactivate this instance. CORBA object is deactivated (do not * respond any more to CORBA calls), the connection to Regsitry is removed * (Registry informed of deactivation), internal server reference counter on @@ -214,7 +198,7 @@ void Engines_Parallel_Component_i::destroy() } //============================================================================= -/*! +/*! * CORBA method: return CORBA reference of the Container * */ @@ -228,12 +212,12 @@ Engines::Container_ptr Engines_Parallel_Component_i::GetContainerRef() } //============================================================================= -/*! - * CORBA method: - * Gives a sequence of (key=string,value=any) to the component. +/*! + * CORBA method: + * Gives a sequence of (key=string,value=any) to the component. * Base class component stores the sequence in a map. * The map is cleared before. - * This map is for use by derived classes. + * This map is for use by derived classes. * \param dico sequence of (key=string,value=any) */ //============================================================================= @@ -249,8 +233,8 @@ void Engines_Parallel_Component_i::setProperties(const Engines::FieldsDict& dico } //============================================================================= -/*! - * CORBA method: +/*! + * CORBA method: * returns a previously stored map (key=string,value=any) as a sequence. * (see setProperties) */ @@ -272,7 +256,7 @@ Engines::FieldsDict* Engines_Parallel_Component_i::getProperties() } //============================================================================= -/*! +/*! * CORBA method: used by Supervision to give names to this instance */ //============================================================================= @@ -282,17 +266,17 @@ void Engines_Parallel_Component_i::Names( const char * graphName , { _graphName = graphName; _nodeName = nodeName; - MESSAGE("Engines_Parallel_Component_i::Names( '" << _graphName << "' , '" + MESSAGE("Engines_Parallel_Component_i::Names( '" << _graphName << "' , '" << _nodeName << "' )"); } //============================================================================= -/*! +/*! * CORBA method: used in Supervision */ //============================================================================= -bool Engines_Parallel_Component_i::Kill_impl() +bool Engines_Parallel_Component_i::Kill_impl() { // MESSAGE("Engines_Parallel_Component_i::Kill_i() pthread_t "<< pthread_self() // << " pid " << getpid() << " instanceName " @@ -321,7 +305,7 @@ bool Engines_Parallel_Component_i::Kill_impl() } //============================================================================= -/*! +/*! * CORBA method: used in Supervision */ //============================================================================= @@ -341,7 +325,7 @@ bool Engines_Parallel_Component_i::Stop_impl() << " machineName " << Kernel_Utils::GetHostname().c_str()<< " _id " << hex << _id << dec << " _ThreadId " << _ThreadId ); #endif - + bool RetVal = false ; #ifndef WIN32 @@ -361,7 +345,7 @@ bool Engines_Parallel_Component_i::Stop_impl() } //============================================================================= -/*! +/*! * CORBA method: used in Supervision */ //============================================================================= @@ -393,7 +377,7 @@ bool Engines_Parallel_Component_i::Suspend_impl() { return false ; } - else + else { #ifndef WIN32 RetVal = Killer( _ThreadId ,SIGINT ) ; @@ -408,7 +392,7 @@ bool Engines_Parallel_Component_i::Suspend_impl() } //============================================================================= -/*! +/*! * CORBA method: used in Supervision */ //============================================================================= @@ -435,7 +419,7 @@ bool Engines_Parallel_Component_i::Resume_impl() if ( _ThreadId > 0 && pthread_self().p != _ThreadId->p ) #endif { - if ( _Sleeping ) + if ( _Sleeping ) { _Sleeping = false ; RetVal = true ; @@ -449,8 +433,8 @@ bool Engines_Parallel_Component_i::Resume_impl() } //============================================================================= -/*! - * CORBA method: +/*! + * CORBA method: */ //============================================================================= @@ -490,7 +474,7 @@ CORBA::Long Engines_Parallel_Component_i::CpuUsed_impl() // << _serviceName << " " << cpu << std::endl ; } } - else + else { cpu = _ThreadCpuUsed ; // std::cout << pthread_self() << " Engines_Parallel_Component_i::CpuUsed_impl " @@ -507,7 +491,7 @@ CORBA::Long Engines_Parallel_Component_i::CpuUsed_impl() //============================================================================= -/*! +/*! * C++ method: return Container Servant */ //============================================================================= @@ -518,32 +502,7 @@ Engines_Parallel_Container_i *Engines_Parallel_Component_i::GetContainerPtr() } //============================================================================= -/*! - * C++ method: set study Id - * \param studyId 0 if instance is not associated to a study, - * >0 otherwise (== study id) - * \return true if the set of study Id is OK - * must be set once by Container, at instance creation, - * and cannot be changed after. - */ -//============================================================================= - -CORBA::Boolean Engines_Parallel_Component_i::setStudyId(CORBA::Long studyId) -{ - ASSERT( studyId >= 0); - CORBA::Boolean ret = false; - if (_studyId < 0) // --- not yet initialized - { - _studyId = studyId; - ret = true; - } - else - if ( _studyId == studyId) ret = true; - return ret; -} - -//============================================================================= -/*! +/*! * C++ method: return CORBA instance id, the id is set in derived class * constructor, when instance is activated. */ @@ -556,7 +515,7 @@ PortableServer::ObjectId * Engines_Parallel_Component_i::getId() } //============================================================================= -/*! +/*! * C++ method: used by derived classes for supervision */ //============================================================================= @@ -628,7 +587,7 @@ void Engines_Parallel_Component_i::beginService(const char *serviceName) } //============================================================================= -/*! +/*! * C++ method: used by derived classes for supervision */ //============================================================================= @@ -651,7 +610,7 @@ void Engines_Parallel_Component_i::endService(const char *serviceName) } //============================================================================= -/*! +/*! * C++ method: -- CHECK IF USED -- */ //============================================================================= @@ -662,7 +621,7 @@ char* Engines_Parallel_Component_i::graphName() } //============================================================================= -/*! +/*! * C++ method: -- CHECK IF USED -- */ //============================================================================= @@ -673,7 +632,7 @@ char* Engines_Parallel_Component_i::nodeName() } //============================================================================= -/*! +/*! * C++ method: used in Supervision (see kill_impl) */ //============================================================================= @@ -711,7 +670,7 @@ bool Engines_Parallel_Component_i::Killer( pthread_t ThreadId , int signum ) perror("Killer pthread_kill error") ; return false ; } - else + else { #ifndef WIN32 MESSAGE(pthread_self() << "Killer : ThreadId " << ThreadId @@ -727,9 +686,9 @@ bool Engines_Parallel_Component_i::Killer( pthread_t ThreadId , int signum ) } //============================================================================= -/*! +/*! * C++ method: - */ + */ //============================================================================= void SetCpuUsed() @@ -739,7 +698,7 @@ void SetCpuUsed() } //============================================================================= -/*! +/*! * C++ method: */ //============================================================================= @@ -747,12 +706,12 @@ void SetCpuUsed() void Engines_Parallel_Component_i::SetCurCpu() { _ThreadCpuUsed = CpuUsed() ; - // MESSAGE(pthread_self() << + // MESSAGE(pthread_self() << // " Engines_Parallel_Component_i::SetCurCpu() _ThreadCpuUsed " << _ThreadCpuUsed) ; } //============================================================================= -/*! +/*! * C++ method: */ //============================================================================= @@ -777,7 +736,7 @@ long Engines_Parallel_Component_i::CpuUsed() else { // std::cout << pthread_self() << "Engines_Parallel_Component_i::CpuUsed _ThreadId " - // << _ThreadId << " " << _serviceName<< " _StartUsed " + // << _ThreadId << " " << _serviceName<< " _StartUsed " // << _StartUsed << std::endl ; } #else @@ -806,7 +765,7 @@ void Engines_Parallel_Component_i::CancelThread() } //============================================================================= -/*! +/*! * C++ method: Send message to event channel */ //============================================================================= @@ -818,7 +777,7 @@ void Engines_Parallel_Component_i::sendMessage(const char *event_type, } //============================================================================= -/*! +/*! * C++ method: return standard library name built on component name */ //============================================================================= @@ -836,35 +795,34 @@ std::string Engines_Parallel_Component_i::GetDynLibraryName(const char *componen #else std::string ret=componentName; ret+="Engine.dll"; -#endif +#endif return ret; } //============================================================================= -/*! +/*! * C++ method: DumpPython default implementation */ //============================================================================= -Engines::TMPFile* Engines_Parallel_Component_i::DumpPython(CORBA::Object_ptr theStudy, - CORBA::Boolean isPublished, +Engines::TMPFile* Engines_Parallel_Component_i::DumpPython(CORBA::Boolean isPublished, CORBA::Boolean isMultiFile, CORBA::Boolean& isValidScript) { - const char* aScript = isMultiFile ? "def RebuildData(theStudy): pass" : ""; + const char* aScript = isMultiFile ? "def RebuildData(): pass" : ""; char* aBuffer = new char[strlen(aScript)+1]; strcpy(aBuffer, aScript); CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer; int aBufferSize = strlen(aBuffer)+1; - Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aBufferSize, aBufferSize, anOctetBuf, 1); + Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aBufferSize, aBufferSize, anOctetBuf, 1); isValidScript = true; - return aStreamFile._retn(); + return aStreamFile._retn(); } -Engines::Salome_file_ptr -Engines_Parallel_Component_i::setInputFileToService(const char* service_name, - const char* Salome_file_name) +Engines::Salome_file_ptr +Engines_Parallel_Component_i::setInputFileToService(const char* service_name, + const char* Salome_file_name) { // Try to find the service, if it doesn't exist, we add it. _Service_file_map_it = _Input_Service_file_map.find(service_name); @@ -879,7 +837,7 @@ Engines_Parallel_Component_i::setInputFileToService(const char* service_name, _t_Salome_file_map * _map = _Input_Service_file_map[service_name]; _t_Proxy_Salome_file_map * _proxy_map = _Proxy_Input_Service_file_map[service_name]; _t_IOR_Proxy_Salome_file_map * _IOR_proxy_map = _IOR_Proxy_Input_Service_file_map[service_name]; - + pthread_mutex_lock(deploy_mutex); std::string proxy_ior; @@ -898,16 +856,16 @@ Engines_Parallel_Component_i::setInputFileToService(const char* service_name, if (getMyRank() == 0) { proxy = new Engines::Parallel_Salome_file_proxy_impl(CORBA::ORB::_duplicate(_orb), new paco_omni_fabrique()); - proxy->copyGlobalContext(this); + proxy->copyGlobalContext(this); PaCO::PacoTopology_t serveur_topo; serveur_topo.total = getTotalNode(); proxy->setTopology(serveur_topo); - // We register the CORBA objet into the POA + // We register the CORBA object into the POA CORBA::Object_ptr proxy_ref = proxy->_this(); // We send the reference to all the nodes... - Engines::Parallel_Component_var component_proxy = + Engines::Parallel_Component_var component_proxy = Engines::Parallel_Component::_narrow(InterfaceParallel_impl::_proxy); component_proxy->send_parallel_proxy_object(proxy_ref); @@ -925,13 +883,13 @@ Engines_Parallel_Component_i::setInputFileToService(const char* service_name, // into the proxy. for (int i = 0; i < getTotalNode(); i++) { if (i == getMyRank()) { - Parallel_Salome_file_i * servant = - new Parallel_Salome_file_i(CORBA::ORB::_duplicate(_orb), + Parallel_Salome_file_i * servant = + new Parallel_Salome_file_i(CORBA::ORB::_duplicate(_orb), proxy_ior.c_str(), i); - servant->copyGlobalContext(this); - - // We register the CORBA objet into the POA + servant->copyGlobalContext(this); + + // We register the CORBA object into the POA servant->POA_PaCO::InterfaceParallel::_this(); // Register the servant @@ -961,9 +919,9 @@ Engines_Parallel_Component_i::setInputFileToService(const char* service_name, return Engines::Salome_file::_narrow(proxy_ref); } -Engines::Salome_file_ptr -Engines_Parallel_Component_i::setOutputFileToService(const char* service_name, - const char* Salome_file_name) +Engines::Salome_file_ptr +Engines_Parallel_Component_i::setOutputFileToService(const char* service_name, + const char* Salome_file_name) { // Try to find the service, if it doesn't exist, we add it. _Service_file_map_it = _Output_Service_file_map.find(service_name); @@ -978,7 +936,7 @@ Engines_Parallel_Component_i::setOutputFileToService(const char* service_name, _t_Salome_file_map * _map = _Output_Service_file_map[service_name]; _t_Proxy_Salome_file_map * _proxy_map = _Proxy_Output_Service_file_map[service_name]; _t_IOR_Proxy_Salome_file_map * _IOR_proxy_map = _IOR_Proxy_Output_Service_file_map[service_name]; - + pthread_mutex_lock(deploy_mutex); std::string proxy_ior; @@ -997,16 +955,16 @@ Engines_Parallel_Component_i::setOutputFileToService(const char* service_name, if (getMyRank() == 0) { proxy = new Engines::Parallel_Salome_file_proxy_impl(CORBA::ORB::_duplicate(_orb), new paco_omni_fabrique()); - proxy->copyGlobalContext(this); + proxy->copyGlobalContext(this); PaCO::PacoTopology_t serveur_topo; serveur_topo.total = getTotalNode(); proxy->setTopology(serveur_topo); - // We register the CORBA objet into the POA + // We register the CORBA object into the POA CORBA::Object_ptr proxy_ref = proxy->_this(); // We send the reference to all the nodes... - Engines::Parallel_Component_var component_proxy = + Engines::Parallel_Component_var component_proxy = Engines::Parallel_Component::_narrow(InterfaceParallel_impl::_proxy); component_proxy->send_parallel_proxy_object(proxy_ref); @@ -1024,13 +982,13 @@ Engines_Parallel_Component_i::setOutputFileToService(const char* service_name, // into the proxy. for (int i = 0; i < getTotalNode(); i++) { if (i == getMyRank()) { - Parallel_Salome_file_i * servant = - new Parallel_Salome_file_i(CORBA::ORB::_duplicate(_orb), + Parallel_Salome_file_i * servant = + new Parallel_Salome_file_i(CORBA::ORB::_duplicate(_orb), proxy_ior.c_str(), i); - servant->copyGlobalContext(this); - - // We register the CORBA objet into the POA + servant->copyGlobalContext(this); + + // We register the CORBA object into the POA servant->POA_PaCO::InterfaceParallel::_this(); // Register the servant @@ -1060,9 +1018,9 @@ Engines_Parallel_Component_i::setOutputFileToService(const char* service_name, return Engines::Salome_file::_narrow(proxy_ref); } -Engines::Salome_file_ptr -Engines_Parallel_Component_i::getInputFileToService(const char* service_name, - const char* Salome_file_name) +Engines::Salome_file_ptr +Engines_Parallel_Component_i::getInputFileToService(const char* service_name, + const char* Salome_file_name) { // Try to find the service, if it doesn't exist, we throw an exception. _Proxy_Service_file_map_it = _Proxy_Input_Service_file_map.find(service_name); @@ -1088,9 +1046,9 @@ Engines_Parallel_Component_i::getInputFileToService(const char* service_name, return Sfile->_this(); } -Engines::Salome_file_ptr -Engines_Parallel_Component_i::getOutputFileToService(const char* service_name, - const char* Salome_file_name) +Engines::Salome_file_ptr +Engines_Parallel_Component_i::getOutputFileToService(const char* service_name, + const char* Salome_file_name) { // Try to find the service, if it doesn't exist, we throw an exception. _Proxy_Service_file_map_it = _Proxy_Output_Service_file_map.find(service_name); @@ -1117,8 +1075,8 @@ Engines_Parallel_Component_i::getOutputFileToService(const char* service_name, } -void -Engines_Parallel_Component_i::checkInputFilesToService(const char* service_name) +void +Engines_Parallel_Component_i::checkInputFilesToService(const char* service_name) { // Try to find the service, if it doesn't exist, nothing to do. _Proxy_Service_file_map_it = _Proxy_Input_Service_file_map.find(service_name); @@ -1136,8 +1094,8 @@ Engines_Parallel_Component_i::checkInputFilesToService(const char* service_name) } } -void -Engines_Parallel_Component_i::checkOutputFilesToService(const char* service_name) +void +Engines_Parallel_Component_i::checkOutputFilesToService(const char* service_name) { // Try to find the service, if it doesn't exist, nothing to do. _Proxy_Service_file_map_it = _Proxy_Output_Service_file_map.find(service_name); @@ -1157,21 +1115,21 @@ Engines_Parallel_Component_i::checkOutputFilesToService(const char* service_name } //============================================================================= -/*! +/*! * C++ method: Used by the Parallel Component to deploy a Parallel Salome_file - */ + */ //============================================================================= -void +void Engines_Parallel_Component_i::send_parallel_proxy_object(CORBA::Object_ptr proxy_ref) { _proxy = _orb->object_to_string(proxy_ref); } //============================================================================= -/*! +/*! * C++ method: Used by the Parallel Component to deploy a Parallel Salome_file - */ + */ //============================================================================= -void +void Engines_Parallel_Component_i::wait_parallel_object_proxy() { char * proxy = NULL; proxy = get_parallel_proxy_object(); @@ -1183,18 +1141,18 @@ Engines_Parallel_Component_i::wait_parallel_object_proxy() { } //============================================================================= -/*! +/*! * C++ method: Used by the Parallel Component to deploy a Parallel Salome_file - */ + */ //============================================================================= -char * +char * Engines_Parallel_Component_i::get_parallel_proxy_object() { return _proxy; } //============================================================================= -/*! +/*! * C++ method: used to configure the Salome_file into the runtime. * \param service_name name of the service that use this Salome_file * \param file_port_name name of the Salome_file @@ -1204,7 +1162,7 @@ Engines_Parallel_Component_i::get_parallel_proxy_object() { void Engines_Parallel_Component_i::configureSalome_file(std::string service_name, std::string file_port_name, - Engines::Parallel_Salome_file_proxy_impl * file) + Engines::Parallel_Salome_file_proxy_impl * file) { // By default this method does nothing }