From: secher Date: Fri, 3 Dec 2004 13:32:31 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=64261064edf86c69ed96afd47c2689613a1f7dac;p=modules%2Fkernel.git *** empty log message *** --- diff --git a/idl/SALOME_Component.idl b/idl/SALOME_Component.idl index ecad1fa41..2e1cfd5f3 100644 --- a/idl/SALOME_Component.idl +++ b/idl/SALOME_Component.idl @@ -90,6 +90,10 @@ module Engines Name of the machine containing this container (location of the container). */ readonly attribute string machineName ; +/*! + shutdown corba server +*/ + void Shutdown() ; /*! Returns True if the %container has been killed */ diff --git a/idl/SALOME_MPIContainer.idl b/idl/SALOME_MPIContainer.idl index 8265c7380..c23e1c061 100644 --- a/idl/SALOME_MPIContainer.idl +++ b/idl/SALOME_MPIContainer.idl @@ -34,6 +34,9 @@ module Engines // start MPI container executable MPIContainer start_MPIimpl( in string ContainerName, in short nbproc ); + // shutdown corba server + void MPIShutdown() ; + // asynchronous version to load and remove parallel component in parallel oneway void SPload_impl(in string nameToRegister, in string componentName); oneway void SPremove_impl(in Component component_i); diff --git a/src/Container/Component_i.cxx b/src/Container/Component_i.cxx index a03faf92b..a3b851b47 100644 --- a/src/Container/Component_i.cxx +++ b/src/Container/Component_i.cxx @@ -115,10 +115,10 @@ void Engines_Component_i::destroy() delete _myConnexionToRegistry; _myConnexionToRegistry = 0 ; + _thisObj->_remove_ref(); _poa->deactivate_object(*_id) ; CORBA::release(_poa) ; delete(_id) ; - _thisObj->_remove_ref(); MESSAGE("Engines_Component_i::destroyed") ; } diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index b753a6707..9fcfd75d1 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -154,6 +154,13 @@ void Engines_Container_i::ping() MESSAGE("Engines_Container_i::ping() pid "<< getpid()); } + // shutdown corba server +void Engines_Container_i::Shutdown() +{ + MESSAGE("Engines_Container_i::Shutdown()"); + _orb->shutdown(0); +} + //! Kill current container bool Engines_Container_i::Kill_impl() { MESSAGE("Engines_Container_i::Kill() pid "<< getpid() << " containerName " diff --git a/src/Container/SALOME_Container_i.hxx b/src/Container/SALOME_Container_i.hxx index 6a65dcb3c..73b2a954a 100644 --- a/src/Container/SALOME_Container_i.hxx +++ b/src/Container/SALOME_Container_i.hxx @@ -72,6 +72,9 @@ public: char* machineName(); void ping(); + // shutdown corba server + void Shutdown(); + //! Kill current container bool Kill_impl() ; diff --git a/src/MPIContainer/MPIContainer_i.cxx b/src/MPIContainer/MPIContainer_i.cxx index ad729c45a..43aa33d59 100644 --- a/src/MPIContainer/MPIContainer_i.cxx +++ b/src/MPIContainer/MPIContainer_i.cxx @@ -44,6 +44,7 @@ Engines_MPIContainer_i::Engines_MPIContainer_i(int nbproc, int numproc, { MESSAGE("[" << numproc << "] activate object"); _id = _poa->activate_object(this); + this->_add_ref(); if(numproc==0){ @@ -52,8 +53,9 @@ Engines_MPIContainer_i::Engines_MPIContainer_i(int nbproc, int numproc, ASSERT(SINGLETON_::IsAlreadyExisting()) ; _NS->init_orb( orb ) ; - Engines::Container_ptr pCont - = Engines::Container::_narrow(POA_Engines::MPIContainer::_this()); +// Engines::Container_ptr pCont +// = Engines::Container::_narrow(POA_Engines::MPIContainer::_this()); + Engines::Container_ptr pCont = Engines::Container::_narrow(_poa->id_to_reference(*_id)); SCRUTE(_containerName); _NS->Register(pCont, _containerName.c_str()); } @@ -384,3 +386,18 @@ void Engines_MPIContainer_i::Lfinalize_removal() 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 7d9ddc9a2..a971b7f20 100644 --- a/src/MPIContainer/MPIContainer_i.hxx +++ b/src/MPIContainer/MPIContainer_i.hxx @@ -56,6 +56,9 @@ class Engines_MPIContainer_i : public POA_Engines::MPIContainer, // 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); diff --git a/src/MPIContainer/SALOME_MPIContainer.cxx b/src/MPIContainer/SALOME_MPIContainer.cxx index d6fb4474f..52152364e 100644 --- a/src/MPIContainer/SALOME_MPIContainer.cxx +++ b/src/MPIContainer/SALOME_MPIContainer.cxx @@ -4,6 +4,7 @@ #include "Utils_SINGLETON.hxx" #include "utilities.h" #include +#include "LocalTraceCollector.hxx" using namespace std; int main(int argc, char* argv[]) @@ -12,21 +13,18 @@ int main(int argc, char* argv[]) int flag; Engines_MPIContainer_i * myContainer=NULL; - BEGIN_OF(argv[0]) + MPI_Init(&argc,&argv); + MPI_Comm_size(MPI_COMM_WORLD,&nbproc); + MPI_Comm_rank(MPI_COMM_WORLD,&numproc); + + // Initialise the ORB. + ORB_INIT &init = *SINGLETON_::Instance() ; + CORBA::ORB_var &orb = init( argc , argv ) ; + LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb); + + BEGIN_OF("[" << numproc << "] " << argv[0]) try { - MESSAGE("Connection MPI"); - MPI_Init(&argc,&argv); - MPI_Comm_size(MPI_COMM_WORLD,&nbproc); - MPI_Comm_rank(MPI_COMM_WORLD,&numproc); - - MESSAGE("[" << numproc << "] Initialisation CORBA"); - // Initialise the ORB. - // CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()) ; - CORBA::ORB_var &orb = init( argc , argv ) ; - // Obtain a reference to the root POA. CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); @@ -65,7 +63,7 @@ int main(int argc, char* argv[]) containerName = argv[1] ; } - MESSAGE("[" << numproc << "] Chargement container"); + MESSAGE("[" << numproc << "] MPIContainer: load MPIContainer servant"); myContainer = new Engines_MPIContainer_i(nbproc,numproc,orb,factory_poa, containerName,argc,argv); pman->activate(); @@ -96,6 +94,8 @@ int main(int argc, char* argv[]) if(flag) MPI_Finalize(); - END_OF(argv[0]); + END_OF("[" << numproc << "] " << argv[0]); + delete myThreadTrace; + return 0 ; } diff --git a/src/TestMPIContainer/Makefile.in b/src/TestMPIContainer/Makefile.in index 59ba1abad..12a26621d 100644 --- a/src/TestMPIContainer/Makefile.in +++ b/src/TestMPIContainer/Makefile.in @@ -31,7 +31,9 @@ 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 +LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeMPILifeCycleCORBA -lSalomeLifeCycleCORBA -lSalomeMPIContainer -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace ${MPI_LIBS} +CXXFLAGS+=${MPI_INCLUDES} +CXX_DEPEND_FLAG+=${MPI_INCLUDES} @CONCLUDE@ diff --git a/src/TestMPIContainer/TestMPIComponentEngine.cxx b/src/TestMPIContainer/TestMPIComponentEngine.cxx index b0bf10b0c..aee37178c 100644 --- a/src/TestMPIContainer/TestMPIComponentEngine.cxx +++ b/src/TestMPIContainer/TestMPIComponentEngine.cxx @@ -7,6 +7,7 @@ // $Header$ //============================================================================= +#include #include "utilities.h" #include "TestMPIComponentEngine.hxx" using namespace std; @@ -22,7 +23,7 @@ TestMPIComponentEngine::TestMPIComponentEngine(int nbproc, int numproc, { MESSAGE("activate object") _thisObj = this ; - _id = _poa->activate_object(_thisObj); + _id = _poa->reference_to_id(_thisObj->_this()); } TestMPIComponentEngine::TestMPIComponentEngine(): Engines_Component_i(), MPIObject_i() @@ -35,19 +36,18 @@ TestMPIComponentEngine::~TestMPIComponentEngine() void TestMPIComponentEngine::Coucou(CORBA::Long L) { - BEGIN_OF("[" << _numproc << "] TestMPIComponentEngine::Coucou()"); if(_numproc==0) for(int ip=1;ip<_nbproc;ip++) Engines::TestMPIComponent::_narrow((*_tior)[ip])->SPCoucou(L); - MESSAGE("[" << _numproc << "] TestMPIComponentEngine : L = " << L); - END_OF("[" << _numproc << "] TestMPIComponentEngine::Coucou()"); + SPCoucou(L); } void TestMPIComponentEngine::SPCoucou(CORBA::Long L) { - BEGIN_OF("[" << _numproc << "] TestMPIComponentEngine::SPCoucou()"); + BEGIN_OF("[" << _numproc << "] TestMPIComponentEngine::Coucou()"); MESSAGE("[" << _numproc << "] TestMPIComponentEngine : L = " << L); - END_OF("[" << _numproc << "] TestMPIComponentEngine::SPCoucou()"); + END_OF("[" << _numproc << "] TestMPIComponentEngine::Coucou()"); + MPI_Barrier(MPI_COMM_WORLD); } extern "C" diff --git a/src/TestMPIContainer/TestMPIContainer.cxx b/src/TestMPIContainer/TestMPIContainer.cxx index b195a0199..898007487 100644 --- a/src/TestMPIContainer/TestMPIContainer.cxx +++ b/src/TestMPIContainer/TestMPIContainer.cxx @@ -20,24 +20,27 @@ # include "Utils_SINGLETON.hxx" #include "SALOME_NamingService.hxx" #include "OpUtil.hxx" +#include "LocalTraceCollector.hxx" using namespace std; 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); + + BEGIN_OF(argv[0]) try{ int status; - MESSAGE("COUCOU"); if( argc != 3 || strcmp(argv[1],"-np") ){ cout << "Usage: TestMPIContainer -np nbproc" << endl; exit(0); } - // 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) ; @@ -48,15 +51,12 @@ int main (int argc, char * argv[]) string hostName = GetHostname(); containerName += hostName + "/MPIFactoryServer_" + argv[2]; - MESSAGE(containerName); - string dirn(getenv("KERNEL_ROOT_DIR")); dirn += "/lib/salome/libSalomeTestMPIComponentEngine.so"; - MESSAGE(dirn.c_str()); // Try to resolve MPI Container obj = NS.Resolve(containerName.c_str()) ; - Engines::Container_var iGenFact = Engines::Container::_narrow(obj); + Engines::MPIContainer_var iGenFact = Engines::MPIContainer::_narrow(obj); if(CORBA::is_nil(iGenFact)){ @@ -82,41 +82,42 @@ int main (int argc, char * argv[]) do{ sleep(1); obj = NS.Resolve(containerName.c_str()) ; - iGenFact = Engines::Container::_narrow(obj); + iGenFact = Engines::MPIContainer::_narrow(obj); MESSAGE("Waiting for MPI Container " << containerName << " : it = " << it ); }while( CORBA::is_nil(iGenFact) && (it++<15) ); } if(CORBA::is_nil(iGenFact)){ - MESSAGE("echec recuperation poignee container"); + MESSAGE("launching container failed"); exit(1); } + Engines::TestMPIComponent_var m1; - for (int iter = 0; iter < 1 ; iter++){ - MESSAGE("----------------------------------------------------" << iter); - obj = iGenFact->load_impl("TestMPIComponent",dirn.c_str()); +// for (int iter = 0; iter < 1 ; iter++){ +// MESSAGE("----------------------------------------------------" << iter); + obj = iGenFact->load_impl("TestMPIComponent",dirn.c_str()); - m1 = Engines::TestMPIComponent::_narrow(obj); - if(CORBA::is_nil(m1)){ - INFOS("echec recuperation poignee composant"); - } - else{ - - INFOS("recup m1"); - SCRUTE(m1->instanceName()); - INFOS("Lancement de coucou"); - m1->Coucou(1L); - INFOS("On remove le composant"); - iGenFact->remove_impl(m1) ; - sleep(5); - } + INFOS("Get Handle on MPI Component"); + m1 = Engines::TestMPIComponent::_narrow(obj); + if(CORBA::is_nil(m1)){ + INFOS("getting handle on MPI component failed"); + } + else{ + m1->Coucou(1L); +// // sleep(5); + INFOS("Unload MPI Component"); + iGenFact->remove_impl(m1) ; } - // Clean-up. - iGenFact->finalize_removal() ; - orb->destroy(); +// } +// // Clean-up. +// // iGenFact->finalize_removal() ; +// // sleep(5); + iGenFact->MPIShutdown(); +// INFOS("shut down corba server for Test MPI Container"); +// orb->destroy(); } catch(CORBA::COMM_FAILURE& ex) { INFOS("Caught system exception COMM_FAILURE -- unable to contact the object."); @@ -131,5 +132,7 @@ int main (int argc, char * argv[]) INFOS("Caught unknown exception."); } - return 0; + END_OF(argv[0]); + delete myThreadTrace; + return 0 ; }