X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FParallelContainer%2FSALOME_ParallelComponent_i.cxx;h=4a2e797172accb10b132b0ccaefb5e36b2d8bcef;hb=d8edd4804d9e6513a17c497c1a30326d4ba0d677;hp=112132bab75a5f413a5963561b2cc197bf544450;hpb=ebe3541632797c5fad97573b46655718ddd61444;p=modules%2Fkernel.git diff --git a/src/ParallelContainer/SALOME_ParallelComponent_i.cxx b/src/ParallelContainer/SALOME_ParallelComponent_i.cxx index 112132bab..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 @@ -53,11 +53,10 @@ int SIGUSR11 = 1000; extern bool _Sleeping ; static Engines_Parallel_Component_i * theEngines_Component ; -bool Engines_Parallel_Component_i::_isMultiStudy = false; 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), @@ -115,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) @@ -138,7 +137,7 @@ Engines_Parallel_Component_i::~Engines_Parallel_Component_i() } //============================================================================= -/*! +/*! * CORBA method: return name of the instance, unique in this Container */ //============================================================================= @@ -149,7 +148,7 @@ char* Engines_Parallel_Component_i::instanceName() } //============================================================================= -/*! +/*! * CORBA method: return name of the component class */ //============================================================================= @@ -160,7 +159,7 @@ char* Engines_Parallel_Component_i::interfaceName() } //============================================================================= -/*! +/*! * CORBA method: Test if instance is alive and responds */ //============================================================================= @@ -177,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 @@ -199,7 +198,7 @@ void Engines_Parallel_Component_i::destroy() } //============================================================================= -/*! +/*! * CORBA method: return CORBA reference of the Container * */ @@ -213,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) */ //============================================================================= @@ -234,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) */ @@ -257,7 +256,7 @@ Engines::FieldsDict* Engines_Parallel_Component_i::getProperties() } //============================================================================= -/*! +/*! * CORBA method: used by Supervision to give names to this instance */ //============================================================================= @@ -267,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 " @@ -306,7 +305,7 @@ bool Engines_Parallel_Component_i::Kill_impl() } //============================================================================= -/*! +/*! * CORBA method: used in Supervision */ //============================================================================= @@ -326,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 @@ -346,7 +345,7 @@ bool Engines_Parallel_Component_i::Stop_impl() } //============================================================================= -/*! +/*! * CORBA method: used in Supervision */ //============================================================================= @@ -378,7 +377,7 @@ bool Engines_Parallel_Component_i::Suspend_impl() { return false ; } - else + else { #ifndef WIN32 RetVal = Killer( _ThreadId ,SIGINT ) ; @@ -393,7 +392,7 @@ bool Engines_Parallel_Component_i::Suspend_impl() } //============================================================================= -/*! +/*! * CORBA method: used in Supervision */ //============================================================================= @@ -420,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 ; @@ -434,8 +433,8 @@ bool Engines_Parallel_Component_i::Resume_impl() } //============================================================================= -/*! - * CORBA method: +/*! + * CORBA method: */ //============================================================================= @@ -475,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 " @@ -492,7 +491,7 @@ CORBA::Long Engines_Parallel_Component_i::CpuUsed_impl() //============================================================================= -/*! +/*! * C++ method: return Container Servant */ //============================================================================= @@ -503,7 +502,7 @@ Engines_Parallel_Container_i *Engines_Parallel_Component_i::GetContainerPtr() } //============================================================================= -/*! +/*! * C++ method: return CORBA instance id, the id is set in derived class * constructor, when instance is activated. */ @@ -516,7 +515,7 @@ PortableServer::ObjectId * Engines_Parallel_Component_i::getId() } //============================================================================= -/*! +/*! * C++ method: used by derived classes for supervision */ //============================================================================= @@ -588,7 +587,7 @@ void Engines_Parallel_Component_i::beginService(const char *serviceName) } //============================================================================= -/*! +/*! * C++ method: used by derived classes for supervision */ //============================================================================= @@ -611,7 +610,7 @@ void Engines_Parallel_Component_i::endService(const char *serviceName) } //============================================================================= -/*! +/*! * C++ method: -- CHECK IF USED -- */ //============================================================================= @@ -622,7 +621,7 @@ char* Engines_Parallel_Component_i::graphName() } //============================================================================= -/*! +/*! * C++ method: -- CHECK IF USED -- */ //============================================================================= @@ -633,7 +632,7 @@ char* Engines_Parallel_Component_i::nodeName() } //============================================================================= -/*! +/*! * C++ method: used in Supervision (see kill_impl) */ //============================================================================= @@ -671,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 @@ -687,9 +686,9 @@ bool Engines_Parallel_Component_i::Killer( pthread_t ThreadId , int signum ) } //============================================================================= -/*! +/*! * C++ method: - */ + */ //============================================================================= void SetCpuUsed() @@ -699,7 +698,7 @@ void SetCpuUsed() } //============================================================================= -/*! +/*! * C++ method: */ //============================================================================= @@ -707,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: */ //============================================================================= @@ -737,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 @@ -766,7 +765,7 @@ void Engines_Parallel_Component_i::CancelThread() } //============================================================================= -/*! +/*! * C++ method: Send message to event channel */ //============================================================================= @@ -778,7 +777,7 @@ void Engines_Parallel_Component_i::sendMessage(const char *event_type, } //============================================================================= -/*! +/*! * C++ method: return standard library name built on component name */ //============================================================================= @@ -788,39 +787,42 @@ std::string Engines_Parallel_Component_i::GetDynLibraryName(const char *componen #ifndef WIN32 std::string ret="lib"; ret+=componentName; +#ifdef __APPLE__ + ret+="Engine.dylib"; +#else ret+="Engine.so"; +#endif #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); @@ -835,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; @@ -854,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); @@ -881,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 @@ -917,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); @@ -934,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; @@ -953,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); @@ -980,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 @@ -1016,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); @@ -1044,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); @@ -1073,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); @@ -1092,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); @@ -1113,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(); @@ -1139,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 @@ -1160,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 }