From 40fd9d9c992ea33700f6eca3f953b3060b41003c Mon Sep 17 00:00:00 2001 From: mkr Date: Fri, 22 Jul 2005 11:33:47 +0000 Subject: [PATCH] Merge with BR_V300_lcrm branch. --- src/Container/Component_i.cxx | 32 +- src/Container/Container_i.cxx | 84 ++- src/Container/SALOME_Component_i.hxx | 6 +- src/Container/SALOME_Container.cxx | 156 ++---- src/Container/SALOME_ContainerManager.cxx | 47 +- src/Container/SALOME_ContainerManager.hxx | 10 +- .../SALOME_ContainerManagerServer.cxx | 6 + src/Container/SALOME_Container_i.hxx | 21 +- src/LifeCycleCORBA/Makefile.in | 2 +- src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx | 480 +++++------------- src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx | 59 ++- src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py | 41 ++ src/LifeCycleCORBA_SWIG/Makefile.in | 52 ++ src/LifeCycleCORBA_SWIG/TestLifeCycleCORBA.py | 18 + .../libSALOME_LifeCycleCORBA.i | 104 ++++ src/MPIContainer/MPIContainer_i.cxx | 441 ++++++++++------ src/MPIContainer/MPIContainer_i.hxx | 38 +- src/MPIContainer/Makefile.in | 7 +- src/MPIContainer/SALOME_MPIContainer.cxx | 13 +- src/MPILifeCycleCORBA/MPILifeCycleCORBA.py | 143 ------ src/MPILifeCycleCORBA/MPIsalome.py | 5 - src/MPILifeCycleCORBA/Makefile.in | 38 -- .../SALOME_MPILifeCycleCORBA.cxx | 357 ------------- .../SALOME_MPILifeCycleCORBA.hxx | 45 -- .../TestMPILifeCycleCORBA.cxx | 70 --- src/Makefile.in | 7 +- src/NamingService/SALOME_NamingService.cxx | 133 ++++- src/NamingService/SALOME_NamingService.hxx | 19 +- .../SALOME_ResourcesManager.cxx | 114 +++-- .../SALOME_ResourcesManager.hxx | 10 +- src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx | 2 +- src/TestMPIContainer/Makefile.in | 2 +- src/TestMPIContainer/TestMPIContainer.cxx | 6 +- 33 files changed, 1093 insertions(+), 1475 deletions(-) create mode 100644 src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py create mode 100644 src/LifeCycleCORBA_SWIG/Makefile.in create mode 100644 src/LifeCycleCORBA_SWIG/TestLifeCycleCORBA.py create mode 100644 src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i delete mode 100644 src/MPILifeCycleCORBA/MPILifeCycleCORBA.py delete mode 100644 src/MPILifeCycleCORBA/MPIsalome.py delete mode 100644 src/MPILifeCycleCORBA/Makefile.in delete mode 100644 src/MPILifeCycleCORBA/SALOME_MPILifeCycleCORBA.cxx delete mode 100644 src/MPILifeCycleCORBA/SALOME_MPILifeCycleCORBA.hxx delete mode 100644 src/MPILifeCycleCORBA/TestMPILifeCycleCORBA.cxx diff --git a/src/Container/Component_i.cxx b/src/Container/Component_i.cxx index 01ad220b8..2d3ef4c52 100644 --- a/src/Container/Component_i.cxx +++ b/src/Container/Component_i.cxx @@ -250,21 +250,14 @@ void Engines_Component_i::destroy() Engines::Container_ptr Engines_Component_i::GetContainerRef() { - MESSAGE("Engines_Component_i::GetContainerRef"); CORBA::Object_ptr o = _poa->id_to_reference(*_contId) ; return Engines::Container::_narrow(o); } -//============================================================================= -/*! - * 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. - * \param dico sequence of (key=string,value=any) - */ -//============================================================================= +Engines_Container_i *Engines_Component_i::GetContainerPtr() +{ + return dynamic_cast(_poa->id_to_servant(*_contId)) ; +} void Engines_Component_i::setProperties(const Engines::FieldsDict& dico) { @@ -778,22 +771,6 @@ string Engines_Component_i::GetDynLibraryName(const char *componentName) return ret; } -//============================================================================= -/*! - * C++ method: - */ -//============================================================================= - -string Engines_Component_i::BuildComponentNameForNS(const char *ComponentName, - const char *ContainerName, - const char *hostname) -{ - string ret = - Engines_Container_i::BuildContainerNameForNS(ContainerName,hostname); - ret+="/"; - ret+=ComponentName; - return ret; -} //============================================================================= /*! * C++ method: DumpPython default implementation @@ -813,3 +790,4 @@ Engines::TMPFile* Engines_Component_i::DumpPython(CORBA::Object_ptr theStudy, isValidScript = true; return aStreamFile._retn(); } + diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index 681532b53..02d8254fb 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -56,7 +56,7 @@ using namespace std; bool _Sleeping = false ; -// Needed by multi-threaded Python +// // Needed by multi-threaded Python --- Supervision int _ArgC ; char ** _ArgV ; @@ -72,7 +72,6 @@ extern "C" {void SigIntHandler(int, siginfo_t *, void *) ; } #endif -const char *Engines_Container_i::_defaultContainerName="FactoryServer"; map Engines_Container_i::_cntInstances_map; map Engines_Container_i::_library_map; map Engines_Container_i::_toRemove_map; @@ -109,25 +108,14 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, if(activAndRegist) ActSigIntHandler() ; - _ArgC = argc ; - _ArgV = argv ; - _argc = argc ; _argv = argv ; - int i = strlen( _argv[ 0 ] ) - 1 ; - while ( i >= 0 ) - { - if ( _argv[ 0 ][ i ] == '/' ) - { - _argv[ 0 ][ i+1 ] = '\0' ; - break ; - } - i -= 1 ; - } + string hostname = GetHostname(); MESSAGE(hostname << " " << getpid() << " Engines_Container_i starting argc " << _argc << " Thread " << pthread_self() ) ; - i = 0 ; + + int i = 0 ; while ( _argv[ i ] ) { MESSAGE(" argv" << i << " " << _argv[ i ]) ; @@ -143,8 +131,12 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, _isSupervContainer = false; if (strcmp(argv[1],"SuperVisionContainer") == 0) _isSupervContainer = true; - _containerName = BuildContainerNameForNS(containerName,hostname.c_str()); - + if (_isSupervContainer) + { + _ArgC = argc ; + _ArgV = argv ; + } + _orb = CORBA::ORB::_duplicate(orb) ; _poa = PortableServer::POA::_duplicate(poa) ; @@ -159,6 +151,8 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, CORBA::Object_var obj=_poa->id_to_reference(*_id); Engines::Container_var pCont = Engines::Container::_narrow(obj); + + _containerName = _NS->BuildContainerNameForNS(containerName,hostname.c_str()); SCRUTE(_containerName); _NS->Register(pCont, _containerName.c_str()); @@ -253,7 +247,7 @@ void Engines_Container_i::ping() void Engines_Container_i::Shutdown() { MESSAGE("Engines_Container_i::Shutdown()"); - _NS->Destroy_Name(_containerName.c_str()); + _NS->Destroy_FullDirectory(_containerName.c_str()); //_remove_ref(); //_poa->deactivate_object(*_id); if(_isServantAloneInProcess) @@ -781,25 +775,6 @@ bool Engines_Container_i::isPythonContainer(const char* ContainerName) return ret; } -//============================================================================= -/*! - * Returns string = container path + name, to use in Naming service - */ -//============================================================================= - -string Engines_Container_i::BuildContainerNameForNS(const char *ContainerName, - const char *hostname) -{ - string ret="/Containers/"; - ret += hostname; - ret+="/"; - if (strlen(ContainerName)== 0) - ret+=_defaultContainerName; - else - ret += ContainerName; - return ret; -} - //============================================================================= /*! * @@ -825,7 +800,13 @@ void ActSigIntHandler() perror("SALOME_Container main ") ; exit(0) ; } - INFOS(pthread_self() << "SigIntHandler activated") ; + //PAL9042 JR : during the execution of a Signal Handler (and of methods called through Signal Handlers) + // use of streams (and so on) should never be used because : + // streams of C++ are naturally thread-safe and use pthread_mutex_lock ===> + // A stream operation may be interrupted by a signal and if the Handler use stream we + // may have a "Dead-Lock" ===HangUp + //==INFOS is commented + // INFOS(pthread_self() << "SigIntHandler activated") ; #else signal( SIGINT, SigIntHandler ); signal( SIGUSR1, SigIntHandler ); @@ -837,15 +818,20 @@ void SetCpuUsed() ; #ifndef WNT void SigIntHandler(int what , siginfo_t * siginfo , - void * toto ) -{ - MESSAGE(pthread_self() << "SigIntHandler what " << what << endl - << " si_signo " << siginfo->si_signo << endl - << " si_code " << siginfo->si_code << endl - << " si_pid " << siginfo->si_pid) ; + void * toto ) { + //PAL9042 JR : during the execution of a Signal Handler (and of methods called through Signal Handlers) + // use of streams (and so on) should never be used because : + // streams of C++ are naturally thread-safe and use pthread_mutex_lock ===> + // A stream operation may be interrupted by a signal and if the Handler use stream we + // may have a "Dead-Lock" ===HangUp + //==MESSAGE is commented + // MESSAGE(pthread_self() << "SigIntHandler what " << what << endl + // << " si_signo " << siginfo->si_signo << endl + // << " si_code " << siginfo->si_code << endl + // << " si_pid " << siginfo->si_pid) ; if ( _Sleeping ) { _Sleeping = false ; - MESSAGE("SigIntHandler END sleeping.") ; + // MESSAGE("SigIntHandler END sleeping.") ; return ; } else { @@ -855,13 +841,13 @@ void SigIntHandler(int what , siginfo_t * siginfo , } else { _Sleeping = true ; - MESSAGE("SigIntHandler BEGIN sleeping.") ; + // MESSAGE("SigIntHandler BEGIN sleeping.") ; int count = 0 ; while( _Sleeping ) { sleep( 1 ) ; count += 1 ; } - MESSAGE("SigIntHandler LEAVE sleeping after " << count << " s.") ; + // MESSAGE("SigIntHandler LEAVE sleeping after " << count << " s.") ; } return ; } @@ -998,3 +984,5 @@ void SigIntHandler( int what ) { // MESSAGE("Engines_Container_i::machineName " << s); // return CORBA::string_dup(s.c_str()) ; // } + + diff --git a/src/Container/SALOME_Component_i.hxx b/src/Container/SALOME_Component_i.hxx index b30f87aa4..f20b5a141 100644 --- a/src/Container/SALOME_Component_i.hxx +++ b/src/Container/SALOME_Component_i.hxx @@ -43,6 +43,7 @@ #include "NOTIFICATION.hxx" class RegistryConnexion; +class Engines_Container_i; #if defined CONTAINER_EXPORTS #if defined WIN32 @@ -87,6 +88,7 @@ public: void ping(); Engines::Container_ptr GetContainerRef(); + Engines_Container_i *GetContainerPtr(); PortableServer::ObjectId * getId(); void setProperties(const Engines::FieldsDict& dico); @@ -115,9 +117,6 @@ public: static bool isMultiStudy(); static bool isMultiInstance(); static std::string GetDynLibraryName(const char *componentName); - static std::string BuildComponentNameForNS(const char *ComponentName, - const char *ContainerName, - const char *hostname); protected: static bool _isMultiStudy; static bool _isMultiInstance; @@ -148,3 +147,4 @@ private: }; #endif + diff --git a/src/Container/SALOME_Container.cxx b/src/Container/SALOME_Container.cxx index e5308e8ab..3e13155c3 100644 --- a/src/Container/SALOME_Container.cxx +++ b/src/Container/SALOME_Container.cxx @@ -30,10 +30,7 @@ #include #include -//#include "Utils_ORB_INIT.hxx" -//#include "Utils_SINGLETON.hxx" #include -#include "SALOME_NamingService.hxx" #include "SALOME_Container_i.hxx" #include "utilities.h" #include "SALOMETraceCollector.hxx" @@ -58,6 +55,7 @@ int main(int argc, char* argv[]) #ifdef HAVE_MPI2 MPI_Init(&argc,&argv); #endif + // Initialise the ORB. CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ; SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); @@ -80,117 +78,67 @@ int main(int argc, char* argv[]) Py_Initialize() ; PySys_SetArgv( argc , argv ) ; } - - try{ - // Obtain a reference to the root POA. - // obtain the root poa manager - // - long TIMESleep = 500000000; - int NumberOfTries = 40; - int a; - timespec ts_req; - ts_req.tv_nsec=TIMESleep; - ts_req.tv_sec=0; - timespec ts_rem; - ts_rem.tv_nsec=0; - ts_rem.tv_sec=0; - CosNaming::NamingContext_var inc; - PortableServer::POA_var root_poa; - CORBA::Object_var theObj; - CORBA::Object_var obj; - CORBA::Object_var object; - //SALOME_NamingService &naming = *SINGLETON_::Instance() ; - int CONTAINER=0; - const char * Env = getenv("USE_LOGGER"); - int EnvL =0; - if(Env != NULL && strlen(Env)) - EnvL=1; - - CosNaming::Name name; - name.length(1); - name[0].id=CORBA::string_dup("Logger"); - PortableServer::POAManager_var pman; - for(int i = 1; i <= NumberOfTries; i++){ - if(i != 1) - a=nanosleep(&ts_req,&ts_rem); - try{ - obj = orb->resolve_initial_references("RootPOA"); - if(!CORBA::is_nil(obj)) - root_poa = PortableServer::POA::_narrow(obj); - if(!CORBA::is_nil(root_poa)) - pman = root_poa->the_POAManager(); - if(!CORBA::is_nil(orb)) - theObj = orb->resolve_initial_references("NameService"); - if (!CORBA::is_nil(theObj)) - inc = CosNaming::NamingContext::_narrow(theObj); - }catch(CORBA::SystemException&){ - MESSAGE( "Container: CORBA::SystemException: Unable to contact the Naming Service" ); - } - if(!CORBA::is_nil(inc)){ - MESSAGE( "Container: Naming Service was found" ); - if(EnvL == 1){ - for(int j = 1; j <= NumberOfTries; j++){ - if(j != 1) - a=nanosleep(&ts_req, &ts_rem); - try{ - object = inc->resolve(name); - }catch(CosNaming::NamingContext::NotFound){ - MESSAGE( "Container: Logger Server wasn't found" ); - }catch(...){ - MESSAGE( "Container: Unknown exception" ); - } - if(!CORBA::is_nil(object)){ - MESSAGE( "Container: Logger Server was found" ); - CONTAINER = 1; - break; - } - } - } - } - if(CONTAINER == 1 || (EnvL == 0 && !CORBA::is_nil(inc))) - break; - } - char *containerName = ""; - if(argc > 1){ + char *containerName = ""; + if(argc > 1) + { containerName = argv[1] ; } - // add new container to the kill list - char aCommand[40]; - sprintf(aCommand, "addToKillList.py %d SALOME_Container", getpid()); - system(aCommand); - - Engines_Container_i * myContainer - = new Engines_Container_i(orb, root_poa, containerName , argc , argv ); + try + { + CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); + ASSERT(!CORBA::is_nil(obj)); + PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); - pman->activate(); - + PortableServer::POAManager_var pman = root_poa->the_POAManager(); + + // add new container to the kill list + char aCommand[40]; + sprintf(aCommand, "addToKillList.py %d SALOME_Container", getpid()); + system(aCommand); + + Engines_Container_i * myContainer + = new Engines_Container_i(orb, root_poa, containerName , argc , argv ); + + pman->activate(); + #ifdef CHECKTIME - Utils_Timer timer; - timer.Start(); - timer.Stop(); - MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); - timer.ShowAbsolute(); + Utils_Timer timer; + timer.Start(); + timer.Stop(); + MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); + timer.ShowAbsolute(); #endif - - HandleServerSideSignals(orb); - }catch(CORBA::SystemException&){ - INFOS("Caught CORBA::SystemException."); - }catch(PortableServer::POA::WrongPolicy&){ - INFOS("Caught CORBA::WrongPolicyException."); - }catch(PortableServer::POA::ServantAlreadyActive&){ - INFOS("Caught CORBA::ServantAlreadyActiveException"); - }catch(CORBA::Exception&){ - INFOS("Caught CORBA::Exception."); - }catch(std::exception& exc){ - INFOS("Caught std::exception - "<the_POAManager(); PortableServer::POA_var my_poa; @@ -29,15 +31,19 @@ SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb) CORBA::Object_var obj=my_poa->id_to_reference(id); Engines::ContainerManager_var refContMan = Engines::ContainerManager::_narrow(obj); _NS->Register(refContMan,_ContainerManagerNameInNS); + MESSAGE("constructor end"); } SALOME_ContainerManager::~SALOME_ContainerManager() { + MESSAGE("destructor"); delete _NS; + delete _ResManager; } void SALOME_ContainerManager::Shutdown() { + MESSAGE("Shutdown"); ShutdownContainers(); PortableServer::ObjectId_var oid = _default_POA()->servant_to_id(this); _default_POA()->deactivate_object(oid); @@ -47,6 +53,7 @@ void SALOME_ContainerManager::Shutdown() void SALOME_ContainerManager::ShutdownContainers() { + MESSAGE("ShutdownContainers"); _NS->Change_Directory("/Containers"); vector vec=_NS->list_directory_recurs(); for(vector::iterator iter=vec.begin();iter!=vec.end();iter++) @@ -59,20 +66,20 @@ void SALOME_ContainerManager::ShutdownContainers() } } -Engines::Container_ptr SALOME_ContainerManager::FindOrStartContainer(const char *containerName, const Engines::MachineList& possibleComputers) +Engines::Container_ptr SALOME_ContainerManager::FindOrStartContainer(const Engines::MachineParameters& params, const Engines::MachineList& possibleComputers) { - Engines::Container_ptr ret=FindContainer(containerName,possibleComputers); + Engines::Container_ptr ret=FindContainer(params,possibleComputers); if(!CORBA::is_nil(ret)) return ret; - // Container doesn't exist try to launch it ... + MESSAGE("Container doesn't exist try to launch it ..."); vector vector; - string theMachine=_LoadManager.FindBest(possibleComputers); + string theMachine=_ResManager->FindBest(possibleComputers); string command; if(theMachine==GetHostname()) - command=_ResManager.BuildCommandToLaunchLocalContainer(containerName); + command=_ResManager->BuildCommandToLaunchLocalContainer(params); else - command=_ResManager.BuildTempFileToLaunchRemoteContainer(theMachine,containerName); - _ResManager.RmTmpFile(); + command=_ResManager->BuildTempFileToLaunchRemoteContainer(theMachine,params); + _ResManager->RmTmpFile(); int status=system(command.c_str()); if (status == -1) { MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status -1)"); @@ -93,7 +100,7 @@ Engines::Container_ptr SALOME_ContainerManager::FindOrStartContainer(const char count-- ; if ( count != 10 ) MESSAGE( count << ". Waiting for FactoryServer on " << theMachine); - string containerNameInNS=BuildContainerNameInNS(containerName,theMachine.c_str()); + string containerNameInNS=_NS->BuildContainerNameForNS(params,theMachine.c_str()); SCRUTE(containerNameInNS); CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str()); ret=Engines::Container::_narrow(obj); @@ -107,8 +114,9 @@ Engines::Container_ptr SALOME_ContainerManager::FindOrStartContainer(const char Engines::MachineList *SALOME_ContainerManager::GetFittingResources(const Engines::MachineParameters& params, const char *componentName) { - vector vec=_ResManager.GetFittingResources(params,componentName); + vector vec=_ResManager->GetFittingResources(params,componentName); Engines::MachineList *ret=new Engines::MachineList; + MESSAGE("Machine list length "<length(vec.size()); for(unsigned int i=0;iFindBest(possibleComputers); return CORBA::string_dup(theMachine.c_str()); } -Engines::Container_ptr SALOME_ContainerManager::FindContainer(const char *containerName,const char *theMachine) +Engines::Container_ptr SALOME_ContainerManager::FindContainer(const Engines::MachineParameters& params,const char *theMachine) { - string containerNameInNS(BuildContainerNameInNS(containerName,theMachine)); - SCRUTE(containerNameInNS); + string containerNameInNS(_NS->BuildContainerNameForNS(params,theMachine)); CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str()); if( !CORBA::is_nil(obj) ) return Engines::Container::_narrow(obj); @@ -134,22 +141,14 @@ Engines::Container_ptr SALOME_ContainerManager::FindContainer(const char *contai return Engines::Container::_nil(); } -Engines::Container_ptr SALOME_ContainerManager::FindContainer(const char *containerName,const Engines::MachineList& possibleComputers) +Engines::Container_ptr SALOME_ContainerManager::FindContainer(const Engines::MachineParameters& params,const Engines::MachineList& possibleComputers) { + MESSAGE("FindContainer "<resolve_initial_references("RootPOA"); if(!CORBA::is_nil(obj)) @@ -35,5 +39,7 @@ int main(int argc, char* argv[]) }catch(...){ MESSAGE("Caught unknown exception."); } + END_OF(argv[0]); + delete myThreadTrace; } diff --git a/src/Container/SALOME_Container_i.hxx b/src/Container/SALOME_Container_i.hxx index b1dc79e80..8692181f8 100644 --- a/src/Container/SALOME_Container_i.hxx +++ b/src/Container/SALOME_Container_i.hxx @@ -75,9 +75,9 @@ public: // --- CORBA methods - bool load_component_Library(const char* componentName); + virtual bool load_component_Library(const char* componentName); - Engines::Component_ptr + virtual Engines::Component_ptr create_component_instance( const char* componentName, CORBA::Long studyId); // 0 for multiStudy @@ -92,16 +92,16 @@ public: void remove_impl(Engines::Component_ptr component_i); void finalize_removal(); - void Shutdown(); char* getHostName(); CORBA::Long getPID(); char* name(); - void ping(); - + char* machineName(); + virtual void ping(); + virtual void Shutdown(); + //! Kill current container bool Kill_impl() ; - //char* machineName(); //Engines::Component_ptr instance(const char* nameToRegister, // const char* componentName); @@ -117,13 +117,13 @@ public: int studyId); static bool isPythonContainer(const char* ContainerName); - static std::string BuildContainerNameForNS(const char *ContainerName, - const char *hostname); static void decInstanceCnt(std::string genericRegisterName); protected: - static const char *_defaultContainerName; + int getArgc() { return _argc; } + char **getArgv() { return _argv; } + static std::map _cntInstances_map; static std::map _library_map; // library names, loaded static std::map _toRemove_map;// library names to remove @@ -131,7 +131,7 @@ protected: bool _isSupervContainer; - SALOME_NamingService *_NS ; + SALOME_NamingService *_NS ; std::string _library_path; std::string _containerName; CORBA::ORB_var _orb; @@ -150,3 +150,4 @@ protected: #endif + diff --git a/src/LifeCycleCORBA/Makefile.in b/src/LifeCycleCORBA/Makefile.in index 3b825582f..b23e0d50a 100644 --- a/src/LifeCycleCORBA/Makefile.in +++ b/src/LifeCycleCORBA/Makefile.in @@ -36,7 +36,7 @@ VPATH=.:@srcdir@:@top_srcdir@/idl EXPORT_HEADERS = SALOME_LifeCycleCORBA.hxx -EXPORT_PYSCRIPTS = LifeCycleCORBA.py Launchers.py +EXPORT_PYSCRIPTS = Launchers.py # Libraries targets diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index 34ba164d5..0efb425e5 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -2,7 +2,7 @@ // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either @@ -48,6 +48,15 @@ #include "SALOME_NamingService.hxx" using namespace std; +IncompatibleComponent::IncompatibleComponent( void ): SALOME_Exception( "IncompatibleComponent" ) +{ + ; +} +IncompatibleComponent::IncompatibleComponent( const IncompatibleComponent &ex ): SALOME_Exception( ex ) +{ + ; +} + //============================================================================= /*! * Constructor @@ -56,7 +65,15 @@ using namespace std; SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService *ns) { - _NS = ns; + if (!ns) + { + int argc = 0; + char *xargv = ""; + char **argv = &xargv; + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + _NS = new SALOME_NamingService(orb); + } + else _NS = ns; //add try catch _NS->Change_Directory("/"); // mpv 250105: current directory may be not root // (in SALOMEDS for an example) @@ -80,121 +97,17 @@ SALOME_LifeCycleCORBA::~SALOME_LifeCycleCORBA() { } -//============================================================================= -/*! Public - - * Look for a fully qualified container name in Naming Service - * \param containerName name of the container to find. - * if containerName begins with "/Containers/" it's used as it is. - * We assume string = "/Containers/machine/aContainerName" - * else - * we assume string = "aContainerName" or "machine/aContainerName". - * string "/Containers/machine/aContainerName" is rebuilt. - * if machine = "localhost", machine replaced by GetHostname() - * \return Container CORBA reference or _nil if not found in Naming Service - */ -//============================================================================= - -Engines::Container_ptr -SALOME_LifeCycleCORBA::FindContainer(const char *containerName) -{ - ASSERT(_NS != NULL); - string cont ; - if ( strncmp( containerName , "/Containers/" , 12 ) ) - { // Compatibility ... - string theComputer ; - string theContainer ; - cont = ContainerName( containerName , &theComputer , &theContainer ) ; - } - else - { - cont = containerName ; - } - try - { - SCRUTE( cont ); - CORBA::Object_var obj = _NS->Resolve( cont.c_str() ); - if( !CORBA::is_nil( obj ) ) - { - return Engines::Container::_narrow( obj ) ; - } - } - catch (ServiceUnreachable&) - { - INFOS("Caught exception: Naming Service Unreachable"); - } - catch (...) - { - INFOS("Caught unknown exception."); - } - return Engines::Container::_nil(); -} - -//============================================================================= -/*! Public - - * Find and aready existing and registered component instance. - * \param params machine parameters like type or name... - * \param componentName the name of component class - * \param studyId default = 0 : multistudy instance - * \param instanceName default = "" : to retrieve a specific instance - * \return a CORBA reference of the component instance, or _nil if not found - */ -//============================================================================= - Engines::Component_ptr -SALOME_LifeCycleCORBA::FindComponent(const Engines::MachineParameters& params, - const char *componentName, - int studyId, - const char *instanceName) +SALOME_LifeCycleCORBA::FindOrLoad_Component(const Engines::MachineParameters& params, + const char *componentName, + int studyId) { - ASSERT(0); - return 0; -} - -//============================================================================= -/*! Public - - * Load a component instance on a container defined by machine parameters - * \param params machine parameters like type or name... - * \param componentName the name of component class - * \param studyId default = 0 : multistudy instance - * \return a CORBA reference of the component instance, or _nil if problem - */ -//============================================================================= - -Engines::Component_ptr -SALOME_LifeCycleCORBA::LoadComponent(const Engines::MachineParameters& params, - const char *componentName, - int studyId) -{ - ASSERT(0); - return 0; -} - -//============================================================================= -/*! Public - - * Find and aready existing and registered component instance or load a new - * component instance on a container defined by machine parameters - * \param params machine parameters like type or name... - * \param componentName the name of component class - * \param studyId default = 0 : multistudy instance - * \return a CORBA reference of the component instance, or _nil if problem - */ -//============================================================================= - -Engines::Component_ptr -SALOME_LifeCycleCORBA:: -FindOrLoad_Component(const Engines::MachineParameters& params, - const char *componentName, - int studyId) -{ - if (! isKnownComponentClass(componentName)) - return Engines::Component::_nil(); + if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); - Engines::MachineList_var listOfMachine = - _ContManager->GetFittingResources(params,componentName); - Engines::Component_ptr ret= - FindComponent(params.container_name,componentName,listOfMachine); + Engines::MachineList_var listOfMachine=_ContManager->GetFittingResources(params,componentName); + Engines::Component_ptr ret=FindComponent(params,componentName,listOfMachine); if(CORBA::is_nil(ret)) - return LoadComponent(params.container_name,componentName,listOfMachine); + return LoadComponent(params,componentName,listOfMachine); else return ret; } @@ -207,7 +120,7 @@ FindOrLoad_Component(const Engines::MachineParameters& params, * - 1 localhost/aContainer * - 2 aContainer * - 3 /machine/aContainer - * (not the same rules as FindContainer() method base on protected method + * (not the same rules as FindContainer() method based on protected method * ContainerName() -- MUST BE CORRECTED --) * \param componentName the name of component class * \return a CORBA reference of the component instance, or _nil if problem @@ -218,49 +131,28 @@ Engines::Component_ptr SALOME_LifeCycleCORBA::FindOrLoad_Component(const char *containerName, const char *componentName) { - if (!isKnownComponentClass(componentName)) return Engines::Component::_nil(); + // Check if Component Name is known + if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); + // Chack if containerName contains machine name (if yes: rg>0) char *stContainer=strdup(containerName); string st2Container(stContainer); int rg=st2Container.find("/"); - if(rg>=0) - { - stContainer[rg]='\0'; - if(strcmp(stContainer,"localhost")==0) - { - Engines::Component_ptr ret=FindOrLoad_Component(stContainer+rg+1, - componentName); - free(stContainer); - return ret; - } - else ASSERT(0); // no return in that case... - } - if(rg<0) - { - //containerName doesn't contain "/" => Local container - free(stContainer); - Engines::MachineList_var listOfMachine=new Engines::MachineList; - listOfMachine->length(1); - listOfMachine[0]=CORBA::string_dup(GetHostname().c_str()); - Engines::Component_ptr ret = FindComponent(containerName, - componentName, - listOfMachine.in()); - if(CORBA::is_nil(ret)) - return LoadComponent(containerName,componentName,listOfMachine); - else - return ret; - } - else - { - //containerName contains "/" => Remote container - stContainer[rg]='\0'; - Engines::MachineParameters_var params=new Engines::MachineParameters; - params->container_name=CORBA::string_dup(stContainer+rg+1); - params->hostname=CORBA::string_dup(stContainer); - params->OS=CORBA::string_dup("LINUX"); - free(stContainer); - return FindOrLoad_Component(params,componentName); - } + + Engines::MachineParameters_var params=new Engines::MachineParameters; + if(rg<0) { + params->container_name=CORBA::string_dup(stContainer); + params->hostname=CORBA::string_dup(GetHostname().c_str()); + } + else { + stContainer[rg]='\0'; + params->container_name=CORBA::string_dup(stContainer+rg+1); + params->hostname=CORBA::string_dup(stContainer); + } + params->isMPI = false; + free(stContainer); + return FindOrLoad_Component(params,componentName); + } //============================================================================= @@ -299,228 +191,102 @@ bool SALOME_LifeCycleCORBA::isKnownComponentClass(const char *componentName) return false; } -//============================================================================= -/*! Protected - - * - */ -//============================================================================= +bool SALOME_LifeCycleCORBA::isMpiContainer(const Engines::MachineParameters& params) throw(IncompatibleComponent) +{ +// MESSAGE(params.container_name) +// if( strstr(params.container_name,"MPI") ){ +// if( !params.isMPI ){ +// cerr << "IncompatibleComponent" << endl; +// throw IncompatibleComponent(); +// } +// return true; +// } +// else{ +// if( params.isMPI ){ +// cerr << "IncompatibleComponent" << endl; +// throw IncompatibleComponent(); +// } +// return false; +// } + if( params.isMPI ) + return true; + else + return false; +} + +int SALOME_LifeCycleCORBA::NbProc(const Engines::MachineParameters& params) +{ + if( !isMpiContainer(params) ) + return 0; + else if( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) ) + return 1; + else if( params.nb_node == 0 ) + return params.nb_proc_per_node; + else if( params.nb_proc_per_node == 0 ) + return params.nb_node; + else + return params.nb_node * params.nb_proc_per_node; +} Engines::Component_ptr -SALOME_LifeCycleCORBA::FindComponent(const char *containerName, - const char *componentName, - const Engines::MachineList& listOfMachines) +SALOME_LifeCycleCORBA::FindComponent(const Engines::MachineParameters& params, + const char *componentName, + const Engines::MachineList& listOfMachines) { + const char *containerName = params.container_name; + int nbproc = NbProc(params); + if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); - if(containerName[0]!='\0') - { - Engines::MachineList_var machinesOK=new Engines::MachineList; - unsigned int lghtOfmachinesOK=0; - machinesOK->length(listOfMachines.length()); - for(unsigned int i=0;iResolveFirst(componentNameForNS.c_str()); - if(!CORBA::is_nil(obj)) - { - machinesOK[lghtOfmachinesOK++]=CORBA::string_dup(currentMachine); - } - } - if(lghtOfmachinesOK!=0) - { - machinesOK->length(lghtOfmachinesOK); - CORBA::String_var bestMachine=_ContManager->FindBest(machinesOK); - string componentNameForNS = - Engines_Component_i::BuildComponentNameForNS(componentName, - containerName, - bestMachine); - SCRUTE(componentNameForNS); - CORBA::Object_var obj=_NS->ResolveFirst(componentNameForNS.c_str()); - return Engines::Component::_narrow(obj); - } - else - return Engines::Component::_nil(); - } + + // find list of machines which have component + Engines::MachineList_var machinesOK=new Engines::MachineList; + unsigned int lghtOfmachinesOK=0; + machinesOK->length(listOfMachines.length()); + for(unsigned int i=0;iResolveComponent(currentMachine,containerName,componentName,nbproc); + if(!CORBA::is_nil(obj)) + machinesOK[lghtOfmachinesOK++]=CORBA::string_dup(currentMachine); + } + + // find the best machine among the list which have component + if(lghtOfmachinesOK!=0) { + machinesOK->length(lghtOfmachinesOK); + CORBA::String_var bestMachine=_ContManager->FindBest(machinesOK); + CORBA::Object_var obj = _NS->ResolveComponent(bestMachine,containerName,componentName,nbproc); + return Engines::Component::_narrow(obj); + } else - { - //user specified no container name so trying to find a component in - //the best machine among listOfMachines - CORBA::String_var bestMachine=_ContManager->FindBest(listOfMachines); - //Normally look at all containers launched on bestMachine to see if - //componentName is already launched on one of them. To do.. - string componentNameForNS = - Engines_Component_i::BuildComponentNameForNS(componentName, - containerName, - bestMachine); - SCRUTE(componentNameForNS); - CORBA::Object_var obj = _NS->ResolveFirst(componentNameForNS.c_str()); - return Engines::Component::_narrow(obj); - } + return Engines::Component::_nil(); } -//============================================================================= -/*! Protected - - * - */ -//============================================================================= - -Engines::Component_ptr -SALOME_LifeCycleCORBA::LoadComponent(const char *containerName, - const char *componentName, - const Engines::MachineList& listOfMachines) +Engines::Component_ptr +SALOME_LifeCycleCORBA::LoadComponent(const Engines::MachineParameters& params, + const char *componentName, + const Engines::MachineList& listOfMachines) { - Engines::Container_var cont=_ContManager->FindOrStartContainer(containerName, - listOfMachines); - //string implementation=Engines_Component_i::GetDynLibraryName(componentName); - //return cont->load_impl(componentName, implementation.c_str()); - return cont->load_impl(componentName,""); + Engines::Container_var cont=_ContManager->FindOrStartContainer(params,listOfMachines); + if (CORBA::is_nil(cont)) return Engines::Component::_nil(); + + bool isLoadable = cont->load_component_Library(componentName); + if (!isLoadable) return Engines::Component::_nil(); + + Engines::Component_var myInstance = + cont->create_component_instance(componentName, 0); + return myInstance._retn(); } -//============================================================================= -/*! Protected - - * - */ -//============================================================================= -Engines::Container_ptr -SALOME_LifeCycleCORBA::FindOrStartContainer(const string aComputerContainer , - const string theComputer , - const string theContainer ) -{ - SCRUTE( aComputerContainer ) ; - SCRUTE( theComputer ) ; - SCRUTE( theContainer ) ; - Engines::Container_var aContainer = FindContainer(aComputerContainer.c_str()); - if ( !CORBA::is_nil( aContainer ) ) - { - return aContainer ; - } - Engines::Container_var aFactoryServer ; - bool pyCont = false ; - int len = theContainer.length() ; - if ( !strcmp( &theContainer.c_str()[len-2] , "Py" ) ) - { - pyCont = true ; - } - string addr=_NS->getIORaddr(); - string CMD="SALOME_Container"; - if ( pyCont ) { - CMD="SALOME_ContainerPy.py"; - } - CMD=CMD + " " + theContainer; - CMD=CMD + " -ORBInitRef NameService="+addr; - - /* - * Get the appropriate launcher and ask to launch - */ - PyObject * launcher=getLauncher((char *)theComputer.c_str()); - Launcher_Slaunch(launcher,(char *)theComputer.c_str(),(char *)CMD.c_str()); - /* - * Wait until the container is registered in Naming Service - */ - int count = 5 ; - while ( CORBA::is_nil( aFactoryServer ) && count ) - { -#ifndef WNT - sleep( 1 ) ; -#else - Sleep(1); -#endif - count-- ; - if ( count != 10 ) - MESSAGE( count << ". Waiting for FactoryServer on " << theComputer) - aFactoryServer = FindContainer( aComputerContainer.c_str() ) ; - } - if ( !CORBA::is_nil( aFactoryServer ) ) - { - return aFactoryServer; - } - MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed") ; - return Engines::Container::_nil(); -} -//============================================================================= -/*! Protected - - * \param aComputerContainer container name under one of the forms: - * - 1 aContainer - * - 2 machine/aContainer - * \param theComputer return computer name: - * - 1 machine = GetHostname() - * - 2 machine (localhost replaced by GetHostName()) - * \param theContainer return container name: - * - 1 aContainer - * - 2 aContainer - * \return /Containers/machine/aContainer - */ -//============================================================================= -string SALOME_LifeCycleCORBA::ContainerName(const char *aComputerContainer , - string * theComputer , - string * theContainer ) -{ - char * ContainerName = new char [ strlen( aComputerContainer ) + 1 ] ; - strcpy( ContainerName , aComputerContainer ) ; - string theComputerContainer("/Containers/"); - char *slash = strchr( ContainerName , '/' ) ; // first occurence of '/' - if ( !slash ) // no '/', only the name, without path - { - *theComputer = GetHostname() ; - theComputerContainer += *theComputer ; - theComputerContainer += "/" ; - *theContainer = ContainerName ; - theComputerContainer += *theContainer ; - } - else - { - ASSERT( slash != aComputerContainer); // "/something..." not OK - slash[ 0 ] = '\0' ; - slash += 1 ; - *theContainer = slash ; - if ( !strcmp( ContainerName , "localhost" ) ) - { - *theComputer = GetHostname() ; - } - else - { - *theComputer = ContainerName ; - } - theComputerContainer += *theComputer ; - theComputerContainer += "/" ; - theComputerContainer += *theContainer ; - } - delete [] ContainerName; - return theComputerContainer ; -} -//============================================================================= -/*! Protected - - * - */ -//============================================================================= -string SALOME_LifeCycleCORBA::ComputerPath(const char * theComputer ) -{ - CORBA::String_var path; - CORBA::Object_var obj = _NS->Resolve("/Kernel/ModulCatalog"); - SALOME_ModuleCatalog::ModuleCatalog_var Catalog = - SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ; - try { - path = Catalog->GetPathPrefix( theComputer ); - } - catch (SALOME_ModuleCatalog::NotFound&) { - INFOS("GetPathPrefix(" << theComputer << ") not found!"); - path = "" ; - } - SCRUTE( path ) ; - return CORBA::string_dup( path ) ; -} + + diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx index 92edb4b3a..d5d82f97a 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx @@ -36,41 +36,49 @@ #include #include +#include #include CORBA_CLIENT_HEADER(SALOME_ContainerManager) #include CORBA_CLIENT_HEADER(SALOME_Component) class SALOME_NamingService; +class IncompatibleComponent : public SALOME_Exception +{ +public : + IncompatibleComponent( void ); + IncompatibleComponent( const IncompatibleComponent &ex ); +} ; + class SALOME_LifeCycleCORBA { public: - SALOME_LifeCycleCORBA(SALOME_NamingService *ns); + SALOME_LifeCycleCORBA(SALOME_NamingService *ns = 0); virtual ~SALOME_LifeCycleCORBA(); - Engines::Container_ptr - FindContainer(const char *containerName); // for supervision - - Engines::Component_ptr + Engines::Component_ptr FindComponent(const Engines::MachineParameters& params, - const char *componentName, - int studyId=0, - const char *instanceName=""); + const char *componentName, + const Engines::MachineList& listOfMachines); - Engines::Component_ptr - LoadComponent(const Engines::MachineParameters& params, - const char *componentName, - int studyId=0); + Engines::Component_ptr + LoadComponent(const Engines::MachineParameters& params, + const char *componentName, + const Engines::MachineList& listOfMachines); Engines::Component_ptr FindOrLoad_Component(const Engines::MachineParameters& params, const char *componentName, - int studyId=0); + int studyId =0); Engines::Component_ptr FindOrLoad_Component(const char *containerName, const char *componentName); // for compatibility bool isKnownComponentClass(const char *componentName); + bool isMpiContainer(const Engines::MachineParameters& params) throw(IncompatibleComponent); + int NbProc(const Engines::MachineParameters& params); + //! Establish if a component called "componentName" in a container called "containerName" exists among the list of resources + //! in "listOfMachines". This method uses Naming Service to find the component. protected: @@ -79,30 +87,21 @@ protected: * exists among the list of resources in "listOfMachines". * This method uses Naming Service to find the component. */ + Engines::Component_ptr - FindComponent(const char *containerName, - const char *componentName, - const Engines::MachineList& listOfMachines); + _FindComponent(const char *containerName, + const char *componentName, + const Engines::MachineList& listOfMachines); Engines::Component_ptr - LoadComponent(const char *containerName, - const char *componentName, - const Engines::MachineList& listOfMachines); + _LoadComponent(const char *containerName, + const char *componentName, + const Engines::MachineList& listOfMachines); SALOME_NamingService *_NS; Engines::ContainerManager_var _ContManager; - //private: - - std::string ContainerName( const char * aComputerContainer , - std::string * theComputer , - std::string * theContainer ) ; - std::string ComputerPath( const char * theComputer ) ; - - Engines::Container_ptr - FindOrStartContainer(const std::string aComputerContainer , - const std::string theComputer , - const std::string theContainer ) ; } ; #endif + diff --git a/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py b/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py new file mode 100644 index 000000000..f88ef8722 --- /dev/null +++ b/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py @@ -0,0 +1,41 @@ +# SALOME LifeCycleCORBA : implementation of containers and engines life cycle both in Python and C++ +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : LifeCycleCORBA.py +# Author : Paul RASCLE, EDF +# Module : SALOME +# $Header$ + + +import Engines +from libSALOME_LifeCycleCORBA import * + +class LifeCycleCORBA (SALOME_LifeCycleCORBA): + + def __init__(self, orb = None): + SALOME_LifeCycleCORBA.__init__(self) + + def FindOrLoadComponent(self, containerName, componentName): + return SALOME_LifeCycleCORBA.FindOrLoad_Component(self, + containerName, + componentName) diff --git a/src/LifeCycleCORBA_SWIG/Makefile.in b/src/LifeCycleCORBA_SWIG/Makefile.in new file mode 100644 index 000000000..48fa79e78 --- /dev/null +++ b/src/LifeCycleCORBA_SWIG/Makefile.in @@ -0,0 +1,52 @@ +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Paul RASCLE, EDF +# Module : SALOME +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# Libraries targets + +LIB = libSALOME_LifeCycleCORBAcmodule.la +LIB_SRC = + +LIB_CLIENT_IDL = SALOME_Component.idl SALOME_ContainerManager.idl + +SWIG_DEF = libSALOME_LifeCycleCORBA.i + +EXPORT_PYSCRIPTS = libSALOME_LifeCycleCORBA.py LifeCycleCORBA.py TestLifeCycleCORBA.py + +CPPFLAGS+= $(PYTHON_INCLUDES) + +LIBS+= $(PYTHON_LIBS) -lSalomeLifeCycleCORBA + +LDFLAGS+= -lSalomeLifeCycleCORBA + +@CONCLUDE@ diff --git a/src/LifeCycleCORBA_SWIG/TestLifeCycleCORBA.py b/src/LifeCycleCORBA_SWIG/TestLifeCycleCORBA.py new file mode 100644 index 000000000..479bc930a --- /dev/null +++ b/src/LifeCycleCORBA_SWIG/TestLifeCycleCORBA.py @@ -0,0 +1,18 @@ + +import Engines +import LifeCycleCORBA + +lcc = LifeCycleCORBA.LifeCycleCORBA() + +#obj=lcc.FindOrLoad_Component("FactoryServer","SalomeTestComponent") +#comp=obj._narrow(Engines.TestComponent) +#comp.Coucou(1) + +param={} +param['hostname']='cli76ce' +param['container_name']='myContainer' +smesh=lcc.FindOrLoad_Component(param,'SMESH') + +container=lcc.FindContainer('myContainer') +engine=lcc.FindComponent(param,'SMESH') +geom=lcc.LoadComponent(param,'GEOM') diff --git a/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i b/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i new file mode 100644 index 000000000..b0cedeb17 --- /dev/null +++ b/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i @@ -0,0 +1,104 @@ + + +%module libSALOME_LifeCycleCORBA + +%{ +#include "utilities.h" +#include "SALOME_LifeCycleCORBA.hxx" + + using namespace std; +%} + +%typemap(python,out) Engines::Container_ptr, Engines::Component_ptr +{ + MESSAGE("typemap out on CORBA object ptr"); + SCRUTE($1); + + // --- Get the Python orb + + PyObject* pdict = PyDict_New(); + PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); + PyRun_String("import CORBA", Py_single_input, pdict, pdict); + PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input, + pdict, pdict); + PyObject* orb = PyDict_GetItemString(pdict, "o"); + + // --- Get the C++ orb + + int argc = 0; + char *xargv = ""; + char **argv = &xargv; + CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); + string s = ORB->object_to_string($1); + SCRUTE(s); + PyObject * tmp = PyString_FromString(s.c_str()); + SCRUTE(tmp); + $result = PyObject_CallMethod(orb, "string_to_object", "O", tmp); + SCRUTE($result); +} + + +%typemap(typecheck) const Engines::MachineParameters & +{ + $1 = ($input != 0); +} + +%typemap(python,in) const Engines::MachineParameters & +{ + printf("typemap in on Engines::MachineParameters\n"); + //MESSAGE("typemap in on Engines::MachineParameters"); + //ASSERT (PyDict_Check($input)) + if (PyDict_Check($input) == 1) + { + Engines::MachineParameters *param = new Engines::MachineParameters ; + PyObject *key, *value; + int pos = 0; + while (PyDict_Next($input, &pos, &key, &value)) + { + char* keystr = PyString_AsString(key); + printf("key: %s\n", keystr); + if (strcmp(keystr,"container_name")==0) + { + param->container_name = CORBA::string_dup(PyString_AsString(value)); + } + else if (strcmp(keystr,"hostname")==0) + { + param->hostname = CORBA::string_dup(PyString_AsString(value)); + } + else if (strcmp(keystr,"OS")==0) + { + param->OS = CORBA::string_dup(PyString_AsString(value)); + } + else if (strcmp(keystr,"mem_mb")==0) + { + param->mem_mb = PyLong_AsLong(value); + } + else if (strcmp(keystr,"cpu_clock")==0) + { + param->cpu_clock = PyLong_AsLong(value); + } + else if (strcmp(keystr,"nb_proc_per_node")==0) + { + param->nb_proc_per_node = PyLong_AsLong(value); + } + else if (strcmp(keystr,"nb_node")==0) + { + param->nb_node = PyLong_AsLong(value); + } + } + $1 = param; + } + else + { + printf("pas un dico\n"); + return NULL; + } +} + +%typemap(python,freearg) const Engines::MachineParameters & +{ + MESSAGE("delete $1"); + delete $1; +} + +%include "SALOME_LifeCycleCORBA.hxx" diff --git a/src/MPIContainer/MPIContainer_i.cxx b/src/MPIContainer/MPIContainer_i.cxx index c190fa2bb..3b97ad793 100644 --- a/src/MPIContainer/MPIContainer_i.cxx +++ b/src/MPIContainer/MPIContainer_i.cxx @@ -27,11 +27,14 @@ #include #include #include +#include "SALOME_Component_i.hxx" #include "MPIContainer_i.hxx" #include "SALOME_NamingService.hxx" #include "Utils_SINGLETON.hxx" #include "OpUtil.hxx" #include "utilities.h" +#include +#include "Container_init_python.hxx" using namespace std; // L'appel au registry SALOME ne se fait que pour le process 0 @@ -44,18 +47,21 @@ Engines_MPIContainer_i::Engines_MPIContainer_i(int nbproc, int numproc, { MESSAGE("[" << numproc << "] activate object"); _id = _poa->activate_object(this); - this->_add_ref(); +// this->_add_ref(); if(numproc==0){ - // _NS = new SALOME_NamingService(_orb); - _NS = SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()) ; - _NS->init_orb( orb ) ; + _NS = new SALOME_NamingService(); +// _NS = SINGLETON_::Instance() ; +// ASSERT(SINGLETON_::IsAlreadyExisting()) ; + _NS->init_orb( CORBA::ORB::_duplicate(_orb) ) ; // Engines::Container_ptr pCont // = Engines::Container::_narrow(POA_Engines::MPIContainer::_this()); - Engines::Container_ptr pCont = Engines::Container::_narrow(_poa->id_to_reference(*_id)); + CORBA::Object_var obj=_poa->id_to_reference(*_id); + Engines::Container_var pCont = Engines::Container::_narrow(obj); + string hostname = GetHostname(); + _containerName = _NS->BuildContainerNameForNS(containerName,hostname.c_str()); SCRUTE(_containerName); _NS->Register(pCont, _containerName.c_str()); } @@ -73,122 +79,299 @@ Engines_MPIContainer_i::Engines_MPIContainer_i(int nbproc, int numproc) Engines_MPIContainer_i::~Engines_MPIContainer_i(void) { MESSAGE("[" << _numproc << "] Engines_MPIContainer_i::~Engines_MPIContainer_i()"); - if( !handle_map.empty() ){ - MESSAGE("[" << _numproc << "] Engines_MPIContainer_i::~Engines_MPIContainer_i: warning destroy a not empty container"); +} + +// Load component +void Engines_MPIContainer_i::Shutdown() +{ + int ip; + MESSAGE("[" << _numproc << "] shutdown of MPI Corba Server"); + if( _numproc == 0 ){ + _NS->Destroy_FullDirectory(_containerName.c_str()); + for(ip= 1;ip<_nbproc;ip++) + (Engines::MPIContainer::_narrow((*_tior)[ip]))->Shutdown(); } + _orb->shutdown(0); + } -// Start MPI Container -Engines::MPIContainer_ptr Engines_MPIContainer_i::start_MPIimpl( - const char* ContainerName, - CORBA::Short nbproc ) +// Load a component library +bool Engines_MPIContainer_i::load_component_Library(const char* componentName) { + if( _numproc == 0 ){ + // Invocation du chargement du composant dans les autres process + for(int ip= 1;ip<_nbproc;ip++) + (Engines::MPIContainer::_narrow((*_tior)[ip]))->Asload_component_Library(componentName); + } - char nbp[1024]; + return Lload_component_Library(componentName); +} - MESSAGE("[" << _numproc << "] start_impl argc " << _argc << " ContainerName " << ContainerName - << hex << this << dec) ; - _numInstanceMutex.lock() ; // lock on the instance number +void Engines_MPIContainer_i::Asload_component_Library(const char* componentName) +{ + Lload_component_Library(componentName); +} + +bool Engines_MPIContainer_i::Lload_component_Library(const char* componentName) +{ + string aCompName = componentName; - CORBA::Object_var obj = Engines::MPIContainer::_nil() ; - bool nilvar = true ; - try { - string cont("/Containers/"); - cont += machineName() ; - cont += "/" ; - cont += ContainerName; - INFOS("[" << _numproc << "] " << machineName() << " start_impl unknown container " << cont.c_str() - << " try to Resolve" ); - obj = _NS->Resolve( cont.c_str() ); - nilvar = CORBA::is_nil( obj ) ; - if ( nilvar ) { - INFOS("[" << _numproc << "] " << machineName() << " start_impl unknown container " - << ContainerName); + // --- try dlopen C++ component + + string impl_name = string ("lib") + aCompName + string("Engine.so"); + SCRUTE(impl_name); + + _numInstanceMutex.lock(); // lock to be alone + // (see decInstanceCnt, finalize_removal)) + if (_toRemove_map[impl_name]) _toRemove_map.erase(impl_name); + if (_library_map[impl_name]) + { + MESSAGE("[" << _numproc << "] Library " << impl_name << " already loaded"); + _numInstanceMutex.unlock(); + return true; } + + void* handle; + handle = dlopen( impl_name.c_str() , RTLD_LAZY ) ; + if ( handle ) + { + _library_map[impl_name] = handle; + _numInstanceMutex.unlock(); + return true; + } + else + { + INFOS("[" << _numproc << "] Can't load shared library : " << impl_name); + INFOS("[" << _numproc << "] error dlopen: " << dlerror()); + } + _numInstanceMutex.unlock(); + + // --- try import Python component + + INFOS("[" << _numproc << "] try import Python component "<Ascreate_component_instance(componentName,studyId); } - catch (ServiceUnreachable&) { - INFOS("[" << _numproc << "] " << machineName() << "Caught exception: Naming Service Unreachable"); - } - catch (...) { - INFOS("[" << _numproc << "] " << machineName() << "Caught unknown exception."); + + return Lcreate_component_instance(componentName,studyId); +} + +void Engines_MPIContainer_i::Ascreate_component_instance( const char* componentName, + CORBA::Long studyId) +{ + Lcreate_component_instance(componentName,studyId); +} + +Engines::Component_ptr +Engines_MPIContainer_i::Lcreate_component_instance( const char* genericRegisterName, CORBA::Long studyId) +{ + if (studyId < 0) { + INFOS("studyId must be > 0 for mono study instance, =0 for multiStudy"); + return Engines::Component::_nil() ; } - if ( !nilvar ) { + + Engines::Component_var iobject = Engines::Component::_nil() ; + Engines::MPIObject_var pobj; + + string aCompName = genericRegisterName; + if (_library_map[aCompName]) { // Python component + if (_isSupervContainer) { + INFOS("Supervision Container does not support Python Component Engines"); + return Engines::Component::_nil(); + } + _numInstanceMutex.lock() ; // lock on the instance number + _numInstance++ ; + int numInstance = _numInstance ; _numInstanceMutex.unlock() ; - MESSAGE("[" << _numproc << "] start_impl container found without new launch") ; - return Engines::MPIContainer::_narrow(obj); - } - int i = 0 ; - while ( _argv[ i ] ) { - MESSAGE("[" << _numproc << "] argv" << i << " " << _argv[ i ]) ; - i++ ; + + char aNumI[12]; + sprintf( aNumI , "%d" , numInstance ) ; + string instanceName = aCompName + "_inst_" + aNumI ; + string component_registerName = + _containerName + "/" + instanceName; + + Py_ACQUIRE_NEW_THREAD; + PyObject *mainmod = PyImport_AddModule("__main__"); + PyObject *globals = PyModule_GetDict(mainmod); + PyObject *pyCont = PyDict_GetItemString(globals, "pyCont"); + PyObject *result = PyObject_CallMethod(pyCont, + "create_component_instance", + "ssl", + aCompName.c_str(), + instanceName.c_str(), + studyId); + string iors = PyString_AsString(result); + SCRUTE(iors); + Py_RELEASE_NEW_THREAD; + + CORBA::Object_var obj = _orb->string_to_object(iors.c_str()); + iobject = Engines::Component::_narrow( obj ) ; + pobj = Engines::MPIObject::_narrow(obj) ; + if( _numproc == 0 ) + _NS->Register(iobject, component_registerName.c_str()) ; + // Root recupere les ior des composants des autre process + BCastIOR(_orb,pobj,false); + + return iobject._retn(); } - sprintf(nbp,"mpirun -np %d SALOME_MPIContainer ",nbproc); - string shstr(nbp); - shstr += ContainerName ; - if ( _argc == 4 ) { - shstr += " " ; - shstr += _argv[ 2 ] ; - shstr += " " ; - shstr += _argv[ 3 ] ; + + //--- try C++ + + string impl_name = string ("lib") + genericRegisterName +string("Engine.so"); + void* handle = _library_map[impl_name]; + if ( !handle ) { + INFOS("shared library " << impl_name <<"must be loaded before instance"); + return Engines::Component::_nil() ; } - shstr += " > /tmp/" ; - shstr += ContainerName ; - shstr += ".log 2>&1 &" ; - MESSAGE("system(" << shstr << ")") ; - int status = system( shstr.c_str() ) ; - if (status == -1) { - INFOS("[" << _numproc << "] Engines_MPIContainer_i::start_impl SALOME_MPIContainer failed (system command status -1)") ; + else { + iobject = createMPIInstance(genericRegisterName, + handle, + studyId); + return iobject._retn(); } - else if (status == 217) { - INFOS("[" << _numproc << "] Engines_MPIContainer_i::start_impl SALOME_MPIContainer failed (system command status 217)") ; +} + +Engines::Component_ptr +Engines_MPIContainer_i::createMPIInstance(string genericRegisterName, + void *handle, + int studyId) +{ + Engines::Component_var iobject; + Engines::MPIObject_var pobj; + // --- find the factory + + string aGenRegisterName = genericRegisterName; + string factory_name = aGenRegisterName + string("Engine_factory"); + SCRUTE(factory_name) ; + + typedef PortableServer::ObjectId * (*MPIFACTORY_FUNCTION) + (int,int, + CORBA::ORB_ptr, + PortableServer::POA_ptr, + PortableServer::ObjectId *, + const char *, + const char *) ; + + MPIFACTORY_FUNCTION MPIComponent_factory + = (MPIFACTORY_FUNCTION) dlsym(handle, factory_name.c_str()); + + char *error ; + if ( (error = dlerror() ) != NULL) { + // Try to load a sequential component + MESSAGE("[" << _numproc << "] Try to load a sequential component"); + _numInstanceMutex.unlock() ; + iobject = Engines_Container_i::createInstance(genericRegisterName,handle,studyId); + if( CORBA::is_nil(iobject) ) return Engines::Component::_duplicate(iobject); } - INFOS("[" << _numproc << "] " << machineName() << " Engines_MPIContainer_i::start_impl SALOME_MPIContainer launch done"); - - obj = Engines::MPIContainer::_nil() ; - try { - string cont("/Containers/"); - cont += machineName() ; - cont += "/" ; - cont += ContainerName; - nilvar = true ; - int count = 20 ; - while ( nilvar && count >= 0) { - sleep( 1 ) ; - obj = _NS->Resolve(cont.c_str()); - nilvar = CORBA::is_nil( obj ) ; - if ( nilvar ) { - INFOS("[" << _numproc << "] " << count << ". " << machineName() - << " start_impl unknown container " << cont.c_str()); - count -= 1 ; + + // --- create instance + + iobject = Engines::Component::_nil() ; + + try + { + _numInstanceMutex.lock() ; // lock on the instance number + _numInstance++ ; + int numInstance = _numInstance ; + _numInstanceMutex.unlock() ; + + char aNumI[12]; + sprintf( aNumI , "%d" , numInstance ) ; + string instanceName = aGenRegisterName + "_inst_" + aNumI ; + string component_registerName = + _containerName + "/" + instanceName; + + // --- Instanciate required CORBA object + + PortableServer::ObjectId *id ; //not owner, do not delete (nore use var) + id = (MPIComponent_factory) ( _nbproc,_numproc,_orb, _poa, _id, instanceName.c_str(), + aGenRegisterName.c_str() ) ; + + // --- get reference & servant from id + + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = Engines::Component::_narrow( obj ) ; + pobj = Engines::MPIObject::_narrow(obj) ; + + Engines_Component_i *servant = + dynamic_cast(_poa->reference_to_servant(iobject)); + ASSERT(servant); + //SCRUTE(servant->pd_refCount); + servant->_remove_ref(); // compensate previous id_to_reference + //SCRUTE(servant->pd_refCount); + _listInstances_map[instanceName] = iobject; + _cntInstances_map[aGenRegisterName] += 1; + SCRUTE(aGenRegisterName); + SCRUTE(_cntInstances_map[aGenRegisterName]); + //SCRUTE(servant->pd_refCount); + bool ret_studyId = servant->setStudyId(studyId); + ASSERT(ret_studyId); + + // --- register the engine under the name + // containerName(.dir)/instanceName(.object) + + if( _numproc == 0 ){ + _NS->Register( iobject , component_registerName.c_str() ) ; + MESSAGE( component_registerName.c_str() << " bound" ) ; } + // Root recupere les ior des composants des autre process + BCastIOR(_orb,pobj,false); + } - _numInstanceMutex.unlock() ; - if ( !nilvar ) { - MESSAGE("[" << _numproc << "] start_impl container found after new launch of SALOME_MPIContainer") ; + catch (...) + { + INFOS( "Container_i::createInstance exception catched" ) ; } - return Engines::MPIContainer::_narrow(obj); - } - catch (ServiceUnreachable&) { - INFOS("[" << _numproc << "] " << machineName() << "Caught exception: Naming Service Unreachable"); - } - catch (...) { - INFOS("[" << _numproc << "] " << machineName() << "Caught unknown exception."); - } - _numInstanceMutex.unlock() ; - MESSAGE("[" << _numproc << "] start_impl MPI container not found after new launch of SALOME_MPIContainer") ; - return Engines::MPIContainer::_nil() ; + return iobject._retn(); } // Load component Engines::Component_ptr Engines_MPIContainer_i::load_impl(const char* nameToRegister, const char* componentName) { - int ip; - if( _numproc == 0 ){ // Invocation du chargement du composant dans les autres process - for(ip= 1;ip<_nbproc;ip++) - (Engines::MPIContainer::_narrow((*_tior)[ip]))->SPload_impl(nameToRegister, + for(int ip= 1;ip<_nbproc;ip++) + (Engines::MPIContainer::_narrow((*_tior)[ip]))->Asload_impl(nameToRegister, componentName); } @@ -197,7 +380,7 @@ Engines::Component_ptr Engines_MPIContainer_i::load_impl(const char* nameToRegis } // Load component -void Engines_MPIContainer_i::SPload_impl(const char* nameToRegister, +void Engines_MPIContainer_i::Asload_impl(const char* nameToRegister, const char* componentName) { Lload_impl(nameToRegister,componentName); @@ -277,7 +460,6 @@ Engines::Component_ptr Engines_MPIContainer_i::Lload_impl( _NS->Register(iobject, component_registerName.c_str()) ; } - handle_map[instanceName] = handle; _numInstanceMutex.unlock() ; // Root recupere les ior des composants des autre process @@ -303,25 +485,20 @@ void Engines_MPIContainer_i::remove_impl(Engines::Component_ptr component_i) for(ip= 1;ip<_nbproc;ip++){ spcptr = Engines::MPIObject::_narrow((*(pcptr->tior()))[ip]); cptr = (Engines::Component_ptr)spcptr; - (Engines::MPIContainer::_narrow((*_tior)[ip]))->SPremove_impl(cptr); + (Engines::MPIContainer::_narrow((*_tior)[ip]))->Asremove_impl(cptr); } } Lremove_impl(component_i); } -void Engines_MPIContainer_i::SPremove_impl(Engines::Component_ptr component_i) +void Engines_MPIContainer_i::Asremove_impl(Engines::Component_ptr component_i) { Lremove_impl(component_i); } void Engines_MPIContainer_i::Lremove_impl(Engines::Component_ptr component_i) { - int ip; - Engines::Component_ptr cptr; - Engines::MPIObject_ptr pcptr; - Engines::MPIObject_ptr spcptr; - BEGIN_OF("[" << _numproc << "] MPIContainer_i::Lremove_impl"); ASSERT(! CORBA::is_nil(component_i)); @@ -331,19 +508,8 @@ void Engines_MPIContainer_i::Lremove_impl(Engines::Component_ptr component_i) component_i->destroy() ; MESSAGE("[" << _numproc << "] test key handle_map"); _numInstanceMutex.lock() ; // lock on the remove on handle_map - if (handle_map[instanceName]) // if key does not exist, created & initialized null - { - remove_map[instanceName] = handle_map[instanceName] ; - } - else MESSAGE("[" << _numproc << "] no key handle_map"); - handle_map.erase(instanceName) ; _numInstanceMutex.unlock() ; MESSAGE("[" << _numproc << "] list handle_map"); - map::iterator im ; - for (im = handle_map.begin() ; im != handle_map.end() ; im ++) - { - MESSAGE("[" << _numproc << "] stay " << (*im).first); - } END_OF("[" << _numproc << "] MPIContainer_i::Lremove_impl"); @@ -356,13 +522,13 @@ void Engines_MPIContainer_i::finalize_removal() if( _numproc == 0 ){ // Invocation de la destruction du composant dans les autres process for(ip= 1;ip<_nbproc;ip++) - (Engines::MPIContainer::_narrow((*_tior)[ip]))->SPfinalize_removal(); + (Engines::MPIContainer::_narrow((*_tior)[ip]))->Asfinalize_removal(); } Lfinalize_removal(); } -void Engines_MPIContainer_i::SPfinalize_removal() +void Engines_MPIContainer_i::Asfinalize_removal() { Lfinalize_removal(); } @@ -371,33 +537,18 @@ void Engines_MPIContainer_i::Lfinalize_removal() { BEGIN_OF("[" << _numproc << "] MPIContainer_i::Lfinalize_removal"); - map::iterator im ; - // lock on the explore remove_map & dlclose - _numInstanceMutex.lock() ; - for (im = remove_map.begin() ; im != remove_map.end() ; im ++) - { - void * handle = (*im).second ; - MESSAGE("[" << _numproc << "] dlclose " << (*im).first); - dlclose(handle) ; - } - MESSAGE("[" << _numproc << "] remove_map.clear()"); - remove_map.clear() ; - _numInstanceMutex.unlock() ; +// map::iterator im ; +// // lock on the explore remove_map & dlclose +// _numInstanceMutex.lock() ; +// for (im = remove_map.begin() ; im != remove_map.end() ; im ++) +// { +// void * handle = (*im).second ; +// MESSAGE("[" << _numproc << "] dlclose " << (*im).first); +// dlclose(handle) ; +// } +// MESSAGE("[" << _numproc << "] remove_map.clear()"); +// remove_map.clear() ; +// _numInstanceMutex.unlock() ; END_OF("[" << _numproc << "] MPIContainer_i::Lfinalize_removal"); } - -// Load component -void Engines_MPIContainer_i::MPIShutdown() -{ - int ip; - MESSAGE("[" << _numproc << "] shutdown of Corba Server"); - if( _numproc == 0 ){ - for(ip= 1;ip<_nbproc;ip++) - (Engines::MPIContainer::_narrow((*_tior)[ip]))->Shutdown(); - } - - Shutdown(); - -} - diff --git a/src/MPIContainer/MPIContainer_i.hxx b/src/MPIContainer/MPIContainer_i.hxx index a971b7f20..a73af8b38 100644 --- a/src/MPIContainer/MPIContainer_i.hxx +++ b/src/MPIContainer/MPIContainer_i.hxx @@ -48,38 +48,58 @@ class Engines_MPIContainer_i : public POA_Engines::MPIContainer, // Destructor ~Engines_MPIContainer_i(); - // Launch a new MPI container from the current container - Engines::MPIContainer_ptr start_MPIimpl(const char* ContainerName, - CORBA::Short nbproc); + // shutdown corba server + void Shutdown(); + + // Load a component library + // synchronous version for process 0 + bool load_component_Library(const char* componentName); + // asynchronous version for other process + void Asload_component_Library(const char* componentName); + + // Create an instance of component + // synchronous version for process 0 + Engines::Component_ptr + create_component_instance( const char* componentName, + CORBA::Long studyId); // 0 for multiStudy + // asynchronous version for other process + void Ascreate_component_instance( const char* componentName, + CORBA::Long studyId); // 0 for multiStudy // Load a component in current MPI container // synchronous version for process 0 Engines::Component_ptr load_impl(const char* nameToRegister, const char* componentName); - // shutdown corba server - void MPIShutdown(); - // asynchronous version for other process - void SPload_impl(const char* nameToRegister, const char* componentName); + void Asload_impl(const char* nameToRegister, const char* componentName); // Unload a component from current MPI container // synchronous version for process 0 void remove_impl(Engines::Component_ptr component_i); // asynchronous version for other process - void SPremove_impl(Engines::Component_ptr component_i); + void Asremove_impl(Engines::Component_ptr component_i); // synchronous version for process 0 void finalize_removal(); // asynchronous version for other process - void SPfinalize_removal(); + void Asfinalize_removal(); private: // local version to not duplicate code // called by synchronous and asynchronous version + bool Lload_component_Library(const char* componentName); + Engines::Component_ptr + Lcreate_component_instance( const char* componentName, + CORBA::Long studyId); // 0 for multiStudy Engines::Component_ptr Lload_impl(const char* nameToRegister, const char* componentName); void Lremove_impl(Engines::Component_ptr component_i); void Lfinalize_removal(); + Engines::Component_ptr + createMPIInstance(std::string genericRegisterName, + void *handle, + int studyId); + }; #endif diff --git a/src/MPIContainer/Makefile.in b/src/MPIContainer/Makefile.in index d01e24df8..af110328f 100644 --- a/src/MPIContainer/Makefile.in +++ b/src/MPIContainer/Makefile.in @@ -52,12 +52,15 @@ BIN = SALOME_MPIContainer BIN_SRC = BIN_SERVER_IDL = SALOME_MPIObject.idl SALOME_MPIContainer.idl -LDFLAGS+= -lSalomeContainer -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification -lSALOMELocalTrace +CPPFLAGS+= $(PYTHON_INCLUDES) +LDFLAGS+= -lSalomeContainer -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification -lSALOMELocalTrace -lSalomeResourcesManager ifeq (@WITHMPI@,yes) + LIBS += $(PYTHON_LIBS) $(MPI_LIBS) CXXFLAGS+=${MPI_INCLUDES} CXX_DEPEND_FLAG+=${MPI_INCLUDES} - LDFLAGS+= ${MPI_LIBS} + LDFLAGSFORBIN= $(LDFLAGS) -lSALOMETraceCollector + LIBSFORBIN= $(LIBS) endif @CONCLUDE@ diff --git a/src/MPIContainer/SALOME_MPIContainer.cxx b/src/MPIContainer/SALOME_MPIContainer.cxx index 52152364e..1d74a218b 100644 --- a/src/MPIContainer/SALOME_MPIContainer.cxx +++ b/src/MPIContainer/SALOME_MPIContainer.cxx @@ -4,13 +4,12 @@ #include "Utils_SINGLETON.hxx" #include "utilities.h" #include -#include "LocalTraceCollector.hxx" +#include "SALOMETraceCollector.hxx" using namespace std; int main(int argc, char* argv[]) { int nbproc, numproc; - int flag; Engines_MPIContainer_i * myContainer=NULL; MPI_Init(&argc,&argv); @@ -20,7 +19,7 @@ int main(int argc, char* argv[]) // Initialise the ORB. ORB_INIT &init = *SINGLETON_::Instance() ; CORBA::ORB_var &orb = init( argc , argv ) ; - LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb); + SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); BEGIN_OF("[" << numproc << "] " << argv[0]) try { @@ -69,7 +68,6 @@ int main(int argc, char* argv[]) pman->activate(); orb->run(); - orb->destroy(); } catch(CORBA::SystemException&){ @@ -90,12 +88,11 @@ int main(int argc, char* argv[]) if(myContainer) delete myContainer; - MPI_Initialized(&flag); - if(flag) - MPI_Finalize(); END_OF("[" << numproc << "] " << argv[0]); delete myThreadTrace; - return 0 ; + + MPI_Finalize(); + } diff --git a/src/MPILifeCycleCORBA/MPILifeCycleCORBA.py b/src/MPILifeCycleCORBA/MPILifeCycleCORBA.py deleted file mode 100644 index 0b26acfb0..000000000 --- a/src/MPILifeCycleCORBA/MPILifeCycleCORBA.py +++ /dev/null @@ -1,143 +0,0 @@ -#============================================================================== -# File : MPILifeCycleCORBA.py -# Created : ven may 30 08:42:01 CEST 2003 -# Author : Bernard SECHER, CEA -# Project : SALOME -# Copyright : CEA 2003 -# $Header$ -#============================================================================== - -from LifeCycleCORBA import * -from Utils_Identity import getShortHostName - -class MPILifeCycleCORBA(LifeCycleCORBA): - #------------------------------------------------------------------------- - - def __init__(self, orb): - MESSAGE( "MPILifeCycleCORBA::__init__" ) - LifeCycleCORBA.__init__(self, orb) - - #------------------------------------------------------------------------- - - def FindOrStartMPIContainer(self, theComputer , theMPIContainerRoot, nbproc ): - theMPIContainer = theMPIContainerRoot + "_" + str(nbproc) - MESSAGE( "FindOrStartMPIContainer" + theComputer + theMPIContainer ) - aMPIContainer = self.FindContainer( theComputer + "/" + theMPIContainer ) - if aMPIContainer is None : - if (theMPIContainerRoot == "MPIFactoryServer") | (theMPIContainerRoot == "MPIFactoryServerPy") : - if theComputer == getShortHostName() : - rshstr = "" - else : - rshstr = "rsh -n " + theComputer + " " - path = self.ComputerPath( theComputer ) -## if path != "" : -## rshstr = rshstr + path + "/../bin/salome/" -## else : -## rshstr = rshstr + os.getenv( "KERNEL_ROOT_DIR" ) + "/bin/" -# rshstr = rshstr + os.getenv( "PWD" ) + "/" - if theMPIContainerRoot == "MPIFactoryServer" : - rshstr = rshstr + "mpirun -np " + str(nbproc) + " " + path + "SALOME_MPIContainer " - else : - rshstr = rshstr + path + "SALOME_MPIContainerPy.py '" - rshstr = rshstr + theMPIContainer + " -" - omniORBcfg = os.getenv( "OMNIORB_CONFIG" ) -# omniORBcfg = os.getenv( "HOME" ) + "/.omniORB.cfg" - file = os.open( omniORBcfg , os.O_RDONLY ) - ORBInitRef = os.read(file,132) - if ORBInitRef[len(ORBInitRef)-1] == '\n' : - ORBInitRef,bsn = ORBInitRef.split('\n') - os.close( file ) - rshstr = rshstr + ORBInitRef - if theMPIContainerRoot == "MPIFactoryServerPy" : - rshstr = rshstr + "'" - rshstr = rshstr + " > /tmp/" + theMPIContainer + "_" - rshstr = rshstr + theComputer - rshstr = rshstr + ".log 2>&1 &" - os.system( rshstr ) - MESSAGE( "FindOrStartMPIContainer" + rshstr + " done" ) - else : - if theMPIContainer.find('Py') == -1 : - aMPIContainer = self.FindContainer( theComputer + "/" + "MPIFactoryServer_" + str(nbproc) ) - else : - aMPIContainer = self.FindContainer( theComputer + "/" + "MPIFactoryServerPy_" + str(nbproc) ) - aMPIContainer = aMPIContainer.start_impl( theMPIContainer ) - - count = 21 - while aMPIContainer is None : - time.sleep(1) - count = count - 1 - MESSAGE( str(count) + ". Waiting for " + theComputer + "/" + theMPIContainer ) - aMPIContainer = self.FindContainer( theComputer + "/" + theMPIContainer ) - if count == 0 : - return aMPIContainer - - return aMPIContainer - #os.system("rsh -n dm2s0017 /export/home/SALOME_ROOT/bin/runSession SALOME_Container -ORBInitRef NameService=corbaname::dm2s0017:1515") - - #------------------------------------------------------------------------- - - def FindOrLoadMPIComponent(self, MPIcontainerName, MPIcomponentName, nbproc): - - theComputer,theMPIContainerRoot = self.ContainerName( MPIcontainerName ) - theMPIContainer = theMPIContainerRoot + "_" + str(nbproc) - name = [CosNaming.NameComponent(theComputer,"dir"), - CosNaming.NameComponent(theMPIContainer,"dir"), - CosNaming.NameComponent(MPIcomponentName,"object")] - try: - obj = self._containerRootContext.resolve(name) - except CosNaming.NamingContext.NotFound, ex: - MESSAGE( "component " + MPIcomponentName + " not found, trying to load" ) - MPIcontainer = self.FindContainer(theComputer + "/" + theMPIContainer) - if MPIcontainer is None: - MESSAGE( "MPIcontainer " + theComputer + "/" + theMPIContainer + " not found in Naming Service, trying to start" ) - if (theMPIContainerRoot != "MPIFactoryServer") & (theMPIContainerRoot != "MPIFactoryServerPy") : - if theMPIContainer.find('Py') == -1 : - theMPIFactorycontainerRoot = "MPIFactoryServer" - theMPIFactorycontainer = theMPIFactorycontainerRoot + "_" + str(nbproc) - else : - theMPIFactorycontainerRoot = "MPIFactoryServerPy" - theMPIFactorycontainer = theMPIFactorycontainerRoot + "_" + str(nbproc) - MPIFactorycontainer = self.FindContainer(theComputer + "/" + theMPIFactorycontainer) - if MPIFactorycontainer is None: - MESSAGE( "MPIcontainer " + theComputer + "/" + theMPIFactorycontainer + " not found in Naming Service, trying to start" ) - MPIFactorycontainer = self.FindOrStartMPIContainer(theComputer,theMPIFactorycontainerRoot,nbproc) - else: - MPIFactorycontainer = self.FindOrStartMPIContainer(theComputer,theMPIContainerRoot,nbproc) - if MPIFactorycontainer != None : - MPIcontainer = self.FindOrStartMPIContainer(theComputer,theMPIContainerRoot,nbproc) - - if MPIcontainer != None: - compoinfo = self._catalog.GetComponent(MPIcomponentName) - if compoinfo is None: - MESSAGE( "MPIcomponent " + MPIcomponentName + " not found in Module Catalog" ) - else: - try: - machineName = theComputer - path = compoinfo.GetPathPrefix(machineName) + "/" - except SALOME_ModuleCatalog.NotFound, ex: - MESSAGE( "machine " + machineName + " not found in Module Catalog" ) - MESSAGE( "trying localhost" ) - try: - path = compoinfo.GetPathPrefix("localhost") + "/" - except SALOME_ModuleCatalog.NotFound, ex: - path = "" - implementation = path + "lib" + MPIcomponentName + "Engine.so" - MESSAGE( "Trying to load " + implementation ) - try: - MPIcomponent = MPIcontainer.load_impl(MPIcomponentName, implementation) - MESSAGE( "component " + MPIcomponent._get_instanceName() + " launched !" ) - return MPIcomponent - except: - MESSAGE( "component " + MPIcomponentName + " NOT launched !" ) - - else: - try: - MPIcomponent = obj._narrow(Engines.Component) - if MPIcomponent is None: - MESSAGE( MPIcomponentName + " is not a component !" ) - else: - MESSAGE( "MPIcomponent " + MPIcomponent._get_instanceName() + " found !" ) - return MPIcomponent - except: - MESSAGE( MPIcomponentName + " failure" ) - return None diff --git a/src/MPILifeCycleCORBA/MPIsalome.py b/src/MPILifeCycleCORBA/MPIsalome.py deleted file mode 100644 index 789641fd1..000000000 --- a/src/MPILifeCycleCORBA/MPIsalome.py +++ /dev/null @@ -1,5 +0,0 @@ -import salome -from MPILifeCycleCORBA import * - -# create an LifeCycleCORBA instance -lcc = MPILifeCycleCORBA(salome.orb) diff --git a/src/MPILifeCycleCORBA/Makefile.in b/src/MPILifeCycleCORBA/Makefile.in deleted file mode 100644 index ab76b0360..000000000 --- a/src/MPILifeCycleCORBA/Makefile.in +++ /dev/null @@ -1,38 +0,0 @@ -#============================================================================== -# File : Makefile.in -# Created : lun jui 2 20:32:24 CEST 2001 -# Author : Paul RASCLE, EDF - Marc Tajchman, CEA -# Project : SALOME -# Copyright : EDF 2001 -# $Header$ -#============================================================================== - -# source path -top_srcdir=@top_srcdir@ -top_builddir=../.. -srcdir=@srcdir@ -VPATH=.:@srcdir@:@top_srcdir@/idl - - -@COMMENCE@ - -EXPORT_HEADERS = SALOME_MPILifeCycleCORBA.hxx - -EXPORT_PYSCRIPTS = MPIsalome.py MPILifeCycleCORBA.py - -# Libraries targets - -LIB = libSalomeMPILifeCycleCORBA.la -LIB_SRC = SALOME_MPILifeCycleCORBA.cxx -LIB_CLIENT_IDL = SALOME_MPIObject.idl SALOME_MPIContainer.idl \ - SALOME_Component.idl SALOME_ModuleCatalog.idl - -# Executables targets -BIN = TestMPILifeCycleCORBA -BIN_SRC = -BIN_CLIENT_IDL = Logger.idl SALOME_MPIObject.idl SALOME_MPIContainer.idl SALOME_TestMPIComponent.idl - -LDFLAGS += -lSalomeNS -lSalomeLifeCycleCORBA -lOpUtil -lSALOMELocalTrace - -@CONCLUDE@ - diff --git a/src/MPILifeCycleCORBA/SALOME_MPILifeCycleCORBA.cxx b/src/MPILifeCycleCORBA/SALOME_MPILifeCycleCORBA.cxx deleted file mode 100644 index 5dfe13fcb..000000000 --- a/src/MPILifeCycleCORBA/SALOME_MPILifeCycleCORBA.cxx +++ /dev/null @@ -1,357 +0,0 @@ -//============================================================================= -// File : SALOME_MPILifeCycleCORBA.cxx -// Created : mar jui 03 14:55:50 CEST 2003 -// Author : Bernard SECHER CEA -// Project : SALOME -// Copyright : CEA 2003 -// $Header$ -//============================================================================= - -#include -#include -#include -#include -#include -#include - -#include "OpUtil.hxx" -#include "utilities.h" - -#include - -#include "SALOME_MPILifeCycleCORBA.hxx" -#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog) -#include "SALOME_NamingService.hxx" -using namespace std; - -SALOME_MPILifeCycleCORBA::SALOME_MPILifeCycleCORBA() : - SALOME_LifeCycleCORBA() -{ - _MPIFactoryServer = NULL; -} - -SALOME_MPILifeCycleCORBA::SALOME_MPILifeCycleCORBA(SALOME_NamingService *ns) : - SALOME_LifeCycleCORBA(ns) -{ - _MPIFactoryServer = NULL; -} - -SALOME_MPILifeCycleCORBA::~SALOME_MPILifeCycleCORBA() -{ -} - -Engines::MPIContainer_var SALOME_MPILifeCycleCORBA::FindOrStartMPIContainer( - const std::string theComputer , - const std::string theMPIContainerRoot, - const int nbproc) -{ - char nbp[1024]; - - sprintf(nbp,"_%d",nbproc); - std::string theMPIContainer = theMPIContainerRoot + nbp; - std::string aComputerContainer = theComputer + "/" + theMPIContainer; - - SCRUTE( aComputerContainer ) ; - SCRUTE( theComputer ) ; - SCRUTE( theMPIContainer ) ; - - // On recherche si le containe rest deja lance - Engines::MPIContainer_var aMPIContainer = Engines::MPIContainer::_narrow(FindContainer(aComputerContainer.c_str())); - - //On a trouve le container: on renvoie une poigne dessus - if ( !CORBA::is_nil( aMPIContainer ) ) { - MESSAGE("MPIContainer " << aComputerContainer << " found!!!"); - return aMPIContainer ; - } - // On a pas trouve le container - else { - MESSAGE("MPIContainer " << aComputerContainer << " not found!!!"); - // On recherche un container generique - bool pyCont = false ; - int len = theMPIContainer.length() ; - if ( !strcmp( &theMPIContainerRoot.c_str()[len-2] , "Py" ) ) { - pyCont = true ; - } - std::string MPIFactoryServer = theComputer ; - if ( pyCont ) { - MPIFactoryServer += "/MPIFactoryServerPy" ; - } - else { - MPIFactoryServer += "/MPIFactoryServer" ; - } - MPIFactoryServer += nbp; - Engines::MPIContainer_var aMPIFactoryServer = Engines::MPIContainer::_narrow(FindContainer( MPIFactoryServer.c_str())); - - // On n'a pas trouve le container generique: on lance le container demande - if ( CORBA::is_nil( aMPIFactoryServer ) ) { -// rsh -n ikkyo /export/home/rahuel/SALOME_ROOT/bin/runSession SALOME_Container -ORBInitRef NameService=corbaname::dm2s0017:1515 & - std::string rsh( "" ) ; - if ( theComputer!= GetHostname() ) { - rsh += "rsh -n " ; - rsh += theComputer ; - rsh += " " ; - } - std::string path = ComputerPath( theComputer.c_str() ) ; - SCRUTE( path ) ; - // rsh += "runSession " ; - if ( pyCont ) { - MESSAGE("MPI python container not implemented"); - return Engines::MPIContainer::_nil(); -// rsh += "SALOME_MPIContainerPy.py " ; -// rsh += "MPIFactoryServerPy -" ; - } - else { - sprintf(nbp,"mpirun -np %d %sSALOME_MPIContainer ",nbproc,path.c_str()); - rsh += nbp; - rsh += theMPIContainer +" -" ; - } - std::string omniORBcfg( getenv( "OMNIORB_CONFIG" ) ) ; - ifstream omniORBfile( omniORBcfg.c_str() ) ; - char ORBInitRef[12] ; - char nameservice[132] ; - omniORBfile >> ORBInitRef ; - rsh += ORBInitRef ; - rsh += " " ; - omniORBfile >> nameservice ; - omniORBfile.close() ; - char * bsn = strchr( nameservice , '\n' ) ; - if ( bsn ) { - bsn[ 0 ] = '\0' ; - } - rsh += nameservice ; - if ( pyCont ) { - rsh += " > /tmp/MPIFactoryServerPy_" ; - } - else { - rsh += " > /tmp/MPIFactoryServer_" ; - } - sprintf(nbp,"%d_",nbproc); - rsh += nbp; - rsh += theComputer ; - rsh += ".log 2>&1 &" ; - SCRUTE( rsh ); - int status = system( rsh.c_str() ) ; - if (status == -1) { - INFOS("SALOME_MPILifeCycleCORBA::FindOrStartMPIContainer rsh failed (system command status -1)") ; - } - else if (status == 217) { - INFOS("SALOME_MPILifeCycleCORBA::FindOrStartContainer rsh failed (system command status 217)") ; - } - else { - int count = 21 ; - while ( CORBA::is_nil( aMPIFactoryServer ) && count ) { - sleep( 1 ) ; - count-- ; - if ( count != 10 ) - MESSAGE( count << ". Waiting for FactoryServer on " << theComputer) - aMPIFactoryServer = Engines::MPIContainer::_narrow(FindContainer( MPIFactoryServer.c_str())); - } - if ( CORBA::is_nil( aMPIFactoryServer ) ) { - INFOS("SALOME_MPILifeCycleCORBA::FindOrStartMPIContainer rsh failed") ; - } - else if ( strcmp( theComputer.c_str() , GetHostname().c_str() ) ) { - _MPIFactoryServer = aMPIFactoryServer ; - } - } - } - // On a trouve le container generique distant: on se sert de lui - // pour lancer un nouveau container MPI - // a revoir... - if ( !CORBA::is_nil( aMPIFactoryServer ) ) { - if ( strcmp( theMPIContainer.c_str() , "MPIFactoryServer" ) || - strcmp( theMPIContainer.c_str() , "MPIFactoryServerPy" ) ) { - MESSAGE("MPI Container not found ! trying to start " << aComputerContainer); - Engines::MPIContainer_var myMPIContainer = aMPIFactoryServer->start_MPIimpl( theMPIContainer.c_str(), nbproc ) ; - if ( !CORBA::is_nil( myMPIContainer ) ) { - MESSAGE("MPIContainer " << aComputerContainer << " started"); - return myMPIContainer ; - } - else { - MESSAGE("MPIContainer " << aComputerContainer << " NOT started"); - } - } - else { - MESSAGE("MPIContainer " << aComputerContainer << " started"); - return aMPIFactoryServer ; - } - } - } - return Engines::MPIContainer::_nil(); -} - -// Engines::Component_var SALOME_MPILifeCycleCORBA::FindOrLoad_MPIComponent -// (const char *MPIcontainerName, -// const char *MPIcomponentName, -// const char *implementation, -// const int nbproc) -// { -// BEGIN_OF("FindOrLoad_MPIComponent(1)"); -// ASSERT(_NS != NULL); -// string theComputer ; -// string theMPIContainer ; -// string theComputerContainer = ContainerName( MPIcontainerName , -// &theComputer , -// &theMPIContainer ) ; -// Engines::MPIContainer_var cont = FindOrStartMPIContainer( theComputerContainer , -// theComputer , -// theMPIContainer, -// nbproc) ; -// // ASSERT(!CORBA::is_nil(cont)); - -// string path( theComputerContainer ); -// path = path + "/"; -// path = path + MPIcomponentName; -// SCRUTE(path); -// try -// { -// CORBA::Object_var obj = _NS->Resolve(path.c_str()); -// if (CORBA::is_nil(obj)) -// { -// MESSAGE("MPIComponent not found ! trying to load " << path); -// Engines::Component_var compo -// = cont->load_impl(MPIcomponentName, implementation); -// // ASSERT(!CORBA::is_nil(compo)); -// MESSAGE("MPIComponent launched !" << path); -// return compo; -// } -// else -// { -// MESSAGE("MPIComponent found !" << path); -// Engines::Component_var compo = Engines::Component::_narrow(obj); -// // ASSERT(!CORBA::is_nil(compo)); -// try -// { -// compo->ping(); -// } -// catch (CORBA::COMM_FAILURE&) -// { -// INFOS("Caught CORBA::SystemException CommFailure. Engine " -// << path << "does not respond" ); -// } -// return compo; -// } -// } -// catch (ServiceUnreachable&) -// { -// INFOS("Caught exception: Naming Service Unreachable"); -// } -// catch (...) -// { -// INFOS("Caught unknown exception."); -// } -// return Engines::Component::_nil(); -// } - -Engines::Component_var SALOME_MPILifeCycleCORBA::FindOrLoad_MPIComponent - (const char *MPIcontainerName, - const char *MPIcomponentName, - const int nbproc) -{ - - char nbp[1024]; - - sprintf(nbp,"_%d",nbproc); -// BEGIN_OF("FindOrLoad_Component(2)"); - ASSERT(_NS != NULL); - string theComputer ; - string theMPIContainerRoot ; - string theMPIContainer; - string theComputerContainer = ContainerName( MPIcontainerName , - &theComputer , - &theMPIContainerRoot ) ; - theMPIContainer = theMPIContainerRoot + nbp; - Engines::MPIContainer_var cont = FindOrStartMPIContainer( theComputer , - theMPIContainerRoot, - nbproc ) ; - - if ( CORBA::is_nil( cont ) ) { - MESSAGE("MPIContainer not found ! " << theComputerContainer ); - return Engines::Component::_nil(); - } - -// char * machine = cont->machineName() ; - const char * machine = theComputer.c_str() ; - - string path( theComputerContainer ); - path += nbp; - path += "/"; - path += MPIcomponentName; - SCRUTE(path); - - try { - CORBA::Object_var obj = _NS->Resolve(path.c_str()); - if ( CORBA::is_nil( obj ) ) { - MESSAGE("MPIComponent not found ! trying to load " << path); - CORBA::Object_var obj2 = _NS->Resolve("/Kernel/ModulCatalog"); - SALOME_ModuleCatalog::ModuleCatalog_var Catalog = - SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj2); - - SALOME_ModuleCatalog::Acomponent_ptr compoInfo = - Catalog->GetComponent(MPIcomponentName); - if (CORBA::is_nil (compoInfo)) - { - INFOS("Catalog Error : Component not found in the catalog") - return Engines::Component::_nil(); -// exit (-1); - } - - string path; - try - { - path = compoInfo->GetPathPrefix( machine ) ; - path += "/" ; - } - catch (SALOME_ModuleCatalog::NotFound&) - { - MESSAGE("GetPathPrefix(" << machine << ") not found!" - << "trying localhost"); - try { - path = compoInfo->GetPathPrefix("localhost") ; - path += "/" ; - } - catch (SALOME_ModuleCatalog::NotFound&) { - MESSAGE("GetPathPrefix(localhost) not found!") ; - path = "" ; - } - } - - SCRUTE(path); - string implementation(path); - implementation += "lib"; - implementation += MPIcomponentName; - implementation += "Engine.so"; - - Engines::Component_var compo - = cont->load_impl(MPIcomponentName, implementation.c_str()); - -// ASSERT(!CORBA::is_nil(compo)); -// MESSAGE("Component launched !" << path); - return compo; - } - else - { - MESSAGE("MPIComponent found !" << path); - Engines::Component_var compo = Engines::Component::_narrow(obj); - // ASSERT(!CORBA::is_nil(compo)); - try - { - string instanceName = compo->instanceName(); - } - catch (CORBA::SystemException&) - { - INFOS("Caught CORBA::SystemException CommFailure. Engine " - << path << "does not respond" ); - } - return compo; - } - } - catch (ServiceUnreachable&) - { - INFOS("Caught exception: Naming Service Unreachable"); - } - catch (...) - { - INFOS("Caught unknown exception."); - } - return Engines::Component::_nil(); -} diff --git a/src/MPILifeCycleCORBA/SALOME_MPILifeCycleCORBA.hxx b/src/MPILifeCycleCORBA/SALOME_MPILifeCycleCORBA.hxx deleted file mode 100644 index e560a072e..000000000 --- a/src/MPILifeCycleCORBA/SALOME_MPILifeCycleCORBA.hxx +++ /dev/null @@ -1,45 +0,0 @@ -//============================================================================= -// File : SALOME_MPILifeCycleCORBA.hxx -// Created : mar jui 03 14:55:45 CEST 2003 -// Author : Bernard SECHER, CEA -// Project : SALOME -// Copyright : CEA 2003 -// $Header$ -//============================================================================= - -#ifndef _SALOME_MPILIFECYCLECORBA_HXX_ -#define _SALOME_MPILIFECYCLECORBA_HXX_ - -#include -#include -#include - -#include -#include CORBA_CLIENT_HEADER(SALOME_MPIContainer) -#include "SALOME_LifeCycleCORBA.hxx" - -class SALOME_MPILifeCycleCORBA : public SALOME_LifeCycleCORBA -{ -public: - SALOME_MPILifeCycleCORBA(); - SALOME_MPILifeCycleCORBA(SALOME_NamingService *ns); - virtual ~SALOME_MPILifeCycleCORBA(); - -// Engines::Component_var FindOrLoad_MPIComponent(const char *MPIcontainerName, -// const char *MPIcomponentName, -// const char *implementationPath, -// const int nbproc); - Engines::Component_var FindOrLoad_MPIComponent(const char *MPIcontainerName, - const char *MPIcomponentName, - const int nbproc); -protected: - Engines::MPIContainer_var _MPIFactoryServer ; - -private: - Engines::MPIContainer_var FindOrStartMPIContainer(const std::string theComputer , - const std::string theMPIContainerRoot, - const int nbproc) ; - -} ; - -#endif diff --git a/src/MPILifeCycleCORBA/TestMPILifeCycleCORBA.cxx b/src/MPILifeCycleCORBA/TestMPILifeCycleCORBA.cxx deleted file mode 100644 index 680ba3766..000000000 --- a/src/MPILifeCycleCORBA/TestMPILifeCycleCORBA.cxx +++ /dev/null @@ -1,70 +0,0 @@ -// using namespace std; -//============================================================================= -// File : TestMPILifeCycleCORBA.cxx -// Created : mer jui 4 13:11:27 CEST 2003 -// Author : Bernard SECHER, 2003 -// Project : SALOME -// Copyright : CEA 2003 -// $Header$ -//============================================================================= - -#include "utilities.h" -#include -#include -#include -#include -#include CORBA_CLIENT_HEADER(SALOME_MPIContainer) -#include CORBA_CLIENT_HEADER(SALOME_TestMPIComponent) - -# include "Utils_ORB_INIT.hxx" -# include "Utils_SINGLETON.hxx" -#include "SALOME_NamingService.hxx" -#include "SALOME_MPILifeCycleCORBA.hxx" -#include "OpUtil.hxx" -using namespace std; - -int main (int argc, char * argv[]) -{ - - try{ - // Initializing omniORB - CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); - - // Obtain a reference to the root POA - CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ; - PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ; - - // Use Name Service to find container - SALOME_NamingService NS(orb); - - SALOME_MPILifeCycleCORBA LCC(&NS); - - Engines::Component_var comp = LCC.FindOrLoad_MPIComponent("MPIFactoryServer","TestMPIComponent",2); - - Engines::TestMPIComponent_var m1 = Engines::TestMPIComponent::_narrow(comp); - if(CORBA::is_nil(m1)){ - INFOS("echec recuperation poignee composant"); - } - else{ - - INFOS("Lancement de coucou"); - m1->Coucou(1L); - } - - orb->destroy(); - } - catch(CORBA::COMM_FAILURE& ex) { - INFOS("Caught system exception COMM_FAILURE -- unable to contact the object."); - } - catch(CORBA::SystemException&) { - INFOS("Caught a CORBA::SystemException."); - } - catch(CORBA::Exception&) { - INFOS("Caught CORBA::Exception."); - } - catch(...) { - INFOS("Caught unknown exception."); - } - - return 0; -} diff --git a/src/Makefile.in b/src/Makefile.in index 04f690535..df0e392ff 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -36,12 +36,12 @@ SUBDIRS = SALOMELocalTrace SALOMETraceCollector Logger Utils \ CASCatch GenericObj NamingService Registry \ ModuleCatalog DataTypeCatalog RessourcesCatalog \ ResourcesManager Notification NOTIFICATION_SWIG \ - Container TestContainer LifeCycleCORBA HDFPersist \ - SALOMEDSClient TOOLSDS SALOMEDSImpl SALOMEDS KERNEL_PY \ + Container TestContainer LifeCycleCORBA LifeCycleCORBA_SWIG HDFPersist \ + SALOMEDSClient TOOLSDS SALOMEDSImpl SALOMEDS KERNEL_PY \ ModuleGenerator Communication ifeq (@mpi_ok@,yes) - SUBDIRS+= MPIContainer MPILifeCycleCORBA TestMPIContainer + SUBDIRS+= MPIContainer TestMPIContainer endif ifeq (@WITH_BATCH@,yes) @@ -49,3 +49,4 @@ ifeq (@WITH_BATCH@,yes) endif @MODULE@ + diff --git a/src/NamingService/SALOME_NamingService.cxx b/src/NamingService/SALOME_NamingService.cxx index 0a4af7c3c..b84b8daf0 100644 --- a/src/NamingService/SALOME_NamingService.cxx +++ b/src/NamingService/SALOME_NamingService.cxx @@ -33,6 +33,7 @@ #include #include +#include using namespace std; @@ -69,7 +70,8 @@ SALOME_NamingService::SALOME_NamingService(CORBA::ORB_ptr orb) SALOME_NamingService::~SALOME_NamingService() { - MESSAGE("SALOME_NamingService destruction"); + // Problem MESSAGE with singleton: late destruction, after trace system destruction ? + //MESSAGE("SALOME_NamingService destruction"); } //---------------------------------------------------------------------- @@ -377,6 +379,10 @@ CORBA::Object_ptr SALOME_NamingService::Resolve(const char* Path) * \param Path const char* argument like "/path/name" * search the fist reference like "/path(.dir)/name*(.kind)" * If the NamingService is out, the exception ServiceUnreachable is thrown + + + + * \return the object reference */ //---------------------------------------------------------------------- @@ -418,6 +424,109 @@ CORBA::Object_ptr SALOME_NamingService::ResolveFirst(const char* Path) return obj; } +//---------------------------------------------------------------------- +/*! Function : Resolve Component from hostname, containername, componentName and number of prcoessors + * Purpose : method to get the ObjRef of a component + * If the NamingService is out, the exception ServiceUnreachable is thrown + * \param hostname const char* argument + * \param containername const char* argument + * \param componentname const char* argument + * \param nbproc const int argument + * \return the object reference + */ +//---------------------------------------------------------------------- + +CORBA::Object_ptr SALOME_NamingService::ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc) +{ + + string name="/Containers/"; + name += hostname; + if( strlen(containerName) != 0 ){ + name += "/"; + if( nbproc >=1 ){ + char *newContainerName = new char[strlen(containerName)+8]; + sprintf(newContainerName,"%s_%d",containerName,nbproc); + name += newContainerName; + } + else + name += containerName; + name += "/"; + name += componentName; + return ResolveFirst(name.c_str()); + } + else { + Change_Directory(name.c_str()); + vector contList = list_directory(); + for(unsigned int ind = 0; ind < contList.size(); ind++){ + name = contList[ind].c_str(); + name += "/"; + name += componentName; + CORBA::Object_ptr obj = ResolveFirst(name.c_str()); + if( !CORBA::is_nil(obj) ) + return obj; + } + return CORBA::Object::_nil(); + } + +} + +string SALOME_NamingService::ContainerName(const char *containerName) +{ + string ret; + + if (strlen(containerName)== 0) + ret = "FactoryServer"; + else + ret = containerName; + + return ret; +} + +string SALOME_NamingService::ContainerName(const Engines::MachineParameters& params) +{ + int nbproc; + if( !params.isMPI ) + nbproc = 0; + else if( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) ) + nbproc = 1; + else if( params.nb_node == 0 ) + nbproc = params.nb_proc_per_node; + else if( params.nb_proc_per_node == 0 ) + nbproc = params.nb_node; + else + nbproc = params.nb_node * params.nb_proc_per_node; + + string ret=ContainerName(params.container_name); + + if( nbproc >=1 ){ + char *suffix = new char[8]; + sprintf(suffix,"_%d",nbproc); + ret += suffix; + } + + return ret; +} + +string SALOME_NamingService::BuildContainerNameForNS(const char *containerName, const char *hostname) +{ + string ret="/Containers/"; + ret += hostname; + ret+="/"; + ret+=ContainerName(containerName); + + return ret; +} + +string SALOME_NamingService::BuildContainerNameForNS(const Engines::MachineParameters& params, const char *hostname) +{ + string ret="/Containers/"; + ret += hostname; + ret+="/"; + ret+=ContainerName(params); + + return ret; +} + //---------------------------------------------------------------------- /*! Function : Find * Purpose : method to research a name from the current directory @@ -1116,6 +1225,27 @@ void SALOME_NamingService::Destroy_Directory(const char* Path) delete[] resultat_resolve_Path ; } +//---------------------------------------------------------------------- +/*! Function : Destroy_Directory. + * Purpose : method to destroy a directory if it is empty. + * WARNING : The complete Path to the directory (from the root_context) + * to destroy should be given. + * If the NamingService is out, the exception ServiceUnreachable is thrown. + * \param Path const char* arguments + */ +//---------------------------------------------------------------------- + +void SALOME_NamingService::Destroy_FullDirectory(const char* Path) + throw(ServiceUnreachable) +{ + Change_Directory(Path); + vector contList = list_directory(); + for(unsigned int ind = 0; ind < contList.size(); ind++) + Destroy_Name(contList[ind].c_str()); + Destroy_Directory(Path); + Destroy_Name(Path); +} + //---------------------------------------------------------------------- /*! Function : _initialize_root_context * Purpose : method called by constructor to initialize _root_context @@ -1451,3 +1581,4 @@ char * SALOME_NamingService::getIORaddr() { return _orb->object_to_string(_root_context); } + diff --git a/src/NamingService/SALOME_NamingService.hxx b/src/NamingService/SALOME_NamingService.hxx index 8fb27f025..d418b47b7 100644 --- a/src/NamingService/SALOME_NamingService.hxx +++ b/src/NamingService/SALOME_NamingService.hxx @@ -35,6 +35,9 @@ #include #include "Utils_Mutex.hxx" +#include +#include CORBA_CLIENT_HEADER(SALOME_ContainerManager) +#include CORBA_CLIENT_HEADER(SALOME_Component) //class ServiceUnreachable; #include "ServiceUnreachable.hxx" @@ -75,10 +78,19 @@ public: CORBA::Object_ptr Resolve(const char* Path) throw( ServiceUnreachable); - //! method to get an ObjRef, given a symbolic name without instance suffix "/Path/Name*.kind" + //! method to get the ObjRef of a component + CORBA::Object_ptr ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc=0); + + //! method to get an ObjRef, given a symbolic name without instance suffix "/Path/Name*.kind" CORBA::Object_ptr ResolveFirst(const char* Path) throw( ServiceUnreachable); + std::string ContainerName(const char *ContainerName); + std::string ContainerName(const Engines::MachineParameters& params); + + std::string BuildContainerNameForNS(const char *ContainerName, const char *hostname); + std::string BuildContainerNameForNS(const Engines::MachineParameters& params, const char *hostname); + //! method to research a name from the naming service's current directory int Find(const char* name) throw(ServiceUnreachable); @@ -116,6 +128,10 @@ public: virtual void Destroy_Directory(const char* Path) throw(ServiceUnreachable); + //! method to destroy a directory even if it is not empty + virtual void Destroy_FullDirectory(const char* Path) + throw(ServiceUnreachable); + //! get IORstring naming service address char * getIORaddr(); @@ -154,3 +170,4 @@ protected: }; #endif // SALOME_NAMINGSERVICE_H + diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index 7466676a5..d63c122c7 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -14,6 +14,7 @@ #endif #include #include +#include #include #include #include @@ -26,12 +27,14 @@ using namespace std; //just for test -SALOME_ResourcesManager::SALOME_ResourcesManager(const char *xmlFilePath):_path_resources(xmlFilePath) +SALOME_ResourcesManager::SALOME_ResourcesManager(CORBA::ORB_ptr orb,const char *xmlFilePath):_path_resources(xmlFilePath) { + _NS=new SALOME_NamingService(orb); } -SALOME_ResourcesManager::SALOME_ResourcesManager() +SALOME_ResourcesManager::SALOME_ResourcesManager(CORBA::ORB_ptr orb) { + _NS=new SALOME_NamingService(orb); _path_resources=getenv("KERNEL_ROOT_DIR"); _path_resources+="/share/salome/resources/CatalogResources.xml"; ParseXmlFile(); @@ -39,17 +42,21 @@ SALOME_ResourcesManager::SALOME_ResourcesManager() SALOME_ResourcesManager::~SALOME_ResourcesManager() { + delete _NS; } vector SALOME_ResourcesManager::GetFittingResources(const Engines::MachineParameters& params,const char *moduleName) throw(SALOME_Exception) { + MESSAGE("ResourcesManager::GetFittingResources"); vector ret; //To be sure that we search in a correct list. ParseXmlFile(); const char *hostname=(const char *)params.hostname; if(hostname[0]!='\0') { - if(_resourcesList.find(hostname)!=_resourcesList.end()) + if( strcmp(hostname,"localhost") == 0 || strcmp(hostname,GetHostname().c_str()) == 0 ) + ret.push_back(GetHostname().c_str()); + else if(_resourcesList.find(hostname)!=_resourcesList.end()) // params.hostame is in the list of resources so return it. ret.push_back(hostname); else @@ -191,7 +198,7 @@ bool isPythonContainer(const char* ContainerName) return ret; } -string SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer(const string& machine,const char *containerName) +string SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer(const string& machine,const Engines::MachineParameters& params) { _TmpFileName=BuildTemporaryFileName(); ofstream tempOutputFile; @@ -212,12 +219,34 @@ string SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer(const strin tempOutputFile << "export PYTHONPATH" << endl; tempOutputFile << "source " << resInfo.PreReqFilePath << endl; // ! env vars + if(params.isMPI){ + tempOutputFile << "mpirun -np "; + int nbproc; + if( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) ) + nbproc = 1; + else if( params.nb_node == 0 ) + nbproc = params.nb_proc_per_node; + else if( params.nb_proc_per_node == 0 ) + nbproc = params.nb_node; + else + nbproc = params.nb_node * params.nb_proc_per_node; + std::ostringstream o; + tempOutputFile << nbproc << " "; + } tempOutputFile << (*(resInfo.ModulesPath.find("KERNEL"))).second << "/bin/salome/"; - if(isPythonContainer(containerName)) - tempOutputFile << "SALOME_ContainerPy.py "; - else - tempOutputFile << "SALOME_Container "; - tempOutputFile << containerName << " -"; + if(params.isMPI){ + if(isPythonContainer(params.container_name)) + tempOutputFile << "pyMPI SALOME_ContainerPy.py "; + else + tempOutputFile << "SALOME_MPIContainer "; + } + else{ + if(isPythonContainer(params.container_name)) + tempOutputFile << "SALOME_ContainerPy.py "; + else + tempOutputFile << "SALOME_Container "; + } + tempOutputFile << _NS->ContainerName(params) << " -"; AddOmninamesParams(tempOutputFile); tempOutputFile << " &" << endl; tempOutputFile.flush(); @@ -246,27 +275,48 @@ string SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer(const strin command+=_TmpFileName; command += " > "; command += "/tmp/"; - command += containerName; + command += _NS->ContainerName(params); command += "_"; command += machine; - command += ".log &"; + command += ".log 2>&1 &"; cout << "Command is ... " << command << endl; return command; } -string SALOME_ResourcesManager::BuildCommandToLaunchLocalContainer(const char *containerName) +string SALOME_ResourcesManager::BuildCommandToLaunchLocalContainer(const Engines::MachineParameters& params) { _TmpFileName=""; string command; - if(isPythonContainer(containerName)) - command="SALOME_ContainerPy.py "; - else - command="SALOME_Container "; - command+=containerName; + int nbproc=0; + if(params.isMPI){ + command="mpirun -np "; + if( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) ) + nbproc = 1; + else if( params.nb_node == 0 ) + nbproc = params.nb_proc_per_node; + else if( params.nb_proc_per_node == 0 ) + nbproc = params.nb_node; + else + nbproc = params.nb_node * params.nb_proc_per_node; + std::ostringstream o; + o << nbproc << " "; + command += o.str(); + if(isPythonContainer(params.container_name)) + command+="pyMPI SALOME_ContainerPy.py "; + else + command+="SALOME_MPIContainer "; + } + else{ + if(isPythonContainer(params.container_name)) + command="SALOME_ContainerPy.py "; + else + command="SALOME_Container "; + } + command+=_NS->ContainerName(params); command+=" -"; AddOmninamesParams(command); command+=" > /tmp/"; - command+=containerName; + command+=_NS->ContainerName(params); command += "_"; command += GetHostname(); command += "_"; @@ -329,21 +379,23 @@ void SALOME_ResourcesManager::SelectOnlyResourcesWithOS(vector& hosts,co { string base(OS); for(map::const_iterator iter=_resourcesList.begin();iter!=_resourcesList.end();iter++) + { if((*iter).second.OS==base) - hosts.push_back((*iter).first); + hosts.push_back((*iter).first); + } } //Warning need an updated parsed list : _resourcesList void SALOME_ResourcesManager::KeepOnlyResourcesWithModule(vector& hosts,const char *moduleName) const throw(SALOME_Exception) { - for(vector::iterator iter=hosts.begin();iter!=hosts.end();iter++) + for(vector::iterator iter=hosts.begin();iter!=hosts.end();) { MapOfParserResourcesType::const_iterator it=_resourcesList.find(*iter); const map& mapOfModulesOfCurrentHost=(((*it).second).ModulesPath); if(mapOfModulesOfCurrentHost.find(moduleName)==mapOfModulesOfCurrentHost.end()) - { - hosts.erase(iter); - } + hosts.erase(iter); + else + iter++; } } @@ -351,11 +403,12 @@ void SALOME_ResourcesManager::AddOmninamesParams(string& command) const { string omniORBcfg( getenv( "OMNIORB_CONFIG" ) ) ; ifstream omniORBfile( omniORBcfg.c_str() ) ; - char ORBInitRef[12] ; + char ORBInitRef[11] ; + char egal[3] ; char nameservice[132] ; omniORBfile >> ORBInitRef ; - command += ORBInitRef ; - command += " " ; + command += "ORBInitRef " ; + omniORBfile >> egal ; omniORBfile >> nameservice ; omniORBfile.close() ; char * bsn = strchr( nameservice , '\n' ) ; @@ -369,11 +422,12 @@ void SALOME_ResourcesManager::AddOmninamesParams(ofstream& fileStream) const { string omniORBcfg( getenv( "OMNIORB_CONFIG" ) ) ; ifstream omniORBfile( omniORBcfg.c_str() ) ; - char ORBInitRef[12] ; + char ORBInitRef[11] ; + char egal[3] ; char nameservice[132] ; omniORBfile >> ORBInitRef ; - fileStream << ORBInitRef; - fileStream << " "; + fileStream << "ORBInitRef "; + omniORBfile >> egal ; omniORBfile >> nameservice ; omniORBfile.close() ; char * bsn = strchr( nameservice , '\n' ) ; @@ -403,3 +457,5 @@ string SALOME_ResourcesManager::BuildTemporaryFileName() const } + + diff --git a/src/ResourcesManager/SALOME_ResourcesManager.hxx b/src/ResourcesManager/SALOME_ResourcesManager.hxx index c62c86e70..b8dca196c 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.hxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.hxx @@ -6,6 +6,7 @@ #include #include "SALOME_ResourcesCatalog_Handler.hxx" #include "SALOME_LoadRateManager.hxx" +#include "SALOME_NamingService.hxx" #include CORBA_CLIENT_HEADER(SALOME_ContainerManager) #include #include @@ -34,10 +35,10 @@ class RESOURCESMANAGER_EXPORT SALOME_ResourcesManager { public: //! standard constructor - SALOME_ResourcesManager(); + SALOME_ResourcesManager(CORBA::ORB_ptr orb); //!just for test - SALOME_ResourcesManager(const char *xmlFilePath); + SALOME_ResourcesManager(CORBA::ORB_ptr orb,const char *xmlFilePath); //! standard destructor ~SALOME_ResourcesManager(); @@ -49,10 +50,10 @@ public: std::string FindBest(const Engines::MachineList& listOfMachines); //! method that builds in a temporary file the script to be launched - std::string BuildTempFileToLaunchRemoteContainer(const std::string& machine,const char *containerName); + std::string BuildTempFileToLaunchRemoteContainer(const std::string& machine,const Engines::MachineParameters& params); //! method that builds the command to be launched. - std::string BuildCommandToLaunchLocalContainer(const char *containerName); + std::string BuildCommandToLaunchLocalContainer(const Engines::MachineParameters& params); //! method that remove the generated temporary file in case of a remote launch. void RmTmpFile(); @@ -78,6 +79,7 @@ public: const MapOfParserResourcesType& GetList() const; private: + SALOME_NamingService *_NS; //! method to verify ressources catalog content - return true if verfication is OK bool _verify_resources(MapOfParserResourcesType resourceslist); diff --git a/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx b/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx index aa18c5e57..9af1467a3 100644 --- a/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx +++ b/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx @@ -2,13 +2,13 @@ // Author : Sergey RUIN // Module : SALOME -using namespace std; #include "SALOMEDS_UseCaseIterator_i.hxx" #include "SALOMEDS_SObject_i.hxx" #include "SALOMEDS.hxx" #include "SALOMEDSImpl_SObject.hxx" #include "utilities.h" +using namespace std; //============================================================================ /*! Function : constructor diff --git a/src/TestMPIContainer/Makefile.in b/src/TestMPIContainer/Makefile.in index b268fd20e..451d9d20f 100644 --- a/src/TestMPIContainer/Makefile.in +++ b/src/TestMPIContainer/Makefile.in @@ -31,7 +31,7 @@ BIN_SRC = BIN_CLIENT_IDL = Logger.idl SALOME_MPIObject.idl SALOME_MPIContainer.idl SALOME_TestMPIComponent.idl BIN_SERVER_IDL = -LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeMPILifeCycleCORBA -lSalomeLifeCycleCORBA -lSalomeMPIContainer -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace ${MPI_LIBS} +LDFLAGSFORBIN+= -lSalomeNotification -lSalomeNS -lSalomeLifeCycleCORBA -lSalomeMPIContainer -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace -lSalomeResourcesManager ${MPI_LIBS} CXXFLAGS+=${MPI_INCLUDES} CXX_DEPEND_FLAG+=${MPI_INCLUDES} diff --git a/src/TestMPIContainer/TestMPIContainer.cxx b/src/TestMPIContainer/TestMPIContainer.cxx index 898007487..f17d5a630 100644 --- a/src/TestMPIContainer/TestMPIContainer.cxx +++ b/src/TestMPIContainer/TestMPIContainer.cxx @@ -20,7 +20,7 @@ # include "Utils_SINGLETON.hxx" #include "SALOME_NamingService.hxx" #include "OpUtil.hxx" -#include "LocalTraceCollector.hxx" +#include "SALOMETraceCollector.hxx" using namespace std; int main (int argc, char * argv[]) @@ -29,7 +29,7 @@ int main (int argc, char * argv[]) // Initializing omniORB ORB_INIT &init = *SINGLETON_::Instance() ; CORBA::ORB_var &orb = init( argc , argv ) ; - LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb); + SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); BEGIN_OF(argv[0]) try{ @@ -115,7 +115,7 @@ int main (int argc, char * argv[]) // // Clean-up. // // iGenFact->finalize_removal() ; // // sleep(5); - iGenFact->MPIShutdown(); + iGenFact->Shutdown(); // INFOS("shut down corba server for Test MPI Container"); // orb->destroy(); } -- 2.39.2