From 47bca5d3279eb05222db96b3cfa4e6a644865682 Mon Sep 17 00:00:00 2001 From: rahuel Date: Fri, 5 Mar 2004 15:11:50 +0000 Subject: [PATCH] *** empty log message *** --- idl/ContainersManager.idl | 7 + idl/SALOME_Component.idl | 1 + resources/ResourcesCatalog.xml | 6 +- src/Container/Container_i.cxx | 37 +- src/Container/SALOME_Container_i.hxx | 1 + .../ContainersManager_Server.cxx | 14 +- src/ContainersManager/ContainersManager_i.cxx | 450 +++++++++++++++--- src/ContainersManager/ContainersManager_i.hxx | 24 +- .../TestContainersManager.py | 48 +- .../ResourcesManager_Server.cxx | 7 +- src/TestContainer/TestContainer.cxx | 9 +- 11 files changed, 503 insertions(+), 101 deletions(-) diff --git a/idl/ContainersManager.idl b/idl/ContainersManager.idl index 736646a38..57b6eccb8 100644 --- a/idl/ContainersManager.idl +++ b/idl/ContainersManager.idl @@ -55,6 +55,8 @@ module Containers { boolean ping() ; + Engines::Container FindOneContainer( in string aContainerName ) ; + Engines::Container FindContainer( in MachineParameters MyParams ) ; Engines::ListOfContainers FindContainers( in MachineParameters MyParams ) ; @@ -64,6 +66,9 @@ module Containers { Engines::Component FindComponent( in MachineParameters MyParams , in string ComponentName ) ; + Engines::Component FindOneComponent( in string aContainerName , + in string ComponentName ) ; + Engines::ListOfComponents FindComponents( in MachineParameters MyParams , in string ComponentName ) ; @@ -74,6 +79,8 @@ module Containers { Engines::Component FindOrLoad_Component( in MachineParameters MyParams , in string ComponentName ) ; + void destroy() ; + } ; } ; diff --git a/idl/SALOME_Component.idl b/idl/SALOME_Component.idl index 717c37859..9c0a4873b 100644 --- a/idl/SALOME_Component.idl +++ b/idl/SALOME_Component.idl @@ -51,6 +51,7 @@ module Engines interface Container { + void destroy() ; /*! Initializes the %container with a definite name. \param ContainerName Name of the container diff --git a/resources/ResourcesCatalog.xml b/resources/ResourcesCatalog.xml index a48cf65d1..d936070e8 100644 --- a/resources/ResourcesCatalog.xml +++ b/resources/ResourcesCatalog.xml @@ -1,8 +1,8 @@ - bordolex.saclay.opencascade.com - bordolex + dunex.saclay.opencascade.com + dunex 0 1 1 @@ -29,7 +29,7 @@ /home/Salome2/MED_install .:${KERNEL_ROOT_DIR}/bin/salome:${GEOM_ROOT_DIR}/bin/salome:${SUPERV_ROOT_DIR}/bin/salome:${MED_ROOT_DIR}/bin/salome:${SMESH_ROOT_DIR}/bin/salome:${VISU_ROOT_DIR}/bin/salome:/home/SALOME_1.2c/graphviz-1.9/bin:/home/SALOME_1.2c/doxygen-1.3-rc2/bin:/home/SALOME_1.2c/HappyDoc-r2_1/bin:/home/SALOME_1.2c/omniORB-3.0.5/bin/i586_linux_2.0_glibc2.1:/home/SALOME_1.2c/VTK-4.2.2/bin:/home/SALOME_1.2c/med-2.1.6/bin:/home/SALOME_1.2c/hdf5-1.4.4/bin:/home/SALOME_1.2c/SWIG-1.3.17/bin:/usr/bin:/opt/j2sdk1.4.0_02/bin:/usr/local/bin:/usr/X11R6/bin:/usr/bin:/bin:/usr/bin:/usr/bin:/usr/lib/qt-3.0.5/bin:/usr/bin:/usr/bin:/usr/bin:/usr/bin:/usr/lib/qt-3.0.5/bin:/usr/bin:/usr/bin ${KERNEL_ROOT_DIR}/lib/salome:${GEOM_ROOT_DIR}/lib/salome:${SUPERV_ROOT_DIR}/lib/salome:${MED_ROOT_DIR}/lib/salome:${SMESH_ROOT_DIR}/lib/salome:${VISU_ROOT_DIR}/lib/salome:/home/SALOME_1.2c/graphviz-1.9/lib/graphviz:/home/SALOME_1.2c/omniORB-3.0.5/lib/i586_linux_2.0_glibc2.1:/home/SALOME_1.2c/VTK-4.2.2/lib/vtk:/home/SALOME_1.2c/med-2.1.6/lib:/home/SALOME_1.2c/hdf5-1.4.4/lib:/home/SALOME_1.2c/qwt-0.4.1/lib:/home/SALOME_1.2c/SWIG-1.3.17/lib::/usr/lib/python2.2:/home/SALOME_1.2c/CAS4.0/Linux/lib:/home/SALOME_1.2c/CAS4.0/lin/lib:/home/SALOME_1.2c/CAS4.0/Linux/lib::/usr/lib:/usr/lib:/usr/lib/qt-3.0.5/lib:/usr/bin:/usr/lib/python2.2/site-packages - ${KERNEL_ROOT_DIR}/bin/salome:${KERNEL_ROOT_DIR}/lib/salome:${GEOM_ROOT_DIR}/bin/salome:${GEOM_ROOT_DIR}/lib/salome:${SUPERV_ROOT_DIR}/bin/salome:${SUPERV_ROOT_DIR}/lib/salome:${MED_ROOT_DIR}/bin/salome:${MED_ROOT_DIR}/lib/salome:${SMESH_ROOT_DIR}/bin/salome:${SMESH_ROOT_DIR}/lib/salome:${VISU_ROOT_DIR}/bin/salome:${VISU_ROOT_DIR}/lib/salome:${KERNEL_ROOT_DIR}/lib/python2.2/site-packages/salome:${KERNEL_ROOT_DIR}/share/salome/resources/:/home/SALOME_1.2c/HappyDoc-r2_1/lib/python2.2/site-packages/happydoclib:/home/SALOME_1.2c/Numeric-22.0/lib/python2.2/site-packages/Numeric:/home/SALOME_1.2c/omniORB-3.0.5/lib/python:/home/SALOME_1.2c/omniORB-3.0.5/lib/i586_linux_2.0_glibc2.1::/usr/lib/python2.2:/usr/lib/python2.2/site-packages:/usr/lib/python2.2/site-packages + ${KERNEL_ROOT_DIR}/lib/python2.2/site-packages/salome/shared_modules:${KERNEL_ROOT_DIR}/lib/salome:${KERNEL_ROOT_DIR}/lib/python2.2/site-packages/salome:${KERNEL_ROOT_DIR}/bin/salome:${GEOM_ROOT_DIR}/bin/salome:${GEOM_ROOT_DIR}/lib/salome:${SUPERV_ROOT_DIR}/lib/python2.2/site-packages/salome/shared_modules:${SUPERV_ROOT_DIR}/lib/salome:${SUPERV_ROOT_DIR}/lib/python2.2/site-packages/salome:${SUPERV_ROOT_DIR}/bin/salome:${MED_ROOT_DIR}/bin/salome:${MED_ROOT_DIR}/lib/salome:${SMESH_ROOT_DIR}/bin/salome:${SMESH_ROOT_DIR}/lib/salome:${VISU_ROOT_DIR}/bin/salome:${VISU_ROOT_DIR}/lib/salome:${KERNEL_ROOT_DIR}/lib/python2.2/site-packages/salome:${KERNEL_ROOT_DIR}/share/salome/resources/:/home/SALOME_1.2c/HappyDoc-r2_1/lib/python2.2/site-packages/happydoclib:/home/SALOME_1.2c/Numeric-22.0/lib/python2.2/site-packages/Numeric:/home/SALOME_1.2c/omniORB-3.0.5/lib/python:/home/SALOME_1.2c/omniORB-3.0.5/lib/i586_linux_2.0_glibc2.1::/usr/lib/python2.2:/usr/lib/python2.2/site-packages:/usr/lib/python2.2/site-packages /home/SALOME_1.2c/CAS4.0 diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index 786d1f982..a49e3a8f9 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -145,6 +145,15 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, Engines_Container_i::~Engines_Container_i() { MESSAGE("Container_i::~Container_i()"); + exit( 0 ) ; +} + +void Engines_Container_i::destroy() { + MESSAGE( "Manager_i::destroy" ) ; + _poa->deactivate_object(*_id) ; + CORBA::release(_poa) ; + delete(_id) ; + this->_remove_ref(); } char* Engines_Container_i::name() @@ -181,7 +190,7 @@ Engines::Container_ptr Engines_Container_i::start_impl( const char* ContainerNam const Engines::ContainerType aContainerType ) { MESSAGE("start_impl argc " << _argc << " ContainerName " << ContainerName << hex << this << dec) ; - _numInstanceMutex.lock() ; // lock on the instance number +// _numInstanceMutex.lock() ; // lock on the instance number CORBA::Object_var obj = Engines::Container::_nil() ; bool nilvar = true ; @@ -206,7 +215,7 @@ Engines::Container_ptr Engines_Container_i::start_impl( const char* ContainerNam INFOS(machineName() << "Caught unknown exception."); } if ( !nilvar ) { - _numInstanceMutex.unlock() ; +// _numInstanceMutex.unlock() ; MESSAGE("start_impl container found without runSession") ; return Engines::Container::_narrow(obj); } @@ -261,7 +270,7 @@ Engines::Container_ptr Engines_Container_i::start_impl( const char* ContainerNam count -= 1 ; } } - _numInstanceMutex.unlock() ; +// _numInstanceMutex.unlock() ; if ( !nilvar ) { MESSAGE("start_impl container found after runSession(SALOME_Container)") ; } @@ -274,7 +283,7 @@ Engines::Container_ptr Engines_Container_i::start_impl( const char* ContainerNam INFOS(machineName() << "Caught unknown exception."); } } - _numInstanceMutex.unlock() ; +// _numInstanceMutex.unlock() ; MESSAGE("start_impl container not found after runSession(SALOME_Container)") ; return Engines::Container::_nil() ; } @@ -306,7 +315,7 @@ Engines::Component_ptr Engines_Container_i::load_impl( const char* nameToRegiste } string factory_name = _nameToRegister + string("Engine_factory"); - // SCRUTE(factory_name) ; + SCRUTE(factory_name) ; typedef PortableServer::ObjectId * (*FACTORY_FUNCTION) (CORBA::ORB_ptr, @@ -328,6 +337,17 @@ Engines::Component_ptr Engines_Container_i::load_impl( const char* nameToRegiste Engines::Component_var iobject = Engines::Component::_nil() ; try { CORBA::Object_var obj = _NS->Resolve( component_registerName.c_str() ) ; + if ( !CORBA::is_nil( obj ) ) { + MESSAGE( "Container_i::load_impl " << component_registerName.c_str() << " already bound" ) ; + iobject = Engines::Component::_narrow( obj ) ; + try { + iobject->ping() ; + } + catch (...) { + MESSAGE( "Container_i::load_impl " << component_registerName.c_str() << " NOT responding" ) ; + obj = CORBA::Object::_nil() ; + } + } if ( CORBA::is_nil( obj ) ) { // Instanciate required CORBA object PortableServer::ObjectId * id ; @@ -342,10 +362,6 @@ Engines::Component_ptr Engines_Container_i::load_impl( const char* nameToRegiste _NS->Register( iobject , component_registerName.c_str() ) ; MESSAGE( "Container_i::load_impl " << component_registerName.c_str() << " bound" ) ; } - else { // JR : No ReBind !!! - MESSAGE( "Container_i::load_impl " << component_registerName.c_str() << " already bound" ) ; - iobject = Engines::Component::_narrow( obj ) ; - } } catch (...) { MESSAGE( "Container_i::load_impl catched" ) ; @@ -361,6 +377,8 @@ Engines::Component_ptr Engines_Container_i::load_impl( const char* nameToRegiste void Engines_Container_i::remove_impl(Engines::Component_ptr component_i) { ASSERT(! CORBA::is_nil(component_i)); + string component_registerName = _containerName + "/" + component_i->interfaceName() ; + _NS->Destroy_Name( component_registerName.c_str() ) ; string instanceName = component_i->instanceName() ; MESSAGE("unload component " << instanceName); component_i->destroy() ; @@ -379,6 +397,7 @@ void Engines_Container_i::remove_impl(Engines::Component_ptr component_i) { MESSAGE("reste " << (*im).first); } + MESSAGE("end of remove_impl"); } void Engines_Container_i::finalize_removal() diff --git a/src/Container/SALOME_Container_i.hxx b/src/Container/SALOME_Container_i.hxx index 9ddbcc8c0..bcb91ab12 100644 --- a/src/Container/SALOME_Container_i.hxx +++ b/src/Container/SALOME_Container_i.hxx @@ -58,6 +58,7 @@ public: int flag); virtual ~Engines_Container_i(); + void destroy() ; Engines::Container_ptr start_impl( const char* ContainerName , const Engines::ContainerType ) ; diff --git a/src/ContainersManager/ContainersManager_Server.cxx b/src/ContainersManager/ContainersManager_Server.cxx index 0a5745623..00c7fbbea 100644 --- a/src/ContainersManager/ContainersManager_Server.cxx +++ b/src/ContainersManager/ContainersManager_Server.cxx @@ -28,6 +28,7 @@ #include #include "SALOME_NamingService.hxx" +#include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" #include "ContainersManager_i.hxx" @@ -38,8 +39,10 @@ int main( int argc , char **argv ) { try { // initialize the ORB - CORBA::ORB_ptr orb = CORBA::ORB_init ( argc , argv ) ; - + ORB_INIT &init = *SINGLETON_::Instance() ; + ASSERT(SINGLETON_::IsAlreadyExisting()) ; + CORBA::ORB_var &orb = init( argc , argv ) ; + long TIMESleep = 250000000 ; int NumberOfTries = 40 ; int a ; @@ -125,8 +128,9 @@ int main( int argc , char **argv ) { _NS = new SALOME_NamingService( orb ) ; // Active ContainersManager - Manager_i * MyContainersManager = new Manager_i( orb , _NS , argc , argv ) ; - poa->activate_object ( MyContainersManager ) ; + Manager_i * MyContainersManager = SINGLETON_::Instance() ; + MyContainersManager->Init( orb , poa , _NS , argc , argv ) ; +// _Id = _Poa->activate_object ( MyContainersManager ) ; mgr->activate() ; CORBA::Object_ptr TheContainersManager = MyContainersManager->_this() ; @@ -139,6 +143,8 @@ int main( int argc , char **argv ) { poa->destroy( 1 , 1 ) ; + orb->destroy(); + } catch ( CORBA::SystemException& ) { INFOS("Caught CORBA::SystemException.") ; diff --git a/src/ContainersManager/ContainersManager_i.cxx b/src/ContainersManager/ContainersManager_i.cxx index f8017c0f9..8fbb255b9 100644 --- a/src/ContainersManager/ContainersManager_i.cxx +++ b/src/ContainersManager/ContainersManager_i.cxx @@ -28,17 +28,23 @@ using namespace std ; +#include "Utils_SINGLETON.hxx" + #include "utilities.h" #include "ContainersManager_i.hxx" Manager_i::Manager_i() { + MESSAGE( "Manager_i::Manager_i default constructor" ) ; } -Manager_i::Manager_i( CORBA::ORB_ptr orb , +void Manager_i::Init( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , SALOME_NamingService * NamingService , int argc , char ** argv ) { - _Orb = orb ; + _Orb = CORBA::ORB::_duplicate( orb ) ; + _Poa = PortableServer::POA::_duplicate( poa ) ; + _Id = _Poa->activate_object ( this ) ; _NamingService = NamingService ; CORBA::Object_var obj = NamingService->Resolve( "/Kernel/ResourcesManager" ) ; _ResourcesManager = Resources::Manager::_narrow( obj ) ; @@ -100,6 +106,38 @@ Manager_i::Manager_i( CORBA::ORB_ptr orb , } +void Manager_i::destroy() { + MESSAGE( "Manager_i::destroy" ) ; + int i ; + MESSAGE( "Manager_i::destroy " << _ListOfEnginesComponents.size() << " components" ) ; + for ( i = 0 ; i < _ListOfEnginesComponents.size() ; i++ ) { + try { + _NamingService->Destroy_Name( _ListOfComponentsNames[ i ].c_str() ) ; + _ListOfEnginesComponents[ i ]->destroy() ; + MESSAGE( "Manager_i::destroy Component " << _ListOfComponentsNames[ i ] ) ; + } + catch ( ... ) { + MESSAGE( "Manager_i::destroy Component " << _ListOfComponentsNames[ i ] << " failed" ) ; + } + } + MESSAGE( "Manager_i::destroy " << _ListOfEnginesContainers.size() << " containers" ) ; + for ( i = 0 ; i < _ListOfEnginesContainers.size() ; i++ ) { + try { + _NamingService->Destroy_Name( _ListOfContainersNames[ i ].c_str() ) ; + _ListOfEnginesContainers[ i ]->destroy() ; + MESSAGE( "Manager_i::destroy Container " << _ListOfContainersNames[ i ] ) ; + } + catch ( ... ) { + MESSAGE( "Manager_i::destroy Container " << _ListOfContainersNames[ i ] << " failed" ) ; + } + } + _Poa->deactivate_object(*_Id) ; + CORBA::release(_Poa) ; + delete(_Id) ; + this->_remove_ref(); + _NamingService->Destroy_Name( "/Kernel/ContainersManager" ) ; +} + Manager_i::~Manager_i() { MESSAGE( "Manager_i::~Manager_i" ) ; } @@ -125,23 +163,98 @@ bool Manager_i::ping() { return true ; } +string Manager_i::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 , '/' ) ; + if ( !slash ) { + *theComputer = GetHostname() ; + theComputerContainer += *theComputer ; + theComputerContainer += "/" ; + *theContainer = ContainerName ; + theComputerContainer += *theContainer ; + } + else { + slash[ 0 ] = '\0' ; + slash += 1 ; + *theContainer = slash ; + if ( !strcmp( ContainerName , "localhost" ) ) { + *theComputer = GetHostname() ; + } + else { + *theComputer = ContainerName ; + } + theComputerContainer += *theComputer ; + theComputerContainer += "/" ; + theComputerContainer += *theContainer ; + } + if ( strlen( theContainer->c_str() ) == 0 ) { + theContainer = new string( "FactoryServer" ) ; + } + return theComputerContainer ; +} + Engines::Container_ptr Manager_i::FindContainer( const Containers::MachineParameters & myParams ) { Containers::MachineParameters MyParams = (Containers::MachineParameters & ) myParams ; + Engines::Container_var aContainer = Engines::Container::_nil() ; if ( strcmp( MyParams.HostName ,"localhost" ) == 0 ) { MyParams.HostName = GetHostname().c_str() ; } MESSAGE( "Manager_i::FindContainer " << MyParams.HostName << " " << MyParams.ContainerName ) ; - _ListOfContainers = FindContainers( MyParams ) ; - _EnginesContainer = Engines::Container::_nil() ; - if ( _ListOfContainers->length() ) { - _EnginesContainer = _ListOfContainers[ 0 ] ; - MESSAGE( "Manager_i::FindContainer --> " << _EnginesContainer->machineName() << " " - << _EnginesContainer->name() ) ; + MESSAGE( "Manager_i::FindContainer MutexManager pthread_mutex_lock :" ) ; + if ( pthread_mutex_lock( &_MutexManager ) ) { + perror("Manager_i::FindContainer MutexManager pthread_mutex_lock ") ; + exit( 0 ) ; + } + MESSAGE( "Manager_i::FindContainer MutexManager pthread_mutex_locked" ) ; + try { + _ListOfContainers = FindContainersLocked( MyParams ) ; + _EnginesContainer = Engines::Container::_nil() ; + if ( _ListOfContainers->length() ) { + _EnginesContainer = _ListOfContainers[ 0 ] ; + aContainer = _ListOfContainers[ 0 ] ; + MESSAGE( "Manager_i::FindContainer --> " << aContainer->machineName() << " " + << aContainer->name() ) ; + } + else { + MESSAGE( "Manager_i::FindContainer --> Engines::Container::_nil" ) ; + } + } + catch ( ... ) { + MESSAGE( "Manager_i::FindContainer catched" ) ; + } + if ( pthread_mutex_unlock( &_MutexManager ) ) { + perror("Manager_i::FindContainer MutexManager pthread_mutex_unlock ") ; + exit( 0 ) ; + } + MESSAGE( "Manager_i::FindContainer MutexManager pthread_mutex_unlocked" ) ; + return Engines::Container::_duplicate( aContainer ) ; +} + +Engines::Container_ptr Manager_i::FindOneContainer( const char * aContainerName ) { + Containers::MachineParameters * MyParams = Parameters() ; + string theComputer ; + string theContainer ; + ContainerName( aContainerName , &theComputer , &theContainer ) ; + MyParams->HostName = theComputer.c_str() ; + MyParams->ContainerName = theContainer.c_str() ; + int l = strlen( aContainerName ) ; + if ( strcmp( &aContainerName[ l-2 ] , "Py" ) ) { + MyParams->ContainerType = Engines::Cpp ; } else { - MESSAGE( "Manager_i::FindContainer --> Engines::Container::_nil" ) ; + MyParams->ContainerType = Engines::Python ; } - return Engines::Container::_duplicate( _EnginesContainer ) ; + if ( strcmp( MyParams->HostName ,"localhost" ) == 0 ) { + MyParams->HostName = GetHostname().c_str() ; + } + MESSAGE( "Manager_i::FindOneContainer " << MyParams->HostName << " " << MyParams->ContainerName ) ; + Engines::Container_ptr aContainer = FindContainer( *MyParams ) ; + delete MyParams ; + return aContainer ; } Engines::ListOfContainers * Manager_i::FindContainers( const Containers::MachineParameters & myParams ) { @@ -152,6 +265,34 @@ Engines::ListOfContainers * Manager_i::FindContainers( const Containers::Machine if ( strlen( MyParams.ContainerName ) && MyParams.ContainerType == Engines::Undefined ) { MyParams.ContainerType = Engines::Cpp ; } + MESSAGE( "Manager_i::FindContainers MutexManager pthread_mutex_lock :" ) ; + if ( pthread_mutex_lock( &_MutexManager ) ) { + perror("Manager_i::FindContainersMutexManager pthread_mutex_lock ") ; + exit( 0 ) ; + } + Engines::ListOfContainers_var aListOfContainers ; + MESSAGE( "Manager_i::FindContainers MutexManager pthread_mutex_locked" ) ; + try { + aListOfContainers = FindContainersLocked( MyParams ) ; + } + catch ( ... ) { + MESSAGE( "Manager_i::FindContainers catched" ) ; + } +// aListOfContainers->length( _ListOfContainers->length() ) ; +// int i ; +// for ( i = 0 ; i < _ListOfContainers->length() ; i++ ) { +// aListOfContainers[ i ] = Engines::Container::_duplicate( _ListOfContainers[ i ] ) ; +// MESSAGE( "Manager_i::FindContainers " << i << ". " << _ListOfContainers[ i ]->name() ) ; +// } + if ( pthread_mutex_unlock( &_MutexManager ) ) { + perror("Manager_i::FindContainers MutexManager pthread_mutex_unlock ") ; + exit( 0 ) ; + } + MESSAGE( "Manager_i::FindContainers MutexManager pthread_mutex_unlocked" ) ; + return aListOfContainers._retn() ; +} + +Engines::ListOfContainers * Manager_i::FindContainersLocked( Containers::MachineParameters & MyParams ) { _ListOfComputers = _ResourcesManager->GetComputers( MyParams ) ; MESSAGE( "Manager_i::FindContainers " << MyParams.HostName << " " << MyParams.ContainerName << " " << _ListOfComputers->length() << " computers found" ) ; @@ -167,6 +308,17 @@ Engines::ListOfContainers * Manager_i::FindContainers( const Containers::Machine _FullContainerName = _FullHostName + "/" + string( (char * ) MyParams.ContainerName ) ; _ContainerObject = _NamingService->Resolve( _FullContainerName.c_str() ) ; MESSAGE( "Manager_i::FindContainers NamingService->Resolve( " << _FullContainerName << " )" ) ; + if ( !CORBA::is_nil( _ContainerObject ) ) { + try { + _EnginesContainer = Engines::Container::_narrow( _ContainerObject ) ; + _EnginesContainer->ping() ; + } + catch(...) { + _ContainerObject = CORBA::Object::_nil() ; + _EnginesContainer = Engines::Container::_nil() ; + MESSAGE( "Manager_i::FindContainers " << _FullContainerName << " NOT responding" ) ; + } + } if ( !CORBA::is_nil( _ContainerObject ) ) { _EnginesContainer = Engines::Container::_narrow( _ContainerObject ) ; if ( _EnginesContainer->type() == MyParams.ContainerType ) { @@ -233,25 +385,25 @@ Engines::Container_ptr Manager_i::FindOrStartContainer( const Containers::Machin << " " << MyParams.ContainerType << " " << MyParams.Os << " " << MyParams.Memory << " " << MyParams.CpuClock << " " << MyParams.NbProc << " " << MyParams.NbNode << " " << MyParams.NsHostName << " " << MyParams.NsPort ) ; - MESSAGE( "MutexManager pthread_mutex_lock :" ) ; + MESSAGE( "Manager_i::FindOrStartContainer MutexManager pthread_mutex_lock :" ) ; if ( pthread_mutex_lock( &_MutexManager ) ) { - perror("MutexManager pthread_mutex_lock ") ; + perror("Manager_i::FindOrStartContainer MutexManager pthread_mutex_lock ") ; exit( 0 ) ; } - MESSAGE( "MutexManager pthread_mutex_locked" ) ; + MESSAGE( "Manager_i::FindOrStartContainer MutexManager pthread_mutex_locked" ) ; try { _StartContainer = true ; - _EnginesContainer = FindOrStartContainerLocked( MyParams , "" ) ; + aContainer = FindOrStartContainerLocked( MyParams , "" ) ; } catch ( ... ) { - MESSAGE(" catch") ; + MESSAGE("Manager_i::FindOrStartContainer catch") ; } if ( pthread_mutex_unlock( &_MutexManager ) ) { - perror("MutexManager pthread_nriContainmutex_unlock ") ; + perror("Manager_i::FindOrStartContainer MutexManager pthread_nriContainmutex_unlock ") ; exit( 0 ) ; } - MESSAGE( "MutexManager pthread_mutex_unlocked" ) ; - return Engines::Container::_duplicate( _EnginesContainer ) ; + MESSAGE( "Manager_i::FindOrStartContainer MutexManager pthread_mutex_unlocked" ) ; + return Engines::Container::_duplicate( aContainer ) ; } Engines::Container_ptr Manager_i::FindOrStartContainerLocked( Containers::MachineParameters & myParams , @@ -260,7 +412,7 @@ Engines::Container_ptr Manager_i::FindOrStartContainerLocked( Containers::Machin _EnginesComponent = Engines::Component::_nil() ; _ListOfComponents = new Engines::ListOfComponents() ; _ListOfComponents->length( 0 ) ; - _ListOfContainers = FindContainers( myParams ) ; + _ListOfContainers = FindContainersLocked( myParams ) ; _ComponentName = aComponentName ; MESSAGE( "MutexManager FindOrStartContainerLocked " << _ListOfContainers->length() << " containers found" << " CORBA::is_nil( _EnginesContainer ) " << CORBA::is_nil( _EnginesContainer ) ) ; @@ -286,12 +438,20 @@ Engines::Container_ptr Manager_i::FindOrStartContainerLocked( Containers::Machin _EnginesContainer = _ListOfContainers[ i ] ; MESSAGE( "Manager_i::FindOrStartContainerLocked --> " << _EnginesContainer->machineName() << " " << _EnginesContainer->name() << " Component " << _ComponentName ) ; - _EnginesComponent = Engines::Component::_duplicate( Engines::Component::_narrow( _ComponentObject ) ) ; - int size = _ListOfComponents->length() ; - _ListOfComponents->length( size + 1 ) ; - _ListOfComponents[ size ] = Engines::Component::_duplicate( _EnginesComponent ) ; - MESSAGE( "Manager_i::FindOrStartContainerLocked --> " << _EnginesComponent->instanceName() << " " - << _EnginesComponent->interfaceName() ) ; + try { + _EnginesComponent = Engines::Component::_duplicate( Engines::Component::_narrow( _ComponentObject ) ) ; + _EnginesComponent->ping() ; + int size = _ListOfComponents->length() ; + _ListOfComponents->length( size + 1 ) ; + _ListOfComponents[ size ] = Engines::Component::_duplicate( _EnginesComponent ) ; + MESSAGE( "Manager_i::FindOrStartContainerLocked --> " << _EnginesComponent->instanceName() << " " + << _EnginesComponent->interfaceName() ) ; + } + catch( ... ) { + _EnginesComponent = Engines::Component::_nil() ; + MESSAGE( "Manager_i::FindOrStartContainerLocked --> " << myParams.HostName << " " + << myParams.ContainerName << " " << _ComponentName << " NOT responding" ) ; + } } else { MESSAGE( "Manager_i::FindOrStartContainerLocked --> " << myParams.HostName << " " @@ -330,7 +490,7 @@ Engines::Container_ptr Manager_i::FindOrStartContainerLocked( Containers::Machin _ComponentObject = _NamingService->Resolve( _FullComponentName.c_str() ) ; if ( !CORBA::is_nil( _ComponentObject ) ) { MESSAGE( "Manager_i::FindOrStartContainerLocked --> " << _EnginesContainer->machineName() << " " - << _EnginesContainer->name() << " Component " << _ComponentName ) ; + << _EnginesContainer->name() << " Component " << _FullComponentName ) ; _EnginesComponent = Engines::Component::_duplicate( Engines::Component::_narrow( _ComponentObject ) ) ; MESSAGE( "Manager_i::FindOrStartContainerLocked --> " << _EnginesComponent->instanceName() << " " << _EnginesComponent->interfaceName() ) ; @@ -347,6 +507,9 @@ Engines::Container_ptr Manager_i::FindOrStartContainerLocked( Containers::Machin else { StartContainer( myParams ) ; } + if ( strlen( _ComponentName.c_str() ) ) { + _FullComponentName = _FullContainerName + "/" + _ComponentName ; + } } return Engines::Container::_duplicate( _EnginesContainer ) ; } @@ -514,7 +677,7 @@ Engines::Container_ptr Manager_i::StartContainer( const Containers::MachineParam MESSAGE( "StartContainer" << count << ". Waiting for " << MyParams.ContainerName << " on " << MyParams.HostName ) ; } - _EnginesContainer = FindContainer( MyParams ) ; + FindContainersLocked( MyParams ) ; } if ( CORBA::is_nil( _EnginesContainer ) ) { INFOS("StartContainer rsh/ssh failed " ) ; @@ -526,13 +689,38 @@ Engines::Container_ptr Manager_i::StartContainer( const Containers::MachineParam << MyParams.ContainerName ) ; _EnginesContainer = _EnginesContainer->start_impl( MyParams.ContainerName , MyParams.ContainerType ) ; } + if ( !CORBA::is_nil( _EnginesContainer ) ) { + int size = _ListOfEnginesContainers.size() ; + _ListOfEnginesContainers.resize( size + 1 ) ; + _ListOfContainersNames.resize( size + 1 ) ; + _ListOfEnginesContainers[ size ] = Engines::Container::_duplicate( _EnginesContainer ) ; + _ListOfContainersNames[ size ] = _EnginesContainer->name() ; + } return Engines::Container::_duplicate( _EnginesContainer ) ; } Engines::Component_ptr Manager_i::FindComponent( const Containers::MachineParameters & myParams , const char * ComponentName ) { - _StartContainer = false ; - return Find_Component( myParams , ComponentName ) ; + MESSAGE( "Manager_i::FindComponent MutexManager pthread_mutex_lock :" ) ; + if ( pthread_mutex_lock( &_MutexManager ) ) { + perror("Manager_i::FindComponent MutexManager pthread_mutex_lock ") ; + exit( 0 ) ; + } + MESSAGE( "Manager_i::FindComponent MutexManager pthread_mutex_locked" ) ; + Engines::Component_ptr aComponent = Engines::Component::_nil() ; + try { + _StartContainer = false ; + aComponent = Find_Component( myParams , ComponentName ) ; + } + catch ( ... ) { + MESSAGE( "Manager_i::FindComponent catched" ) ; + } + if ( pthread_mutex_unlock( &_MutexManager ) ) { + perror("Manager_i::FindComponent MutexManager pthread_mutex_unlock ") ; + exit( 0 ) ; + } + MESSAGE( "Manager_i::FindComponent MutexManager pthread_mutex_unlocked" ) ; + return aComponent ; } Engines::Component_ptr Manager_i::Find_Component( const Containers::MachineParameters & myParams , @@ -554,6 +742,43 @@ Engines::Component_ptr Manager_i::Find_Component( const Containers::MachineParam return Engines::Component::_duplicate( _EnginesComponent ) ; } +Engines::Component_ptr Manager_i::FindOneComponent( const char * aContainerName , + const char * ComponentName ) { + Containers::MachineParameters * MyParams = Parameters() ; + string theComputer ; + string theContainer ; + ContainerName( aContainerName , &theComputer , &theContainer ) ; + MyParams->HostName = theComputer.c_str() ; + MyParams->ContainerName = theContainer.c_str() ; + int l = strlen( aContainerName ) ; + if ( strcmp( &aContainerName[ l-2 ] , "Py" ) ) { + MyParams->ContainerType = Engines::Cpp ; + } + else { + MyParams->ContainerType = Engines::Python ; + } + if ( strcmp( MyParams->HostName ,"localhost" ) == 0 ) { + MyParams->HostName = GetHostname().c_str() ; + } + MESSAGE( "Manager_i::FindOneComponent " << MyParams->HostName << " " << MyParams->ContainerName ) ; + MESSAGE( "FindComponents HostName " << MyParams->HostName << " ContainerName " << MyParams->ContainerName + << " ComponentName " << ComponentName ) ; + MESSAGE( "Manager_i::FindOneComponent MutexManager pthread_mutex_lock :" ) ; + if ( pthread_mutex_lock( &_MutexManager ) ) { + perror("Manager_i::FindOneComponent MutexManager pthread_mutex_lock ") ; + exit( 0 ) ; + } + MESSAGE( "Manager_i::FindOneComponent MutexManager pthread_mutex_locked" ) ; + Engines::Component_ptr aComponent = Find_Component( *MyParams , ComponentName ) ; + if ( pthread_mutex_unlock( &_MutexManager ) ) { + perror("Manager_i::FindOneComponent MutexManager pthread_mutex_unlock ") ; + exit( 0 ) ; + } + MESSAGE( "Manager_i::FindOneComponent MutexManager pthread_mutex_unlocked" ) ; + delete MyParams ; + return aComponent ; +} + Engines::ListOfComponents * Manager_i::FindComponents( const Containers::MachineParameters & myParams , const char * ComponentName ) { Containers::MachineParameters MyParams = (Containers::MachineParameters & ) myParams ; @@ -562,28 +787,46 @@ Engines::ListOfComponents * Manager_i::FindComponents( const Containers::Machine } MESSAGE( "FindComponents HostName " << MyParams.HostName << " ContainerName " << MyParams.ContainerName << " ComponentName " << ComponentName ) ; - _StartContainer = false ; - _EnginesContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ; - if ( _ListOfComponents->length() ) { - MESSAGE( "FindComponents " << _ListOfComponents->length() << " components" ) ; - int i ; - for ( i = 0 ; i < _ListOfComponents->length() ; i++ ) { - MESSAGE( "FindComponents" << i << " instanceName " << _ListOfComponents[ i ]->instanceName() - << " interfaceName " << _ListOfComponents[ i ]->interfaceName() ) ; - _ListOfComponents[ i ]->ping() ; + MESSAGE( "Manager_i::FindComponents MutexManager pthread_mutex_lock :" ) ; + if ( pthread_mutex_lock( &_MutexManager ) ) { + perror("Manager_i::FindComponents MutexManager pthread_mutex_lock ") ; + exit( 0 ) ; + } + MESSAGE( "Manager_i::FindComponents MutexManager pthread_mutex_locked" ) ; + Engines::ListOfComponents_var aListOfComponents = new Engines::ListOfComponents() ; + try { + _StartContainer = false ; + _EnginesContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ; + if ( _ListOfComponents->length() ) { + MESSAGE( "FindComponents " << _ListOfComponents->length() << " components" ) ; + int i ; + for ( i = 0 ; i < _ListOfComponents->length() ; i++ ) { + MESSAGE( "FindComponents" << i << " instanceName " << _ListOfComponents[ i ]->instanceName() + << " interfaceName " << _ListOfComponents[ i ]->interfaceName() ) ; + _ListOfComponents[ i ]->ping() ; + } + } + else if ( !CORBA::is_nil( _EnginesComponent ) ) { + _ListOfComponents->length( 1 ) ; + _ListOfComponents[ 0 ] = Engines::Component::_duplicate( _EnginesComponent ) ; + MESSAGE( "FindComponents instanceName " << _EnginesComponent->instanceName() << " interfaceName " + << _EnginesComponent->interfaceName() << " " << _ListOfComponents->length() << " components" ) ; + _ListOfComponents[ 0 ]->ping() ; + } + else { + MESSAGE( "FindComponents ComponentName " << ComponentName << " NOT found" ) ; } + aListOfComponents = _ListOfComponents ; } - else if ( !CORBA::is_nil( _EnginesComponent ) ) { - _ListOfComponents->length( 1 ) ; - _ListOfComponents[ 0 ] = Engines::Component::_duplicate( _EnginesComponent ) ; - MESSAGE( "FindComponents instanceName " << _EnginesComponent->instanceName() << " interfaceName " - << _EnginesComponent->interfaceName() << " " << _ListOfComponents->length() << " components" ) ; - _ListOfComponents[ 0 ]->ping() ; + catch ( ... ) { + MESSAGE( "Manager_i::FindComponents catched" ) ; } - else { - MESSAGE( "FindComponents ComponentName " << ComponentName << " NOT found" ) ; + if ( pthread_mutex_unlock( &_MutexManager ) ) { + perror("Manager_i::FindComponentsMutexManager pthread_mutex_unlock ") ; + exit( 0 ) ; } - return _ListOfComponents._retn() ; + MESSAGE( "Manager_i::FindComponentsMutexManager pthread_mutex_unlocked" ) ; + return aListOfComponents._retn() ; } @@ -597,48 +840,68 @@ Engines::Component_ptr Manager_i::FindOrLoad_ComponentPath( const Containers::Ma MyParams.HostName = GetHostname().c_str() ; } BEGIN_OF("FindOrLoad_Component( const Containers::MachineParameters & MyParams , const char * ComponentName , const char * ImplementationPath 1)"); - MESSAGE( "MutexManager pthread_mutex_lock :" ) ; + MESSAGE( "Manager_i::FindOrLoad_ComponentPath MutexManager pthread_mutex_lock :" ) ; if ( pthread_mutex_lock( &_MutexManager ) ) { - perror("MutexManager pthread_mutex_lock ") ; + perror("Manager_i::FindOrLoad_ComponentPath MutexManager pthread_mutex_lock ") ; exit( 0 ) ; } - MESSAGE( "MutexManager pthread_mutex_locked" ) ; + MESSAGE( "Manager_i::FindOrLoad_ComponentPath MutexManager pthread_mutex_locked" ) ; try { _StartContainer = true ; EnginesComponent = Find_Component( MyParams , ComponentName ) ; if ( CORBA::is_nil( EnginesComponent ) ) { - MESSAGE("Component not found " << _ComponentName ) ; + MESSAGE("FindOrLoad_ComponentPath Component not found " << _ComponentName ) ; // aContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ; } else { - MESSAGE("Component was found " << _ComponentName ) ; + MESSAGE("FindOrLoad_ComponentPath Component was found " << _ComponentName ) ; } aContainer = _EnginesContainer ; } catch ( ... ) { - MESSAGE(" catch") ; + MESSAGE("FindOrLoad_ComponentPath catch") ; } + string aComponentName = _ComponentName ; + string aFullComponentName = _FullComponentName ; if ( pthread_mutex_unlock( &_MutexManager ) ) { - perror("MutexManager pthread_mutex_unlock ") ; + perror("Manager_i::FindOrLoad_ComponentPath MutexManager pthread_mutex_unlock ") ; exit( 0 ) ; } - MESSAGE( "MutexManager pthread_mutex_unlocked" ) ; + MESSAGE( "Manager_i::FindOrLoad_ComponentPath MutexManager pthread_mutex_unlocked" ) ; if ( !CORBA::is_nil( aContainer ) && CORBA::is_nil( EnginesComponent ) ) { - MESSAGE("Component not found ! trying to load " << _ComponentName ) ; + MESSAGE("FindOrLoad_ComponentPath Component not found ! trying to load " << aFullComponentName ) ; EnginesComponent = aContainer->load_impl( ComponentName, ImplementationPath ) ; if ( !CORBA::is_nil( EnginesComponent ) ) { - MESSAGE( "Component launched ! " << _ComponentName ) ; + MESSAGE( "FindOrLoad_ComponentPath Component launched ! " << aFullComponentName ) ; try { EnginesComponent->ping() ; } catch ( CORBA::COMM_FAILURE& ) { - INFOS("Caught CORBA::SystemException CommFailure. Engine " << _ComponentName << "does not respond" ) ; + INFOS("FindOrLoad_ComponentPath Caught CORBA::SystemException CommFailure. Engine " << aFullComponentName << "does not respond" ) ; EnginesComponent = Engines::Component::_nil() ; } } else { - MESSAGE( "Component NOT launched ! " << _ComponentName ) ; + MESSAGE( "FindOrLoad_ComponentPath Component NOT launched ! " << aFullComponentName ) ; + } + } + if ( !CORBA::is_nil( _EnginesComponent ) ) { + MESSAGE( "Manager_i::FindOrLoad_ComponentPath MutexManager pthread_mutex_lock :" ) ; + if ( pthread_mutex_lock( &_MutexManager ) ) { + perror("Manager_i::FindOrLoad_ComponentPath MutexManager pthread_mutex_lock ") ; + exit( 0 ) ; + } + MESSAGE( "Manager_i::FindOrLoad_ComponentPath MutexManager pthread_mutex_locked" ) ; + int size = _ListOfEnginesComponents.size() ; + _ListOfEnginesComponents.resize( size + 1 ) ; + _ListOfComponentsNames.resize( size + 1 ) ; + _ListOfEnginesComponents[ size ] = Engines::Component::_duplicate( EnginesComponent ) ; + _ListOfComponentsNames[ size ] = aFullComponentName ; + if ( pthread_mutex_unlock( &_MutexManager ) ) { + perror("Manager_i::FindOrLoad_ComponentPath MutexManager pthread_mutex_unlock ") ; + exit( 0 ) ; } + MESSAGE( "Manager_i::FindOrLoad_ComponentPath MutexManager pthread_mutex_unlocked" ) ; } return Engines::Component::_duplicate( EnginesComponent ) ; } @@ -652,51 +915,82 @@ Engines::Component_ptr Manager_i::FindOrLoad_Component( const Containers::Machin MyParams.HostName = GetHostname().c_str() ; } BEGIN_OF("FindOrLoad_Component( const Containers::MachineParameters & MyParams , const char * ComponentName )"); - MESSAGE( "MutexManager pthread_mutex_lock :" ) ; + MESSAGE( "Manager_i::FindOrLoad_Component MutexManager pthread_mutex_lock :" ) ; if ( pthread_mutex_lock( &_MutexManager ) ) { - perror("MutexManager pthread_mutex_lock ") ; + perror("Manager_i::FindOrLoad_Component MutexManager pthread_mutex_lock ") ; exit( 0 ) ; } - MESSAGE( "MutexManager pthread_mutex_locked" ) ; + MESSAGE( "Manager_i::FindOrLoad_Component MutexManager pthread_mutex_locked" ) ; try { _StartContainer = true ; EnginesComponent = Find_Component( MyParams , ComponentName ) ; if ( CORBA::is_nil( EnginesComponent ) ) { - MESSAGE("Component not found " << _ComponentName ) ; + MESSAGE("FindOrLoad_Component Component not found " << _FullComponentName ) ; // aContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ; } else { - MESSAGE("Component was found " << _ComponentName ) ; + MESSAGE("FindOrLoad_Component Component was found " << _FullComponentName ) ; } aContainer = _EnginesContainer ; } catch ( ... ) { - MESSAGE(" catch") ; + MESSAGE("FindOrLoad_Component catch") ; } + string aComponentName = _ComponentName ; + string aFullComponentName = _FullComponentName ; if ( pthread_mutex_unlock( &_MutexManager ) ) { - perror("MutexManager pthread_mutex_unlock ") ; + perror("Manager_i::FindOrLoad_Component MutexManager pthread_mutex_unlock ") ; exit( 0 ) ; } - MESSAGE( "MutexManager pthread_mutex_unlocked" ) ; + MESSAGE( "Manager_i::FindOrLoad_Component MutexManager pthread_mutex_unlocked" ) ; if ( !CORBA::is_nil( aContainer ) && CORBA::is_nil( EnginesComponent ) ) { - MESSAGE("Component not found ! trying to load " << _ComponentName ) ; + MESSAGE("FindOrLoad_Component Component not found ! trying to load " << aFullComponentName ) ; string ImplementationPath( "lib" ) ; ImplementationPath += ComponentName ; ImplementationPath += "Engine.so" ; - EnginesComponent = aContainer->load_impl( ComponentName, ImplementationPath.c_str() ) ; - if ( !CORBA::is_nil( EnginesComponent ) ) { - MESSAGE( "Component launched ! " << _ComponentName ) ; - try { - EnginesComponent->ping() ; + try { + EnginesComponent = aContainer->load_impl( ComponentName, ImplementationPath.c_str() ) ; + if ( !CORBA::is_nil( EnginesComponent ) ) { + MESSAGE( "FindOrLoad_Component Component launched ! " << _ComponentName << " on " << aFullComponentName ) ; + try { + EnginesComponent->ping() ; + } + catch ( CORBA::COMM_FAILURE& ) { + INFOS("FindOrLoad_Component Caught CORBA::SystemException CommFailure. Engine " << aFullComponentName << "does not respond" ) ; + EnginesComponent = Engines::Component::_nil() ; + } } - catch ( CORBA::COMM_FAILURE& ) { - INFOS("Caught CORBA::SystemException CommFailure. Engine " << _ComponentName << "does not respond" ) ; - EnginesComponent = Engines::Component::_nil() ; + else { + MESSAGE( "FindOrLoad_Component Component NOT launched ! " << aFullComponentName ) ; } } - else { - MESSAGE( "Component NOT launched ! " << _ComponentName ) ; + catch (...) { + EnginesComponent = Engines::Component::_nil() ; + MESSAGE( "Component NOT launched ! " << aFullComponentName << " load_impl catched" ) ; + } + } + if ( !CORBA::is_nil( EnginesComponent ) ) { + MESSAGE( "Manager_i::FindOrLoad_Component MutexManager pthread_mutex_lock :" ) ; + if ( pthread_mutex_lock( &_MutexManager ) ) { + perror("Manager_i::FindOrLoad_Component MutexManager pthread_mutex_lock ") ; + exit( 0 ) ; + } + MESSAGE( "Manager_i::FindOrLoad_Component MutexManager pthread_mutex_locked" ) ; + int size = _ListOfEnginesComponents.size() ; + _ListOfEnginesComponents.resize( size + 1 ) ; + _ListOfComponentsNames.resize( size + 1 ) ; + _ListOfEnginesComponents[ size ] = Engines::Component::_duplicate( EnginesComponent ) ; + _ListOfComponentsNames[ size ] = aFullComponentName ; + MESSAGE( "FindOrLoad_Component " << aFullComponentName << " added in listofcomponents" ) ; + int i ; + for ( i = 0 ; i < size + 1 ; i++ ) { + MESSAGE( "FindOrLoad_Component " << i << ". " << _ListOfComponentsNames[ i ] ) ; + } + if ( pthread_mutex_unlock( &_MutexManager ) ) { + perror("Manager_i::FindOrLoad_Component MutexManager pthread_mutex_unlock ") ; + exit( 0 ) ; } + MESSAGE( "Manager_i::FindOrLoad_Component MutexManager pthread_mutex_unlocked" ) ; } return Engines::Component::_duplicate( EnginesComponent ) ; } diff --git a/src/ContainersManager/ContainersManager_i.hxx b/src/ContainersManager/ContainersManager_i.hxx index f05863284..cc538e95b 100644 --- a/src/ContainersManager/ContainersManager_i.hxx +++ b/src/ContainersManager/ContainersManager_i.hxx @@ -36,6 +36,7 @@ #include #include #include +#include #include "utilities.h" #include "OpUtil.hxx" @@ -57,6 +58,8 @@ class Manager_i : public POA_Containers::Manager , private: CORBA::ORB_ptr _Orb ; + PortableServer::POA_ptr _Poa ; + PortableServer::ObjectId * _Id ; SALOME_NamingService * _NamingService ; Resources::Manager_var _ResourcesManager ; string _NamingServiceHostName ; @@ -80,8 +83,19 @@ class Manager_i : public POA_Containers::Manager , CORBA::Object_var _ComponentObject ; Engines::Component_var _EnginesComponent ; + vector< string > _ListOfContainersNames ; + vector< Engines::Container_var > _ListOfEnginesContainers ; + vector< string > _ListOfComponentsNames ; + vector< Engines::Component_var > _ListOfEnginesComponents ; + + std::string ContainerName( const char * aComputerContainer , + std::string * theComputer , + std::string * theContainer ) ; + Engines::Container_ptr StartContainer( const Containers::MachineParameters & myParams ) ; + Engines::ListOfContainers * FindContainersLocked( Containers::MachineParameters & MyParams ) ; + Engines::Container_ptr FindOrStartContainerLocked( Containers::MachineParameters & MyParams , const char * ComponentName ) ; @@ -92,19 +106,24 @@ class Manager_i : public POA_Containers::Manager , Manager_i() ; - Manager_i( CORBA::ORB_ptr orb , + void Init( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , SALOME_NamingService * NamingService , int argc , char** argv ) ; virtual ~Manager_i() ; + virtual void destroy() ; + virtual bool ping() ; virtual Containers::MachineParameters * Parameters() ; virtual Engines::Container_ptr FindContainer( const Containers::MachineParameters & MyParams ) ; + virtual Engines::Container_ptr FindOneContainer( const char * aContainerName ) ; + virtual Engines::ListOfContainers * FindContainers( const Containers::MachineParameters & MyParams ) ; virtual Engines::Container_ptr FindOrStartContainer( const Containers::MachineParameters & MyParams ) ; @@ -112,6 +131,9 @@ class Manager_i : public POA_Containers::Manager , virtual Engines::Component_ptr FindComponent( const Containers::MachineParameters & MyParams , const char * ComponentName ) ; + virtual Engines::Component_ptr FindOneComponent( const char * aContainerName , + const char * ComponentName ) ; + virtual Engines::ListOfComponents * FindComponents( const Containers::MachineParameters & MyParams , const char * ComponentName ) ; diff --git a/src/ContainersManager/TestContainersManager.py b/src/ContainersManager/TestContainersManager.py index 45da74dd2..2b1109470 100644 --- a/src/ContainersManager/TestContainersManager.py +++ b/src/ContainersManager/TestContainersManager.py @@ -81,6 +81,18 @@ SuperVisionContainer.ping() print "Container SuperVisionContainer is running on",SuperVisionContainer._get_machineName(),"with name",SuperVisionContainer._get_name(),"and type",SuperVisionContainer.type() +DefaultParams.ContainerName = '' +DefaultParams.ContainerType = Engines.Undefined +ContainerParameters( DefaultParams ) +Containers = MyContainersMgr.FindContainers( DefaultParams ) +ContainerParameters( DefaultParams ) +i = 0 +while i < len( Containers ) : + print "Container running on",Containers[ i ]._get_machineName(),"with name",Containers[ i ]._get_name(),"and type",Containers[ i ].type() + i = i + 1 + + + #ResourcesManager_Server -common /home/Salome2/KERNEL_install/share/salome/resources/ResourcesCatalog.xml -ORBInitRef NameService=corbaname::localhost import Resources @@ -114,7 +126,7 @@ aComputer.Parameters().FullName aComputer = MyResourcesMgr.GetComputer( ListOfComputers ) aComputer.Parameters().FullName -aComputer = MyResourcesMgr.SearchComputer("bordolex") +aComputer = MyResourcesMgr.SearchComputer("dunex") aComputer.Parameters().FullName aComputer = MyResourcesMgr.SearchComputer("bojolex") @@ -206,12 +218,24 @@ while i < len( Containers ) : aContainer = MyContainersMgr.FindContainer( DefaultParams ) print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type() -aContainer = MyContainersMgr.FindContainer( 'FactoryServer' ) ) +aContainer = MyContainersMgr.FindOneContainer( 'FactoryServer' ) print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type() -aContainer = MyContainersMgr.FindContainer( 'localhost/FactoryServer' ) ) +aContainer = MyContainersMgr.FindOneContainer( 'FactoryServerPy' ) print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type() +aContainer = MyContainersMgr.FindOneContainer( 'SuperVisionContainer' ) +print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type() + +aContainer = MyContainersMgr.FindOneContainer( 'localhost/FactoryServer' ) +print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type() + +aContainer = MyContainersMgr.FindOneContainer( 'bojolex/SuperVisionContainer' ) +if aContainer is None : + print "None Container : Ok" +else : + print "ERROR Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type() + DefaultParams.ContainerType = Engines.Cpp Containers = MyContainersMgr.FindContainers( DefaultParams ) i = 0 @@ -226,6 +250,10 @@ while i < len( Containers ) : print "Container running on",Containers[ i ]._get_machineName(),"with name",Containers[ i ]._get_name(),"and type",Containers[ i ].type() i = i + 1 +DefaultParams.ContainerName = 'DunexServerPython' +aPyContainer = MyContainersMgr.FindOrStartContainer( DefaultParams ) +print "Container running on",aPyContainer._get_machineName(),"with name",aPyContainer._get_name(),"and type",aPyContainer.type() + ContainerParameters( DefaultParams ) DefaultParams.ContainerType = Engines.Cpp @@ -281,6 +309,15 @@ while i < len( ListOfComponents ) : print ListOfComponents[ i ].GetContainerRef()._get_name(),ListOfComponents[ i ]._get_instanceName(),ListOfComponents[ i ]._get_interfaceName() i = i + 1 +aAddComponent = MyContainersMgr.FindOneComponent( 'FactoryServer' , "AddComponent" ) +print aAddComponent.GetContainerRef()._get_name(),aAddComponent._get_instanceName(),aAddComponent._get_interfaceName() + +aSubComponent = MyContainersMgr.FindOneComponent( 'FactoryServer' , "SubComponent" ) +print aSubComponent.GetContainerRef()._get_name(),aSubComponent._get_instanceName(),aSubComponent._get_interfaceName() + +aSUPERVComponent = MyContainersMgr.FindOneComponent( 'SuperVisionContainer' , "SUPERV" ) +print aSUPERVComponent.GetContainerRef()._get_name(),aSUPERVComponent._get_instanceName(),aSUPERVComponent._get_interfaceName() + @@ -290,6 +327,8 @@ from LifeCycleCORBA import * orb = CORBA.ORB_init([''], CORBA.ORB_ID) lcc = LifeCycleCORBA( orb ) +t = lcc.FindOrLoadComponent( 'FactoryServer' , 'SalomeTestComponent' ) +print t lccMulComponent = lcc.FindOrLoadComponent( 'SuperVisionContainer' , "MulComponent" ) print lccMulComponent.GetContainerRef()._get_name(),lccMulComponent._get_instanceName(),lccMulComponent._get_interfaceName() @@ -349,3 +388,6 @@ DefaultParams.HostName = 'toto' lcctotoMulComponent = lcc.FindOrLoadComponent( DefaultParams , "MulComponent" ) + +MyContainersMgr.destroy() + diff --git a/src/ResourcesManager/ResourcesManager_Server.cxx b/src/ResourcesManager/ResourcesManager_Server.cxx index 8c3b5bd0f..41e287df0 100755 --- a/src/ResourcesManager/ResourcesManager_Server.cxx +++ b/src/ResourcesManager/ResourcesManager_Server.cxx @@ -28,6 +28,7 @@ #include #include "SALOME_NamingService.hxx" +#include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" #include "ResourcesManager_Impl.hxx" @@ -38,7 +39,9 @@ int main(int argc,char **argv) { try { // initialize the ORB - CORBA::ORB_ptr orb = CORBA::ORB_init ( argc , argv ) ; + ORB_INIT &init = *SINGLETON_::Instance() ; + ASSERT(SINGLETON_::IsAlreadyExisting()) ; + CORBA::ORB_var &orb = init( argc , argv ) ; long TIMESleep = 250000000 ; int NumberOfTries = 40 ; @@ -169,6 +172,8 @@ int main(int argc,char **argv) { poa->destroy( 1 , 1 ) ; + orb->destroy(); + } catch ( CORBA::SystemException& ) { INFOS("Caught CORBA::SystemException.") ; diff --git a/src/TestContainer/TestContainer.cxx b/src/TestContainer/TestContainer.cxx index d1f1c35bb..f80e92a4a 100644 --- a/src/TestContainer/TestContainer.cxx +++ b/src/TestContainer/TestContainer.cxx @@ -148,20 +148,25 @@ int main (int argc, char * argv[]) for (int iter = 0; iter < 3 ; iter++) { INFOS("----------------------------------------------------" << iter); - string dirn = getenv("SALOME_ROOT_DIR"); - dirn += "/lib/salome/libSalomeTestComponentEngine.so"; +// string dirn = getenv("SALOME_ROOT_DIR"); +// dirn += "/lib/salome/libSalomeTestComponentEngine.so"; + iGenFact->ping() ; + string dirn = "libSalomeTestComponentEngine.so"; obj = iGenFact->load_impl("SalomeTestComponent",dirn.c_str()); m1 = Engines::TestComponent::_narrow(obj); INFOS("recup m1"); SCRUTE(m1->instanceName()); INFOS("Coucou " << m1->Coucou(1L)); iGenFact->remove_impl(m1) ; + INFOS("remove_impl done" ); //iGenFact->finalize_removal() ; // unpredictable results ... sleep(5); } // Clean-up. iGenFact->finalize_removal() ; + INFOS("finalize_removal done" ); orb->destroy(); + INFOS("orb destroyed" ); } catch(CORBA::COMM_FAILURE& ex) { INFOS("Caught system exception COMM_FAILURE -- unable to contact the object.") -- 2.39.2